Warning, unable to evaluate the function to numeric values in the region; complex values were detected - Maple Programming Help

Home : Support : Online Help : System : Error Message Guide : complexvaluesdetected

Warning, unable to evaluate the function to numeric values in the region; complex values were detected

 Description The plot(f,x) calling sequence plots the real function, f, a function of the independent variable, x, over a horizontal real range.   This warning message occurs when the expression you are trying to plot using the plot(f,x) calling sequence evaluates to complex values for all of the values in the given range. The plot command only plots real-valued expressions.   Note: The warning message is generated only when no real-valued points are generated.   Verify that you are using the correct syntax for the plotting command and that the function evaluates to real numbers in the specified region.   Alternatively, to plot in the complex plane, use plots[complexplot].

Examples

Example 1: Plotting a complex expression.

The value of is complex, making the expression inside the plot command, complex. Although this example is trivial, this scenario can occur when you inadvertently use a variable name that was assigned another value (complex value in this case) somewhere else in your worksheet.

 > $\mathrm{a}≔\sqrt{5}\cdot \mathrm{I}$
 ${a}{:=}{I}{}\sqrt{{5}}$ (2.1)
 > $\mathrm{plot}\left(\mathrm{a}\cdot {\mathrm{x}}^{2},\mathrm{x}=1..5\right)$

Solution : Change to be real-valued.

 > $\mathrm{a}≔\sqrt{5}$
 ${a}{:=}\sqrt{{5}}$ (2.2)

 > $\mathrm{plot}\left(\mathrm{a}\cdot {\mathrm{x}}^{2},\mathrm{x}=1..5\right)$

Example 2: Real-valued expression with non-real values

In the range given, the solutions for the function $\sqrt{x}$ are all complex values that cannot be plotted with the plot command, resulting in an empty plot.

 >

Solution:

Change plotting range so that only real-values are computed.

Alternatively, to plot in the complex plane, use plots[complexplot].

Example 3: Some real values are computed

In this case, because some real values are computed, the plot is not empty and no warning message is generated.

 >

Solution:

Change plotting range so only real values are computed.

 > $\mathrm{plot}\left(\sqrt{\mathrm{x}},\mathrm{x}=0..10\right)$

Alternatively, to plot in the complex plane, use plots[complexplot].

Example 4: Procedure returns complex value.

The expression,

 >
 ${f}{:=}{\mathbf{proc}}\left({x}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{I}{*}{x}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (2.3)

 > $\mathrm{plot}\left(\mathrm{f},1..2\right)$

Solution : Use the  plots[complexplot] command.

 > $\mathrm{with}\left(\mathrm{plots}\right):$
 > $\mathrm{complexplot}\left(\mathrm{f},1..2\right)$

Example 5:

Similar to the plot command calling sequence, the plot3d command accepts real-valued expressions and plots these expressions over a real range. In this example, the x-values are all negative leading to complex values generated by sqrt(x).

 > $\mathrm{plot3d}\left(\left[\mathrm{sqrt}\left(\mathrm{x}\right),0,2\right],\mathrm{x}=-5..-4,\mathrm{y}=-1..1,\mathrm{axes}="normal"\right)$

Solution: Change the range for the x variable to be positive values. Alternatively, use the plots[complexplot] command instead.

 > $\mathrm{plot3d}\left(\left[\mathrm{sqrt}\left(\mathrm{x}\right),0,2\right],\mathrm{x}=4..5,\mathrm{y}=-1..1,\mathrm{axes}="normal"\right)$
 >