1
$\begingroup$

When I call FunctionDomain for function defined by a formula with If, for example

f[x_]:=If[x<0, x, x^3]

I get

FunctionDomain::nmet: Unable to find the domain with the available methods.>>

What should I do to get a domain of that defined function?

Is any different solution than checking domains of that functions apart?

$\endgroup$
  • 2
    $\begingroup$ I think you may want to use f[x_] := Piecewise[{{x, x < 0}}, x^3] instead of using If $\endgroup$ – happy fish Mar 22 '15 at 15:05
5
$\begingroup$

I'm not sure how you were using FunctionDomain, but running the following example gets your error:

f[x_] := If[x < 0, x, x^3]
FunctionDomain[f[x], x, Reals]
(* FunctionDomain::nmet: Unable to find the domain with the available methods. >> *)

Changing If to Piecewise works though.

f2[x_] := Piecewise[{{x, x < 0}}, x^3] 
FunctionDomain[f2[x], x, Reals]
(* True *)

If you take a look under the "Background" of If in the documentation, that should clear it up a little as to why If fails but Piecewise works.

If is a procedural programming structure whose evaluation branch is determined by the truth value of a specified condition. ... Mathematical functions that evaluate depending on the values of their arguments include Boole and Piecewise.

$\endgroup$
  • $\begingroup$ It was exactly what I was looking for, thank you for quick response $\endgroup$ – adolzi Mar 22 '15 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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