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, 14 Jan 2012 01:30:14 +0100variables get deleted after calulation, overflow?https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/Hello and happy 1000 questions,
I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code
var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
Errorcode:
Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.
Wed, 11 Jan 2012 08:43:10 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/Comment by John Palmieri for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20549#post-id-20549My guess is that you're running out of memory. How much memory does the VirtualBox give to Sage? Can you increase that and see if it helps?Thu, 12 Jan 2012 17:30:22 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20549#post-id-20549Comment by John Palmieri for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20560#post-id-20560When I tried "show(test3)", I got a different error. The latex string for test3 is *very* long, long enough that a closing brace "}" is too far away from the corresponding starting one, so latex (or jsmath) fails. I'm not sure what you expect "show" to do with such long output, anyway. For what it's worth, "show(test2)" works fine for me.Wed, 11 Jan 2012 11:04:16 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20560#post-id-20560Comment by god.one for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20561#post-id-20561Thank you. And it's a lot easier than the way I did it.Wed, 11 Jan 2012 09:39:16 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20561#post-id-20561Comment by god.one for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20553#post-id-20553I think it takes about 0.75h, since the %time command does not evaluate either.Thu, 12 Jan 2012 06:38:32 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20553#post-id-20553Comment by god.one for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20559#post-id-20559Theoretically, I expect show(test3) to give me zero. But even when I just write test3 instead of show(test3) I get the same error.Wed, 11 Jan 2012 11:40:28 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20559#post-id-20559Comment by kcrisman for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20555#post-id-20555I have a question - how long does it take for you to run this? It's been running for QUITE a while for me now and I don't even have test3 done yet. Maybe you are running out of memory or something...Wed, 11 Jan 2012 22:20:54 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20555#post-id-20555Comment by DSM for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20562#post-id-20562Rather than using ">", to get the formatting for code right it's easiest to select the pasted code and hit the button above the text box which reads "101 010". Alternatively you can indent by four spaces.Wed, 11 Jan 2012 09:28:12 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20562#post-id-20562Answer by DSM for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13112#post-id-13112I'm not sure what's causing the problem. eq1 shouldn't be blown away.
So since I can't help on that front, maybe we can approach it in another way. I *think* you're trying to check to see that the n that solve returns really is a solution, which is a good idea. solve has been known to return solutions which aren't really solutions in the past. [If I'm off-base, please disregard the following.]
I'm not sure I know what your code is doing, though. I mean, if test were something like
R 2/3 == R^2 4/9
i.e. some yet-unsimplified expression but one that's true, then your procedure would give a test3 of
18*R == 12*R^2
which isn't even a number, much less 0; it'll still be an expression. At best it might give 0 == 0. In your particular case, several options work for sanity checks:
bool(test)
which should return True,
(test.lhs()/test.rhs()).full_simplify()
which should give 1, and
(test.lhs()-test.rhs()).full_simplify()
which should give 0.
Wed, 11 Jan 2012 13:07:34 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13112#post-id-13112Comment by DSM for <p>I'm not sure what's causing the problem. eq1 shouldn't be blown away.</p>
<p>So since I can't help on that front, maybe we can approach it in another way. I <em>think</em> you're trying to check to see that the n that solve returns really is a solution, which is a good idea. solve has been known to return solutions which aren't really solutions in the past. [If I'm off-base, please disregard the following.]</p>
<p>I'm not sure I know what your code is doing, though. I mean, if test were something like</p>
<pre><code>R 2/3 == R^2 4/9
</code></pre>
<p>i.e. some yet-unsimplified expression but one that's true, then your procedure would give a test3 of </p>
<pre><code>18*R == 12*R^2
</code></pre>
<p>which isn't even a number, much less 0; it'll still be an expression. At best it might give 0 == 0. In your particular case, several options work for sanity checks:</p>
<pre><code>bool(test)
</code></pre>
<p>which should return True,</p>
<pre><code>(test.lhs()/test.rhs()).full_simplify()
</code></pre>
<p>which should give 1, and</p>
<pre><code>(test.lhs()-test.rhs()).full_simplify()
</code></pre>
<p>which should give 0.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20550#post-id-20550Could you post your code? Trying the above techniques on your "test" worked for me.Thu, 12 Jan 2012 12:47:08 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20550#post-id-20550Comment by god.one for <p>I'm not sure what's causing the problem. eq1 shouldn't be blown away.</p>
<p>So since I can't help on that front, maybe we can approach it in another way. I <em>think</em> you're trying to check to see that the n that solve returns really is a solution, which is a good idea. solve has been known to return solutions which aren't really solutions in the past. [If I'm off-base, please disregard the following.]</p>
<p>I'm not sure I know what your code is doing, though. I mean, if test were something like</p>
<pre><code>R 2/3 == R^2 4/9
</code></pre>
<p>i.e. some yet-unsimplified expression but one that's true, then your procedure would give a test3 of </p>
<pre><code>18*R == 12*R^2
</code></pre>
<p>which isn't even a number, much less 0; it'll still be an expression. At best it might give 0 == 0. In your particular case, several options work for sanity checks:</p>
<pre><code>bool(test)
</code></pre>
<p>which should return True,</p>
<pre><code>(test.lhs()/test.rhs()).full_simplify()
</code></pre>
<p>which should give 1, and</p>
<pre><code>(test.lhs()-test.rhs()).full_simplify()
</code></pre>
<p>which should give 0.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20552#post-id-20552Ok, you are right. It has to be something like 0==0. I rewrote the program as you proposed (one minus two equals zero) but even this yields no solution for me.Thu, 12 Jan 2012 06:39:59 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20552#post-id-20552Answer by kcrisman for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13111#post-id-13111A small point; you don't need to (shouldn't?) declare `testx` because you assign them to stuff when you first use them.Wed, 11 Jan 2012 10:59:39 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13111#post-id-13111Comment by god.one for <p>A small point; you don't need to (shouldn't?) declare <code>testx</code> because you assign them to stuff when you first use them.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20558#post-id-20558Thanks for the tip. I deleted the var declaration of testx but same error.Wed, 11 Jan 2012 11:47:15 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20558#post-id-20558Answer by god.one for <p>Hello and happy 1000 questions,</p>
<p>I tried to solve an equation and wanted to reinsert the solutions so I can check weather everything worked correctly. But after the calculations are finished, all variables and their values are gone.
Here is the code</p>
<pre><code>var('n,R,T')
var('test,test2,test3')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test = (eq1.substitute(n=sol[0][n]))
test2 = test*(test.lhs().denominator())*(test.rhs().denominator())
test3 = expand(test2).full_simplify()
show(test3)
</code></pre>
<p>Errorcode:</p>
<pre><code>Traceback (click to the left of this block for traceback)
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("ZXEx"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpDYArBS/___code___.py", line 2, in <module>
exec compile(u'eq1
File "", line 1, in <module>
NameError: name 'eq1' is not defined
</code></pre>
<p>I'm working with sage SageVersion 4.7.2 under win7 with Oracle VirtualBox as recommended. Thanks in advance.</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13118#post-id-13118Hi, here is my code
%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
and the glorious result
0
CPU time: 4575.08 s, Wall time: 4601.30
I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.
Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?Fri, 13 Jan 2012 05:07:49 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?answer=13118#post-id-13118Comment by DSM for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20548#post-id-20548I still don't understand why you're expanding it, though. It'll take much less time if you don't, and it doesn't really work as an independent check.Fri, 13 Jan 2012 12:36:55 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20548#post-id-20548Comment by DSM for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20544#post-id-20544What I meant by it doesn't really work as an independent check is that "expand(y).full_simplify()" doesn't give you any extra information over y.full_simplify() here (unless there's a bug in Sage). As for thinking that it might be easier, you might want to try full_simplify without expanding to check..Fri, 13 Jan 2012 15:13:25 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20544#post-id-20544Comment by god.one for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20547#post-id-20547I thought if I expand the whole thing it is easier for full_simplify to collect all terms and do the simplification. And I don't get what you mean with <it doesn't really work as an independent check>. To what are you refering with 'it'.Fri, 13 Jan 2012 14:48:01 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20547#post-id-20547Comment by kcrisman for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20545#post-id-20545Check whichever answer you like! It seems like John's is a little more important, given that you wouldn't have gotten an answer at all otherwise. Wow, over an hour...Fri, 13 Jan 2012 15:09:45 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20545#post-id-20545Comment by kcrisman for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20546#post-id-20546Never delete a question that isn't spam or a duplicate! You might be surprised who finds this interesting, and both issues are important. Fri, 13 Jan 2012 15:08:38 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20546#post-id-20546Comment by god.one for <p>Hi, here is my code</p>
<pre><code>%time
var('n,R,T')
eq1 = ((n-1)^2/(n+1)^2)==(-1-2*R+R^2-T^2+sqrt(4*T^2+(1-2*R+R^2-T^2)^2))/(2*R-4)
sol=solve(eq1,n,solution_dict=true)
test1 = (eq1.substitute(n=sol[0][n]))
test2 = test1.lhs()-test1.rhs()
test3 = expand(test2).full_simplify()
test3
</code></pre>
<p>and the glorious result</p>
<pre><code>0
CPU time: 4575.08 s, Wall time: 4601.30
</code></pre>
<p>I would like to thank DSM for pointing out that my previous attempt would not result into an integer and John Palmieri to extend the usable memory for the virtual machine.</p>
<p>Since this is a very special question and I got an answer now, should I delete it or which answer should get the answer check?</p>
https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20541#post-id-20541You are right, dropping the expand() command reduces calculation time significantly. @kcrisman I cannot give John the credit since he commented on my question so I cannot check this as the wished answer :)Sat, 14 Jan 2012 01:30:14 +0100https://ask.sagemath.org/question/8619/variables-get-deleted-after-calulation-overflow/?comment=20541#post-id-20541