FunctionDomain doesn’t work with If

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?

=================

2

 

I think you may want to use f[x_] := Piecewise[{{x, x < 0}}, x^3] instead of using If – happy fish Mar 22 '15 at 15:05 ================= 1 Answer 1 ================= 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.      It was exactly what I was looking for, thank you for quick response – adolzi Mar 22 '15 at 15:17