Skip to main content
Edit to relate to previous post of mine
Source Link
Max
  • 1.1k
  • 6
  • 14

EDIT: I just realized this is closely related to a question I asked two years ago, Is FindRoot wrong about its WorkingPrecision? (which is still unanswered). I don't know if the current question counts as a duplicate, but it may ask the same thing more clearly. I hope you still read this one and see if the different phrasing triggers any insights.

I have a similar question as Precision of FindRoot but slightly different. Consider getting an InterpolatingFunction f[t] from NDSolve then finding a root with FindRoot:

Clear[f]
fsol = NDSolve[{f''[t] - f'[t] + f[t] - 1 == 0, f[0] == 1, 
    f'[0] == 1}, f, {t, 0, 20}, WorkingPrecision -> $MachinePrecision];
f[t_] = Evaluate[f[t] /. fsol];

Plot[f[SetPrecision[t, Infinity]], {t, 0, 20}, PlotRange -> All]

t0 = t /. FindRoot[f[t] == 10, {t, 18}, WorkingPrecision -> 50]
Precision@f[t0]
Precision@t0

Output:

f[t]

18.136956334574359755720315216764489747727661914414

11.6327

50.

The precision of my root t0 is equal to the WorkingPrecision I gave in FindRoot, despite that that is higher than the Precision of f itself, which came from NDSolve. My intuition about precision as a concept may be failing me here, but this does not seem right. My hunch is that if you use FindRoot to solve f[t]==number, then your answer for t should be no more precise than the precision of f at that t.

Even if Mathematica is technically right (is it?), I feel it's failing my purposes. There's real error introduced by the imprecision of my f[t]. Once I get t0 and plug it in (in my actual code it won't be back into f[t]!), I want it to reflect that t0 is imprecise because it was solving for an f[t] that was imprecise.

So I'd like answers to (a) Is Mathematica misusing precision here? And if not, then (b) Is there a way to make it reflect precision in a way that seems honest to me?

I have a similar question as Precision of FindRoot but slightly different. Consider getting an InterpolatingFunction f[t] from NDSolve then finding a root with FindRoot:

Clear[f]
fsol = NDSolve[{f''[t] - f'[t] + f[t] - 1 == 0, f[0] == 1, 
    f'[0] == 1}, f, {t, 0, 20}, WorkingPrecision -> $MachinePrecision];
f[t_] = Evaluate[f[t] /. fsol];

Plot[f[SetPrecision[t, Infinity]], {t, 0, 20}, PlotRange -> All]

t0 = t /. FindRoot[f[t] == 10, {t, 18}, WorkingPrecision -> 50]
Precision@f[t0]
Precision@t0

Output:

f[t]

18.136956334574359755720315216764489747727661914414

11.6327

50.

The precision of my root t0 is equal to the WorkingPrecision I gave in FindRoot, despite that that is higher than the Precision of f itself, which came from NDSolve. My intuition about precision as a concept may be failing me here, but this does not seem right. My hunch is that if you use FindRoot to solve f[t]==number, then your answer for t should be no more precise than the precision of f at that t.

Even if Mathematica is technically right (is it?), I feel it's failing my purposes. There's real error introduced by the imprecision of my f[t]. Once I get t0 and plug it in (in my actual code it won't be back into f[t]!), I want it to reflect that t0 is imprecise because it was solving for an f[t] that was imprecise.

So I'd like answers to (a) Is Mathematica misusing precision here? And if not, then (b) Is there a way to make it reflect precision in a way that seems honest to me?

EDIT: I just realized this is closely related to a question I asked two years ago, Is FindRoot wrong about its WorkingPrecision? (which is still unanswered). I don't know if the current question counts as a duplicate, but it may ask the same thing more clearly. I hope you still read this one and see if the different phrasing triggers any insights.

I have a similar question as Precision of FindRoot but slightly different. Consider getting an InterpolatingFunction f[t] from NDSolve then finding a root with FindRoot:

Clear[f]
fsol = NDSolve[{f''[t] - f'[t] + f[t] - 1 == 0, f[0] == 1, 
    f'[0] == 1}, f, {t, 0, 20}, WorkingPrecision -> $MachinePrecision];
f[t_] = Evaluate[f[t] /. fsol];

Plot[f[SetPrecision[t, Infinity]], {t, 0, 20}, PlotRange -> All]

t0 = t /. FindRoot[f[t] == 10, {t, 18}, WorkingPrecision -> 50]
Precision@f[t0]
Precision@t0

Output:

f[t]

18.136956334574359755720315216764489747727661914414

11.6327

50.

The precision of my root t0 is equal to the WorkingPrecision I gave in FindRoot, despite that that is higher than the Precision of f itself, which came from NDSolve. My intuition about precision as a concept may be failing me here, but this does not seem right. My hunch is that if you use FindRoot to solve f[t]==number, then your answer for t should be no more precise than the precision of f at that t.

Even if Mathematica is technically right (is it?), I feel it's failing my purposes. There's real error introduced by the imprecision of my f[t]. Once I get t0 and plug it in (in my actual code it won't be back into f[t]!), I want it to reflect that t0 is imprecise because it was solving for an f[t] that was imprecise.

So I'd like answers to (a) Is Mathematica misusing precision here? And if not, then (b) Is there a way to make it reflect precision in a way that seems honest to me?

Source Link
Max
  • 1.1k
  • 6
  • 14

Precision of FindRoot output doesn't match input

I have a similar question as Precision of FindRoot but slightly different. Consider getting an InterpolatingFunction f[t] from NDSolve then finding a root with FindRoot:

Clear[f]
fsol = NDSolve[{f''[t] - f'[t] + f[t] - 1 == 0, f[0] == 1, 
    f'[0] == 1}, f, {t, 0, 20}, WorkingPrecision -> $MachinePrecision];
f[t_] = Evaluate[f[t] /. fsol];

Plot[f[SetPrecision[t, Infinity]], {t, 0, 20}, PlotRange -> All]

t0 = t /. FindRoot[f[t] == 10, {t, 18}, WorkingPrecision -> 50]
Precision@f[t0]
Precision@t0

Output:

f[t]

18.136956334574359755720315216764489747727661914414

11.6327

50.

The precision of my root t0 is equal to the WorkingPrecision I gave in FindRoot, despite that that is higher than the Precision of f itself, which came from NDSolve. My intuition about precision as a concept may be failing me here, but this does not seem right. My hunch is that if you use FindRoot to solve f[t]==number, then your answer for t should be no more precise than the precision of f at that t.

Even if Mathematica is technically right (is it?), I feel it's failing my purposes. There's real error introduced by the imprecision of my f[t]. Once I get t0 and plug it in (in my actual code it won't be back into f[t]!), I want it to reflect that t0 is imprecise because it was solving for an f[t] that was imprecise.

So I'd like answers to (a) Is Mathematica misusing precision here? And if not, then (b) Is there a way to make it reflect precision in a way that seems honest to me?