Algebra.red 1016 B

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