home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / sm22a.zip / SYMBMATH.H03 < prev    next >
Text File  |  1993-04-21  |  2KB  |  96 lines

  1.             7. Examples
  2.  
  3.     In the following examples, a line of "Input:" means that 
  4. typing the program in the Editor, then leaving the Editor by <Esc>, 
  5. finally running the program by the command "Run", while a line of 
  6. "Output:" means outputs in the "Output" window. # is a comment 
  7. statement. All examples should be terminated by the end statement,
  8. but the end statement may omit in the output of the following examples.
  9.  
  10.  
  11.         7.1 Simplification and Assumption
  12.  
  13.     SymbMath automatically simplifies the output expression. 
  14. Users can further simplify it by using the built-in variable "last" 
  15. in a singe line again and again until they are happy.
  16.  
  17.     Example 7.1.1. Reduce sqrt(x^2).
  18.     Input:
  19. sqrt(x^2)
  20. end
  21.     Output:
  22. x*sgn(x)
  23. end
  24.  
  25.     A first way to reduce this output expression is to substitute
  26. sgn(x) by 1 if x is positive.
  27.     Input:
  28. sqrt(x^2)
  29. subs(last, sgn(x)=1)
  30. end
  31.     Output:
  32. x*sgn(x)
  33. x
  34. end
  35.     A second way to reduce the output expression is to assume
  36. x>0 before evaluation. On this way, all x is affected. The first 
  37. method is local simplification, but the second method is global
  38. simplification. If users declare the variable x is positive or 
  39. negative by 
  40.  
  41.         assume(x > 0)
  42.         assume(x < 0)
  43.  
  44. the output expression is simpler than that if users do not declare it.
  45.  
  46.     Example 7.1.2. Assume x>0 before reduce sqrt(x^2).
  47.     Input:
  48. assume(x >0)
  49. sqrt(x^2)
  50. end
  51.     Output:
  52. assumed
  53. x
  54. end
  55.  
  56.     Users can assume the variable b is even, odd, integer, real 
  57. number, positive or negative  by
  58.  
  59.         iseven(b) := 1          # assume b is even
  60.         isodd(b) := 1           # assume b is odd
  61.         isinteger(b) := 1       # assume b is integer
  62.         isreal(b) := 1          # assume b is real
  63.         isnumber(b) := 1        # assume b is number
  64.         islist(b) := 1        # assume b is a list
  65.         isfree(y,x) := 1    # assume y is free of x
  66.         sgn(b) := 1             # assume b is positive
  67.         sgn(b) := -1            # assume b is negative
  68.  
  69.     All variables are complex by default.
  70.  
  71.     Example 7.1.3.
  72.     Input:
  73. isreal(b) := 1
  74. sqrt(b^2)
  75. end
  76.     Output:
  77. isreal(b) := 1
  78. abs(b)
  79. end
  80.  
  81.     Example 7.1.4. Set f1=x^2+y^3, then put f1 into sin(f1)+
  82. cos(2*f1) and assign the last output to f2.
  83.     Input:
  84. f1=x^2+y^3
  85. sin(f1)+cos(2*f1)
  86. f2=last
  87. end
  88.     Output:
  89. f1 = x^2 + y^3
  90. sin(x^2 + y^3) + cos(2 (x^2 + y^3))
  91. f2 = sin(x^2 + y^3) + cos(2*(x^2 + y^3))
  92. end
  93.  
  94. where a special word "last" stands for the last output, e.g. here
  95. "last" is sin(x^2+y^3)+cos(2*(x^2+y^3)).
  96.