[Date Index]
[Thread Index]
[Author Index]
Some more questions Part II: Mathematica
*To*: mathgroup at smc.vnet.net
*Subject*: [mg22188] Some more questions Part II: Mathematica
*From*: "Jordan Rosenthal" <jr at ece.gatech.edu>
*Date*: Thu, 17 Feb 2000 01:24:24 -0500 (EST)
*Organization*: Georgia Institute of Technology, Atlanta GA, USA
*Sender*: owner-wri-mathgroup at wolfram.com
Hi all,
This group has been so helpful I couldn't resist asking some more questions.
I've split them up into two messages, one for my general questions and the
other strictly Mathematica.
These are the Mathematica questions:
1) Consider the following expression:
intQ = FullSimplify[Integrate[Simplify[(1 - Cos[m*w])*(1 - Cos[n*w])],
{w, 0, wp}]]
Out =
wp +
((m*Cos[n*wp])/(m^2 - n^2) - 1/m)*Sin[m*wp] + ((n*Cos[m*wp])/(n^2 -
m^2) - 1/n)*Sin[n*wp]
In the output there are some common terms which I wanted to make obvious.
so I did the following:
intQ /. (n_ Cos[m_ wp]/(n_^2 - m_^2) - 1/n_)Sin[n_ wp] -> g[n, m]
Out =
wp + g[m, n] + g[n, m]
Now my question. I would like to be able to define g[n_,m_] according to
the replacement rule I just used above. Easy enough, but how can I register
this fact with Simplify so that it uses it during the simplification
process? I assume I need to define it with an upvalue in some way, but I
get protection complaints and am hesitant about using unprotect before
finding out if I'm on the right track. So am I?
2) When converting formulas to other languages (say C for example), it would
be nice to match similar terms as I did above manually; this would make it
easy to write modular functions that can be reused. Is there a
ComplexityFunction anyone can think of which, when given to
Simplify/FullSimplify, will return a formula with the number of matching
terms maximized (or number of dissimilar terms minimized)? It might have an
interesting application for compilers. (Is this ill-defined?)
Thanks,
Jordan
Prev by Date:
**Re: Re: Simple Problem (I suppose...)**
Next by Date:
**Re: sum of recursive fn: solving for n**
Previous by thread:
**Global precision and accuracy.**
Next by thread:
**Integrating Probability Surface_HOW?**
| |