Mathematica symbolic equation simplifcation

  • Mathematica
  • Thread starter Steve Drake
  • Start date
  • #1
Hi Guys,

I am new to mathematica. I have gotten it to do an integration for me, then simplified the answer using FullSimplify.

It does a very good job, but I can see that a futher symbolic substitution would make it even nicer, e.g. I would like to define A = b*x*t. So where ever there is b*x*t in the answer it puts in A, or if there is b^2*x^2*a^2 it puts in A^2.

Is there any way to do that?

Thanks
 

Answers and Replies

  • #2
1,069
29
Simple substitution will work here

In[1]:= 4*b*c*t*x/y/.b*x*t->A

Out[1]= 4 A c/y

Note that does some commutative rearrangement and can sidestep uninvolved variables in this example. But that simple substitution fails if you make other small obvious changes.

In[2]:= 4*b^2*c*t^2*x^2/y/.b*x*t->A

Out[2]= 4 b^2 c t^2 x^2/y

This is because Mathematica does not do "common sense mathematical substitution" but rather does "structural substitution"="brute force mindless does the pattern match (almost) exactly or not" substitution.

Ten or twenty years ago someone wrote an example pattern matcher in Mathematica, called Semantica I believe, which demonstrated "mathematical substitution." That has been uniformly resisted and I don't believe anything in that was adopted or incorporated into Mathematica in the last ten or twenty years.

Or if you have a simple problem then you can write a different pattern.

In[3]:= 4*b^2*c*t^2*x^2/y/.b^e_*x^e_*t^e_->A^e

Out[3]= 4 A^2 c/y

And that fails here

In[4]:= 4*b^2*c*t^2*x^3/y/.b^e_*x^e_*t^e_->A^e

Out[4]= 4 b^2 c t^2 x^3/y

Or you can write a more complicated pattern

In[5]:= 4*b^2*c*t^3*x^4/y/.b^p_*x^q_*t^r_ ->A^Min[p,q,r]*b^(p-Min[p,q,r])*x^(q-Min[p,q,r]) *t^(r-Min[p,q,r])

Out[5]= 4 A^2 c t x^2/y

And that will fail if you think a few moments and come up with other examples to confound it.

Unfortunately, every new user and most typically modestly skilled pattern writers, myself included, are not up to writing the sort of patterns really needed to implement "mathematical substitution" in general.

Usually good advice: If you just cannot figure out why a pattern doesn't match then look at the FullForm of your target. Sometimes using that to see the "structural form" that you are trying to write a pattern for will help. If that isn't enough then use random fumbling around until somehow it works or until you just give up.
 
Last edited:

Related Threads on Mathematica symbolic equation simplifcation

Top