1
$\begingroup$

When i try to solve the following equation, i get error message that "Solve::dinv: ...."due to the presence of Log[s0] term. How to solve this? the code is given below:

sig = 2.;
ks = (Pi/6) (4 sig/Log[s0])^3;
i0 = (2/(9 Pi))^(1/3) sig^0.5 s0^(2 - 0.5 ks);
n0 = i0 tc
m0 = (i0 ks^(1/3) + ((s0 - 1) n0/3)) tc
a0 = (i0 ks^(2/3) + (2 (s0 - 1) m0/3)) tc
rr = 100.;
tc = 1000.;
Solve[{rr - (s0/tc) - i0 ks - (s0 - 1) tc (
  i0 ks^(2/3) +
   (
    2 (s0 - 1) tc/3 (i0 ks^(1/3) + (s0 - 1) tc i0/3)
    )
  ) == 0}, s0
]

Thanks and Regards,

$\endgroup$
2
  • $\begingroup$ This is a numerical problem, use FindRoot $\endgroup$
    – george2079
    Commented Mar 15, 2016 at 19:14
  • $\begingroup$ Thank you george2079, it worked.... $\endgroup$
    – Anand
    Commented Mar 15, 2016 at 19:18

2 Answers 2

2
$\begingroup$

Amplifying on answer by yode. Use exact expressions to avoid need to Rationalize when using Solve

sig = 2;
ks = (Pi/6) (4 sig/Log[s0])^3;
i0 = (2/(9 Pi))^(1/3) Sqrt[sig] s0^(2 - ks/2);
n0 = i0 tc;
m0 = (i0 ks^(1/3) + ((s0 - 1) n0/3)) tc;
a0 = (i0 ks^(2/3) + (2 (s0 - 1) m0/3)) tc;
rr = 100;
tc = 1000;

f[s0_] = rr - (s0/tc) - 
   i0 ks - (s0 - 
      1) tc (i0 ks^(2/3) + (2 (s0 - 1) tc/
         3 (i0 ks^(1/3) + (s0 - 1) tc i0/3)));

Use a constraint with Solve or NSolve

Solve[{f[s0] == 0, 9 < s0 < 11}, s0][[1]] // N

(*  {s0 -> 10.0023}  *)

NSolve[{f[s0] == 0, 9 < s0 < 11}, s0][[1]]

(*  {s0 -> 10.0023}  *)

FindRoot[f[s0], {s0, 10}]

(*  {s0 -> 10.0023}  *)
$\endgroup$
1
  • $\begingroup$ Thank you for detail explanation...Bob Hanlon $\endgroup$
    – Anand
    Commented Mar 15, 2016 at 19:40
2
$\begingroup$

This equation isn't be solved by Solve usually.First we should use Plot to estimate its initial value.Then we use FindRoot to solve it.The process like following:

sig = 2.;
ks = (Pi/6) (4 sig/Log[s0])^3;
i0 = (2/(9 Pi))^(1/3) sig^0.5 s0^(2 - 0.5 ks);
n0 = i0 tc;
m0 = (i0 ks^(1/3) + ((s0 - 1) n0/3)) tc;
a0 = (i0 ks^(2/3) + (2 (s0 - 1) m0/3)) tc;
rr = 100.;
tc = 1000.;
Plot[rr - (s0/tc) - 
  i0 ks - (s0 - 
     1) tc (i0 ks^(2/3) + (2 (s0 - 1) tc/
        3 (i0 ks^(1/3) + (s0 - 1) tc i0/3))), {s0, -8, 8}]

enter image description here

Then you get it.

FindRoot[rr - (s0/tc) - 
  i0 ks - (s0 - 
     1) tc (i0 ks^(2/3) + (2 (s0 - 1) tc/
        3 (i0 ks^(1/3) + (s0 - 1) tc i0/3))), {s0, 7.}]

{s0 -> 10.0023}

$\endgroup$
1
  • $\begingroup$ thank you yode, it (FindRoot) worked... $\endgroup$
    – Anand
    Commented Mar 15, 2016 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.