0
$\begingroup$
 f[x_, y_, z_] := x^2 + y^3 + xy^2 + 4 z
 D[f[x, y, z], x]

gives the result 2 x + 6 x^5 which is obviously wrong. What could be wrong with my code?

also if I try

f[x_, y_, z_] := x^2 + y^3 + x*y^2 + 4 z
D[f[x, y, z], x]

the ansewer is another wrong

2 x + 5 x^4 + 6 x^5

is my error syntax? thanks

$\endgroup$
3
  • 4
    $\begingroup$ Restart the kernel. Something is going wrong here; maybe a hanging definition of y or z. Morever xy^2 should probably be x y^2... $\endgroup$ Commented Jun 20, 2018 at 7:05
  • 5
    $\begingroup$ the most likely explanation is that you defined y=x^2 and z=0 somewhere before. Use Clear[x,y,z] and try your second code again. $\endgroup$
    – halirutan
    Commented Jun 20, 2018 at 7:26
  • 2
    $\begingroup$ In addition, as you may already have noticed, xy^2 is the square of the variable xy, rather than xtimes the squared y. You need to either write x*y^2, or x y^2, according to your liking. $\endgroup$ Commented Jun 20, 2018 at 8:47

1 Answer 1

2
$\begingroup$

Both of those functions work normally on my computer. As @halirutan has suspected, the reason seems to be that you have made some definitions on y and z, thus giving the wrong result.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.