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

MathGroup Archive 2012

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

Search the Archive

Re: How do I assign the solution obtained by FindRoot to a variable?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg128489] Re: How do I assign the solution obtained by FindRoot to a variable?
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Thu, 25 Oct 2012 01:39:51 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net

I would like to store the root/solution obtained by the FindRoot[] function to a variable.  How can I do that?

Thanks!

NS

Hi, Nansheng,

Assume this:

eq=x^2-x-1==0;

is your equation, and this:

FindRoot[eq, {x, 1}]

{x -> 1.61803}

is what FindRoot returns you. Then you may simply do the following:

y = FindRoot[eq, {x, 1}][[1, 2]];
y

1.61803

Is this the thing you had in mind?

Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu






  • Prev by Date: Re: How do I assign the solution obtained by FindRoot to a variable?
  • Next by Date: Re: How accurate is the solution for high degree algebraic
  • Previous by thread: Re: How do I assign the solution obtained by FindRoot to a variable?
  • Next by thread: Tensor product of Matrices