Ask Your Question

fbarbuto's profile - activity

2018-05-19 11:29:56 -0500 commented question Solving ODE using desolve_rk4 but th

I'm not new to Sage but since I don't use it a lot I'm kinda an inexperienced user. But what I would do (whether on Sage or any other numerical package) is to find Temp(t), that is, find Temp as a function of 't' given the 't' and 'Temp' points you supplied as lists. I plotted your points and they represent a broken sinusoidal line, but there may be ways to find a reasonable expression for Temp(t). Then you would substitute Temp(t) in your code by the expression you found.

2018-05-19 10:45:50 -0500 commented answer Unexpected behaviour of arbitrary precision real numbers

That worked, thanks! I was suspecting that the formatted print command should be blamed for that. Yet, the following two lines work nicely on Sage's notebook, too:

W = RealField(200)
print W.pi()

and repr() seems not to be necessary in this case. Too much to learn. :-)

2018-05-19 10:37:30 -0500 received badge  Supporter (source)
2018-05-18 22:06:46 -0500 received badge  Notable Question (source)
2018-05-18 19:29:08 -0500 received badge  Editor (source)
2018-05-18 19:26:56 -0500 asked a question Unexpected behaviour of arbitrary precision real numbers

I've been trying to use arbitrary precision real numbers and I'm a bit confused. The simple snippet below illustrates my point:

R = RealField(200)
z = R(2.0)
print '%.20f' % (z.sqrt())

I should get (or that's what I was expecting) 1.41421356237309504880, but instead I got 1.41421356237309514547 (a disagreement in the last five decimal places). Where am I goofing up? You see, it's a quite simple code. How could I fix it in order to obtain the desired/expected result?

Thanks in advance for any light shed on this matter.

Fausto

2015-02-05 02:10:35 -0500 received badge  Student (source)
2015-02-05 02:10:33 -0500 received badge  Teacher (source)
2015-02-05 02:10:33 -0500 received badge  Self-Learner (source)
2015-02-05 01:42:31 -0500 received badge  Popular Question (source)
2015-02-02 19:42:15 -0500 answered a question list_plot() not working in a terminal session

I found the solution for this problem. All I had to do was to replace the following line:

list_plot(...)

by the following two lines:

p = list_plot(...)

p.show()

And then a plot was plotted.

2015-02-02 16:52:28 -0500 commented question Solving PDEs

Hello,

I assume you want to have your PDE(s) solved numerically. And I don't think SAGE is the best tool to accomplish that. You can certainly solve your PDE with SAGE, but you will have to put a lot of your own code together.

If you want to solve equations like the above with less effort, may I suggest you to use FiPy, a PDE solver that uses the finite volume method (FVM). It has extensive documentation, several examples and a support list where developers and users will help you with your questions.

Good luck!

Fausto

2015-02-02 08:09:27 -0500 asked a question list_plot() not working in a terminal session

Hello,

list_plot() does not produce any plot when I run a script in a terminal (pure text) session. But it does when I run the same script in SAGE's graphical ("notebook()") environment. However, in both ways the execution ends normally (no error messages).

Curiously, if I type list_plot(...array name goes here...) in the terminal after the execution of the aforementioned script, a plot is produced.

Any explanation for that? The script is quite simple and short as shown below.

Thanks for any help.

import time
from sage.all import *
import math

n = [19, 31, 61, 127]
l=len(n)
c = []

for i in range(l-1):
    for k in range(i+1,l):
        ai = 2**n[i]-1
        ak = 2**n[k]-1
        temp = ai*ak
        print ai, ak, ai*ak
        start_cpu = time.clock()
        divs = prime_divisors(temp)     
        cpu_t = time.clock() - start_cpu
        c.append((math.log10(1.0*ai*ak),cpu_t))
        print divs
        print 'CPU time = %.3e \n' % (cpu_t)

list_plot(c)