# Why does Mathematica take so long to solve this equation?

I want to obtain numerical solutions of $v$ for the following equation in Mathematica:

$$\frac{a}{v}=\frac{e^{2.478} o^{6.351}}{\left\{\frac{kv^3}{n}[(n-1)(0.62-0.014d+0.0452d^2)+1]+Mgv(u\cos(z)+\sin(z))\right\}^{6.351}}$$

This is the code I wrote:

f = a/v == E^(2.478) o^(6.351)((k*v^3((n-1.)(0.62-0.0104d+0.0452
d^2)+1.)/n)+M*g*a(uCos[z]+Sin[z]))^(-6.351)

NSolve[f /.
{a -> 20.,
o -> 51.,
k -> 0.19,
n -> 20.,
d -> 0.05,
M -> 80.,
g -> 9.80665,
u -> 1.2,
z -> 0.}
, v]


It takes a very long time to run and I abort it before it gives any output. Is there a way to overcome this? Thank you.

EDIT: I made a mistake in the equation. In the part $Mga(u\cos(z)+\sin(z))$, $a$ should be $v$ instead, which gives $Mgv(u\cos(z)+\sin(z))$.

• Solve doesn't work because the answer is to let v- > infinity, at which point, both sides approach zero. Oct 10 '17 at 21:52
• aside to other things you appear to have introduced a new symbol uCos (see how it is blue.. you need a space in there) Oct 10 '17 at 22:13
• your updated equation has a single root at 0.0285184 (see answer below). Please emphasize correctness of Mathematica code posted for ease of answering, thanks. Oct 10 '17 at 22:35
• You should fix your code. Oct 11 '17 at 0:33

Solve doesn't work because the answer is to let v- > infinity, at which point, both sides approach zero. Here is the right hand side:

Limit[E^(2.478) o^(6.351) ((k*v^3 ((n - 1.)
(0.62 - 0.0104 d + 0.0452 d^2) + 1.)/n) +
M*g*v (uCos[z] + Sin[z]))^(-6.351), v -> Infinity]
0.


The left hand side a/v obviously -> 0 as well. Notice that this is true irrespective of the particular values of the constants.

Playing with your (updated) equation:

(* warning: don't use capital M *)
Clear[f, a, v, o, k, n, d, m, g, u, z]

(* warning: put a space or a * between u and Cos *)
f = a/v == E^(2.478) o^(6.351) ((k*
v^3 ((n - 1.) (0.62 - 0.0104 d + 0.0452 d^2) + 1.)/n) +
m*g*v (u*Cos[z] + Sin[z]))^(-6.351)


f = f /. {a -> 20., o -> 51., k -> 0.19, n -> 20., d -> 0.05,
m -> 80., g -> 9.80665, u -> 1.2, z -> 0.}


Put in appropriate form to plot to visualize any roots

f = f[[1]] - f[[2]]


Plot[f, {v, -0.05, 0.2}]


FindRoot[f, {v, 0.03}]
(* {v -> 0.0285184} *)


Your updated equation has a single root at 0.0285184

The calculation goes very fast if you restrict the domain to Reals

param = {a -> 20., o -> 51., k -> 0.19, n -> 20., d -> 0.05, M -> 80.,
g -> 9.80665, u -> 1.2, z -> 0.} // Rationalize;

f = a/v ==
E^(2.478) o^(6.351) ((k*
v^3 ((n - 1.) (0.62 - 0.0104 d + 0.0452 d^2) + 1.)/n) +
M*g*v (u Cos[z] + Sin[z]))^(-6.351) // Rationalize[#, 0] &;

soln = NSolve[f /. param, v, Reals]

(* {{v -> 0.0285184}} *)


EDIT: Verification

f /. param /. soln[[1]]

(* True *)