Patrik Lundin is a computer programmer from Stockholm, Sweden. It was my good fortune to come across his programs on the web and I immediately recognized the complexity and quality of this particular project. His program allows you to type in a formula for a function and the program reads it and executes it. The formula you type is nothing more than text and the program must read it, modify it, interpret it, and then execute it. This is a monumental task and Patrik's code is a work of art.
I contacted him via e-mail and Patrik graciously sent me the code. He has helped me to understand his code and he has made numerous changes to accommodate our needs. We have sent more than forty e-mail's back and forth to date. The need for this is due to the complexity of code. Actually, the only reason that I could understand any part of such an elaborate program is the impeccable architecture of his code. You and I both owe him a tremendous debt of gratitude for his selfless concern for us. Thank you, Patrik.
This graphing calculator has a beautiful graphing screen. The background is black (very chic) and the functions are drawn in random colors. You will never see the same color twice! However, don't let the style of the program keep you from appreciating the power of its algorithms.
When you type the function and press the plot button, the program reads your typing and recognizes the operators, the numbers, and the variables. It then translates it into a form that the computer can read, known as Reverse Polish Notation. That simply orders the tasks. The program then scans every symbol and compare it to all of the patterns that have been written into the program. When it finds a match it gets the numbers that it needs and performs the corresponding operation. It has to make this search for patterns for each operation that you type in and it must do that about a hundred times for one graph. I hope that next time you watch it graph, you have some appreciation for all the work that the program is doing.
Appropriate Function Inputs
Although Patrik's Calculator can handle most of the expression formats that a commercial graphing reads, there are a few things of which you should be aware. A graphing calculator has a " y = " beside the place that you type the expression that you want graphed. That is not possible with this layout, but you must not put it in yourself. Simply type expression, which is the part of the equation containing the " x ". You of course need to know how to write exponentiation. " x squared " is written as x^2. When typing the exponential function, you may use a common notation, exp(x). However, the constant, e, is referred to by its proper name, "euler". Hence, instead of typing e^x, you should type euler^x. Like most programming languages, the multiplication symbol is a star, *.
Operating the Controls
The Function Input screen is shown above. In the textbox directly below the "Write Function to plot here" label is where you type your function. (Surprised?) You do not need to click on the box the first time, it already has the focus. You simply type the function that you want to see. Below that is a button marked "Plot Function". You click that when you want to see the function graphed.
The function is written in the text area below the "Plot Function" button and then it is plotted. You may plot as many functions as you like; the colors are fun to look at. If you decide the screen is getting too cluttered ( you are having too much fun ) you click the button logically labeled "Erase All Functions".
The bounds of the graph screen may not be optimal for the function you want to see. You may change the portion of the x-y plane that is displayed in the graphing screen. You may change that with the "Xmin", "Xmax", "Ymin", "Ymin" boxes at the bottom of the Function Input screen. Xmin is the x coordinate of left side of the screen and Xmax is the x coordinate of right side of the screen. Ymin is the y coordinate of top of the screen and Ymax is the y coordinate of bottom of the screen. If you change these numbers, the appropriate portion of the x-y plane will be shown when you press "Plot Function". The corresponding portion of the graph of the function will of course be drawn as well.
Finally, there is a button that says "Quit". Ignore it. ( You can run but you can't hide! ) I should have left it out. There's nothing to do on the page except the applet, so when you have finally had enough of a great thing, simply go to another of my programs.
To help you find these features and get familiar with the sequence of tasks, I have created a tutorial. Not that Patrik's superb layout isn't completely self explanatory, but the animations should be a little fun. Click on the link below to view the tutorial.