c1ddb4c814 2021-03-01 1: %%%%%%%%%%%%%%%%%%%%%
c1ddb4c814 2021-03-01 2: % ALGEBRA (SOLVE)
c1ddb4c814 2021-03-01 3: %%%%%%%%%%%%%%%%%%%%%
c1ddb4c814 2021-03-01 4:
c1ddb4c814 2021-03-01 5:
c1ddb4c814 2021-03-01 6: % Solve quadratic equation
c1ddb4c814 2021-03-01 7: solve(x^2+8x+15=0, x);
c1ddb4c814 2021-03-01 8:
c1ddb4c814 2021-03-01 9: % Solve for expression
c1ddb4c814 2021-03-01 10: solve(a*log(sin(x+3))^2 - b, sin(x+3));
c1ddb4c814 2021-03-01 11:
c1ddb4c814 2021-03-01 12: % Solve simultaneous equations
c1ddb4c814 2021-03-01 13: solve({x+3y=7, y-x=1},{x,y});
c1ddb4c814 2021-03-01 14:
c1ddb4c814 2021-03-01 15: % Solve a system with parameters
c1ddb4c814 2021-03-01 16: solve({x=a*z+1, y=b*z},{z,x});
c1ddb4c814 2021-03-01 17:
c1ddb4c814 2021-03-01 18: % Simplify expression
c1ddb4c814 2021-03-01 19: ((((-r1*(1+k1))/(r2*(1+k2)))+((r1)/(r2)))/(((r1)/(r2))));
c1ddb4c814 2021-03-01 20:
c1ddb4c814 2021-03-01 21: % Another solve example
c1ddb4c814 2021-03-01 22: % Note the use of $ as the line termination
c1ddb4c814 2021-03-01 23: % character to suppress output from
c1ddb4c814 2021-03-01 24: % intermediate computations
c1ddb4c814 2021-03-01 25: x1 := sqrt(h^2 + p1^2)$
c1ddb4c814 2021-03-01 26: x2 := sqrt((h/2)^2 + (p-p1)^2)$
c1ddb4c814 2021-03-01 27: x3 := x1 + x2$
c1ddb4c814 2021-03-01 28: dx := df(x3, p1)$
c1ddb4c814 2021-03-01 29: solve(dx, p1);
c1ddb4c814 2021-03-01 30:
c1ddb4c814 2021-03-01 31: % Suppose you are given the equation
c1ddb4c814 2021-03-01 32: % x^2+x+1=0 and wish to determine the
c1ddb4c814 2021-03-01 33: % value of x^3. The following simple
c1ddb4c814 2021-03-01 34: % substitution achieves this.
c1ddb4c814 2021-03-01 35: rule := solve(x^2+x+1=0,x)$
c1ddb4c814 2021-03-01 36: y := (x^3 where rule);
c1ddb4c814 2021-03-01 37:
c1ddb4c814 2021-03-01 38: % Then y=1, because
c1ddb4c814 2021-03-01 39: % x^3=x*(x^2)=-x*(x+1)=-x^2-x=1.
c1ddb4c814 2021-03-01 40:
c1ddb4c814 2021-03-01 41: end;