Tag Info

New answers tagged

1

This code presented in this answer is essentially the same as the code given by DumpsterDoofus. I just want to point out the importance of having meaningful values for the parameters and initial conditions. I also want to show one might explore the parameter space with a Manipulate expression. One of the phenomena demonstrated by the Lotka-Volterra model is ...


2

You forgot to specify initial conditions on $x$ and $y$, which makes plotting impossible. However, even when initial conditions are specified, DSolve seems to choke on some sort of inverse-function garbage, so I'll sidestep it by using NDSolve instead (I'll let others determine why the analytic solution doesn't work): {a, b, c, d} = {1, 2, 3, 4}; {X, Y} = ...


3

Why not make use of Mathematica built-in functional capabilities? The following code can be modified to add whatever stopping condition is desired. jac[f_, vars_] := Outer[D, f[Sequence @@ vars], vars] jacobian[f_, vars_, pt_] := jac[f, vars] /. Thread[vars -> pt] newt[f_, vars_, pt_] := pt - Inverse[jacobian[f, vars, pt]].f[Sequence @@ pt] ...


1

The simplest code to create your module is nr[func_, jac_, y1_, y2_, MaxIter_, Tol_] := Module[{y10 = y1, y20 = y2, counter = 0, DeltaY = {0.1, 0.1}, list = Table[{0, 0}, {i, 1, MaxIter}], i = 1}, While[Norm[DeltaY, 2] > Tol, Result = Solve[jac[y10, y20].{{dy1}, {dy2}} == -func[y10, y20], {dy1, dy2}] // N // Flatten; DeltaY = ...



Top 50 recent answers are included