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.Fri, 03 Jan 2014 12:21:46 +0100checking left hand side of an equationhttps://ask.sagemath.org/question/10880/checking-left-hand-side-of-an-equation/Hi,
I'd like to check if the operation applied to an equation yields the solution as follow:
a=var('a')
eq= a+7==6
print eq.lhs()
LHS =(eq-7).lhs()
print LHS
LHS==a
a is a
LHS is a
I was waiting that the line *LHS==a* yields **True** or **False**. How can I check that LHS contains the variable **a**?
edit
`LHS is a`
yields **False**Fri, 03 Jan 2014 10:49:49 +0100https://ask.sagemath.org/question/10880/checking-left-hand-side-of-an-equation/Answer by tmonteil for <p>Hi,
I'd like to check if the operation applied to an equation yields the solution as follow:
a=var('a')
eq= a+7==6</p>
<pre><code>print eq.lhs()
LHS =(eq-7).lhs()
print LHS
LHS==a
a is a
LHS is a
</code></pre>
<p>I was waiting that the line <em>LHS==a</em> yields <strong>True</strong> or <strong>False</strong>. How can I check that LHS contains the variable <strong>a</strong>?</p>
<p>edit </p>
<pre><code>`LHS is a`
</code></pre>
<p>yields <strong>False</strong></p>
https://ask.sagemath.org/question/10880/checking-left-hand-side-of-an-equation/?answer=15886#post-id-15886The problem here is that, since `LHS` is a symbolic expression, then `LHS == a` will also be a symbolic expression, not a boolean, see:
sage: LHS.parent()
Symbolic Ring
sage: (LHS == a).parent()
Symbolic Ring
You can try:
sage: bool(LHS == a)
True
Also, `LHS is a` yields to False since `LHS` and `a` do not point to the same object in memory.
Fri, 03 Jan 2014 12:21:46 +0100https://ask.sagemath.org/question/10880/checking-left-hand-side-of-an-equation/?answer=15886#post-id-15886