Ask Your Question

franpena's profile - activity

2020-10-21 21:05:36 -0500 received badge  Popular Question (source)
2020-01-07 10:30:33 -0500 received badge  Popular Question (source)
2019-11-30 21:36:21 -0500 received badge  Popular Question (source)
2017-11-30 10:23:21 -0500 received badge  Notable Question (source)
2017-07-19 21:34:47 -0500 received badge  Popular Question (source)
2017-02-14 11:42:39 -0500 asked a question Memory error mixing exact numbers and decimal ones


I wonder why this code gives an error in Sage 7.5.1:

if abs(f(0.7)) < 1e-12:
     print 1

MemoryError: Not enough memory to calculate cyclotomic polynomial of 428914250225777
2017-02-10 10:20:56 -0500 commented answer Evaluating the derivative of piecewise functions

Thank you @paulmasson. So that means that piecewise cannot operate as similar as Piecewise does with symbolic expressions. In my opinion this is a drawback.

2017-02-10 09:54:38 -0500 received badge  Scholar (source)
2017-02-10 09:54:09 -0500 received badge  Editor (source)
2017-02-10 09:38:44 -0500 received badge  Supporter (source)
2017-02-09 10:44:53 -0500 asked a question find_root does not fulfill tolerance

In Sage 7.3 the result of:




One would expect that the error with the exact solution (x=0) would be lower than 1e-13. I imagine that the multiplicity of the root produces this effect. Does somebody know the numerical algorithm behind find_root?

Thanks in advance.

UPDATE: Thanks to @kcrisman, I see that find_root calls brentq. The documentation of such function says:

Safer algorithms are brentq, brenth, ridder, and bisect, but they all require that the root first be bracketed in an interval where the function changes sign. The brentq algorithm is recommended for general use in one dimensional problems when such an interval has been found.

Since 4x^4-x^2 has a root in 0 with multiplicity 2, this condition is not fulfilled. Is there any other command in Sage different from find_root to numerically calculate roots for general functions that can handle with roots with multiplicity bigger than 1?

2017-02-05 07:49:35 -0500 received badge  Student (source)
2017-02-04 19:09:52 -0500 asked a question Evaluating the derivative of piecewise functions


In Sage 7.5 you can numerically evaluate the derivative of a regular symbolic expression using:

sage: h(x) = sin(x)
sage: diff(h)(2).n()

Old Piecewise functions could be treated in the same way:

sage: g = Piecewise([([0,2], sin(x)), ((2,3), cos(x))])
... DeprecationWarning ...
sage: diff(g)(1).n()

However, new piecewise functions don't:

sage: f = piecewise([([0,2], sin(x)), ((2,3), cos(x))])
sage: diff(f)(1).n()
... Error ...

Thanks in advance.

2015-06-05 08:58:30 -0500 commented answer Differences between load and attach

The point is, if there is not a slowdown in the 'attach' performance, should not be always 'attach' preferred over 'load'? I.e., same speed, more features!

2015-06-03 11:18:02 -0500 asked a question Differences between load and attach

Is the automatic reload of modified files the only difference between 'load' and 'attach'? In such case, if there is not a slowdown in the 'attach' performance, should not be always 'attach' preferred over 'load'?