Re: "Solve" or "FindRoot" in a module

• To: mathgroup at smc.vnet.net
• Subject: [mg18560] Re: "Solve" or "FindRoot" in a module
• From: Christian Brechbühler <brech at vision.ee.ethz.ch>
• Date: Sat, 10 Jul 1999 02:18:51 -0400
• Organization: Swiss Federal Institute of Technology
• Sender: owner-wri-mathgroup at wolfram.com

```In article <375F3CAD.3FF0 at bechtel.colorado.edu>, Jung Sik Kong
> >-------------------------------------------------------------------
> >1. How do I extract a solution from the results of
> >   Solve or FindRoot in a module
> >-------------------------------------------------------------------

> >Next is a part of my file.
> >-----------------------------------------------
> >In[1]=StandardDist = NormalDistribution[0,1];
> >In[2]=CDFStandardDist[x_] := CDF[StandardDist, x]
> >In[3]=aa[y_] := Module[ {x},
> >         FindRoot[CDFStandardDist[x]==y,{x,0}] ]
> >
> >
> >In[4]= Plot[aa[y],{y,0.0001,0.9999}]
> >-----------------------------------------------

In this example, you can get the Plot directly:

Plot[Quantile[NormalDistribution[],y],{y,0.0001,0.9999}]

>
> aa[y_] := Module[ {x},
>         x/. FindRoot[CDFStandardDist[x]==y,{x,0}] ];

> >I tried followings, however, all of them are failed;

Number (2) is very close, it just lacks a semicolon,

> >(2)
> >In[1]=aa[y_] := Module[ {x,z},
> >         z=FindRoot[CDFStandardDist[x]==y,{x,0}]
> >         x /. z
> >         ]

--------------------------------------------------------
> >2. How can I use % in a Module.
--------------------------------------------------------

Better not.  It will always refer to whatever was the last result
in the previously evaluated cell.  Not very predictable and probably
not useful.  I try to avoid '%' even in notebooks, because it won't
necessarily refer to the same thing the next time I evaluate the
cell.

HTH

Christian Brechbühler, Dr. sc. techn.

Communication Technology Laboratory, Image Science Group
Swiss Federal Institute of Technology (ETH), Zurich

```

• Prev by Date: Re: "At long last, Sir, have you no shame?"
• Next by Date: Re: RE: Re: Re: easiest way to sort a list?
• Previous by thread: Re: Re: Simplifying constants...bug?
• Next by thread: LaTex for publication