Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

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
  • References: <375F3CAD.3FF0@bechtel.colorado.edu> <7jun0v$ggm$3@dragonfly.wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <375F3CAD.3FF0 at bechtel.colorado.edu>, Jung Sik Kong
<kongj at bechtel.colorado.edu> wrote:
> >-------------------------------------------------------------------
> >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}]

Andrzej Kozlowski gave the canonical answer to the question you asked:
> 
> 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}]
     (*add*)                                       ;
> >         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