2
$\begingroup$

I am trying to find a numerical solution to the following transcendental equation

BallooningFile = {0.`, 0.000136`, 0.000572`, 0.001152`, 0.001907`, 
   0.003004`, 0.004199`, 0.005479`, 0.006834`, 0.008256`, 0.008985`, 
   0.009738`, 0.011271`, 0.01285`, 0.013651`, 0.014468`, 0.016119`, 
   0.017797`, 0.019496`, 0.021211`, 0.022069`, 0.022934`, 0.024661`, 
   0.025522`, 0.026386`, 0.028103`, 0.029806`, 0.031492`, 0.033153`, 
   0.034785`, 0.036383`, 0.037942`, 0.039457`, 0.040924`, 0.042338`, 
   0.043695`, 0.04499`, 0.046221`, 0.047382`, 0.048472`, 0.049486`, 
   0.050421`, 0.051276`, 0.052047`, 0.052732`, 0.053329`, 0.053837`, 
   0.054255`, 0.05458`, 0.054813`, 0.054953`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.054313`, 0.0523`, 
   0.049099`, 0.044931`, 0.040082`, 0.034883`, 0.029689`, 0.024854`, 
   0.020707`, 0.017527`, 0.01553`, 0.015021`, 0.01485`, 0.014888`, 
   0.014998`, 0.015078`, 0.015172`, 0.015281`, 0.0154`, 0.015529`, 
   0.015665`, 0.015807`, 0.01595`};
    BorderValue = 0.0001;    
    AnglesBtm = 
         Table[
          FindRoot[
            Sin[x]/x == 
             1/(If[BallooningFile[[i, 4]] <= BorderValue, 
                 BorderValue, 
                 BallooningFile[[i, 4]]] + 1), {x, .001}][[1, 2]], 
          {i, 1, Length[BallooningFile[[All, 2]]], 1}]

The problem is that I get an error saying:

FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

After some searching on help pages I found out that at least one solution is complex. But I have no idea why on earth would that really be the case? Can somebody explain me this error?

EDIT: Ok, if I change BorderValue from 0.0001 to 0.001 everything works fine. I don't understand this. EDIT2: Corrected code.

$\endgroup$
  • 2
    $\begingroup$ Please post self-contained, working code. $\endgroup$ – Yves Klett Sep 2 '15 at 12:28
  • 1
    $\begingroup$ Downloads are awkward and potentially dangerous. Could you hardcode a working example? $\endgroup$ – Yves Klett Sep 2 '15 at 12:43
  • 1
    $\begingroup$ @YvesKlett There it is, no downloading needed. $\endgroup$ – skrat Sep 2 '15 at 12:49
  • 1
    $\begingroup$ It is the 3rd search, FindRoot[Sin[x]/x == 0.9994283269969577`, {x, 0.001}]. Increase WorkingPrecision to 20 or decrease PrecisionGoal to 6, following the hints in the warning message. Or simply check the results to see if errors are too great. It's just a warning that the error might be more than you want. $\endgroup$ – Michael E2 Sep 2 '15 at 13:03
  • 3
    $\begingroup$ I feel like this site would benefit from a generic Q&A on how to interpret standard warnings (that are not errors) from numeric solvers. $\endgroup$ – Michael E2 Sep 2 '15 at 13:06
8
$\begingroup$

Use Sinc[x] rather than Sin[x]/x

BallooningFile = {0.`, 0.000136`, 0.000572`, 0.001152`, 0.001907`, 0.003004`, 
   0.004199`, 0.005479`, 0.006834`, 0.008256`, 0.008985`, 0.009738`, 
   0.011271`, 0.01285`, 0.013651`, 0.014468`, 0.016119`, 0.017797`, 0.019496`,
    0.021211`, 0.022069`, 0.022934`, 0.024661`, 0.025522`, 0.026386`, 
   0.028103`, 0.029806`, 0.031492`, 0.033153`, 0.034785`, 0.036383`, 
   0.037942`, 0.039457`, 0.040924`, 0.042338`, 0.043695`, 0.04499`, 0.046221`,
    0.047382`, 0.048472`, 0.049486`, 0.050421`, 0.051276`, 0.052047`, 
   0.052732`, 0.053329`, 0.053837`, 0.054255`, 0.05458`, 0.054813`, 0.054953`,
    0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 0.055`, 
   0.055`, 0.055`, 0.055`, 0.055`, 0.054313`, 0.0523`, 0.049099`, 0.044931`, 
   0.040082`, 0.034883`, 0.029689`, 0.024854`, 0.020707`, 0.017527`, 0.01553`,
    0.015021`, 0.01485`, 0.014888`, 0.014998`, 0.015078`, 0.015172`, 
   0.015281`, 0.0154`, 0.015529`, 0.015665`, 0.015807`, 0.01595`};
BorderValue = 0.0001;
AnglesBtm = (x /. 
      FindRoot[Sinc[x] == 
        1/(If[# <= BorderValue, BorderValue, #] + 1), {x, .001}]) & /@ 
   BallooningFile;

ListLinePlot[AnglesBtm]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ Sinc is a good choice for this local example and avoids the precision loss of Sin[x]/x. (+1) $\endgroup$ – Michael E2 Sep 2 '15 at 13:10

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.