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.Mon, 22 Aug 2016 09:53:18 +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/Newton method for one variablehttps://ask.sagemath.org/question/34554/newton-method-for-one-variable/ I try to use 'solve' for nonlinear eauqtions in one variable, but the answer is tautological or "cannot evaluate symbolic expression numerically" if I add "explicit_solutions=True". Is Newton method (or any other, like secant method) implemented in Sage?
Ex:
sage: x=var('x')
sage: (x-cos(x)).solve(x)
[x == cos(x)]
while I would expect x= 0.739085logomathMon, 22 Aug 2016 09:53:18 +0200https://ask.sagemath.org/question/34554/Roots in a solutionhttps://ask.sagemath.org/question/9402/roots-in-a-solution/When I solve the equations I obtained from the code in [this question](http://ask.sagemath.org/question/1848/eliminating-fractions-and-roots-from-equations), I get a number of solutions. Most of them complex numbers, whereas the single real solution simply prints as `r1` when first executing the code, as `r2` next, and so on. So I gather that this is some root which Maxima or whoever is doing the solving cannot reduce to radicals.
So far, so good, but I'd still like to be able to get an idea of what that thing represents. Saving my solutions to a list of dictionaries, I've been able to isolate that value, but I can't seem to find any reasonable methods to obtain further details. In particular, `r.n()` tells me that it
TypeError: cannot evaluate symbolic expression numerically
So what can I do? how can I figure out what this thing actually represents? I believe that it might be some root of a polynomial which still contains one variable from my equation. But how can I obtain that polynomial?MvGMon, 08 Oct 2012 13:19:15 +0200https://ask.sagemath.org/question/9402/solving sqrt(-1) to a real numberhttps://ask.sagemath.org/question/8762/solving-sqrt-1-to-a-real-number/Here is what I am trying to do:
var('x')
A(x)=x/2+(4-x*x)^(1/2)
assume(0<x<2)
maximum = (derivative(A)==0).maxima_methods().rootscontract().simplify()
view(maximum)
view(solve(maximum,x))
A.plot(A,0,2)
and get i multiplied by the root of x^2... if I put the same equation into wolfram, it gives me a real number 2/sqrt(5) (which is correct and makes sense).
How can I make SageMath solve those? I tried simplify() and full_simplify(), maxima_methods() and rootscontract() gives an error in combination with solve().
I guess it's just some syntax error, sorry for that :(
For now I do most in the Sage - Cell Server, which is great.disiThu, 01 Mar 2012 09:26:06 +0100https://ask.sagemath.org/question/8762/