Processing math: 100%
Ask Your Question
1

How to define y=constant function to plot

asked 4 years ago

froli78 gravatar image

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 4 years ago

Emmanuel Charpentier gravatar image

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...

Preview: (hide)
link

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: 4 years ago

Seen: 519 times

Last updated: Nov 24 '20