ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 29 Mar 2022 07:36:07 +0200plot P1 or P2 is right, but I see a wrong in the figure(P1+P2), how to solve it?https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/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)Mon, 28 Mar 2022 12:36:59 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/Comment by TimeVector for <p>The plots <code>P1</code> and <code>P2</code> below are correct,
but when I combine them using <code>P1 + P2</code>,
there is a break. How to solve it?</p>
<pre><code>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)
</code></pre>
https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61725#post-id-61725Sorry. I write the wrong question. let me correct itMon, 28 Mar 2022 16:08:28 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61725#post-id-61725Comment by Emmanuel Charpentier for <p>The plots <code>P1</code> and <code>P2</code> below are correct,
but when I combine them using <code>P1 + P2</code>,
there is a break. How to solve it?</p>
<pre><code>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)
</code></pre>
https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61723#post-id-61723You'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 ?Mon, 28 Mar 2022 15:35:00 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61723#post-id-61723Answer by tmonteil for <p>The plots <code>P1</code> and <code>P2</code> below are correct,
but when I combine them using <code>P1 + P2</code>,
there is a break. How to solve it?</p>
<pre><code>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)
</code></pre>
https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?answer=61728#post-id-61728I 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))])Mon, 28 Mar 2022 17:28:03 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?answer=61728#post-id-61728Comment by TimeVector for <p>I am not sure there is anything wrong in the picture: <code>P2</code> is the graph of a function that is nearly constant:</p>
<pre><code>sage: soln2(30).n()
9.80000000000513
sage: soln2(40).n()
9.80000000000000
sage: soln2(4000).n()
9.80000000000000
</code></pre>
<p>So, when you put it on the same plot as <code>P1</code>, since <code>soln1</code> ranges from 0 to more than 64, the graph of <code>soln2</code> looks flat.</p>
<pre><code>sage: soln1(0).n()
0.000000000000000
sage: soln1(30).n()
64.6075455595015
</code></pre>
<p>I am not sure of what you are expecting at <code>x=30</code>, but you can join the endpoints of the two plots as follows:</p>
<pre><code>sage: P1 + P2 + line2d([(30,soln1(30)), (30,soln2(30))])
</code></pre>
https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61735#post-id-61735Oh！ I know it , thanks!Tue, 29 Mar 2022 07:36:07 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61735#post-id-61735Comment by TimeVector for <p>I am not sure there is anything wrong in the picture: <code>P2</code> is the graph of a function that is nearly constant:</p>
<pre><code>sage: soln2(30).n()
9.80000000000513
sage: soln2(40).n()
9.80000000000000
sage: soln2(4000).n()
9.80000000000000
</code></pre>
<p>So, when you put it on the same plot as <code>P1</code>, since <code>soln1</code> ranges from 0 to more than 64, the graph of <code>soln2</code> looks flat.</p>
<pre><code>sage: soln1(0).n()
0.000000000000000
sage: soln1(30).n()
64.6075455595015
</code></pre>
<p>I am not sure of what you are expecting at <code>x=30</code>, but you can join the endpoints of the two plots as follows:</p>
<pre><code>sage: P1 + P2 + line2d([(30,soln1(30)), (30,soln2(30))])
</code></pre>
https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61734#post-id-61734you can use
P2.show()
see figureTue, 29 Mar 2022 07:32:57 +0200https://ask.sagemath.org/question/61716/plot-p1-or-p2-is-right-but-i-see-a-wrong-in-the-figurep1p2-how-to-solve-it/?comment=61734#post-id-61734