Hi everyone. I've been using basically a whole day on two trivial Mathematica issues, so I'm finally going online for help:(adsbygoogle = window.adsbygoogle || []).push({});

1. Is there any simple way to define the gradient as a new function as such? My try:

Clear["Global`*"]

f[u_] := x*y

gradf[u_] := D[f, {{x, y}}]

gradf

x[u_] := Exp

y := Cos

gradf

Which gives: "General::ivar: E^u is not a valid variable. >>"

I can kind of see what the problem is, but I don't know how to fix it. It works fine if I define gradf as an expression instead of a function (without the [u_]:), but I'd like it as a function. Any simple solution?

2. See the attachment. On the final line, it doesn't evaluate the function r2[0] properly. I think the problem is how h is defined as h[u_]:= f[x,y], doesn't work apparently. Any suggestions?

Also I'd love any general suggestions on how to do things easier or simpler in the notebook attachement. I'm a total beginner in Mathematica (just came from Maple) so I probably do a some things not the easiest or simplest way. Any feedback would be good

Any help is appreciated.

Thanks

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica: Trouble with defining function from gradiant

Tags:

Loading...

Similar Threads - Mathematica Trouble defining | Date |
---|---|

Mathematica Cannot do the integral of the Hyper-geometric function? | Mar 11, 2018 |

Mathematica Cannot Plot This Function in Mathematica | Feb 26, 2018 |

Mathematica: Trouble accurately integrating highly-nonlinear DE | Aug 16, 2013 |

Trouble downloading mathematica packages - probably a very quick solution | Mar 23, 2012 |

[Mathematica] Trouble understanding subscripted variables | Mar 5, 2012 |

**Physics Forums - The Fusion of Science and Community**