Re: Simplifying equations for Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg65839] Re: [mg65752] Simplifying equations for Mathematica
• From: Daniel Lichtblau <danl at wolfram.com>
• Date: Tue, 18 Apr 2006 06:56:35 -0400 (EDT)
• References: <200604160749.DAA11245@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Yaroslav Bulatov wrote:
> [This post has been delayed due to email problems - moderator]
>
>
> I'm trying to solve some likelihood equations, and Mathematica will not
>
> finish in reasonable time. I'm wondering if there is a way I can
>
> rewrite it so that Mathematica can do them
>
>
>
> The concrete example is
>
> f[t1,t2,t3,t4,t5]=Log[Exp[0]+Exp[t1]+Exp[t2]+Exp[t1+t2]+Exp[t5]+Exp[t5+t1
> +t2]+Exp[t5+t2+t4]+Exp[t1+t2+t3+t4+t5]]
>
>
>
> The gradient of f defines a map R^5->R^5, and I need to invert that
>
> map. (This particular example can be solved by hand, but I'm wondering
> about other cases of the same form)
>
>
>
> Here's the command I use to solve it (works on Mathematica 5.2 only)
>
> +Exp[t5]+Exp[t5+t1+t2]+Exp[t5+t2+t4]+Exp[t1+t2+t3+t4+t5]],
> {{t1,t2,t3,t4,t5},1}],{m1,m2,m3,m4,m5}}]],{t1,t2,t3,t4,t5}]
>
>
>
> It's been running for several days on a Pentium 2Ghz. Are there simple
>
> transformations I can do to help Mathematica solve it?

One method is to make it explicitly polynomial by working, in effect,
with "variables" Exp[t1], etc. This can be done as below. We work with
expressions rather than equations.

exprs = Map[Apply[Subtract,#]&,
Exp[t5+t1+t2]+Exp[t5+t2+t4]+Exp[t1+t2+t3+t4+t5]],
{{t1,t2,t3,t4,t5},1}],{m1,m2,m3,m4,m5}}]];

Below we make exponentials into variables, keeping the same names. This
will not work if the variables appear other than in powers of exponentials.

exprs2 = exprs /. {Exp[a_]:>a, Exp[Plus[a__]]:>Apply[Times,a]};
vars = {t1,t2,t3,t4,t5};

This we can solve.

In[75]:= Timing[soln = Solve[exprs2==0, vars];]
Out[75]= {0.344022 Second, Null}

Now take logs of results since in effect we solved for Exp[tj]'s rather
than tj's.

In[76]:= InputForm[Log[vars] /. First[soln]]
Out[76]//InputForm=
{Log[-(5*m1 - 3*m2 - 5*m3 + 4*m4 - m5)/(4*(-2 + m1 + m2 - m3 + m5))],
Log[-(3*m1 - 5*m2 - 3*m3 + 4*m4 + m5)/(4*(2 - m1 - m2 + m3 - m5))],
Log[-(-5*m1 + 3*m2 + 21*m3 - 12*m4 + m5)/(4*(-2 + m1 + m2 - m3 + m5))],
Log[-((m1 - m2 - 3*m3 + 4*m4 - m5)/(-2 + m1 + m2 - m3 + m5))],
Log[-(-m1 - m2 + m3 - 4*m4 + 5*m5)/(4*(-2 + m1 + m2 - m3 + m5))]}

Daniel Lichtblau
Wolfram Research

```

• Prev by Date: Re: Re: Union, Sort at different levels of a list
• Next by Date: Re: Re: Re: Representation and Simulation of Dynamic Systems
• Previous by thread: Simplifying equations for Mathematica
• Next by thread: Re: Simplifying equations for Mathematica