Click on Ed's web-page to get back.
When programming, put a ; between commands. Let's play with a for-next loop. PARI does this for(variable=a,b,command) where a and b are integers you give it.
PARI can handle vectors. Type v=[10,9,8,7,6,5,4,3,2,1] You can pull out an entry like this: type v, on the next line type v.
To enter a matrix with three rows and two columns you could type
Let's play with if. PARI does this if(condition,command 1 ,command 2 ) The condition should include < or > or <> (the last is not equal). If the condition is true, then it will do command 1, if condition is not true it will do command 2. You can leave either command blank. Note issquare(n) outputs 1 if n is a square and 0 if it isn't.
To plug something into an expression, use subst(expression, variable,replacement). So to evaluate x^2 + x + 1 at x=7 I would
f=x^2 + x + 1
Typing the square of every number not divisible by 3:
To get a decimal approximation of a fraction like 18/19, then type 18/19 * 1.0
If you type \l, then everything that happens after that in your PARI session will be entered into a log file called pari.log in whatever directory you're in. Last changed: 4-Dec-2003