I am having a tough time formulating the right question but here goes.
I know that solving the pde as in here gives me an interpolating function. I understand that the interpolating function object is different from the interpolating polynomial.
So if I wanted to approximate the interpolating function through FourierSinSeries
, I don't quite get how I might go about it.
I can't just do:
FourierSinSeries[InterpolatingFunction[{{0.,...},{0.,...},{0.,TMax}},<>],x,4]
I tried that it didn't quite give me a series expansion.
Edit:
Here's what I tried to do to get fourier coefficients describing my interpolating function.
Mathematica code:
Off[NDSolve::ibcinc];
k=0.0677;
{xMin,xMax}={-(\[Pi]/k),\[Pi]/k};
TMax=2500;
uSol[t_,x_]=u[t,x]/.NDSolve[{\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(u[t, x]\)\)==-100 \!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\((
\*SuperscriptBox[\(u[t, x]\), \(3\)]\
\*SubscriptBox[\(\[PartialD]\), \(x, x, x\)]u[t, x])\)\)+1/3 \!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\((
\*SuperscriptBox[\(u[t, x]\), \(3\)]\
\*SubscriptBox[\(\[PartialD]\), \(x\)]u[t, x])\)\)-5 \!\(
\*SubscriptBox[\(\[PartialD]\), \(x\)]\((
\*SuperscriptBox[\((
\*FractionBox[\(u[t, x]\), \(1 + u[t, x]\)])\), \(2\)]\
\*SubscriptBox[\(\[PartialD]\), \(x\)]u[t, x])\)\),u[0,x]==1-0.1 Cos[k x],
(*Piecewise Function for INITIAL CONDITION*)
(*u[0,x]== Piecewise[{{-0.1,-\[Pi]/k<= x<-\[Pi]/(10 k)},{ Cos[x],-\[Pi]/(10 k)<= x<= \[Pi]/(10 k)},{-0.1,\[Pi]/(10 k)<x<= \[Pi]/k}}],*)
(u^(0,1))[t,xMin]==0,
(u^(0,1))[t,xMax]==0,
(u^(0,3))[t,xMin]==0,
(u^(0,3))[t,xMax]==0
(*(u^(0,3))[t,xMin]==0,
(u^(0,3))[t,xMax]==0*)},
u,{t,0,TMax},{x,xMin,xMax},MaxStepSize->0.1,MaxSteps->100000,Method->{"BDF", "MaxDifferenceOrder"-> 5}][[1]]
Fourier series:
Since I now have uSol
which, my fourier coeffs should be:
I1 = NIntegrate[uSol[0.1 TMax, x], {x, xMin, xMax}] (*I1 at time=0.1 TMax*)
a0 = (1/(2*xMin))*I1
an = NIntegrate[uSol[0.1 TMax, x] Cos[n \[Pi] x/xMax], {x, xMin, xMax}]
bn = NIntegrate[uSol[0.1 TMax, x] Sin[n \[Pi] x/xMax], {x, xMin, xMax}]
Using NIntegrate
errors out with:
NIntegrate::inumr: The integrand Cos[0.0677 n x] <<1>>[250.,x] has evaluated to non-numerical values for all sampling points in the region with boundaries {{-46.4046,-46.3046}}. >>
However, using Integrate
instead of NIntegrate
gave me just the input as symbols.
Neither is the coefficient.
So what am I missing? There has to be a simpler way of figurijng out the fourier coeffs of an interpolating function. can I export data out of mathematica into .csv or some other format which is not dependent on mathematica to be interpreted?
NIntegrate[]
). $\endgroup$2 NIntegrate[f[t] Sin[n t], {t, 0, Pi}]/Pi
to generate your series coefficients, I meant. $\endgroup$(u^(0,1))[t,xMin]
, maybe it'sDerivative[0,1][u][t,xMin]
what you want? $\endgroup$NIntegrate
can't integrate symbolic arguments. You haven't fixedn
so the integrand is not numerical; fixn
to something and it should work. Unfortunately cut and pasting doesn't work for the reason @Silvia gave; if you fix that maybe we can help more easily. $\endgroup$