Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg123162] Re: Root finding needs higher accuracy
  • From: Bob Hanlon <hanlonr357 at gmail.com>
  • Date: Fri, 25 Nov 2011 04:54:30 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201111241157.GAA29024@smc.vnet.net>

Tell Reduce or Solve that you are interested in a real root

f12[x_] := Log[x] + x^2/(2 Exp[1]) - 2 x/Sqrt[Exp[1]] + 1

Reduce[f12[x] == 0, x, Reals]

x == Root[{-4*Sqrt[E] + 4*#1 & ,
       1.6487212707001281468486516320736540164304528843786101788282`20.\
311523332141462}]

Solve[f12[x] == 0, x, Reals] // Union

{{x -> Root[{-4*Sqrt[E] + 4*#1 & ,

      1.6487212707001281468486516320736540164304528843786101788282`20.\
311523332141462}]\
    }}

Or restrict x to be positive

Reduce[{f12[x] == 0, x > 0}, x]

x == Root[{-4*Sqrt[E] + 4*#1 & ,
       1.6487212707001281468486516320736540164304528843786101788282`20.\
311523332141462}]

Solve[{f12[x] == 0, x > 0}, x] // Union

{{x -> Root[{-4*Sqrt[E] + 4*#1 & ,

      1.6487212707001281468486516320736540164304528843786101788282`20.\
311523332141462}]\
    }}

It is not clear to me why Mathematica doesn't automatically complete the solve

Solve[-4 Sqrt[E] + 4 x == 0, x] // Flatten

{x -> Sqrt[E]}

Log[x] + x^2/(2 Exp[1]) - 2 x/Sqrt[Exp[1]] + 1 == 0 /. %

True


Bob Hanlon


On Thu, Nov 24, 2011 at 6:57 AM, HwB <hwborchers 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, PrecisionGoal -> 20], 16]
>    # 1.648732212532746
>    SetPrecision[
>        x /. FindRoot[f12[x], {x, 1.0, 3.4}, Method -> "Secant",
>                 AccuracyGoal -> Infinity, PrecisionGoal -> 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
>



  • Prev by Date: Memory low for PDE
  • Next by Date: Re: Non trivial substitution in a very long output
  • Previous by thread: Re: Root finding needs higher accuracy
  • Next by thread: Re: Root finding needs higher accuracy