home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / sm22a.zip / SYMBMATH.H09 < prev    next >
Text File  |  1993-04-15  |  5KB  |  172 lines

  1.             7.7 Equations
  2.             7.7.1 Algebraic Equations
  3.  
  4.     The equations can be operated (e.g. +, -, *, /, ^, expand(), 
  5. diff(), inte()). The operation is done on both sides of the equation, 
  6. as by hand. SymbMath is able to find roots of a polynomial, algebraic 
  7. equations, systems of equations, differential and integral equations.
  8.  
  9.     Example 7.7.1. Solve an equation
  10. sqrt(x+2*k) - sqrt(x-k) === sqrt(k), 
  11. then check the solution by substituting the root into the equation.
  12.     Input:
  13. eq1=(sqrt(x + 2*k) - sqrt(x - k) === sqrt(k))
  14. eq1^2
  15. expand(last)
  16. last-k-2*x
  17. last/(-2)
  18. last^2
  19. expand(last)
  20. last-x^2+2*k^2
  21. last/k
  22. subs(eq1, x=right(last))
  23. end
  24.     Output:
  25. eq1=(sqrt(x + 2*k) - sqrt(x - k) === sqrt(k))
  26. ((2*k + x)^0.5 - ((-k) + x)^0.5)^2 === k
  27. 2*x + k + (-2)*(2*k + x)^0.5*((-k) + x)^0.5 === k
  28. (-2)*(2*k + x)^0.5*((-k) + x)^0.5 === (-2)*x
  29. (2*k + x)^0.5*((-k) + x)^0.5 === x
  30. (2*k + x)*((-k) + x) === x^2
  31. (-2)*k^2 + k*x + x^2 === x^2
  32. k*x === 2*k^2
  33. x === 2*k
  34. k^0.5 === k^0.5
  35.  
  36.     SymbMath can solve many algebraic equations step by step, as 
  37. by hand. This method is useful on teaching, e.g. to show students how 
  38. to solve equations.
  39.     SymbMath has the built-in function 
  40.  
  41.         solve(expr1 === expr2, x)
  42.         solve([expr1 === expr2, expr3 === expr4], [x, y])
  43.  
  44. to solve a polynomial and systems of linear equations on one step.
  45. It is recommended to set the switch expand=on when solve the 
  46. complicated equations. All of the real and complex roots of the 
  47. equation will be found by solve(). The function solve() outputs a 
  48. list of roots when there are multi-roots. Users can get one of roots 
  49. from the list, (see 7.9 List, Array, Vector and Matrices).
  50.     Users can get the left side of the equation by
  51.  
  52.         left(left_side === right_side)
  53.  
  54. or the right side by
  55.  
  56.         right(left_side === right_side)
  57.  
  58.     Example 7.7.2. Solve a+b*x+x^2 === 0, save the root to x.
  59.     Input:
  60. eq1 = (a+b*x+x^2===0)
  61. solve(eq1, x)
  62. x=right(last)
  63. x[1]
  64. x[2]
  65. end
  66.     Output:
  67. eq1 = (a+b*x+x^2 === 0)
  68. x === [-b/2 + sqrt((b/2)^2 - a),  -b/2 - sqrt((b/2)^2 - a)]
  69. x = [-b/2 + sqrt((b/2)^2 - a),  -b/2 - sqrt((b/2)^2 - a)]
  70. -b/2 + sqrt((b/2)^2 - a)
  71. -b/2 - sqrt((b/2)^2 - a)
  72.  
  73.  
  74.     Example 7.7.3. Solve x^3+x^2+x+5 === 2*x+6.
  75.     Input:
  76. num(solve(x^3+x^2+x+5 === 2*x+6, x))
  77. end
  78.     Output:
  79. x === [1, -1, -1]
  80.  
  81.     Function solve() not only solve for a simple variable x
  82. but also for an unknown function, e.g. ln(x).
  83.  
  84.     Example 7.7.4. Solve the equation for ln(x).
  85.     Input:
  86. solve(ln(x)^2+5*ln(x) === -6, ln(x))
  87. exp(last)
  88. end
  89.     Output:
  90. ln(x) === [-2, -3]
  91. x === [exp(-2), exp(-3)]
  92.  
  93.     Example 7.7.5. Rearrange the equations.
  94.     Input:
  95. f = [x+y === 3+a+b, x-y === 1+a-b]
  96. solve(f, [x,y])
  97. solve(f, [a,b])
  98. solve(f, [a,y])
  99. solve(f, [x,b])
  100. end
  101.     Output:
  102. f = [x + y === 3 + a + b, x - y === 1 + a - b]
  103. [x === -1/2*(-4 - 2 a), y === -1/2*(-2 - 2 b)]
  104. [a === -1/2*(4 - 2 x), b === -1/2*(2 - 2 y)]
  105. [b === -1/2*(2 - 2 y), x === -1/2*(-4 - 2 a)]
  106. [a === 1/2*(-4 + 2 x), y === 1/2*(2 + 2 b)]
  107.  
  108.  
  109.  
  110.         7.7.2 Differential Equations
  111.  
  112.     SymbMath can solve the variables separable differential
  113. equations:
  114.         y(x)*d(y(x), x) === f(x)
  115. by integration inte().
  116.     Example: 7.7.2.1
  117.     Input:
  118. y(x)*d(y(x), x) === sin(x)
  119. inte(last, x)
  120. end
  121.     Output:
  122. y(x)*d(y(x), x) === sin(x)
  123. 1/2*y(x)^2 === constant - cos(x)
  124.  
  125.     The function 
  126.  
  127.         dsolve(d(y)/d(x) === f(x,y), y) 
  128.  
  129. can solve the first order variables separable and linear differential 
  130. equations
  131.  
  132.         d(y)/d(x) === h(x) 
  133.         d(y)/d(x) === g(y) 
  134.         d(y)/d(x) === g(y)*x
  135.         d(y)/d(x) === g(x)*y
  136.         d(y)/d(x) === g(x)*y+h(x)
  137.  
  138. on one step. Notice that d(y)/d(x) must be alone on the left hand
  139. side of the equation. It is recommended to set the switch 
  140. expand=on and/or to include 'inte.sm' when solving the complicated 
  141. differential equations.
  142.  
  143.     Example 7.7.2.2 Solve d(y)/d(x)=== -sinh(x)*y+sinh(x)*cosh(x).
  144.     Input:
  145. dsolve(d(y)/d(x) === -sinh(x)*y+sinh(x)*cosh(x), y)
  146. end
  147.     Output:
  148. y === (constant + exp(cosh(x)) - cosh(x)*exp(cosh(x)))*exp(-cosh(x))
  149.  
  150.     Example 7.7.2.3 Solve differential equations. If the result is
  151. a polynomial, then rearrange the equation by solve().
  152.     Input:
  153. dsolve(d(y)/d(x) === x/(2+y), y)
  154. solve(last, y)
  155. end
  156.     Output:
  157. 2*y + 1/2*y^2 === constant + x^2
  158. y === [-2 + sqrt(4 - 2*(-constant - x^2)), -2 - sqrt(4 - 2*(-constant - x^2))]
  159.  
  160.     Example 7.7.2.4. Solve differential equations.
  161.     Input:
  162. dsolve(d(y)/d(x) === x*exp(y), y)
  163. dsolve(d(y)/d(x) === y^2+5*y+6, y)
  164. dsolve(d(y)/d(x) === y/x, y)
  165. dsolve(d(y)/d(x) === y*x+1, y)
  166. end
  167.     Output:
  168. -exp(-y) === constant + x^2
  169. ln((4 + 2*y)/(6 + 2*y)) === constant + x
  170. y === constant*x*sgn(x)
  171. y === exp(1/2*x^2)*(constant + sqrt(1/2)*sqrt(pi)*erf(sqrt(1/2)*x))
  172.