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.Sun, 15 Apr 2012 01:17:01 +0200obtaining all numerical roots of a function in an intervalhttps://ask.sagemath.org/question/8886/obtaining-all-numerical-roots-of-a-function-in-an-interval/Hello, thanks for reading.
I'm working on single variable calculus here:
Basically what I need is what "find_root" does, but I need a list of ALL roots in a given interval, not just one.
So I've been playing with "solve". I found this piece of code which works in most cases:
sage: roots = solve(f(x),x,solution_dict=True)
sage: roots = [s[x] for s in roots]
sage: num_roots = map(n, roots)
but it gives an error if the function is periodic and has inifinite roots, becuase the symbolic expression that "solve" gets has infinite solutions too.
Defining a desired interval should solve this issue, but I have no idea how to implement such thing!
Thanks you and have a good day.NilSun, 15 Apr 2012 01:17:01 +0200https://ask.sagemath.org/question/8886/Finding all the roots at once numericallyhttps://ask.sagemath.org/question/8105/finding-all-the-roots-at-once-numerically/I want to calculate the roots of equations like
tanh(ax) = x
numerically.
But the problem is sage gives option of finding just one root provided I give it the interval where the root may be found.
(tanh(1.5*x)==x).find_root(0.5,2)
But sometimes the interval is not so obvious and I need to know all the numerical roots at once
(If the number of roots are finite that is). Is There a way to do that?
ebsThu, 05 May 2011 07:17:27 +0200https://ask.sagemath.org/question/8105/SAGE digits!!!https://ask.sagemath.org/question/8058/sage-digits/How can I make p.real_roots() in 6 digits??<br> .n(digits=6) DONT work!!!SagudTue, 05 Apr 2011 12:29:16 +0200https://ask.sagemath.org/question/8058/Inaccurate numerical result for roots of square equationhttps://ask.sagemath.org/question/7988/inaccurate-numerical-result-for-roots-of-square-equation/Hi,I have 'Sage Version 4.6.1, Release Date: 2011-01-11' and I using next code to get roots of square equation:
reset()
var('a b c p pz pz2')
a = 0.0000148294611962432
b = 9.90113840830450
c = 1.00000000000000
A = a*p^2 + b*p + c
pz = solve(A == 0, p, solution_dict = True)
pz = [s[p].n() for s in pz];
Result1 = A(p=pz[0])
This way give very bad accuracy of the 1st root (Result1=-0.00138422288000584). What i do wrong? And How to get precision result with Sage? Thanks!avi9526Tue, 08 Mar 2011 12:18:44 +0100https://ask.sagemath.org/question/7988/Numerically find all roots in an intervalhttps://ask.sagemath.org/question/7823/numerically-find-all-roots-in-an-interval/Is there a function to find all the roots of a function on a given interval? I'm thinking of something like this:
<pre>
sage: find_all_roots(lambda z: tan(z)+z/sqrt(9*pi^2-z^2), 0, 10)
[0, 2.835952326711582867481259929, 5.64146101037285257526886564, 8.338774576412169721334841011]
</pre>
Thanks!Just a nobodySat, 18 Dec 2010 17:42:56 +0100https://ask.sagemath.org/question/7823/