- #1
nikolafmf
- 114
- 0
Hello,
I told Mathematica to do a few calculations as follows:
a = 0;
b = 1;
n = 4;
For[i = 0, i < n, i++,
p = 2*x*b - 2*i*a;
a = b;
b = p]
c = CoefficientList[p, x];
l = Length[c];
m = 0;
For[i = 1, i < l + 1, i++,
r = Abs[Part[c, i]]/Abs[Part[c, l]];
If[r > m, m = r, m]]
lowerbound = -m - 1;
upperbound = m + 1;
iter = 5;
f = Function[k, p /. x -> k];
For[z = lowerbound, z < upperbound, z++,
For[i = 0, i < iter, i++,
t = z - f[z]/(D[f[k], k] /. k -> z);
z = t]
Print[N[t]]]
I think this should be executed in a second. But no, Mathematica would run for minutes and won't stop. Can somebody execute this code too, to check if the problem is with my computer or with the code? If the problem is with the code, what kind of problem is it?
I told Mathematica to do a few calculations as follows:
a = 0;
b = 1;
n = 4;
For[i = 0, i < n, i++,
p = 2*x*b - 2*i*a;
a = b;
b = p]
c = CoefficientList[p, x];
l = Length[c];
m = 0;
For[i = 1, i < l + 1, i++,
r = Abs[Part[c, i]]/Abs[Part[c, l]];
If[r > m, m = r, m]]
lowerbound = -m - 1;
upperbound = m + 1;
iter = 5;
f = Function[k, p /. x -> k];
For[z = lowerbound, z < upperbound, z++,
For[i = 0, i < iter, i++,
t = z - f[z]/(D[f[k], k] /. k -> z);
z = t]
Print[N[t]]]
I think this should be executed in a second. But no, Mathematica would run for minutes and won't stop. Can somebody execute this code too, to check if the problem is with my computer or with the code? If the problem is with the code, what kind of problem is it?