Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Defining functions' topicStudent Support Forum > General > Archives > "Defining functions"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Bill Simpson
02/28/12 8:09pm

Perhaps something like this?

In[1]:= f[hv_]:=(s=hv;u=RandomReal[{-s,s}]);
g[]:=RandomReal[{-Sqrt[s^2-u^2],+Sqrt[s^2-u^2]}];

In[3]:= f[2]
Out[3]= 0.317934

In[4]:= g[]
Out[4]= -1.8714

And we can peek at s and u just to verify that they have saved the information for later use.

In[5]:= s
Out[5]= 2

In[6]:= u
Out[6]= 0.317934

URL: ,

Subject (listing for 'Defining functions')
Author Date Posted
Defining functions jordan 02/25/12 11:08am
Re: Defining functions Bill Simpson 02/28/12 8:09pm
< Previous CommentHelp | Reply To Comment | Reply To Topic