Return to the original problem:
s = DSolve[{y''[x] + y[x]==Sum[DiracDelta[x-2^n]/2^n,{n,0,Infinity}],y[-Pi/2]==-1,y'[-Pi/2]== 0}, y[x], x]
According to the Mathematica documentation, this is a piecewise homogeneous differential equation with a special inhomogeneity.
This is solved by a linear combination of the trigonometric function fitted to the boundary condition. There are no boundary conditions given in the problem, so just the general linear combination is the solution. This might too be a complex domain problem.
The inhomogeneity is an infinite sum over delta functions. There is an example in the Mathematica documentation on how in principle such a second-order inhomogeneous differential equation is solved.
The solution is some Ulrich Neumann. But the problem is the treatment of the infinity series of impulses given to the oscillator.
I was able to reproduce the finite series solution by Mathematica DSolve.
r = DSolve[{y''[x] + y[x] == Sum[DiracDelta[x - 2^n]/2^n, {n, 0, k}],
y[-Pi/2] == -1, y'[-Pi/2] == 0}, y[x], x, Assumptions -> k > 1] //
Activate
Which of the two attempts is true for solving the problem.
(i) A finite series step is for sure nice and both work with one.
(ii) the Dirac delta contributes if the argument is zero. That is, in this case, the series 2^n, 1, 2, 4, 8, 18, ... so one. The delta function take in this case the value one. In the given series the next impulse is the half of the one before.
(iii) There is no damping in the differential equation. All impulses are positive.
(iv) The sum over the 1/2^n converges to 2 if the indices start at 0 and go to infinite.
(v) Mathematica solution is a Green's function adapted for the given problem.
(vi) The solutions converge and the problem can be solved the intended path given in the question.
(vii) Mathematica does not solve the infinite series due to convention and not in error.
The problem is run really fast if k is not in the Assumption but given as Integer.
r = DSolve[{y''[x] + y[x] == Sum[DiracDelta[x - 2^n]/2^n, {n, 0, 1}],
y[-Pi/2] == -1, y'[-Pi/2] == 0}, y[x], x]
{{y[x] ->
1/2 (-2 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
Cos[x] HeavisideTheta[-2 + x] Sin[2] + 2 Sin[x] +
Cos[2] HeavisideTheta[-2 + x] Sin[x] +
2 Cos[1] HeavisideTheta[-1 + x] Sin[x])}}
Plot[1/2 (-2 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
Cos[x] HeavisideTheta[-2 + x] Sin[2] + 2 Sin[x] +
Cos[2] HeavisideTheta[-2 + x] Sin[x] +
2 Cos[1] HeavisideTheta[-1 + x] Sin[x]), {x, -\[Pi], \[Pi]}]
r10 = DSolve[{y''[x] + y[x] ==
Sum[DiracDelta[x - 2^n]/2^n, {n, 0, 10}], y[-Pi/2] == -1,
y'[-Pi/2] == 0}, y[x], x]
{{y[x] -> (1/
1024)(-1024 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
512 Cos[x] HeavisideTheta[-2 + x] Sin[2] -
256 Cos[x] HeavisideTheta[-4 + x] Sin[4] -
128 Cos[x] HeavisideTheta[-8 + x] Sin[8] -
64 Cos[x] HeavisideTheta[-16 + x] Sin[16] -
32 Cos[x] HeavisideTheta[-32 + x] Sin[32] -
16 Cos[x] HeavisideTheta[-64 + x] Sin[64] -
8 Cos[x] HeavisideTheta[-128 + x] Sin[128] -
4 Cos[x] HeavisideTheta[-256 + x] Sin[256] -
2 Cos[x] HeavisideTheta[-512 + x] Sin[512] -
Cos[x] HeavisideTheta[-1024 + x] Sin[1024] + 1024 Sin[x] +
Cos[1024] HeavisideTheta[-1024 + x] Sin[x] +
2 Cos[512] HeavisideTheta[-512 + x] Sin[x] +
4 Cos[256] HeavisideTheta[-256 + x] Sin[x] +
8 Cos[128] HeavisideTheta[-128 + x] Sin[x] +
16 Cos[64] HeavisideTheta[-64 + x] Sin[x] +
32 Cos[32] HeavisideTheta[-32 + x] Sin[x] +
64 Cos[16] HeavisideTheta[-16 + x] Sin[x] +
128 Cos[8] HeavisideTheta[-8 + x] Sin[x] +
256 Cos[4] HeavisideTheta[-4 + x] Sin[x] +
512 Cos[2] HeavisideTheta[-2 + x] Sin[x] +
1024 Cos[1] HeavisideTheta[-1 + x] Sin[x])}}
Plot[1/1024 (-1024 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
512 Cos[x] HeavisideTheta[-2 + x] Sin[2] -
256 Cos[x] HeavisideTheta[-4 + x] Sin[4] -
128 Cos[x] HeavisideTheta[-8 + x] Sin[8] -
64 Cos[x] HeavisideTheta[-16 + x] Sin[16] -
32 Cos[x] HeavisideTheta[-32 + x] Sin[32] -
16 Cos[x] HeavisideTheta[-64 + x] Sin[64] -
8 Cos[x] HeavisideTheta[-128 + x] Sin[128] -
4 Cos[x] HeavisideTheta[-256 + x] Sin[256] -
2 Cos[x] HeavisideTheta[-512 + x] Sin[512] -
Cos[x] HeavisideTheta[-1024 + x] Sin[1024] + 1024 Sin[x] +
Cos[1024] HeavisideTheta[-1024 + x] Sin[x] +
2 Cos[512] HeavisideTheta[-512 + x] Sin[x] +
4 Cos[256] HeavisideTheta[-256 + x] Sin[x] +
8 Cos[128] HeavisideTheta[-128 + x] Sin[x] +
16 Cos[64] HeavisideTheta[-64 + x] Sin[x] +
32 Cos[32] HeavisideTheta[-32 + x] Sin[x] +
64 Cos[16] HeavisideTheta[-16 + x] Sin[x] +
128 Cos[8] HeavisideTheta[-8 + x] Sin[x] +
256 Cos[4] HeavisideTheta[-4 + x] Sin[x] +
512 Cos[2] HeavisideTheta[-2 + x] Sin[x] +
1024 Cos[1] HeavisideTheta[-1 + x] Sin[x]), {x, -10 \[Pi],
10 \[Pi]}]
On the smaller interval:
The difference between the two solutions is already really small.
Plot[{1/2 (-2 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
Cos[x] HeavisideTheta[-2 + x] Sin[2] + 2 Sin[x] +
Cos[2] HeavisideTheta[-2 + x] Sin[x] +
2 Cos[1] HeavisideTheta[-1 + x] Sin[x]),
1/1024 (-1024 Cos[x] HeavisideTheta[-1 + x] Sin[1] -
512 Cos[x] HeavisideTheta[-2 + x] Sin[2] -
256 Cos[x] HeavisideTheta[-4 + x] Sin[4] -
128 Cos[x] HeavisideTheta[-8 + x] Sin[8] -
64 Cos[x] HeavisideTheta[-16 + x] Sin[16] -
32 Cos[x] HeavisideTheta[-32 + x] Sin[32] -
16 Cos[x] HeavisideTheta[-64 + x] Sin[64] -
8 Cos[x] HeavisideTheta[-128 + x] Sin[128] -
4 Cos[x] HeavisideTheta[-256 + x] Sin[256] -
2 Cos[x] HeavisideTheta[-512 + x] Sin[512] -
Cos[x] HeavisideTheta[-1024 + x] Sin[1024] + 1024 Sin[x] +
Cos[1024] HeavisideTheta[-1024 + x] Sin[x] +
2 Cos[512] HeavisideTheta[-512 + x] Sin[x] +
4 Cos[256] HeavisideTheta[-256 + x] Sin[x] +
8 Cos[128] HeavisideTheta[-128 + x] Sin[x] +
16 Cos[64] HeavisideTheta[-64 + x] Sin[x] +
32 Cos[32] HeavisideTheta[-32 + x] Sin[x] +
64 Cos[16] HeavisideTheta[-16 + x] Sin[x] +
128 Cos[8] HeavisideTheta[-8 + x] Sin[x] +
256 Cos[4] HeavisideTheta[-4 + x] Sin[x] +
512 Cos[2] HeavisideTheta[-2 + x] Sin[x] +
1024 Cos[1] HeavisideTheta[-1 + x] Sin[x])}, {x, -\[Pi], \[Pi]}]
The solution match the boundary conditions very well.
If all Heavyside functions contribute the plot looks:
This is already chaos.
The reason is clear from the Mathematica documentation for the DiracDelta
function:
Canonicalize arguments:
FunctionExpand[DiracDelta[x^5 - 1]]
1/5 DiracDelta[-1 + x]
That can be easily applied for this case.
The Green's function has to have a Kernel over which there is to integrate, the hidden variable and domain K1 and K2 are essential!
The gross result of all the impulses is a doubling of the amplitude towards Infinity for k
. There is a great problem representing this result for large k in the Plot function because many plot points need to be calculated.
The series without the DiracDelta converges rapidly towards 2. Five summands are well already. So the ten shown in this presentation are already very close to the infinite series.
f[x_] := Sin[x] + NSum[-2^-n HeavisideTheta[-2^n + x] Sin[2^n - x], {n, 0, Infinity}]; f[11/10]
$\endgroup$Sum
instead ofNSum
in your code produces ` Sin[1/10] + Sin[11/10]==0.991041` . Why is that modified ` f[x_] ` a solution of the problem under consideration? The second derivative ofHeavisideTheta
is the derivative odDiracDelta
. $\endgroup$y[x]
notf[x]
, my mistake. $\endgroup$