I am having difficulty solving for the roots of the following interpolating function:
ndsolve = NDSolve[ pdes3, {pGb, pXb, pYb}, {x, -L/2, L/2}, {t, 0, T},
MaxStepSize -> 3/100, MaxSteps -> 75000 ]
How can I find the roots of pXb == 0
, near x = 0
, along with time? Here is what has been tried so far:
I asked a question here, about using Table
and FindRoot
for a 2 variable function. The answer was helpful but used NSolve
instead of FindRoot
. This test program for Cos(x + 3t)
, was to aid in a further problem. The question I want to ask here involves finding the roots of an interpolation function pXb
(values of distance, x
and time, t
for function pXb == 0
), using a function called ndsolve
, shown above.
Main code is shown here, with the above expression at Line 220.
This previous answer, was used to create a FindRoot
expression:
xInit = 0;
xmin = -4 Pi;
xmax = 4 Pi;
tmin = 0;
tmax = 10;
Astep[x_, t_] := Cos[x + 3 t]
Union[Table[{t, x /. FindRoot[Astep[x, t] == 0, {x, xInit, xmin, xmax}]}, {t, tmin, tmax}], SameTest -> Equal]
output: {{0, 0.}, {1, -7.71239}, {2, -4.4292}, {3, -1.14602}, {4, -1.00443}, {5, -0.862833}, {6, -0.72124}, {7, -0.579648}, {8, -0.438055}, {9, -0.296462}, {10, -0.15487}}
However, in this test code, the output did not show all the roots, only one root for each time increment.
By using the answer by Ulrich Neumann, I adapted the main code to include:
Table[{t, x /. NSolve[{pXb[x,t] /. ndsolve == 0, -1 <= x <= 2}, x]}, {t, 1, 10}]
giving error messages:
ReplaceAll::reps: {{{pGb->InterpolatingFunction[{{<<2>>},{<<2>>}},{5,5,1,{<<2>>},{<<2>>},0,{<<2>>},0,0,Automatic,{},{},False},{{<<667>>},{<<398>>}},{Developer`PackedArrayForm,{<<265069>>},{<<795204>>}},{Automatic,Automatic}],pXb->InterpolatingFunction[{{<<2>>},{<<2>>}},{5,5,1,{<<2>>},{<<2>>},0,{<<2>>},0,0,Automatic,{},{},False},{{<<667>>},{<<398>>}},{Developer`PackedArrayForm,{<<265069>>},{<<795204>>}},{Automatic,Automatic}],pYb->InterpolatingFunction[{{<<2>>},{<<2>>}},{5,5,1,{<<2>>},{<<2>>},0,{<<2>>},0,0,Automatic,{},{},False},{{<<667>>},{<<398>>}},{Developer`PackedArrayForm,{<<265069>>},{<<795204>>}},{Automatic,Automatic}]}}==0} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing.
NSolve::nsmet: This system cannot be solved with the methods available to NSolve.
How can I use FindRoot
to obtain all the roots of the pXb
interpolating function along the x
axis, at time increments of t
?
Sated again, the basic problem is to find x
values of pXb
(also called phi_X
) at zero, and then determine the midpoint, x
, either side of phi_X
nearest the origin, for a range of time t
. This is to measure the movement of the resultant Soliton plot shown in the figure below.
The code has been adapted here to run quickly and shows my notes here (commented out code), for including the Table
and FindRoot
commands; and the ndsolve
is shown here.