Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

DSolve gives different answer to NDSolve

  • To: mathgroup at smc.vnet.net
  • Subject: [mg119813] DSolve gives different answer to NDSolve
  • From: Theo Moore <tsg.moore at googlemail.com>
  • Date: Thu, 23 Jun 2011 07:26:49 -0400 (EDT)

I want to solve:

0.2*dy/dz + y = 0.2/z
y (1 - 1000*I) = 0

on the line z = 1 + s*I with s in [-10, 10]. Simple, right? I can first give
the exact solution a go:

f[x_] = 0.2/x;
eqn = 0.2*y'[x] + y[x] == f[x];
yExact[x_] = y[x] /. DSolve[{eqn, y[1 - 1000*I] == 0}, y[x], x][[1]];
P1 = Plot[Re[yExact[1 + t I]], {t, -10, 10} , PlotStyle -> Thick,  PlotRange
-> 0.3]

It gives s solution which tails off on the left, but has (significantly
large) oscillations on the right.

Fair enough. What about a numerical solution? We solve for a function w[t] y[1 + t*I]

sol = NDSolve[{0.2*w'[t] + w[t] == f[1 + t*I], w[-1000] == 0}, w, {t, -10,
10}];
P2 = Plot[Evaluate[Re[w[t] /. sol]], {t, -10, 10}, PlotStyle -> {Thick,
Red}, PlotRange -> 0.3]

Now there are no more oscillations.

Why do we get two different answers? The solution is well behaved along the
domain, with no singularities or branch cuts. If you like, you can also
integrate the first-order ODE and either symbolically or numerically
evaluate the integral. However, you get a solution with oscillations. I
expect oscillations, and I think the numerical NDSolve is incorrect. Have I
made a mistake?

Any help would be appreciated! Thanks.



  • Prev by Date: Re: Assigning part of indexed object
  • Next by Date: Re: Convenient way to add inline formatting to usage Messages
  • Previous by thread: parsing a strig
  • Next by thread: How can I write the input code for a comparison