Ask Your Question
0

plot P1 or P2 is right, but I see a wrong in the figure(P1+P2), how to solve it?

asked 2022-03-28 12:40:58 +0100

anonymous user

Anonymous

updated 2022-03-28 16:11:15 +0100

The plots P1 and P2 below are correct, but when I combine them using P1 + P2, there is a break. How to solve it?

sage: t = SR.var('t')
sage: soln1 = lambda t: 196/3 - 196*exp(-3*t/20)/3
sage: P1 = plot(soln1(t), 0, 30, plot_points=1000)
sage: soln2 = lambda t: 1/10470*(102606*e^t + 573835)*e^(-t)
sage: P2 = plot(soln2(t), 30, 50, plot_points=1000)
P1# the figure is right
P2# the figure is also right
P1+P2 # the figure is wrong in the point (t=30)
edit retag flag offensive close merge delete

Comments

You're asking for it ! You plot

  • P1 between 0 and 29

  • P2 between 30 and 50

Sage, lacking psychic.py, has no way to divine your intention of having "something" (what ?) plotted between 29 and 30.

What do you mean ?

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2022-03-28 15:35:00 +0100 )edit

Sorry. I write the wrong question. let me correct it

TimeVector gravatar imageTimeVector ( 2022-03-28 16:08:28 +0100 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2022-03-28 17:28:03 +0100

tmonteil gravatar image

I am not sure there is anything wrong in the picture: P2 is the graph of a function that is nearly constant:

sage: soln2(30).n()
9.80000000000513
sage: soln2(40).n()
9.80000000000000
sage: soln2(4000).n()
9.80000000000000

So, when you put it on the same plot as P1, since soln1 ranges from 0 to more than 64, the graph of soln2 looks flat.

sage: soln1(0).n()
0.000000000000000
sage: soln1(30).n()
64.6075455595015

I am not sure of what you are expecting at x=30, but you can join the endpoints of the two plots as follows:

sage: P1 + P2 + line2d([(30,soln1(30)), (30,soln2(30))])
edit flag offensive delete link more

Comments

you can use P2.show() see figure

TimeVector gravatar imageTimeVector ( 2022-03-29 07:32:57 +0100 )edit

Oh! I know it , thanks!

TimeVector gravatar imageTimeVector ( 2022-03-29 07:36:07 +0100 )edit

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: 2022-03-28 12:36:59 +0100

Seen: 659 times

Last updated: Mar 28 '22