ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 05 Oct 2011 14:54:33 -0500How do I fix Warning: Output Truncated?https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/Below is my code step by step for using Euler's Method to approximate a solution of a system. It will work when n = 10, but not when n = 100 or 1000. How can I fix it so that the output isn't truncated. Thanks!
# Define RR to be the real numbers, rounding to the nearest number, with 25 bits of precision
RR = RealField(25,rnd='RNDN')
# Define t,x,y to be numbers in RR
t,x,y = PolynomialRing(RR,3,"txy").gens()
# Define the system of equations
firsteq = y
secondeq = -x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
# Define parameters
t0 = 0
x0 = 0
y0 = 2
h = 1/4
n = 10
t1 = t0 + n*h
# Plot the x(t) and y(t) graphs
eulers_method_2x2_plot(firsteq , secondeq, t0, x0, y0, h, t1)Wed, 05 Oct 2011 13:20:25 -0500https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/Answer by DSM for <p>Below is my code step by step for using Euler's Method to approximate a solution of a system. It will work when n = 10, but not when n = 100 or 1000. How can I fix it so that the output isn't truncated. Thanks!</p>
<pre><code># Define RR to be the real numbers, rounding to the nearest number, with 25 bits of precision
RR = RealField(25,rnd='RNDN')
# Define t,x,y to be numbers in RR
t,x,y = PolynomialRing(RR,3,"txy").gens()
# Define the system of equations
firsteq = y
secondeq = -x - x^3/6 + x^5/120 - x^7/5040 + x^9/362880
# Define parameters
t0 = 0
x0 = 0
y0 = 2
h = 1/4
n = 10
t1 = t0 + n*h
# Plot the x(t) and y(t) graphs
eulers_method_2x2_plot(firsteq , secondeq, t0, x0, y0, h, t1)
</code></pre>
https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/?answer=12723#post-id-12723In this case the error message isn't particularly informative, but it looks like what's going on is that the timestep you've selected is too large. Euler's method is (notoriously) poorly behaved, and the code doesn't seem to fail very well when the terms go imaginary.
If you decrease your timestep h, your integration will converge and things should work. By slowing increasing h, you can watch the integration start to fail.
Wed, 05 Oct 2011 13:44:40 -0500https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/?answer=12723#post-id-12723Comment by kcrisman for <p>In this case the error message isn't particularly informative, but it looks like what's going on is that the timestep you've selected is too large. Euler's method is (notoriously) poorly behaved, and the code doesn't seem to fail very well when the terms go imaginary.</p>
<p>If you decrease your timestep h, your integration will converge and things should work. By slowing increasing h, you can watch the integration start to fail.</p>
https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/?comment=21171#post-id-21171I should also point out that this is explicitly documented to be for *pedagogical* purposes only. Wed, 05 Oct 2011 14:54:33 -0500https://ask.sagemath.org/question/8359/how-do-i-fix-warning-output-truncated/?comment=21171#post-id-21171