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.Sat, 29 Jun 2013 17:25:13 +0200Display Y-intercept?https://ask.sagemath.org/question/10272/display-y-intercept/I was able to successfully compute the following with Sage 5.9:
p1 = plot(20*x + 10000, -8,600, ymin = -15, ymax = 30000)
p2 = plot(80*x, -8,600, ymin = -15, ymax = 30000, color = 'orange')
p9 = (p1 + p2)
plot(p9)
Is it possible for me to get Sage to display the point of intersection between the 2 lines?
The intersection occurs at 166 of the x-axis, with a y value of around 13300.
Sun, 23 Jun 2013 21:06:51 +0200https://ask.sagemath.org/question/10272/display-y-intercept/Answer by dazedANDconfused for <p>I was able to successfully compute the following with Sage 5.9:</p>
<pre><code>p1 = plot(20*x + 10000, -8,600, ymin = -15, ymax = 30000)
p2 = plot(80*x, -8,600, ymin = -15, ymax = 30000, color = 'orange')
p9 = (p1 + p2)
plot(p9)
</code></pre>
<p>Is it possible for me to get Sage to display the point of intersection between the 2 lines?</p>
<p>The intersection occurs at 166 of the x-axis, with a y value of around 13300.</p>
https://ask.sagemath.org/question/10272/display-y-intercept/?answer=15159#post-id-15159Here's the code I was trying to indicate in my comment plus a little bit extra to address your latest comments. It uses your code and calc314's code. Since you said you wanted it to display the answer, 166.66 you have asked for just the x-value.
p1 = plot(20*x + 10000, -8,600, ymin = -15, ymax = 30000)
p2 = plot(80*x, -8,600, ymin = -15, ymax = 30000, color = 'orange')
p9 = (p1 + p2)
ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p4=text('%s'%x0,(x0+30,y0-1000))
p5=text('(%s,%s)'%(x0,y0),(x0+30,y0-3000))
p9=p1+p2+p3+p4+p5
show(p9)
print 'x value of intersection', x0
print 'x value of intersection', n(x0,digits=5)
You can, of course, remove the line p5=text('(%s,%s)'%(x0,y0),(x0+30,y0-3000)) and pick the print statement you like best.Sat, 29 Jun 2013 12:44:17 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?answer=15159#post-id-15159Answer by calc314 for <p>I was able to successfully compute the following with Sage 5.9:</p>
<pre><code>p1 = plot(20*x + 10000, -8,600, ymin = -15, ymax = 30000)
p2 = plot(80*x, -8,600, ymin = -15, ymax = 30000, color = 'orange')
p9 = (p1 + p2)
plot(p9)
</code></pre>
<p>Is it possible for me to get Sage to display the point of intersection between the 2 lines?</p>
<p>The intersection occurs at 166 of the x-axis, with a y value of around 13300.</p>
https://ask.sagemath.org/question/10272/display-y-intercept/?answer=15128#post-id-15128You can solve this by hand and plot or by Sage and plot as follows:
ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
Sun, 23 Jun 2013 23:05:59 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?answer=15128#post-id-15128Comment by calc314 for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17441#post-id-17441Ah, I might have miss interpreted your question. @dazedANDconfused is correct. Just use `print x0,y0` to get the coordinates of the intersection point.Thu, 27 Jun 2013 15:42:27 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17441#post-id-17441Comment by dazedANDconfused for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17443#post-id-17443I'm not sure what you're asking. To calc314's additional code can add the line: print x0 and it will display 500/3 below the graph. If you want it displayed on the graph you could add: p4=text('%s'%x0,(x0+30,y0-1000)) to print the coordinates of the point on the graph; just change the line to p9=p1+p2+p3+p4. I had to adjust where it printed [eg y0-1000] because the text came out over the point; I don't know if there's a way to get around that.Thu, 27 Jun 2013 13:14:45 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17443#post-id-17443Comment by bxdin for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17428#post-id-17428I did the following:
p1 = plot (2*x/3 - 1, -10,10, ymin=-10, ymax=10)
p2 = plot (4*x/24 - 1/24, -10,10, ymin=-10, ymax=10, color = 'green')
plot(p1 + p2)
print(x0,y0)
I got the following error message instead, even without the parentheses on the print statement.:
Traceback (click to the left of this block for traceback)
...
NameError: name 'x0' is not defined
Sat, 29 Jun 2013 07:54:37 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17428#post-id-17428Comment by bxdin for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17422#post-id-17422That did the trick thanks.Sat, 29 Jun 2013 17:25:13 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17422#post-id-17422Comment by calc314 for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17427#post-id-17427You did not define x0 or y0. Until these are defined Sage does not know what they are. You need to update and use the first three lines of my answer above.Sat, 29 Jun 2013 08:43:07 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17427#post-id-17427Comment by bxdin for <p>You can solve this by hand and plot or by Sage and plot as follows:</p>
<pre><code>ans=solve(20*x+10000==80*x,x)
x0=ans[0].rhs()
y0=80*x0
p3=point( (x0,y0), size=40)
p9=p1+p2+p3
show(p9)
</code></pre>
https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17457#post-id-17457So there's no way to get Sage to display, 166.66, as the answer?Mon, 24 Jun 2013 20:22:57 +0200https://ask.sagemath.org/question/10272/display-y-intercept/?comment=17457#post-id-17457