Ask Your Question

How to define y=constant function to plot

Hi!

I'm newbe with SageMath and i would like to make an y=constant function to plot but i don't find a way to do it.

I can do x=constant functions plot easily:

c=1 plot(c, (x,-2,2))

But how can I do y=constant if it is possible!?

Thanks!

edit retag close merge delete

1 Answer

Sort by » oldest newest most voted

plot(lambda u:1, (-2, 2)) plots an horizontal line where y is constant (i. e. $y=1$).

Do you want a vertical line, where the same value of x of x corresponds to (infinitely) many values of y ? This by definition cannot be the representation of a function of x.

You can use a parametric representation of such a vertical line ; for example, parametric_plot([1,lambda u:u],(0,2)) will plot the vertical segment from (1,0) to (1,2).

You can also directly use the primitive line : line([(1,0),(1,2)]) will get the same result as before.

There are probably other ways, whose search is left to you as an exercise...

more

Your Answer

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

Add Answer

Stats

Asked: 2020-11-24 00:33:15 +0200

Seen: 57 times

Last updated: Nov 24 '20