I am trying to compare the symbolic solution with numerical solution by using NDSolve. But the two curves are not match when I plot it. Please give me suggestions how to improve the plot?
num = NDSolveValue[ eq1 && (x[0] == xIII[0]) && (x'[0] == xIII'[0]) && (x''[0] == xIII''[0]), x, {t, -1, 1}]; ReImPlot[num[t] - xIII[t], {t, -1, 1}]
xIII[t_] = 2 I Sec[t];
I tried it, but no plot output on my computer.
Gianluca's answer works fine for me. You probably have a conflicting prior definition for some symbol(s). Try with a fresh kernel or evaluate the following prior to evaluating the rest of the code.
ClearAll[Evaluate[Context[] <> "*"]]
still no output plot. I got just one result i.e.,
I don't understand. The function xIII does not seem to be a solution of eq1:
xIII
eq1
Simplify[eq1 /. x -> xIII]
Sorry "xIII=2 i sec(t)", then output is true.