2
$\begingroup$

I know questions about this warning have been posted a thousand times over. But I really couldn't find any solution that worked in my case. It's quite simple:

f[a_] := (1 - 1/a)*-(1/((a - 1)*(c - 1)))*Log[2, (1/((a - 1)*(c - 1)))] - (1 - (1/((a - 1)*(c - 1))))*Log[2, 1 - (1/((a - 1)*(c - 1)))];
Solve[f'[a] == 0, a]

I know from plotting the function that there is a unique solution somewhere around $a = c/10$, but it seems like Mathematica does not find it.

If anybody could help, I would be supremely grateful.

Sacha

$\endgroup$
  • $\begingroup$ What are ranges of a and c variables?. Putting a numeric c that's easy (e.g. ff[a_,c_]:= expression; Reduce[ D[ff[a, 20], a] == 0, {a, c}, Reals]) otherwise Mathematica cannot in general solve two variable transcendental equations, see e.g. Solve symbolically a transcendental trigonometric equation and plot its solutions $\endgroup$ – Artes Nov 27 '14 at 10:30
  • $\begingroup$ The only constraint is that $a \ge 1 + 2/(c-1)$. $\endgroup$ – Sacha Nov 28 '14 at 8:11
1
$\begingroup$

What about such a solution:

 lst = Table[{b, (FindRoot[(D[f[a, b], a] // Simplify[#, a > 0] &) == 
         0, {a, 1.2}] // Chop)[[1, 2]]}, {b, 2, 5, 0.1}];


model1 = p1 + p2*b + p3/b;
ft = FindFit[lst, model1, {p1, p2, p3}, b]
Show[{
  ListPlot[lst],
  Plot[model1 /. ft, {b, 0, 5}, PlotStyle -> Red]
  }, Epilog -> 
  Inset[Row[{Style["a\[TildeTilde]", 12, Italic], 
     Style[model1 /. ft, 12, Italic]}], {4, 1}]]

yielding

(*  {p1 -> -1.12512, p2 -> 0.230532, p3 -> 7.3721}  *)

enter image description here

Have fun!

$\endgroup$
  • $\begingroup$ Thanks a lot. But, uh, could you explain a little bit? I'm not that much into Mathematica. E.g., what does the polynomial mean? $\endgroup$ – Sacha Nov 28 '14 at 8:10
  • $\begingroup$ @Sacha Continuation. Now to the point. lst is the list of approximate solutions obtained with the function FindFit. This function only returns a single solution, and the function Table runs it for the iterated values of the parameter b. Chop is used there to cut away small imaginary machine errors. The result is the list of values of the parameter b against the corresponding solutions of your equation for a. Now this list is already the answer to your question. It represents the numerical solution of your equation for a chosen interval of the parameter b. We can, however, go a step further. $\endgroup$ – Alexei Boulbitch Nov 28 '14 at 8:55
  • $\begingroup$ @Sacha, Continuation 2. FindFit fits the obtained solution to the model1. The choice of the model is up to you. If you know, what should it look like (say, from some external considerations), chose that function with some fitting parameters. If you have no such information, choose the simplest possible. That was my case. I assumed by (a short) trial and error the function model1 where p1, p2 and p3 ate the fitting parameters, and fitted it to the list lst. This is done by the function FindFit. Check Menu/Help/WolframDocumentation/FindFit. Done. You may further plot the list lst and the $\endgroup$ – Alexei Boulbitch Nov 28 '14 at 9:07
  • $\begingroup$ Sacha, This is a preamble. I have placed it above, but made a mistake, removed and added it later. The main point is that I have found no exact solution. It might be OK, if the solution is numerical. Then you use FindRoot function. Check Menu/Help/WolframDocumentation/FindRoot . You may, however, want to obtain an approximate, but still analytical solution. My answer just hits this case. In our previous life there were lots of methods to look for approximate analytical solutions. With the advent of Mma a new very powerful way emerged. This one you find in my answer. See continuations. $\endgroup$ – Alexei Boulbitch Nov 28 '14 at 9:11
  • $\begingroup$ @Sacha, Continuation 3. function model1 with the substituted values of the parameters p1, p2 and p3. This is done by the model1/.ft construct. You can see it on the plot. the approximating function is written below the curve. Tht's it. Have fun! $\endgroup$ – Alexei Boulbitch Nov 28 '14 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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