# "D" Command generates general error in notebook

**URL:** <https://community.wolfram.com/t/d-command-generates-general-error-in-notebook/15719>\
**Category:** Questions\
**Created:** [April 10, 2020, 6:22pm UTC](https://community.wolfram.com/t/d-command-generates-general-error-in-notebook/15719 "2020-04-10T18:22:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![masandlin](https://avatars.discourse-cdn.com/v4/letter/m/839c29/32.png) [@masandlin](https://community.wolfram.com/u/masandlin)\
**Post date:** [April 10, 2020, 6:22pm UTC](https://community.wolfram.com/t/d-command-generates-general-error-in-notebook/15719/1 "2020-04-10T18:22:07Z")

</div>

Hi;

I really like using the “D” Command because of its format and ease of use, however the command seems to cause me calculation problems - See Attached.

I defined the function f[x\_,y\_] and used the function to generate derivatives for both x & y. I then copy and pasted the results into a newly defined function g[x\_,y\_] and subsequently calculated the value of g[1,1]

Next I created another function h[x\_,y\_] using the same “D” commands that generated the solutions that I copy and pasted into the prior “g” function. The new h[x,y] function give the same results as the prior g[x,y] function however when I use the value of h[1,1], I get a “general” error message stating the “1 is not a valid value”.

To further test, I created another function j[x\_,y\_] using the Derivative command which does not give an error message and give the expected results.

I use the “D” command a lot and most of the time it seems to give the desired results, and actually prefer it over the Derivative command because the “D” command is faster to use and I like its format better. Currently, I am trying to figure out when I should use the “D” command and when I should use the Derivative command, or whether I should use the “D” command at all.

Please review the attached and let me know if there is a problem in the “D” command code or in the way I am using the command.

Thanks,

Mitch Sandlin

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [April 10, 2020, 8:00pm UTC](https://community.wolfram.com/t/d-command-generates-general-error-in-notebook/15719/2 "2020-04-10T20:00:41Z")

</div>

You can use the D operator and avoid the problem by defining your function with immediate evaluation:

```
Clear[x, y];
f[x_, y_] = D[x^2 y, x];
f[1, 1]

```

With delayed evaluation you get the error, because the numerical values 1 are replaced into the formula _before_ the derivative is calculated.

A similar problem happens with traditional Leibniz dy/dx notation: if you need the derivative d(log(x))/dx at x=1, you _first_ calculate the derivative with symbolic x, and _then_ replace x=1, not the other way round.
