# when I must declare f= or f(x,y)= ?

HI

Sorry for this really basic SageMath question ;-( :

Does anyone know the reason why an error is generated when I uncomment the 3rd line? and is it possible when a function was declared (f(x)=) object to return to (f=) object ? and when I must declare f(x)= , or simply f= ? despite the reading of Some Common Issues with Functions

var('x')
SGN=(x+2)*(x+1)*(x-1)*(x+1)
#SGN(x)=(x+2)*(x+1)*(x-1)*(x+1)

show(SGN.parent())
f(x)=1/x*sin(x)
plt=plot(f,(x,-3,3),color='blue')
plt+=plot(SGN,(x,-3,3),color='black',linestyle='dashed')
plt+=plot(sgn(SGN),(x,-5,5),color='gray',linestyle='dashed')
show(plt,xmin=-2,xmax=2,ymin=-3,ymax=3, aspect_ratio=1)

show(numerical_integral(f,0,2))
show(numerical_integral(-sgn(SGN)*f,0,1)+numerical_integral(sgn(SGN)*f,1,2))

edit retag close merge delete

1

The problem is with sgn(SGN); this is an inconsistency / missing feature in Sage, because things like cos(SGN) and log(SGN) work fine. I reported this as trac ticket #31282.

Sort by » oldest newest most voted

If you remove the comment, you have to replace sgn(SGN) with sgn(SGN(x)).

For me, the problem is in:

show(SGN.parent())


That prints (LaTeX) SR, while we have:

SGN.parent()
Callable function ring with argument x

SGN(x).parent()
Symbolic Ring

more