Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'making a transformation' topicStudent Support Forum > General > Archives > "making a transformation"

< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
05/21/12 00:41am

In Response To 'Re: Re: making a transformation'
---------
You wrote:
"Hi Bill,
Another example that puzzles me. See attachment.

Attachment: Simpson transformation example.nb"

(* This one doesn't work *)
FullSimplify[(a-b*i)*E^((-p-i*q)*t) + (a+b*i)*E^((-p+i*q)*t)]/. a_ Cos[c_]-b_ Sin[c_]->Sqrt[a^2+b^2]Cos[c+ArcTan[a,b]]

(**because because there is no a*Cos[c]-b*Sin[c] to match**)

and then at the bottom of your notebook

(* but this one doesn't *)

(**again because there is no a*Cos[c]-b*Sin[c] to match**)

Perhaps this will help, think of all pattern matching in Mathematica like this: "IF AND ONLY IF you give me an expression that looks almost EXACTLY like THIS then I will substitute THAT and give it back, otherwise I will give you back your original with no changes at all."

Mathematica does not do "mathematical pattern matching"=understanding the intent of the expression and the pattern. Instead Mathematica does "structureal pattern matching"=if the structure of the expression and the pattern are almost identical then it will work and not otherwise.

Mathematica will almost never look at your expression, realize that it could do a bunch of rearrangement, make a bunch of algebraic changes, then see that there is a way your pattern could match and give you the substitution.

If you need Mathematica to make a brilliant substitution for an expression that isn't almost exactly in the form your simple pattern is in and you need that pattern to work for all kinds of small variations in your expression then you need to be able to write brilliant complicated pattern that will do all that work for you. And the beginning to intermediate Mathematica user doesn't have the skill or knowledge to be able to do that.

For your examples that work and the ones that don't, look at the result from FullSimplify, using FullForm if necessary, and try to see the structures are identical when the substitution works and not identical when it fails.

URL: ,

Subject (listing for 'making a transformation')
Author Date Posted
making a transformation Ed Nowak 05/16/12 05:19am
Re: making a transformation Bill Simpson 05/16/12 1:18pm
Re: Re: making a transformation Ed Nowak 05/19/12 00:18am
Re: Re: making a transformation Ed Nowak 05/19/12 02:14am
Re: Re: Re: making a transformation Bill Simpson 05/21/12 00:41am
Re: Re: Re: Re: making a transformation Ed Nowak 05/25/12 01:18am
Re: Re: Re: Re: making a transformation Ed Nowak 05/25/12 02:23am
Re: Re: Re: Re: Re: making a transformation Bill Simpson 05/26/12 10:14pm
Re: Re: Re: Re: Re: Re: making a transformation Ed Nowak 05/28/12 7:22pm
Re: Re: Re: Re: Re: making a transformation Michael 05/27/12 07:20am
Re: making a transformation Ed Nowak 05/18/12 07:25am
< Previous Comment | Next Comment >Help | Reply To Comment | Reply To Topic