Re: Adding new rules to Simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg56377] Re: [mg56311] Adding new rules to Simplify
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 23 Apr 2005 01:16:09 -0400 (EDT)
- References: <200504221022.GAA18638@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 22 Apr 2005, at 19:22, John Billingham wrote: > I'm trying to teach Mathematica the obvious simplification rules for > Jacobi elliptic functions, which i had hoped would be built in! > Grumble > > Having defined > > > sn[x_ /; !FreeQ[x, JacobiSN] := > x /. JacobiSN[u_, m_]-> Sqrt[(1 - JacobiDN[u, m]^2)/m]; > > sn[x_] := x; > > mySimplify = > Simplify[#, TransformationFunctions -> {sn, Automatic}] &; > > I find that > > mySimplify[1 - (1 - k^2) JacobiSN[p, 1 - k^2]] > > gives me > > JacobiDN[p, 1 - k^2]^2 > > as I had hoped, but that the equivalent expression > > mySimplify[1 + (-1 + k^2) JacobiSN[p, 1 - k^2] > > leaves the formula unsimplified. > > What Mathematica subtlety am I missing here?? > > Thanks, > > John > > I can't beleive that either of your cases worked; they certainly do not work here. What is missing is that you need to specify a ComplexityFunction that will make the result of your desired simplification "simpler" than what you started with. For example this will work: In[1]:= sn[x_] /; !FreeQ[x, JacobiSN] := x /. JacobiSN[u_, m_] -> Sqrt[(1 - JacobiDN[u, m]^2)/m]; In[2]:= sn[x_] := x; In[3]:= mySimplify = Simplify[#1, TransformationFunctions -> {sn, Automatic}, ComplexityFunction -> (Count[#1, JacobiSN[__], Infinity] & )] & ; Now both of your "simplifications" (the results certainly look more "complex") work as intended. Andrzej Kozlowski Chiba, Japan http://www.akikoz.net/andrzej/index.html http://www.mimuw.edu.pl/~akoz/
- References:
- Adding new rules to Simplify
- From: John Billingham <John.Billingham@Nottingham.ac.uk>
- Adding new rules to Simplify