Ask Your Question

Jose Lykon's profile - activity

2021-09-27 21:05:01 +0200 received badge  Famous Question (source)
2017-12-17 11:39:44 +0200 received badge  Notable Question (source)
2013-02-20 08:05:55 +0200 received badge  Popular Question (source)
2011-01-26 14:35:41 +0200 received badge  Student (source)
2011-01-25 10:55:29 +0200 commented answer Coercion problem while defining piecewise function

That was very clear and informative. Thanks a bunch!

2011-01-25 10:54:35 +0200 received badge  Supporter (source)
2011-01-25 01:52:38 +0200 asked a question Coercion problem while defining piecewise function

In a nutshell: I begin by defining the following function:

def g(x):
return math.exp(-1/(1 - x^2))

which poses no problem. Then, I try to use this function g to define a new function, as follows:

f = Piecewise([ [(-.5,.5), 0.44399*g(x)] ])

which returns the following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/Applications/sage/<ipython console> in <module>()

/Applications/sage/<ipython console> in g(x)

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/fraction_field_element.so in sage.rings.fraction_field_element.FractionFieldElement.__float__ (sage/rings/fraction_field_element.c:8540)()

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/polynomial/polynomial_element.so in sage.rings.polynomial.polynomial_element.Polynomial.__float__ (sage/rings/polynomial/polynomial_element.c:8243)()

TypeError: cannot coerce nonconstant polynomial to float

-----------

I am not sure of what is going wrong here. Any ideas/solutions would be deeply appreciated.

-jl