graph
Some math thing suggested by friend
Posted July 10th, 2008 by MgcclBNL lunch break.
Adam was talking about a function T(f(x),g(x)) that takes any linear function f(x) and apply g(x), but make it seems like f(x) is the x-axis.
Without drawing a graph, it's quite ambiguous of what the above sentence mean.
A graph example, where f(x) = x, g(x) = sin(x).
So I told him, to do that, just do the g(x) on x-axis and then rotate the entire graph with the origin as center until the original x-axis is on f(x).
He then asked, what if f(x) is not a linear function.
For a second I can't think of something out, and soon, I was distracted so I said I will look up tonight.
On the road back to my office, the answer popped up. My answer is trivial and it's just one way to see the question, and I believe there must be other ways.
T(f(x),g(x)) generates a graph, where each point of the graph is the point g(x) away from (x, f(x)) and on the line that perpendicular to f'(x) and intersects (x,f(x)).
Finding a universal equation for this T(f(x),g(x)) to graph it:
It's trivial. The above description almost instantly lead to the result.

I have to use parametric, because can be a one to many function even if both functions are one to one functions.
If f(x) is not differentiable at some points, then the graph is not defined at those points.
Some nice graphs generated from Mathematica
f(x) = x^2, g(x) = floor(|x|)
f(x) = sin(x), g(x) = sin(4x)
Ones I used maxima + gnuplot
f(x) = sin(x), g(x) = floor(x)
f(x) = sin(x), g(x) = x
f(x) = sin(x), g(x) = log(x)
f(x) = sin(x), g(x) = x^2
f(x) = sin(x), g(x) = sqrt(2)
I hope I know what this stuff Adam thought of is called.
- Mgccl's blog
- 2 comments
- 352 reads
DAG Taxonomy
Posted July 5th, 2008 by MgcclI have decided to create a taxonomy database library based on direct acyclic graph(DAG), actually it is based on polytree. Like the tree taxonomy, except allow one node to have more than one direct parent node.
Like this structure, that can't be constructed from tree based taxonomy.
A hash table storing nodes. Indices are integers.
The node stores three sets of integers, the indices of direct parent nodes, the indices of direct child nodes, and the items.
The items are integers only, each item refers to the item wish to be classified. Those items can be thought as ids. When the database return items, those items can be used in a SQL query to request the content of items.
These are specs of the database, and all the possible operations:
- Return all items directly under a node.
- Return all items under a node or it's child nodes.
- Return relationship from node A to node B.(parent, child or neither)
- Return all items under a complex query. For example, items that are classified as part of node A but not node B
- Insertion of new node
- deletion of nodes
- Find the smallest graph that contains some specific nodes as it's child node. Useful when there are things having the same name but different meaning. So with this process, it can return stuff like Graph(Graph Theory) and Graph(Plotting Functions)
- Move a node from one place to another.(supply old parent and new parents, or supply a entirely new node)
- Save/Load the database to/from a file
- Normalization process of the database:
- If an node has an direct item that is also an direct item of any of it's child node. Remove the item from node.
- If an node has a direct parent node P1 and P2, if P1 is a child node of P2, then remove P2 from the direct parent node
- If an node has a direct child node C1 and C2, if C1 is a parent node of C2, then remove C2 from the direct parent node
- If nodes refer to nodes that doesn't exist, remove that reference
- Each time, insertion, alter, and deletion of nodes and items are operated, normalization operation starts, so the database is always normalized
In the end the database looks like this:
There will be a separated database handling converting integers ids into it's respectable names.
Slowly progressing. I only need to finish it by the time I start building a math problem database. C++ is hard.
- Mgccl's blog
- Add new comment
- 274 reads
Plotting my mood
Posted January 3rd, 2008 by MgcclI did a plot of the mood wave though out the the day.
Sometimes, I wish I have stereotypical white parents(SWP). If I have a goal, SWP will support me. SWP will bring back pizza once in a while, SWP eat out with family once in a while, SWP permits food like chips and soda around the house, most importantly, SWP allows their kids to stay at home if they are really sick. While my Asian parents (MAP) don't eat out with family, does not allow rubbish food because they are just cheap, does not have any form of popular entertainment, only cares about the SATs and have extremely high expectation on me. I hate having MAP always nagging about the SATs. I can not just throw away everything and do the SATs, let me be what I want to be. It's such a sad thing that I can not select my own family member. >.< My god they don't even believe in me. I don't drink, smoke or do drugs, and the SWP can believe kids who does all of the above and MAP will not. I lived too long in a White neighborhood, I should know I can't expect much from MAP. I will get to college and finally I can move away from them.
The day is quite bad. The worst time is when some students got a +20 bonus points in their test because others failed to do a simple lab. WTF!!!,if it's like 5 points I can understand... 20 points, is 1/5 of a test!? Of course, I'm suppose to be happy about it, I'm sure the reason we did not finish the simple lab is not me or my partner, but the equipment. My group did the exact same test 3 times with no result, that wasted us 40 minutes, then we did it again with another set(the 3rd set we tried) of chemical and equipment, and everything start to go well. But the 40 minutes is already wasted so our group can not finish the lab. 
There are only 8 set of equipment out there, and strangely, twice, we chose the ones that does not work. What's the odd. If there is a god, it must hate us.
After chem, it's pre-calc, and I'm doing math problems from the Five Hundred Mathematical Challenges. I used the entire period solve 2 questions. Turns out the answer have really elegant proof can be done in less than 5 minutes.
That's way to depressing. In fact, doing math problems is really depressing until I found the solution, then get destroyed by seeing other's solutions. This joke would perfectly explain what I'm like when I do math. From a page filled with corny math jokes.
"So how's your boyfriend doing, the math student?"
"Don't mention that crazy pervert to me anymore! We broke up."
"How can you say such a nasty thing about him? He seemed to be such a nice boy."
"Imagine! He was restless during the days and couldn't sleep at night - always trying to solve his math problems. When he had finally done it, he wasn't happy: he would call himself a complete idiot and throw all his notes into the garbage. One day, I couldn't take it anymore, and I told him to drop math. You know what he told me?"
"No."
"He said, he enjoyed it!!!"
The graph is created with JPgraph with cubic spline connects the points.
One of the MAP is such a control freak, she want to control everything, include my future occupation and marriage. Just wait... when I get to college, I will tell her to stay out of my life. Can't wait till that day.
- Mgccl's blog
- Add new comment
- 506 reads
What to use to serving dynamic plotted math functions
Posted December 2nd, 2007 by MgcclI was trying hard to find a alternative for showing mathematical graphs on my site. I want a grapher designed for plotting math equations (not statistical charts) and crap free.
I'm using a shared hosting, GNUplot + Simple PHP interface is not the most simple choice, especially the interface is far away from complete, more of a proof of concept script.
webMathematica, well, the Amateur version is free, but requires Premier Service, which requires a mathematica license. Let's say I brought mathematica student edition for $129 just to get the license and then pay for premier service to get my "free webMathematica amateur", that cost more than 2 years of quality hosting on site5. Other than it's expensiveness, it's totally amazing because it's the web front end of Mathematica.
If you have mathematica on your server, you can use WITM as a front end, or write your own [there's a command line version of mathematica comes with your beloved $129]. Remember to make cache system. Trust me, plotting the factorial from 1 to 10^5 is not cpu friendly. I will write about that really soon.
openPlaG is simple to use and take less than 1 minute to install (or even less.. download.. extract) and free. Over 150 built in math functions, include derivative and integral. But implemented in PHP result it's slowness. Write a cache module will avoid the problem of generating images on the fly with a interpreting language.
But openPlaG is only a back up for what I'm really using right now, a duplicate of Walter Zorn's Online Function Grapher.
It uses almost no server CPU (except output the js file) when compared with openPlaG. I believe it's the best choice for anyone who don't have the money, the time and the CPU. In the Drupal implementation [mathfilter], it is iframe a php file on the server, increases some CPU usage.
Calc5's graph calculator would be exactly what I would like to use to show graphs on this site. Compare to Walter's, this script uses canvas, and easy to zoom in/out, drag the plot to move around like in Google map. too bad there is no "embed this graph" link anywhere and does not show the corrdinate of the mouse either.
JS masters really can make a graphing calculator in JS and save all mathematicians.
- Mgccl's blog
- 1 comment
- 1046 reads








Recent comments
14 hours 41 min ago
1 day 6 hours ago
1 day 23 hours ago
3 days 17 hours ago
3 days 23 hours ago
4 days 2 hours ago
4 days 8 hours ago
4 days 14 hours ago
4 days 17 hours ago
4 days 19 hours ago