Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12146 > unrolled thread

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

Started byNS Lin <nansheng.lin@gmail.com>
First post2012-10-23 05:02 +0000
Last post2012-10-24 07:43 +0000
Articles 3 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  How do I assign the solution obtained by FindRoot to a variable? NS Lin <nansheng.lin@gmail.com> - 2012-10-23 05:02 +0000
    Re: How do I assign the solution obtained by FindRoot to a variable? "Dr. Wolfgang Hintze" <weh@snafu.de> - 2012-10-24 07:32 +0000
    Re: How do I assign the solution obtained by FindRoot to a variable? "Nasser M. Abbasi" <nma@12000.org> - 2012-10-24 07:43 +0000

#12146 — How do I assign the solution obtained by FindRoot to a variable?

FromNS Lin <nansheng.lin@gmail.com>
Date2012-10-23 05:02 +0000
SubjectHow do I assign the solution obtained by FindRoot to a variable?
Message-ID<k658dg$h6c$1@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

[toc] | [next] | [standalone]


#12161

From"Dr. Wolfgang Hintze" <weh@snafu.de>
Date2012-10-24 07:32 +0000
Message-ID<k685j6$m8q$1@smc.vnet.net>
In reply to#12146
On 23 Okt., 07:04, NS Lin <nansheng....@gmail.com> wrote:
> I would like to store the root/solution obtained by the FindRoot[] function to a variable.  How can I do that?
>
> Thanks!
>
> NS

In[472]:= eq = x == Exp[-x]

Out[472]= x == E^(-x)

In[475]:= z = x /. FindRoot[eq, {x, 1}]

Out[475]= 0.5671432904097838

In[477]:= Exp[-z]

Out[477]= 0.5671432904097838

Regards,
Wolfgang

[toc] | [prev] | [next] | [standalone]


#12163

From"Nasser M. Abbasi" <nma@12000.org>
Date2012-10-24 07:43 +0000
Message-ID<k6866b$md5$1@smc.vnet.net>
In reply to#12146
On 10/23/2012 12:02 AM, NS Lin wrote:

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


In[7]:= Clear[x]

sol=FindRoot[Sin[x]+Exp[x],{x,0}]
Out[8]= {x->-0.588533}

In[9]:= x=x/.sol
Out[9]= -0.588533

In[10]:= x
Out[10]= -0.588533


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web