ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 07 Jan 2019 07:40:18 -0600Generic Symbolic function as input in actual funcitonhttp://ask.sagemath.org/question/44932/generic-symbolic-function-as-input-in-actual-funciton/So I have this assignment for university, and I'm trying to write a generic Newton's method which will take any symbolic function as input. I just don't know how to declare this on the function's inputs. Here's the function I want as input:
f(x) = 14 * x * exp(x-2) - 12 * exp(x-2) - 7 * x^3 + 20 * x^2 - 26 * x + 12
and here's the function I want to create:
def Newton_Raphson(foo, start):
dfoo = diff(foo)
ddfoo = diff(dfoo)
t0 = time.time()
while foo(start) * ddfoo(start) <= 0:
start += 10^-6
NR = start - foo(start) / dfoo(start)
noNR = 1
while abs(foo(NR)) > 10^-6:
NR = start - foo(start)/dfoo(start)
start = NR
error = (NR - start)
noNR += 1
t1 = time.time()
tNR = t1 - t0
return NR, noNR, error, tNR
Any ideas on this? Also do you have any other suggestions on this code?FjolfrinMon, 07 Jan 2019 07:40:18 -0600http://ask.sagemath.org/question/44932/Coding p-adic Newton's method to solve polynomials?http://ask.sagemath.org/question/32608/coding-p-adic-newtons-method-to-solve-polynomials/ I'm confused as to how to code the p-adic Newton's method in order to solve polynomials, and specifying solutions to a specific number of p-adic digits. Any help?veryconfusedSat, 20 Feb 2016 13:54:57 -0600http://ask.sagemath.org/question/32608/newton's method for multiple variables / arbitrary precisionhttp://ask.sagemath.org/question/11367/newtons-method-for-multiple-variables-arbitrary-precision/I am trying to find a numerical approximation with arbitrary precision to a real solution to a system of multivariate polynomial equations.
I start out with an approximation which is somewhat close to solving the system, up to an precision of about 1e-05. (Meaning that the equations that I try to evaluate are not zero, but smaller than 1e-05 for my starting value)
In [this question](http://ask.sagemath.org/question/3974/solving-system-of-polynomial-equations-over-reals) is it recommended to use scipy's fmin_tnc method, which is what I did. This works out very nicely and it quickly gave a new solution which now solves my system with precision 1e-07. In the [Scipy doc](http://docs.scipy.org/doc/scipy-0.13.0/reference/generated/scipy.optimize.fmin_tnc.html) it is stated that one can set the "epsilon" parameter, but not smaller than machine precision. So it seems like I can't get much more precision with this method?!
Let's say I want to solve my system with precision 1e-250. My questions are:
1. Can I use the fmin_tnc function to find solutions with higher precision?
2. I there another way in sage to find real solutions to polynomial systems locally (e.g. with the pari/gp)?mfTue, 20 May 2014 11:25:59 -0500http://ask.sagemath.org/question/11367/solving system of polynomial equations over reals using newton methodhttp://ask.sagemath.org/question/11359/solving-system-of-polynomial-equations-over-reals-using-newton-method/I have a set of polynomial equations and I want to find one of its real solutions close to some point, and I need only one solution. Here is an example:
This is the list of equations and variables:
Equations = [x_0*x_1*x_2*x_3 - x_0*x_1 - x_0*x_2 - x_0*x_3 - x_1*x_2 - x_1*x_3 + 2*x_0 + 2*x_1 - 448, -x_0*x_1*x_2 - x_0*x_1*x_3 - x_0*x_2*x_3 - x_1*x_2*x_3 + 3*x_0 +
3*x_1 + 2*x_2 + 2*x_3 + 452, x_0*x_1 + x_0*x_2 + x_0*x_3 + x_1*x_2 + x_1*x_3 + x_2*x_3 - 159, -x_0 - x_1 - x_2 - x_3 + 21]
Variables = [x_0, x_1, x_2, x_3]
If I ask Sage to solve this
S = solve(Equations,Variables)
it returns a bunch of solutions. But in some cases it doesn't give me any real solutions. I can prove that the above set of equations has a real solution close to `[2,4,7,8]`. Is there any way that I can perform an algorithm like the Newton's method with the start point `[2,4,7,8]`, and find that real solution?k1Sat, 19 Apr 2014 12:12:09 -0500http://ask.sagemath.org/question/11359/Newton's identities in Sagehttp://ask.sagemath.org/question/9847/newtons-identities-in-sage/**EDIT**
I actually need:
$s_k=[c_1s_{k-1}+...+c_{k-1}s_1-kc_k]$ ? could somebody help me to change tobias welch's answer so that it computes $s_k$ instead of $c_k$?
**END EDIT**
I'm combining netwon's identities with le verrier's algorithm
I need some help coding the following on python.
$c_k=\frac{-1}{k}(s_k+c_1s_{k-1}+c_2s_{k-2}+\dots+c_{k-1}s_1)$
where $s_k=Tr(A^k)$, for some square matrix A, $\forall k=1,2,3,\dots,n$
So, i'd like to type in $c(k)$ and python spits out the value for $c_k$ as defined above.
jtaaMon, 25 Feb 2013 03:08:03 -0600http://ask.sagemath.org/question/9847/Newton's cubic Fractal help. Plotting http://ask.sagemath.org/question/8555/newtons-cubic-fractal-help-plotting/I'm solving newton's cubic for all the black points that occur within the fractal:
I have the code:
LA(x) = x - (x^3.0-1)/(3.0*x^2.0)
S = solve(LA==0,x)
for s in S:
solve(LA == s.rhs(),x)
and i want to take all those points I'm generating and plot them in a scatter plot. I think I have to use an array? Can anyone tell me exactly how I tell sage to put these points in an array then plot them? Thanks everyone for your help
----------
rower9911Wed, 14 Dec 2011 14:44:19 -0600http://ask.sagemath.org/question/8555/Newton's cubic Math Modelinghttp://ask.sagemath.org/question/8548/newtons-cubic-math-modeling/I need to find the "black points" (where the function becomes undefined) of an equation x^3 -1 using newtons method. So the function turns out to be F(x) = x - (x^3-1)/(3x^2). Is there a way to find a majority of the points (where x is undefined as in the Newton cubic fractal photo aka the black points) using Sage?rower9911Mon, 12 Dec 2011 15:05:24 -0600http://ask.sagemath.org/question/8548/