Ask Your Question
3

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

asked 2021-01-22 11:32:00 +0100

ortollj gravatar image

updated 2023-01-09 23:59:54 +0100

tmonteil gravatar image

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)[0])
show(numerical_integral(-sgn(SGN)*f,0,1)[0]+numerical_integral(sgn(SGN)*f,1,2)[0])
edit retag flag offensive close merge delete

Comments

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.

rburing gravatar imagerburing ( 2021-01-22 12:35:43 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-01-22 12:30:57 +0100

tmonteil gravatar image

updated 2021-01-22 12:31:11 +0100

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
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-01-22 11:32:00 +0100

Seen: 294 times

Last updated: Jan 22 '21