MathGroup Archive 2005

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

Search the Archive

Re: Defining functions using the output of an other function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg59620] Re: Defining functions using the output of an other function
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Sun, 14 Aug 2005 04:38:07 -0400 (EDT)
  • References: <ddk892$167$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Eckhard Schlemm wrote:
> Hi
> 
> Is there any possibility in mathematica to define a function using te output
> of another function such as   D[] oder Solve[] ?
> 
> for ex.
> 
> r[t_]::=Solve[y=x^2,y,x];
> 
> That actually does not work, just in order to illustrate what i am talking
> about^^
> 
> Thanks a lot
> 
> Eckhard
> 
> 
Hi,

Of course - Mathematica is nothing if not flexible! First note that you 
need to use == to define an equation for Solve:

Solve[y==x^2,x]

Now we can define a function that uses this:

f[y_]=(x/.Solve[y==x^2,x])[[2]]

There are two points to note:

1)	Solve returns two solutions, and I picked the second one.

2)	I defined the function using = rather than := so that the rhs was 
evaluated at once.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Using the VectorCalculus
  • Next by Date: Re: Defining functions using the output of an other function
  • Previous by thread: Re: Defining functions using the output of an other function
  • Next by thread: Re: Re: Defining functions using the output of an other function