Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11822
| From | maves <vesel.mateja@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | NIntegrate within NDSolve-optimization? |
| Date | 2012-09-20 04:26 +0000 |
| Message-ID | <k3e5tf$isv$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
Hello,
I am trying to numerically solve a set of differential equations, and the problem is that the expression also contains numerical integrals, I believe this is why I am getting large numerical errors.
Firstly, I define three integrals (for instance for b=6, c=0.5):
int1[x_?NumericQ, z_?NumericQ] :=
NIntegrate[-(R (x - R Cos[\[Phi]]))/
((x - R Cos[\[Phi]])^2 + (R Sin[\[Phi]])^2 + (z -
Z)^2)^(3/2), {\[Phi], 0, 2 Pi}, {R, b, b + c}, {Z,
R - (b + c), -R + (b + c)}];
int2[x_?NumericQ, z_?NumericQ] :=
NIntegrate[-(R (z-Z))/
((x - R Cos[\[Phi]])^2 + (R Sin[\[Phi]])^2 + (z -
Z)^2)^(3/2), {\[Phi], 0, 2 Pi}, {R, b, b + c}, {Z,
R - (b + c), -R + (b + c)}];
int3[x_?NumericQ, z_?NumericQ] :=
NIntegrate[-R/((x - R Cos[\[Phi]])^2 + (R Sin[\[Phi]])^2 + (z -
Z)^2)^(1/2), {\[Phi], 0, 2 Pi}, {R, b, b + c}, {Z,
R - (b + c), -R + (b + c)}];
And then I use them in NDSolve:
s = NDSolve[{
x''[t] == int1[x[t], z[t]],
z''[t] == int2[x[t], z[t]],
x[0] == 7.1, x'[0] == 0, z'[0] == 0, z'[0] == 1}, {x, x=
', z,
z'}, {t, 0, 5}][[1]]
And plot the solution:
ParametricPlot[Evaluate[{x[t], z[t]} /. s], {t, 0, 5},
PlotRange -> All]
Plot[Evaluate[0.5*((x'[t])^2+(z'[t])^2+int3[x[t],z[t]]) /. s], {t, 0, 5}]
I change the initial conditions and try to find something "useful", but this second plot shows me, that something just isn't right, as it should be constant, but it oscillates with a huge amplitude. Could this be due to numerical errors and how you think I should optimize my code to get a good result? Is this combination of NIntegrate and NDSolve even acceptable?
Thank you.
But the solution just doesn't seem right
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
NIntegrate within NDSolve-optimization? maves <vesel.mateja@gmail.com> - 2012-09-20 04:26 +0000
csiph-web