From: Sam Takoy on 28 Jul 2010 02:54 Hi, This: NDSolve[{ 1 + r'[x]^2 - r[x] r''[x] == 0, r[0] == r[1] == 1}, r, {x, 0, 1}] should solve the catenary problem, but it gives 1/0 errors. Can you suggest a fix? Many thanks! Sam
From: Kevin J. McCann on 29 Jul 2010 06:44 Your problem is likely in the attempt to solve a boundary value problem rather than an initial value problem. Here is a quick shooting method that gets the answer: (* Define the shooter. Takes an initial slope of a and returns r[1] *) Clear[shoot, a] shoot[a_?NumberQ] := Module[{r, x, y}, y = r /. NDSolve[{1 + \!\(\*SuperscriptBox["r", "\[Prime]", MultilineFunction->None]\)[x]^2 - r[x] \!\(\*SuperscriptBox["r", "\[Prime]\[Prime]", MultilineFunction->None]\)[x] == 0, r[0] == 1, r'[0] == a}, r, {x, 0, 1}][[1]]; y[1] ] (* Find the correct initial slope *) \[Alpha] = a /. FindRoot[shoot[a] == 1, {a, -1, 1}] (* Now that we have the correct slope, solve the DE *) R = r /. NDSolve[{1 + \!\(\*SuperscriptBox["r", "\[Prime]", MultilineFunction->None]\)[x]^2 - r[x] \!\(\*SuperscriptBox["r", "\[Prime]\[Prime]", MultilineFunction->None]\)[x] == 0, r[0] == 1, r'[0] == \[Alpha]}, r, {x, 0, 1}][[1]] (* Plot it *) Plot[R[x], {x, 0, 1}, PlotRange -> {0.5, 1}] Kevin Sam Takoy wrote: > Hi, > > This: > > NDSolve[{ 1 + r'[x]^2 - r[x] r''[x] == 0, r[0] == r[1] == 1}, r, {x, 0, 1}] > > should solve the catenary problem, but it gives 1/0 errors. Can you > suggest a fix? > > Many thanks! > > Sam >
|
Pages: 1 Prev: TeXForm in 7.0.0 Next: FindRoot with NDSolve inside of it doesn't work |