5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c: % ALGEBRA (SOLVE)
5f892713c3 2021-03-03 trnsz@pobox.c: %%%%%%%%%%%%%%%%%%%%%
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Specify blue for echoed input
5f892713c3 2021-03-03 trnsz@pobox.c: color("Blue");
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Turn on fancy output
5f892713c3 2021-03-03 trnsz@pobox.c: fancy_output;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Turn input echo on
5f892713c3 2021-03-03 trnsz@pobox.c: on echo;
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Solve quadratic equation
5f892713c3 2021-03-03 trnsz@pobox.c: solve(x^2+8x+15=0, x);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Solve for expression
5f892713c3 2021-03-03 trnsz@pobox.c: solve(a*log(sin(x+3))^2 - b, sin(x+3));
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Solve simultaneous equations
5f892713c3 2021-03-03 trnsz@pobox.c: solve({x+3y=7, y-x=1},{x,y});
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Solve a system with parameters
5f892713c3 2021-03-03 trnsz@pobox.c: solve({x=a*z+1, y=b*z},{z,x});
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Simplify expression
5f892713c3 2021-03-03 trnsz@pobox.c: ((((-r1*(1+k1))/(r2*(1+k2)))+((r1)/(r2)))/(((r1)/(r2))));
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Another solve example
5f892713c3 2021-03-03 trnsz@pobox.c: % Note the use of $ as the line termination
5f892713c3 2021-03-03 trnsz@pobox.c: % character to suppress output from
5f892713c3 2021-03-03 trnsz@pobox.c: % intermediate computations
5f892713c3 2021-03-03 trnsz@pobox.c: x1 := sqrt(h^2 + p1^2)$
5f892713c3 2021-03-03 trnsz@pobox.c: x2 := sqrt((h/2)^2 + (p-p1)^2)$
5f892713c3 2021-03-03 trnsz@pobox.c: x3 := x1 + x2$
5f892713c3 2021-03-03 trnsz@pobox.c: dx := df(x3, p1)$
5f892713c3 2021-03-03 trnsz@pobox.c: solve(dx, p1);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Suppose you are given the equation
5f892713c3 2021-03-03 trnsz@pobox.c: % x^2+x+1=0 and wish to determine the
5f892713c3 2021-03-03 trnsz@pobox.c: % value of x^3. The following simple
5f892713c3 2021-03-03 trnsz@pobox.c: % substitution achieves this.
5f892713c3 2021-03-03 trnsz@pobox.c: rule := solve(x^2+x+1=0,x)$
5f892713c3 2021-03-03 trnsz@pobox.c: y := (x^3 where rule);
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Then y=1, because
5f892713c3 2021-03-03 trnsz@pobox.c: % x^3=x*(x^2)=-x*(x+1)=-x^2-x=1.
5f892713c3 2021-03-03 trnsz@pobox.c:
5f892713c3 2021-03-03 trnsz@pobox.c: % Turn off echo
5f892713c3 2021-03-03 trnsz@pobox.c: off echo;