Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unable to coerce to real

I'm having trouble with the find_local_minimum and find_local_maximum functions on the absolute value of a complex function. For instance, the following code is logical and works mathematically, but not in Sage:

x = var('x')
find_local_maximum(abs(i*x), 1000, 3000)

But alas, I get the error:

TypeError: unable to coerce to a real number

I've also tried adding an explicit conversion to real (desperate times):

x = var('x')
find_local_maximum(abs(i*x).real(), 1000, 3000)

This gave the same error.

How do I get around this issue? And is there the possibility that this could be resolved in the Sage codebase? It seems feasible, since the plot function works just fine with the exact same function.

Unable to coerce to real

I'm having trouble with the find_local_minimum and find_local_maximum functions on the absolute value of a complex function. For instance, the following code is logical and works mathematically, but not in Sage:

x = var('x')
find_local_maximum(abs(i*x), 1000, 3000)

But alas, I get the error:

TypeError: unable to coerce to a real number

I've also tried adding an explicit conversion to real (desperate times):

x = var('x')
find_local_maximum(abs(i*x).real(), 1000, 3000)

This gave the same error.

How do I get around this issue? And is there the possibility that this could be resolved in the Sage codebase? It seems feasible, since the plot function works just fine with the exact same function.