|
[Date Index]
[Thread Index]
[Author Index]
Re: Turning Derivative into Function (Newbie Question)
- To: mathgroup at smc.vnet.net
- Subject: [mg115457] Re: Turning Derivative into Function (Newbie Question)
- From: Murray Eisenberg <murray at math.umass.edu>
- Date: Tue, 11 Jan 2011 19:21:10 -0500 (EST)
Because g is NOT a "function" when you set:
g := f'[x]
(No more than f would be had you started with f := x^2.)
Whenever you now call g, you get the value of f[x], namely, 2x.
If you really want to define g that way, then you can use a rule and
replacement:
g /. x-> 2
But it's probably better to do things like this:
Clear[g]
g[x_] = f'[x] (* note Set, =, not SetDelayed, := *)
g[2]
4
Or, if you prefer a more functional approach:
Clear[g]
g = f'
g[2]
4
On 1/11/2011 6:58 AM, Just A Stranger wrote:
> When I apply a function that outputs another function, how come I can not
> pass arguments to the new function? Am I missing some principle about how
> Mathematica functions work? Could someone please point me to the relevant
> documentation?
>
>
> A simple example to illustrate my confusion:
>
> In[1]: f[x_] := x^2
> In[2]: g := f'[x]
>
> So now I have:
>
> In[3]: g
> out[3]: 2x
>
> as expected
>
> So how come I get the following when trying to pass an argument to g:
>
> In[4]: g[2]
> Out[4]: 2x[2]
>
> Instead of the output I want:
>
> *Ou[4]: 4
>
>
> I tried
>
> In: g[x_] := f'[x]
>
> But it seems to think I'm trying to assign a function to Times.
> "SetDelayed::write: Tag Times in (2 x)[y_] is Protected.>>"
>
> Thank you very much for any help :)
>
>
--
Murray Eisenberg murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Prev by Date:
Cubic equations again...
Next by Date:
Re: Turning Derivative into Function (Newbie Question)
Previous by thread:
Re: Turning Derivative into Function (Newbie Question)
Next by thread:
Re: Turning Derivative into Function (Newbie Question)
|