I am a new user in Wolfram language.
Please, I am trying to calculate accurate solutions $R$ of an algébric equation which contains the Dawson function. The equation is:
$$1+\frac{\theta }{k^2}+\frac{R^2}{k^2}\left[\frac{\sqrt{\frac{2}{\theta }} \left(\frac{1}{2} \theta ^2 \left(\frac{R^2}{2}+1\right)^2+\theta \left(\frac{R^2}{2}+1\right)+1\right) \left(-2 F\left(\sqrt{\frac{\theta }{2}} R\right)\right)}{R}+1+\theta \left(\frac{1}{4 \theta }+\frac{R^2}{4}+1\right)\right]=0$$
where,
$F$ : is the Dawson function
$1<k<3$ : real
$R<1$ : real
$\theta \ggg 1$ : real >>1
To do it, I think we have to use Findroot. The code that I used is the following:
eq[R_?NumericQ, k_?NumericQ, \[Theta]_?NumericQ]:=1+\[Theta]/k^2+R^2/k^2 (1+\[Theta](1+1/(4\[Theta])+R^2/4)+(Sqrt[2/\[Theta]] 1/R (1+\[Theta](1+(R^2)/2)+\[Theta]^2/2 (1+(R^2)/2)^2)(-2 DawsonF[Sqrt[\[Theta]/2]R])))
solr[k_,\[Theta]_]:=Re[R/.FindRoot[eq[R,k,\[Theta]],{R,1.1/k},AccuracyGoal->16,PrecisionGoal->16,WorkingPrecision->25]]
The solutions $R$ that I'm looking for must satisfy: for all values $1<k<3$ we have always $R<1$.
But for $k<2.1$ all solutions satisfy $R>>1$, so the condition $R<1$ is not satisfied.
Block[{\[Theta]=100},Table[{k,solr[k,\[Theta]]},{k,1,3,0.1}]]
(* {{1.,-402.0221127442610480453402},{1.1,162.7992531392247315125129},{1.2,560.0440880401854997217024},{1.3,149.3137124001590352102585}, {1.4,927.9240354439233066791802},{1.5,1204.227451826562972959649},{1.6, 352.3919638872815653450775},{1.7,-578.9018078239970096174140},{1.8,2.284779688985257597042901},{1.9,1.366209370422262795909812},{2.,1.059718464650025788056352},{2.1,0.8928149869232555556054552},{2.2,0.7840644848720738071277466},{2.3,0.7061209842390898952755792},{2.4,0.6468555823332280593457180},{2.5,0.5999539682600659528508929},{2.6,0.5617652337478441609444316},{2.7,0.5300143374213611634335440},{2.8,0.5031957080178527133949467},{2.9,0.4802563992569976549295289},{3.,0.4604211571053869996277583}} *)
I think this is due to the precision that I can't control.
Any help please on this problem!
\[ThinSpace]
in your code. It is a formatting quantity. $\endgroup$ – bbgodfrey May 15 '18 at 19:39FindRoot[eq[R, k, θ], {R, 1/2, 0, 1}]
will not give roots outside0 < R < 1
, but it will quit if its search reaches either end-point, returning the value of that end-point. So, I do not view this as much of an improvement. Instead, use (for instance)R /. FindInstance[(eq1 /. {k -> 3, θ-> 100}) == 0 && 0 < R < 1, {R}, 5] // N
, as suggested by @Mariusz. There is no answer to your comment of which of the two solutions is better. Both are valid and can be found byFindRoot
too, although with more effort. $\endgroup$ – bbgodfrey May 21 '18 at 23:14Reduce[(eq1 /. {k -> 3, θ -> 100}) == 0 && 0 < R < 1, {R}] // N
also works and may use the same algorithm in this case. $\endgroup$ – bbgodfrey May 21 '18 at 23:28