Message Boards Message Boards

0
|
3627 Views
|
3 Replies
|
3 Total Likes
View groups...
Share
Share this post:

graph of the difference of two interpolating functions

Posted 11 years ago
Good evening everybody!
Unfortunately, I didn't manage to draw the graph of the difference of two interpolating functions, that were received as numerical solution of two ODEs.
Some typical methods, such as ordinary "-" and some combinations with these functions didn't help.
Thanks beforehand.
 r := 0.1;
 c := 1/r;
 c1 := 0.01;
 a := 1; b := 0;
 s = NDSolve[{Z''[z] + r*(-c1*Sin[z]*Exp[-z/r] + c)*Z[z] == 0,
     Z[b] == 0, Z'[0] == a}, Z[z], {z, 0, 100}];
 s1 = NDSolve[{Y''[z] + r*c*Y[z] == 0, Y[b] == 0, Y'[0] == a},
    Y[z], {z, 0, 100}];
 nsol[z_]: = (Z[z] /. (s[[1]][[1]])) - (Y[z] /. (s1[[1]][[1]]));
Plot[nsol[z], {z, 0, 100}]
POSTED BY: Mark Turtsinskyi
3 Replies
Posted 11 years ago
Just another way (with no advantage) you can solve the system for the desired function:
 r := 0.1;
 
 c := 1/r;
 
 c1 := 0.01;
 
 a := 1; b := 0;
 
 sol = Y[z] - Z[z] /.First@NDSolve[
{{
Z''[z] + r*(-c1*Sin[z]*Exp[-z/r] + c)*Z[z] == 0,

Z[b] == 0, Z'[0] == a}, {Y''[z] + r*c*Y[z] == 0, Y[b] == 0,

Y'[0] == a
}},
{Y[z] - Z[z]}, {z, 0, 100}];
You can plot:
Plot[sol, {z, 0, 100}]
POSTED BY: Mark Dooris
Posted 11 years ago
r := 0.1;
c := 1/r;
c1 := 0.01;
a := 1; b := 0;
s = NDSolve[{Z''[z] + r*(-c1*Sin[z]*Exp[-z/r] + c)*Z[z] == 0, Z[b] == 0, Z'[0] == a}, Z[z], {z, 0, 100}][[1, 1]];
s1 = NDSolve[{Y''[z] + r*c*Y[z] == 0, Y[b] == 0, Y'[0] == a}, Y[z], {z, 0, 100}][[1, 1]];
nsol = (Z[z] - Y[z]) /. {s, s1};
Plot[nsol, {z, 0, 100}]
POSTED BY: Bill Simpson
Thanks a lot!
POSTED BY: Mark Turtsinskyi
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