ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 29 Aug 2011 22:07:46 -0500Solving a linear equationhttp://ask.sagemath.org/question/8298/solving-a-linear-equation/Hello,
I have a problem with the solution of a linear equation given by sage.
sage: a,b,c,d=var('a,b,c,d')
sage: v(t)=a*t^3+b*t^2+c*t+d
sage: v1(t)=diff(v(t),t)
sage: g1=v(0)==0
sage: g2=v(5)==1
sage: g3=v1(5)==0
sage: g4=v(1.5)==0.2
sage: solve([g1,g2,g3,g3],[a,b,c,d])
[[a == r1, b == -10*r1 - 1/25, c == 25*r1 + 2/5, d == 0]]
The right solution is `a=-62/3675, b=473/3675, c=-16/735, d=0`!
What's wrong with my implementation in sage?
Thomas
By the way: How can I realize the typical pre-formatted "sage:... look" in my postings??
Mon, 29 Aug 2011 09:12:56 -0500http://ask.sagemath.org/question/8298/solving-a-linear-equation/Comment by kcrisman for <p>Hello,</p>
<p>I have a problem with the solution of a linear equation given by sage.</p>
<pre><code>sage: a,b,c,d=var('a,b,c,d')
sage: v(t)=a*t^3+b*t^2+c*t+d
sage: v1(t)=diff(v(t),t)
sage: g1=v(0)==0
sage: g2=v(5)==1
sage: g3=v1(5)==0
sage: g4=v(1.5)==0.2
sage: solve([g1,g2,g3,g3],[a,b,c,d])
[[a == r1, b == -10*r1 - 1/25, c == 25*r1 + 2/5, d == 0]]
</code></pre>
<p>The right solution is <code>a=-62/3675, b=473/3675, c=-16/735, d=0</code>!</p>
<p>What's wrong with my implementation in sage?</p>
<p>Thomas</p>
<p>By the way: How can I realize the typical pre-formatted "sage:... look" in my postings??</p>
http://ask.sagemath.org/question/8298/solving-a-linear-equation/?comment=21296#post-id-21296I've edited it to show you how to get that wonderful pre-formatted look - just click "edit" to see how it's done!Mon, 29 Aug 2011 09:41:51 -0500http://ask.sagemath.org/question/8298/solving-a-linear-equation/?comment=21296#post-id-21296Answer by kcrisman for <p>Hello,</p>
<p>I have a problem with the solution of a linear equation given by sage.</p>
<pre><code>sage: a,b,c,d=var('a,b,c,d')
sage: v(t)=a*t^3+b*t^2+c*t+d
sage: v1(t)=diff(v(t),t)
sage: g1=v(0)==0
sage: g2=v(5)==1
sage: g3=v1(5)==0
sage: g4=v(1.5)==0.2
sage: solve([g1,g2,g3,g3],[a,b,c,d])
[[a == r1, b == -10*r1 - 1/25, c == 25*r1 + 2/5, d == 0]]
</code></pre>
<p>The right solution is <code>a=-62/3675, b=473/3675, c=-16/735, d=0</code>!</p>
<p>What's wrong with my implementation in sage?</p>
<p>Thomas</p>
<p>By the way: How can I realize the typical pre-formatted "sage:... look" in my postings??</p>
http://ask.sagemath.org/question/8298/solving-a-linear-equation/?answer=12609#post-id-12609Your answer is just one of the ones for this.
sage: r1=-62/3675
sage: -10*r1-1/25
473/3675
sage: 25*r1+2/5
-16/735
Maxima returns a solve like this when there is a parameter. In this case, one parameter, `r1`, which can be any real number. Are you sure your matrix has non-zero determinant?
Or did you intend
sage: solve([g1,g2,g3,g4],[a,b,c,d])
instead of
sage: solve([g1,g2,g3,g3],[a,b,c,d])
Actually, I think this is the real issue - typos trip us all up :(Mon, 29 Aug 2011 09:46:47 -0500http://ask.sagemath.org/question/8298/solving-a-linear-equation/?answer=12609#post-id-12609Answer by tmaxara for <p>Hello,</p>
<p>I have a problem with the solution of a linear equation given by sage.</p>
<pre><code>sage: a,b,c,d=var('a,b,c,d')
sage: v(t)=a*t^3+b*t^2+c*t+d
sage: v1(t)=diff(v(t),t)
sage: g1=v(0)==0
sage: g2=v(5)==1
sage: g3=v1(5)==0
sage: g4=v(1.5)==0.2
sage: solve([g1,g2,g3,g3],[a,b,c,d])
[[a == r1, b == -10*r1 - 1/25, c == 25*r1 + 2/5, d == 0]]
</code></pre>
<p>The right solution is <code>a=-62/3675, b=473/3675, c=-16/735, d=0</code>!</p>
<p>What's wrong with my implementation in sage?</p>
<p>Thomas</p>
<p>By the way: How can I realize the typical pre-formatted "sage:... look" in my postings??</p>
http://ask.sagemath.org/question/8298/solving-a-linear-equation/?answer=12611#post-id-12611> Or did you intend
> sage: solve([g1,g2,g3,g4],[a,b,c,d])
> instead of...
Yes!!
Yesterday I sat an hour ...and now I have made a spelling error!
Thank you
ThomasMon, 29 Aug 2011 22:07:46 -0500http://ask.sagemath.org/question/8298/solving-a-linear-equation/?answer=12611#post-id-12611