MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Root finding needs higher accuracy

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123209] Re: Root finding needs higher accuracy
  • From: DrMajorBob <btreat1 at austin.rr.com>
  • Date: Sat, 26 Nov 2011 05:09:30 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <jalbrn$sib$1@smc.vnet.net> <201111250957.EAA11192@smc.vnet.net>
  • Reply-to: drmajorbob at yahoo.com

Sadly, WorkingPrecision->30 gets us just 10 correct digits:

f[x_] := Log[x] + x^2/(2 Exp[1]) - 2 x/Sqrt[Exp[1]] + 1
root = x /.
   FindRoot[f[x], {x, 1.5}, PrecisionGoal -> 20, WorkingPrecision -> 30]
Replace[RealDigits@N[root, 25] - RealDigits@N[Sqrt@E, 25] //
   First, {x : Longest[0 ..], ___} :> Length@{x}]

1.64872127035491043009143137899

10

Bobby

On Fri, 25 Nov 2011 03:57:13 -0600, Peter Falloon <pfalloon at gmail.com>  
wrote:

> On Nov 24, 11:04 pm, HwB <hwborch... at googlemail.com> wrote:
>> I would like to numerically find the root of the following function
>> with up to 20 digits.
>>
>>     f12[x_] := Log[x] + x^2 / (2 Exp[1]) - 2 x / Sqrt[Exp[1]] + 1
>>
>> This problem is known to be difficult for solvers in double precision
>> arithmetics. I thought it should be easy with Mathematica, but the
>> following attempts were not successful.
>>
>>     SetPrecision[
>>         x /. FindRoot[f12[x], {x, 1.0, 3.4}, Method -> "Brent",
>>                  AccuracyGoal -> Infinity, PrecisionGoa=
> l -> 20], 16]
>>     # 1.648732212532746
>>     SetPrecision[
>>         x /. FindRoot[f12[x], {x, 1.0, 3.4}, Method -> "Secant",
>>                  AccuracyGoal -> Infinity, PrecisionGoa=
> l -> 20], 16]
>>     # 1.648710202030051
>>
>> The true root obviously is Sqrt[Exp[1]]//N = 1.648721270700128...
>>
>> The symbolic solver explicitely says it cannot solve this expression.
>> What do I need to do to get a much more exact result out of
>> Mathematica?
>>
>> Many thanks, Hans Werner
>
> You need to increase the WorkingPrecision:
>
> In[658]:= f[x_] := Log[x] + x^2 / (2 Exp[1]) - 2 x / Sqrt[Exp[1]] + 1
> x0 = x /. FindRoot[f[x], {x, 1.5}, PrecisionGoal->20, WorkingPrecision-
>> 30];
> {x0, f[x0]}
>
> Out[660]= {1.64872127035488735592446035944, 0.*10^-30}
>
> Cheers,
> Peter.
>


-- 
DrMajorBob at yahoo.com



  • Prev by Date: Re: Using Equal with Real Numbers
  • Next by Date: Re: Root finding needs higher accuracy
  • Previous by thread: Re: Root finding needs higher accuracy
  • Next by thread: Re: Root finding needs higher accuracy