Skip to main content
Routine clean-up
Source Link
m_goldberg
  • 108.1k
  • 16
  • 104
  • 259

how to calculate Calculating the error forin the solution of a system of ODEs solved by NDSolve

I have solved system of ODEs by using the NDSolve and iNDSolve. I want to calculate the error for my system of equationsthe solutions. So far iI have calculated error by plotting results of each equation.

  1. Is itwhat I'm doing the correct way to obtain the error for my problem?
  2. I am not sure the results I gotam getting are accurate enough depending upon this error analysis or not?. If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytemsolving the system of ODEs

s = 
  NDSolve[
    {x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], 
     x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, 
    {x, y}, {t, 20}]

To obtainI am examining the error for one ofthe 1st equation is as followswith

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, 
 WorkingPrecision -> 50]

enter image description here

theand for my secondthe 2nd equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

enter image description here

how to calculate the error for the system of ODEs solved by NDSolve

I have solved system of ODEs by using the NDSolve and i want to calculate the error for my system of equations. So far i have calculated error by plotting results of each equation.

  1. Is it the correct way to obtain the error for my problem?
  2. I am not sure the results I got are accurate enough depending upon this error analysis or not? If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytem of ODEs

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], 
   x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, 
   y}, {t, 20}]

To obtain the error for one of equation is as follows

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, 
 WorkingPrecision -> 50]

enter image description here

the for my second equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

enter image description here

Calculating the error in the solution of a system of ODEs

I have solved system of ODEs by using NDSolve. I want to calculate the error of the solutions. So far I have calculated error by plotting results of each equation.

  1. Is what I'm doing the correct way to obtain the error for my problem?
  2. I am not sure the results I am getting are accurate enough. If not, then kindly suggest some other way to calculate the error.

My code for solving the system of ODEs

s = 
  NDSolve[
    {x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], 
     x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, 
    {x, y}, {t, 20}]

I am examining the error for the 1st equation with

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

enter image description here

and for the 2nd equation

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

enter image description here

I have solved system of ODEs by using the NDSolve and i want to calculate the error for my system of equations. So far i have calculated error by plotting results of each equation.

  1. Is it the correct way to obtain the error for my problem?
  2. I am not sure the results I got are accurate enough depending upon this error analysis or not? If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytem of ODEs

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, y}, {t, 20}]

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], 
   x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, 
   y}, {t, 20}]

To obtain the error for one of equation is as follows

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, 
 WorkingPrecision -> 50]

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here

the for my second equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here

I have solved system of ODEs by using the NDSolve and i want to calculate the error for my system of equations. So far i have calculated error by plotting results of each equation.

  1. Is it the correct way to obtain the error for my problem?
  2. I am not sure the results I got are accurate enough depending upon this error analysis or not? If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytem of ODEs

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, y}, {t, 20}]

To obtain the error for one of equation is as follows

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here

the for my second equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here

I have solved system of ODEs by using the NDSolve and i want to calculate the error for my system of equations. So far i have calculated error by plotting results of each equation.

  1. Is it the correct way to obtain the error for my problem?
  2. I am not sure the results I got are accurate enough depending upon this error analysis or not? If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytem of ODEs

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], 
   x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, 
   y}, {t, 20}]

To obtain the error for one of equation is as follows

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, 
 WorkingPrecision -> 50]

enter image description here

the for my second equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50]

enter image description here

Source Link
sara
  • 83
  • 3

how to calculate the error for the system of ODEs solved by NDSolve

I have solved system of ODEs by using the NDSolve and i want to calculate the error for my system of equations. So far i have calculated error by plotting results of each equation.

  1. Is it the correct way to obtain the error for my problem?
  2. I am not sure the results I got are accurate enough depending upon this error analysis or not? If not, then kindly suggest some other way to calculate the error for my problem.

Many thanks in advance.

My code for sytem of ODEs

s = NDSolve[{x''[t] == -(1/2)*y[t]*x'[t], y''[t] == x'[t], x'[0] == -1 + x[0], y[0] == 0, x[10] == 0, y'[10] == 0}, {x, y}, {t, 20}]

To obtain the error for one of equation is as follows

Plot[(x''[t] + (1/2)*y[t]*x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here

the for my second equation is as follows

Plot[(y''[t] + x'[t]) /. s, {t, 1, 10}, WorkingPrecision -> 50] enter image description here