As I understand we have 3 questions:
- How to implement Newton's iterations method to solve nonlinear problem?
- How to implement Newton's iterations method in a case of vector form
a[0], for example, randomly distributed a[0]?
- How to parallelize code in a case of randomly distributed
a[0]?
Solution 1-2
Clear[f, g, a]
f = x^3 - 6x^2 + 11x - 6;
g = D[f, x]; nmax = 10; jmax = 15;
a[0] = RandomReal[{-1, 1}, jmax];
Do[a[n + 1] =
Table[a[n][[j]] - N[f/g /. x -> a[n][[j]]], {j, jmax}], {n, 0, nmax}]
mat = Table[a[n], {n, 0, nmax}]
(* {{-0.567701, 0.183781, -0.122707, 0.981023, -0.78634,
0.841471, 0.490745, 0.132565, -0.0935607, 0.829216,
0.454513, -0.229974, 0.478757, -0.404825, 0.907072}, {0.197046,
0.653079, 0.471811, 0.999483, 0.0591077, 0.972456, 0.82135,
0.623468, 0.48941, 0.968683, 0.802566, 0.406538, 0.815177, 0.298725,
0.989351}, {0.660693, 0.89993, 0.81158, 1., 0.580462, 0.998931,
0.966173, 0.886414, 0.820665, 0.998629, 0.959918, 0.777159,
0.964157, 0.718194, 0.999834}, {0.903334, 0.987817, 0.962965, 1.,
0.866068, 0.999998, 0.998409, 0.984694, 0.965952, 0.999997,
0.997796, 0.950916, 0.998222, 0.927972, 1.}, {0.988559, 0.999784,
0.998106, 1., 0.979485, 1., 0.999996, 0.999661, 0.998389, 1.,
0.999993, 0.996757, 0.999995, 0.993336, 1.}, {0.999809, 1.,
0.999995, 1., 0.999398, 1., 1., 1., 0.999996, 1., 1., 0.999984, 1.,
0.999934, 1.}, {1., 1., 1., 1., 0.999999, 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}*)
Visualization
ListLinePlot[Transpose[mat], PlotRange -> All]

Solution 3
ParallelDo[
a[n + 1] =
Table[a[n][[j]] - N[f/g /. x -> a[n][[j]]], {j, jmax}], {n, 0, nmax}]
mat1 = Table[a[n], {n, 0, nmax}]
(* {{-0.567701, 0.183781, -0.122707, 0.981023, -0.78634,
0.841471, 0.490745, 0.132565, -0.0935607, 0.829216,
0.454513, -0.229974, 0.478757, -0.404825, 0.907072}, {0.197046,
0.653079, 0.471811, 0.999483, 0.0591077, 0.972456, 0.82135,
0.623468, 0.48941, 0.968683, 0.802566, 0.406538, 0.815177, 0.298725,
0.989351}, {0.660693, 0.89993, 0.81158, 1., 0.580462, 0.998931,
0.966173, 0.886414, 0.820665, 0.998629, 0.959918, 0.777159,
0.964157, 0.718194, 0.999834}, {0.903334, 0.987817, 0.962965, 1.,
0.866068, 0.999998, 0.998409, 0.984694, 0.965952, 0.999997,
0.997796, 0.950916, 0.998222, 0.927972, 1.}, {0.988559, 0.999784,
0.998106, 1., 0.979485, 1., 0.999996, 0.999661, 0.998389, 1.,
0.999993, 0.996757, 0.999995, 0.993336, 1.}, {0.999809, 1.,
0.999995, 1., 0.999398, 1., 1., 1., 0.999996, 1., 1., 0.999984, 1.,
0.999934, 1.}, {1., 1., 1., 1., 0.999999, 1., 1., 1., 1., 1., 1.,
1., 1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1., 1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.,
1.}, {1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1., 1.}}*)
Visualization
ListLinePlot[Transpose[mat1], PlotRange -> All]

a[0]!=0in the output shown. The second result shows, from my understanding, that the kernels are not communicating with one another. Perhaps one should useDistributeDefinitions? – CA Trevillian Jan 05 '22 at 03:32ParallelTable, and showsa[1]througha[8]. The OP doesn't show the output ofTablefor the first example. So I thinka[0]is still equal to0(on all kernels). The question seems based on a misunderstanding of how variables are treated in parallel kernels. —Well, technically, no question is actually asked. We're simply shown code that runs as expected. – Michael E2 Jan 05 '22 at 04:55Detailssection:ParallelTable will give the same results as Table, except for side effects during the computation. So there are no guarantees thatParallelTablewill gracefully revert toTableif the parallel functionality is of no use. – Syed Jan 05 '22 at 07:31