0
$\begingroup$

I'm trying to solve a differential equation numerically. I've written this code but it is leading to some errors "initial history needs to be specified for all variables for delay-differential equations" however I am not intending to solve a 'delay' equation. Could someone point out my mistake(s)? Thanks.

m = 511000;
cl = 299792458;
E0 = 100*^6;
λ = 0.001;
k = 2 Pi/λ;
A = 10*^-10;
a0 = λ/4;
f[t_] := x'[t]/Sqrt[1 - (x'[t]/cl)^2]
eqns = {f'[t] == E0 Sin[((cl*t - g[t]) - a0) k], g[t] == Integrate[x'[ta], {ta, 0, t}], x[0] == a0, x'[0] == 0.97*cl}
b = NDSolve[eqns, x'[t], {t, 0, A}, MaxStepSize -> 3.3*^-12, Method -> "ExplicitEuler"]
Plot[{Evaluate[x'[t] /. b]}, {t, 0, A}, PlotRange -> All]
$\endgroup$
2
  • $\begingroup$ why don't you just sub x[t]-a0 for Integrate[x'[ta], {ta, 0, t}] ? $\endgroup$ – george2079 Dec 4 '15 at 19:15
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Apr 12 '16 at 3:40
1
$\begingroup$

Taking george2079's comment one step further and eliminating g altogether, I get the following:

eqns = {f'[t] == E0 Sin[((cl*t - (x[t] - a0)) - a0) k], x[0] == a0, 
   x'[0] == 0.97*cl};
b = NDSolve[eqns, x'[t], {t, 0, A}];
Plot[{Evaluate[x'[t] /. b]}, {t, 0, A}, PlotRange -> All]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.