I encounter a problem when I try to integrate the piecewise function defined in the following code:
ClearAll["Global`*"];
(* Parameters of the problem*)
M = 1; (* Mass scale*)
A = M/4 ;(* Background Amplitude*)
a = A; (* Perturbation Amplitude*)
L = 0.1/M; (* Background Length scale*)
Lb = 30*L; (* Boundary distance*)
l = L/20; (* Perturbation Length scale*)
d = L/3; (* Spatial translation of the perturbation *)
tmax = 10*L; (* Maximal time*)
\[Kappa] = 3*M; (*Velociy field stiffness*)
\[Delta]\[Chi]0[x_] =
a/(1 + ((x - d)/l)^2) +
a/(1 + ((x + d)/l)^2); (* Initial perturbation profile*)
(* Construct an initial characteristic with the correct asymptotical \
behaviour *)
f1[x_] = -\[Kappa]*
x; (* Desired profile close to x=0 to create the caustic *)
f2[x_] = 1; (* Asymptotical profile *)
v[x_] = Piecewise[{
{f1[x], -L < x < L},
{f2[x], x < -Lb/2 || x > Lb/2},
{Interpolation[{{{-Lb/2}, f2[-Lb/2], f2'[-Lb/2], f2''[-Lb/2],
f2'''[-Lb/2], f2''''[-Lb/2]}, {{-L}, f1[-L], f1'[-L]}}][
x], -Lb/2 < x < -L},
{Interpolation[{{{Lb/2}, f2[Lb/2], f2'[Lb/2]}, {{L}, f1[L],
f1'[L]}}][x], L < x < Lb/2}}];
(* Define the initial condition for the field *)
s[x_] = M^2*Sqrt[(2 - 2*(v[x])^2)/(3 - (v[x])^2)];
q[x_] = Integrate[s[x], x,
Assumptions -> -Lb < x < Lb]; (* Integrate the spatial derivative*)
The piecewise function is called v[x] and it is defined explicitly on the intervals: [-L,L] ; ]-inf, Lb/2] and [Lb/2, +inf[ and defined as an interpolation on the remaining intervals. Then I define s[x] by using this piecewise function v[x]. When I try to define a function q[x] as the integral of s[x] , I have the following error:
Integrate::ilim: Invalid integration variable or limit(s) in -2.99988.
I have read the documentation on this error but I don't manage to relate this to my problem. Can anybody help me please?
Thanks a lot.
Integrate[s[x],{ x, -Lb , Lb}]
rather thanIntegrate[s[x], x, Assumptions -> -Lb < x < Lb]
$\endgroup$Integrate[s[x],{x,-.1,.1}]
andIntegrate[s[x],{x,1.5,3}]
andIntegrate[s[x],{x,-3,-1.5}]
appear to work with the rest of your code unchanged, but anything which strays into yourInterpolation
zones fails. Does that give you any ideas what to start looking at? Definingq[x_]
and then using x as a variable of integration worries me. $\endgroup$