“Processing” is a free programming environment designed for non-programmers. This page describes how to use Processing to calculate values of a function. This might be useful for algebra homework:

- Download the Processing programming environment. Processing is available for Mac and Windows (and Linux).
- Unzip or install, as needed. Set up a shortcut if you wish.
- Invoke Processing
- Copy and paste this program into the main window:
void setup() { int x; float y; for ( x=1; x<10; x++) { y = log( x ); print(x); print("\t"); println(y); } }

- To run the program, press the “play” button on the top left. The answers appear in the black part of the window below where you pasted the program. Ignore the little pop-up box as we’re not using this feature.

Other tips:

- Log here is really ln. Very bad choice of name, if you ask me.
- If you need a log to a different base, remember than
log(different base) (x) = log (x)/log(different base)

- Use plenty of parenthesis to make sure that calculations are done in the order you would like
- Use as many spaces or new lines as you wish to make it more readable. The program ignores these so-called “white spaces”.
- To raise to a power, use the “pow” command e.g. x squared is pow(x,2)
- Times is ‘*’
- Your equation (and every statement) must end with a semicolon
- If you change your program you have to hit the “stop” button and then the “play” button again in order to see the results

Here is a more complex example for y=5+(log(base 12) ((x-7)squared). Note that in this example x must be greater than 7 so that we never take the log of zero:

void setup() { int x; float y; for ( x=8; x<20; x++) { y = 5+ ( log ( pow( x-7 , 2)) /log(12) ); print(x); print("\t"); println(y); } }

Here is an example of a quadratic function, and also shows how to increase x in steps of 5:

void setup() { int x; float y; for ( x = -20; x < 20; x += 5) { y = 3*pow (x, 2) + 12*x - 5; print(x); print("\t"); println(y); } }

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.