Message Boards Message Boards

GROUPS:

Compare the symbolic solution with numerical solution

Posted 22 days ago
311 Views
|
8 Replies
|
3 Total Likes
|

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?

POSTED BY: A Afi
8 Replies

I don't understand. The function xIII does not seem to be a solution of eq1:

Simplify[eq1 /. x -> xIII]
POSTED BY: Gianluca Gorni
Posted 22 days ago

Sorry "xIII=2 i sec(t)", then output is true.

POSTED BY: A Afi
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}]
POSTED BY: Gianluca Gorni
xIII[t_] = 2 I Sec[t];
POSTED BY: Gianluca Gorni
Posted 21 days ago

I tried it, but no plot output on my computer.

POSTED BY: A Afi
Posted 21 days ago

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[] <> "*"]]
POSTED BY: Rohit Namjoshi
Posted 21 days ago

still no output plot. I got just one result i.e.,

Attachments:
POSTED BY: A Afi

You give initial data that do not match xIII:

{xIII[0], xIII'[0], xIII''[0]}
With[{ww = 10^(-2), tt = 1},
  {x0 = xA /. w -> ww,
   x0p = Sqrt[ww - x0^2 - (1/4) x0^4],
   x00p = -x0 - (1/2) x0^3}] // N

How can you expect the solutions to coincide?

POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract