# Mathematica Solve Hangs Indefinitely

The following code hangs

Clear[S, Ext, k, α, β, γ, δ, f, a, b, c];
S[k_] := α β^(f – k) γ^(f – k)^2 δ^(f – k)^3;
Ext[k_] := a + b k + c k^2;
Solve[{S'[km] == Ext'[km], S”[km] == Ext”[km], Ext[km] == S[km]}, {a, b, c}, Reals];

This sort of algebra was going to get really ugly and I was really hoping Mathematica could handle it… any ideas on how what might be causing Mathematica to get stuck in the “Running…” state? My goal is is a solution for {a,b,c} in terms of {α, β, γ, δ, f, km}.

=================

I am new to Mathematica, so I may have messed up the syntax, but the three equations in solve aim to say “S evaluated at km is equal to Ext evaluated at km” and similarly for their derivatives.
– AGB
Jan 22 ’14 at 17:22

=================

1

=================

You are over complicating this problem. But, first a couple of observations. There are some typos and other things I would change in your code, so I would re-write it as follows:

Clear[S, Ext, k, α, β, γ, δ, f, a, b, c];
S[k_] := α β^(f – k) γ^(f – k)^2 δ^(f – k)^3;
Ext[k_] := a + b k + c k^2;
Solve[{S'[kmin] == Ext'[kmin], S”[kmin] == Ext”[kmin],
Ext[kmin] == S[kmin], Ext[0] == Sqrt[2] α}, {a, b, c}, Reals]

Note, the change from Set (=) to SetDelayed (:=) which would have revealed the typo in the definition of Ext. Also, Subscript is nice for formatted output, but it tends to just clutter things. My next step would be to eliminate any variables that a, b, and c do not depend on. So, barring any extra info, that means the equations reduce to

eqns = {Sp == Ext'[kmin], Spp == Ext”[kmin], Ext[kmin] == S,
Ext[0] == Sqrt[2] α}
(*
{Sp == b + 2 c kmin, Spp == 2 c, a + b kmin + c kmin^2 == S,
a == Sqrt[2] α}
*)

which is an overdetermined system, and has no solutions. However, the key point is do not give Solve more than you have to. It is good at what it does, but it might take a while to chew through all of the extra stuff.

Thanks for the quick response, and for catching those definite typos. I edited the original question to correct for the typos; I also removed the 4th constraint as to avoid overdetermining the system, but the solve command still hangs.
– AGB
Jan 22 ’14 at 4:49

Define hangs. How long do you wait?
– rcollyer
Jan 22 ’14 at 13:21

Solve works just fine if you make the following substitutions: S[km] -> s, S'[km] -> sp, and S”[km] -> spp, which Solve returns from almost instantly.
– rcollyer
Jan 22 ’14 at 15:01

When I make the substitutions you suggest, solve does return instantaneously. However, what I really want is a solution for {a,b,c} in terms of {α, β, γ, δ, f, km}.
– AGB
Jan 22 ’14 at 17:19

Right, which you now have, you just have to substitute back in. This can be automated by the rules: {s -> S[km], sp -> S'[km], spp -> S”[km]} which you use on the solution returned by Solve. This works as long as {α, β, γ, δ, f, km} are not dependent on {a, b, c}.
– rcollyer
Jan 22 ’14 at 18:15