home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / sci / math / symbolic / 2930 < prev    next >
Encoding:
Text File  |  1992-11-09  |  2.2 KB  |  55 lines

  1. Newsgroups: sci.math.symbolic
  2. Path: sparky!uunet!walter!qualcom.qualcomm.com!antonio
  3. From: antonio@qualcomm.com (Franklin Antonio)
  4. Subject: obscure Mathematica question
  5. Message-ID: <1992Oct27.222733.22398@qualcomm.com>
  6. Organization: Qualcomm, Inc., San Diego, CA
  7. Date: Tue, 27 Oct 1992 22:27:33 GMT
  8. Lines: 45
  9.  
  10.  
  11. I apologize for the not-very-explicit subject line.  I really don't know
  12. how to describe this question, because i'm obviously missing a concept.
  13.  
  14. I have a situation where I know that some variables can only take on
  15. the values 0 or 1.  Therefore, for these specific variables, I know
  16. that when raised to any positive integer power, they stay the same.
  17. Therefore, I would like to simplify by substituting X in place of X^2
  18. or X^3 or X^4, etc.
  19.  
  20. In a program that someone sent me, the following statements appear,
  21. which seem to tell Mathematica about this situation...
  22.  
  23. Unprotect[Power]
  24. w[i_]^(2) := w[i]
  25. w[i_]^(3) := w[i]
  26. w[i_]^(4) := w[i]
  27. w[i_]^(5) := w[i]
  28. w[i_]^(6) := w[i]
  29. w[i_]^(7) := w[i]
  30. w[i_]^(8) := w[i]
  31.  
  32. Now my question... I had expected that when I evaluated an expression
  33. containing w[3]^5, for example, this should simplify to w[3], because
  34. of the above definitions.  This, however, does not happen.
  35.  
  36. If i write a simple expression, such as w[4]^3 + w[3]^4, and evaluate it,
  37. it comes back w[3] + w[4] as expected.  Complex expressions however,
  38. still contain powers of these variables, and this keeps these expressions
  39. from simplifying properly.  (LOTS of terms would combine if Mathematica
  40. understood that all exponents on these w's could be dropped.)
  41.  
  42. There seem to be times where one needs to help Mathematica along by telling
  43. it explicitly what to do next, and maybe this is one of those times?
  44.  
  45. What do I do to tell Mathematica to make these substitutions?  I figure 
  46. I could use /. to tell it to use a rule explicitly, but what I don't 
  47. understand is why/how it is that it sometimes doesn't know about these
  48. definitions that i've installed in power, and whether there is a way
  49. to say HEY YOU, please actually USE these definitions you have.
  50.  
  51. There is SO MUCH i need to know to use Mathematica effectively!  The books
  52. are so difficult to use, because there's no index by "concept whose name
  53. i don't even know".
  54.  
  55.