# graph of the difference of two interpolating functions

Posted 9 years ago
2926 Views
|
3 Replies
|
3 Total Likes
|
 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' == a}, Z[z], {z, 0, 100}]; s1 = NDSolve[{Y''[z] + r*c*Y[z] == 0, Y[b] == 0, Y' == a},     Y[z], {z, 0, 100}]; nsol[z_]: = (Z[z] /. (s[][])) - (Y[z] /. (s1[][]));Plot[nsol[z], {z, 0, 100}]
3 Replies
Sort By:
Posted 9 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' == a}, {Y''[z] + r*c*Y[z] == 0, Y[b] == 0, Y' == a}}, {Y[z] - Z[z]}, {z, 0, 100}];You can plot:Plot[sol, {z, 0, 100}] Posted 9 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' == a}, Z[z], {z, 0, 100}][[1, 1]];s1 = NDSolve[{Y''[z] + r*c*Y[z] == 0, Y[b] == 0, Y' == a}, Y[z], {z, 0, 100}][[1, 1]];nsol = (Z[z] - Y[z]) /. {s, s1};Plot[nsol, {z, 0, 100}]
Posted 9 years ago
 Thanks a lot!