python - sympy plot conflict with piecewise function -



python - sympy plot conflict with piecewise function -

i have created piecewise function using sympy:

x= symbols('x') xl = (1-x)**2 xh = (x-1)**1.5 xx= piecewise((xl,x<=1),(xh,x>1)) plot(xx,(x,0,2),adaptive=false, num_of_points=200)

it works calculate xx @ value of x between 0 , 2 (only range of interest).

when plot it, returns error negative number can't raised fractional power, should never happen, it's when x greater 1 fractional powerfulness applies.

is processing both pieces on total range reason? thoughts?

in end, workaround used abs(x-1):

x= symbols('x') xl = (1-x)**2 xh = abs(x-1)**1.5 xx= piecewise((xl,x<=1),(xh,x>1)) plot(xx,(x,0,2),adaptive=false, num_of_points=200)

it's right when number used, , avoids error. submitted bug on github.

python plot sympy piecewise

Comments