Suppose we have the following Piecewise
function:
gg[x_?NumericQ] :=
Piecewise[{{x^4 - 6 x^3 + 5, x <= 1}, {8 x^2 - x^7, x > 1}}]
We can find the root of the function easily by:
FindRoot[gg[x], {x, 10}]
(* {x -> 1.51572} *)
The problem emerges when we make for example the second function complex:
gcom[x_?NumericQ] :=
Piecewise[{{x^4 - 6 x^3 + 5, x <= 1}, {8 x^2 - x^7 I, x > 1}}]
In this case FindRoot
does not work:
FindRoot[gcom[x], {x, 10}]
LessEqual::nord: Invalid comparison with 1.24121 -0.147854 I attempted.
Greater::nord: Invalid comparison with 1.24121 -0.147854 I attempted.
LessEqual::nord: Invalid comparison with 1.24121 -0.147854 I attempted.
Greater::nord: Invalid comparison with 1.24121 -0.147854 I attempted.
FindRoot::nlnum: The function value {\[Piecewise] -3.813+2.96586 I 1.24121 -0.147854 I<=1
8.6317 -6.15431 I 1.24121 -0.147854 I>1
0 True
} is not a list of numbers with dimensions {1} at {x} = {1.24121 -0.147854 I}.
Note that outside the Piecewise
function Mathematica can find the complex root:
FindRoot[8 x^2 - x^7 I, {x, 10}]
(* {x -> 1.44153 - 0.468382 I} *)
So my question is how can I find the complex roots of a complex-valued function in a Piecewise
?
FindRoot
to find that? Moreover, you equation is overdetermined: two real quations for one real parameter. $\endgroup$gcom
doesn't work with complex input, e.g.,gcom[1+I]
doesn't work. You need to change the conditions in your piecewise so that they work with complex input. $\endgroup$Piecewise
has meaning for a complex function.FindRoot
must enter a complex number for your argument. How willPiecewise
deal with this. Perhaps you need to define branch cuts. $\endgroup$gcom[x_?NumericQ] := Piecewise[{{x^4 - 6 x^3 + 5, Re[x] <= 1}, {8 x^2 - x^7 I, Re[x] > 1}}]; FindRoot[gcom[x], {x, 10}]
? $\endgroup$