Hacker News new | ask | show | jobs
by seanhunter 511 days ago
Some other useful things:

1)solve to solve a system and “variable: expression” will assign that expression to that variable. You can then substitute the results into a later expression using a “,”. So you might do

   solns:solve([x+3*y=5,5*x-2*y=4],[x,y]);
   z:%e^(x,y),solns;
That will solve the system and then substitute those solutions into the expression for z.

2)pi, e, and the imaginary unit are called %pi, %e and %i respectively.

3)The symbolic solver is a lot less powerful than mathematica but you can do

   load(“to_poly_solve”);
To get a polynomial solver that will at least get you all the roots of polynomials and does better on most trigonometric equations.

   load(“drawdf”);
Is useful for drawing vector fields, phase portraits and that type of thing.

4) you can use a single quote to delay evaluation of something. Like say you want to write a differential equation and you don’t want it to actually try to evaluate the derivative inline, you can write something like

   osc:‘diff(x,t,2) + r*’diff(x,t) + k*x = p*cos(omega\*t);
…for a forced harmonic oscilator. Or whatever. This is useful if you want to mess with the expression a bit before you try to solve the expression (eg doing substitutions or whatnot).*