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