I need an expression for the real 7/3 power of a real-valued function, i.e., a reformulation of

f[x_] := g[x]^(7/3)

that works for negative values of g[x]. This function and its first and second derivatives are used in heavy computation (i.e. in objectives to FindMinimum) and need to be well-defined at all values of x. In particular, I've tried the following, which don't work:

f[x_] := g[x]^(7/3)

which gives complex values at negative values of g[x], and

f[x_] := Surd[g[x],3]^7

which gives a "Infinite expression" error when its derivative is evaluated at 0.

  • $\begingroup$ (-1)^(7/3) == ??? $\endgroup$ Mar 6, 2013 at 17:00
  • 2
    $\begingroup$ @belisarius I'm sure he's interpreting this as -1 and that's rather the point of the new CubeRoot and Surd functions. $\endgroup$ Mar 6, 2013 at 17:02
  • $\begingroup$ Why doesn't f[x_] := Piecewise[{{g[x]^(7/3), g[x] >= 0}}, -(-g[x])^(7/3)] work? $\endgroup$
    – whuber
    Mar 6, 2013 at 17:52
  • $\begingroup$ @belisarius I want the real 7/3 power of a real number, which is well defined over all $\mathbb{R}$. $\endgroup$
    – user168715
    Mar 6, 2013 at 19:27
  • $\begingroup$ @whuber Thanks, I will try that. $\endgroup$
    – user168715
    Mar 6, 2013 at 19:27

1 Answer 1


To some extent, this is understandable given the formula for the derivative of the Surd.

D[Surd[x^4, 3], x] // InputForm
(* Out: (4*x^3)/(3*Surd[x^4, 3]^2) *)

Of course, this formula is good, except when $x=0$. Computer algebra systems frequently return this type of "generic" result. If you really need to work at zero, perhaps something like the following will work:

Clear[f, fp];
f[x_] = CubeRoot[x^7];
fp[x_] := f'[x] /; x != 0;
fp[0] = fp[0.0] = 0;

This should define a function fp representing your derivative that might work as expected. It also might depend on what you need to do with it.

  • 1
    $\begingroup$ $f$ is used as input to functionals in my code that themselves take D of it, so if possible I would like to avoid having to define the derivative of f specially. $\endgroup$
    – user168715
    Mar 6, 2013 at 19:26
  • $\begingroup$ (Also, I suppose I hoped Mathematica would be "smart" enough to take a limit at 0, instead of throwing up its hands and aborting with an error.) $\endgroup$
    – user168715
    Mar 6, 2013 at 19:30
  • $\begingroup$ If I define the function just as f[x_] := Surd[x, 3]^7 and then make this: Plot[Evaluate[D[f[x], x]], {x, -1, 1}] it returns a plot. However, if I define it like this: f[x_] = D[Surd[x, 3]^7, x] /; x != 0; and try to draw the same plot or the one with the exclusion: Plot[Evaluate[f[x]], {x, -1, 1}, Exclusions -> x == 0] it returns nothing at all. Do you know why? $\endgroup$ Mar 7, 2013 at 8:39
  • $\begingroup$ @Alexei It is semantically meaningless. Test it yourself by plugging in some particular arguments, as in f[1]. Remove the /; x!= 0 codicil and you might be more successful. $\endgroup$
    – whuber
    Mar 7, 2013 at 9:07
  • $\begingroup$ @whuber. Thank you. In fact I started my question with that. I tried your test as well and see what happens, but I seem to not understand its origin. Where is the difference between the operator written in the answer above and the one I wrote? I seem to only combined the second and third lines from that answer in one statement. The result is, however, clearly not what I expected, meaning that I am missing something important. $\endgroup$ Mar 8, 2013 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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