I am trying to solve for Tcm and Mag by solving nonlinear equations using FindRoot command using following code:
Tc0 = 1;
rg = [email protected];
ratio = [email protected];
\[CapitalGamma]0 = rg 2 \[Pi] Tc0;
\[CapitalGamma]p = ratio \[CapitalGamma]0;
\[CapitalGamma]t = \[CapitalGamma]0 + \[CapitalGamma]p;
nMax = 10000;
Ts = [email protected];
Tc = [email protected];
(*Fourth order algebraic equation for gwn*)
{sol1[n_, Mag_, Tcm_] , sol2[n_, Mag_, Tcm_] , sol3[n_, Mag_, Tcm_] ,
sol4[n_, Mag_, Tcm_] } =
gwn /. Solve[
1/gwn^2 == 1 + Mag^2/((2 n + 1) Pi Tcm + 2 \[CapitalGamma]t gwn )^2,
gwn];
(*Equation for Tcm*)
sumArg4Tcm[n_, Mag_, Tcm_] =
2 Pi Tcm (2 n +
1) Pi Tcm (sol4[n, Mag, Tcm ] - 1)/((2 n + 1) Pi Tcm +
2 \[CapitalGamma]p )/((2 n + 1) Pi Tcm +
2 \[CapitalGamma]p sol4[n, Mag, Tcm ] );
target1Tcm[Tcm_] =
Log[Tcm/Tc] + PolyGamma[1/2 + \[CapitalGamma]p/(\[Pi] Tcm)] -
PolyGamma[1/2 + \[CapitalGamma]p/(\[Pi] Tc)];
myTrial4Tcm[Mag_?NumericQ, Tcm_?NumericQ] :=
Parallelize[Sum[sumArg4Tcm[n, Mag, Tcm ] , {n, 0, nMax}] ] // Chop;
(*Equation for Mag*)
sumArg4Mag[n_, Mag_, Tcm_] =
2 Pi Tcm (2 n +
1) Pi Tcm (sol4[n, Mag, Tcm ] - 1)/((2 n + 1) Pi Tcm +
2 \[CapitalGamma]t )/((2 n + 1) Pi Tcm +
2 \[CapitalGamma]t sol4[n, Mag, Tcm ] );
target1Mag[Tcm_] =
Log[Tcm/Ts] + PolyGamma[1/2 + \[CapitalGamma]t/(\[Pi] Tcm)] -
PolyGamma[1/2 + \[CapitalGamma]t/(\[Pi] Ts)];
myTrial4Mag[Mag_?NumericQ, Tcm_?NumericQ] :=
Parallelize[Sum[sumArg4Mag[n, Mag, Tcm ] , {n, 0, nMax}] ] // Chop;
AbsoluteTiming[FindRoot[{Re[myTrial4Tcm[Mag, Tcm] - target1Tcm[Tcm]], Re[myTrial4Mag[Mag, Tcm] - target1Mag[Tcm]]}, {Mag, 2.28}, {Tcm, 0.235},
WorkingPrecision -> 10]]
Running above code gave me an error
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.
Then I used options WorkingPrecision -> 10 but also gave me same error.
Can someone help me to get the right value?
MachinePrecision
corresponds to roughly 15 or 16 digits. 10 is less than that. $\endgroup$Tc = [email protected]
is a machine precision number so the calculations are done with machine precision. To rationalize useTc = Rationalize[0.942857, 0]
See documentation forRationalize
$\endgroup$MachinePrecision
numbers, there is no attempt to track or control precision. The result is whatever comes out of the machine calculations and the precision isMachinePrecision
, i.e., unknown. Specifying aWorkingPrecision
of10
will result in arbitrary-precision calculations and Mathematica will track and control precision and attempt to maintain 10 digits of precision. It will not always succeed in achieving that precision, but in any eventPrecision
(orInputForm
orFullForm
) will show the precision that was achieved. $\endgroup$