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.Mon, 29 Aug 2016 13:04:46 +0200solving systems of equations returns [] Reduxhttps://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.
I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:
- var('x' ,'y' ,'z', 'lam')
- var('F')
- F = x*y*z - lam * (x*y*z-9)
- var('dFx', 'dFy', 'dFz', 'dFlam')
- dFx=diff(F,x)
- dFy=diff(F,y)
- dFz=diff(F,z)
- dFlam=diff(F,lam)
- solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)
but the **solve** returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?
Thanks.
BobM
Sat, 27 Aug 2016 10:28:29 +0200https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/Comment by slelievre for <p>I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.</p>
<p>I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:</p>
<ul>
<li>var('x' ,'y' ,'z', 'lam')</li>
<li>var('F')</li>
<li>F = x<em>y</em>z - lam * (x<em>y</em>z-9) </li>
<li>var('dFx', 'dFy', 'dFz', 'dFlam') </li>
<li>dFx=diff(F,x)</li>
<li>dFy=diff(F,y) </li>
<li>dFz=diff(F,z)</li>
<li>dFlam=diff(F,lam)</li>
<li>solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)</li>
</ul>
<p>but the <strong>solve</strong> returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?</p>
<p>Thanks.</p>
<p>BobM</p>
https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?comment=34637#post-id-34637To display inline code, surround it within backticks `.
To display blocks of code, either indent them with 4 spaces,
or select the corresponding lines and click the "code" button
(the icon with '101 010').
Can you edit your question to do that?Mon, 29 Aug 2016 13:04:46 +0200https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?comment=34637#post-id-34637Answer by tmonteil for <p>I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.</p>
<p>I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:</p>
<ul>
<li>var('x' ,'y' ,'z', 'lam')</li>
<li>var('F')</li>
<li>F = x<em>y</em>z - lam * (x<em>y</em>z-9) </li>
<li>var('dFx', 'dFy', 'dFz', 'dFlam') </li>
<li>dFx=diff(F,x)</li>
<li>dFy=diff(F,y) </li>
<li>dFz=diff(F,z)</li>
<li>dFlam=diff(F,lam)</li>
<li>solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)</li>
</ul>
<p>but the <strong>solve</strong> returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?</p>
<p>Thanks.</p>
<p>BobM</p>
https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?answer=34613#post-id-34613I can not reproduce your problem on 7.4.beta2:
sage: var('x' ,'y' ,'z', 'lam')
(x, y, z, lam)
sage: F = x*y*z - lam * (x*y*z-9)
sage: F
x*y*z - (x*y*z - 9)*lam
sage: dFx=diff(F,x)
sage: dFy=diff(F,y)
sage: dFz=diff(F,z)
sage: dFlam=diff(F,lam)
sage: dFz
-lam*x*y + x*y
sage: solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)
[[x == 9/(r1*r2), y == r1, z == r2, lam == 1]]
Sat, 27 Aug 2016 13:06:21 +0200https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?answer=34613#post-id-34613Comment by BobM for <p>I can not reproduce your problem on 7.4.beta2:</p>
<pre><code>sage: var('x' ,'y' ,'z', 'lam')
(x, y, z, lam)
sage: F = x*y*z - lam * (x*y*z-9)
sage: F
x*y*z - (x*y*z - 9)*lam
sage: dFx=diff(F,x)
sage: dFy=diff(F,y)
sage: dFz=diff(F,z)
sage: dFlam=diff(F,lam)
sage: dFz
-lam*x*y + x*y
sage: solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)
[[x == 9/(r1*r2), y == r1, z == r2, lam == 1]]
</code></pre>
https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?comment=34617#post-id-34617But what is the latest non-beta version of Sage?Sun, 28 Aug 2016 16:05:54 +0200https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?comment=34617#post-id-34617Answer by slelievre for <p>I searched the wiki and found the "solve always returns []" question. But it doesn't help me. I will admit that I am a complete neophyte with Sagemath and have been playing with version 7.2 on my windows machine.</p>
<p>I was trying to do something very simple: solve a basic Lagrange Multiplier problem, so I defined the following:</p>
<ul>
<li>var('x' ,'y' ,'z', 'lam')</li>
<li>var('F')</li>
<li>F = x<em>y</em>z - lam * (x<em>y</em>z-9) </li>
<li>var('dFx', 'dFy', 'dFz', 'dFlam') </li>
<li>dFx=diff(F,x)</li>
<li>dFy=diff(F,y) </li>
<li>dFz=diff(F,z)</li>
<li>dFlam=diff(F,lam)</li>
<li>solve([dFx==0,dFy==0,dFz==0,dFlam==0],x,y,z,lam)</li>
</ul>
<p>but the <strong>solve</strong> returns []. It should return something like x==3, y==3, z==3, shouldn't it? Is there an alternative way to approach this?</p>
<p>Thanks.</p>
<p>BobM</p>
https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?answer=34636#post-id-34636This seems to work in Sage 7.3 (the latest public release).
Not sure what change between Sage 7.2 and Sage 7.3 made this work.
One could try to check which ticket is responsible among those merged in Sage 7.3.
http://www.sagemath.org/changelogs/sage-7.3.txt
$ sage -v
SageMath version 7.3, Release Date: 2016-08-04
$ sage -q
sage: x, y, z, lam = var('x' ,'y' ,'z', 'lam')
sage: F = x*y*z - lam * (x*y*z-9); F
x*y*z - (x*y*z - 9)*lam
sage: dFx = diff(F, x)
sage: dFy = diff(F, y)
sage: dFz = diff(F, z)
sage: dFlam = diff(F, lam)
sage: dFx, dFy, dFz, dFlam
(-lam*y*z + y*z, -lam*x*z + x*z, -lam*x*y + x*y, -x*y*z + 9)
sage: solve([dFx == 0, dFy == 0, dFz == 0, dFlam == 0], x, y, z, lam)
[[x == 9/(r1*r2), y == r1, z == r2, lam == 1]]
sage:Mon, 29 Aug 2016 13:04:01 +0200https://ask.sagemath.org/question/34608/solving-systems-of-equations-returns-redux/?answer=34636#post-id-34636