# \[?\] Define the output of a function as a new function?

**URL:** <https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379>\
**Category:** Questions\
**Created:** [April 22, 2017, 7:38pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379 "2017-04-22T19:38:25Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobias1](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tobias1](https://community.wolfram.com/u/tobias1)\
**Post date:** [April 22, 2017, 7:38pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/1 "2017-04-22T19:38:25Z")

</div>

Hey Guys!

I’ve got the following problem. I have the function

```
f[a_,b_,c_]=a+b/c

```

Now I’d like to set a new function

```
g[a_,b_,c_]=D[f[a_,b_,c_],a_]

```

So the plan would be to have a new function which I can use to compute g for different a,b,c. For example I’d say `a=1 b=2 c=3` and Mathematica would tell me `g`. Obviously it does not work because i have the same variables on the right and on the left side. I’ve already googled my brain away but I found no solution. Do you have some advice for me?

I am sorry if I formatted something wrong, this is my first activity in the Wolfram community.

Thanks,  
Tobias

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [April 22, 2017, 8:51pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/2 "2017-04-22T20:51:19Z")

</div>

I think you want this:

```
ClearAll[f, g]
f[a_, b_, c_] := a + b/c
g[a_, b_, c_] = D[f[a, b, c], a]

```

you can now check the definition of g:

```
??g

```

giving

```
g[a_,b_,c_]=1

```

as expected…

---

<div class="post-metadata">

**Author:** ![tobias1](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tobias1](https://community.wolfram.com/u/tobias1)\
**Post date:** [April 23, 2017, 1:54pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/3 "2017-04-23T13:54:23Z")

</div>

This works, but if i define a,b and c it’s not working anymore.

---

<div class="post-metadata">

**Author:** ![sghuisman](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/sghuisman/32/27850_2.png) [@sghuisman](https://community.wolfram.com/u/sghuisman)\
**Post date:** [April 23, 2017, 2:29pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/4 "2017-04-23T14:29:19Z")

</div>

We don’t know what you want to do, so you might either need = or := depending on what you want to do. If a, b and, c are numbers, the derivative does not make any sense, you can’t do the derivate with respect to a number…

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [April 23, 2017, 2:42pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/5 "2017-04-23T14:42:57Z")

</div>

To understand what is happening, you should read:

- [https://mathematica.stackexchange.com/questions/8829/what-is-the-difference-between-set-and-setdelayed](https://mathematica.stackexchange.com/questions/8829/what-is-the-difference-between-set-and-setdelayed)

I noticed you used `a_`, with the `_` on the right hand side of a definition. This is wrong. `a_` is a pattern and `a` is the name of that pattern. The pattern should appear only on the left hand side. Please read:

- [Functions and Programs—Wolfram Documentation](https://reference.wolfram.com/language/tutorial/DefiningFunctions.html)
- [Patterns—Wolfram Documentation](https://reference.wolfram.com/language/tutorial/Introduction-Patterns.html)

Finally, the easiest way to solve this problem is to use `Derivative` (look it up!):

```
g = Derivative[1,0,0][f]

```

---

<div class="post-metadata">

**Author:** ![tobias1](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tobias1](https://community.wolfram.com/u/tobias1)\
**Post date:** [April 27, 2017, 9:48pm UTC](https://community.wolfram.com/t/define-the-output-of-a-function-as-a-new-function/10379/6 "2017-04-27T21:48:54Z")

</div>

Hey,

thanks for your answers, I read the articles and was able to solve a half of the actual problem, which is the following:

I have the function

```
El[k_ , l_, d_] := k * l / (0.25*d^2*Pi)

```

and computed the gaussian variance formula

```
Eld [k_, l_, d_, kd_, ld_, dd_] := 
 Sqrt[kd (Derivative[1, 0, 0][El])^2 + 
   ld (Derivative[1, 0, 0][El])^2 + dd (Derivative[1, 0, 0][El])^2]

```

It works pretty well for El… `El[1,2,3]` gives me 0.282942.

However, `Eld[1, 2, 3, 4, 5, 6]` doesn’t work, which makes sense because Eld can’t give k,l and d to El. However, I do not know how to solve this problem. Can you help me again?

Thank you,

Tobias
