How to solve nested differential equations in R?
up vote
0
down vote
favorite
I would like to solve a couple of nested differential equations in R. Suppose that x'=x+a with x(T) given and y'= y + x+b with y(0) given, where a and b are constant. The first equation is independent from the second and it can be solved with deSolve by reversing time, since it has a terminal condition. The second equation needs to be solved using the solution of the first equation and with time moving forward since it has an initial condition. Is there any way to store the value of the solution for x in such a way that can be used for solving the y equation?
I tried to use X <- out[, "X"], where out is the output for the function solving for the x equation, and plug X into the function solving for y, but I get the following message:
The number of derivatives returned by func() must equal the length of the initial conditions vector.
I understand the nature of the problem, but I do not know to get rid of this.
r differential-equations
add a comment |
up vote
0
down vote
favorite
I would like to solve a couple of nested differential equations in R. Suppose that x'=x+a with x(T) given and y'= y + x+b with y(0) given, where a and b are constant. The first equation is independent from the second and it can be solved with deSolve by reversing time, since it has a terminal condition. The second equation needs to be solved using the solution of the first equation and with time moving forward since it has an initial condition. Is there any way to store the value of the solution for x in such a way that can be used for solving the y equation?
I tried to use X <- out[, "X"], where out is the output for the function solving for the x equation, and plug X into the function solving for y, but I get the following message:
The number of derivatives returned by func() must equal the length of the initial conditions vector.
I understand the nature of the problem, but I do not know to get rid of this.
r differential-equations
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to solve a couple of nested differential equations in R. Suppose that x'=x+a with x(T) given and y'= y + x+b with y(0) given, where a and b are constant. The first equation is independent from the second and it can be solved with deSolve by reversing time, since it has a terminal condition. The second equation needs to be solved using the solution of the first equation and with time moving forward since it has an initial condition. Is there any way to store the value of the solution for x in such a way that can be used for solving the y equation?
I tried to use X <- out[, "X"], where out is the output for the function solving for the x equation, and plug X into the function solving for y, but I get the following message:
The number of derivatives returned by func() must equal the length of the initial conditions vector.
I understand the nature of the problem, but I do not know to get rid of this.
r differential-equations
I would like to solve a couple of nested differential equations in R. Suppose that x'=x+a with x(T) given and y'= y + x+b with y(0) given, where a and b are constant. The first equation is independent from the second and it can be solved with deSolve by reversing time, since it has a terminal condition. The second equation needs to be solved using the solution of the first equation and with time moving forward since it has an initial condition. Is there any way to store the value of the solution for x in such a way that can be used for solving the y equation?
I tried to use X <- out[, "X"], where out is the output for the function solving for the x equation, and plug X into the function solving for y, but I get the following message:
The number of derivatives returned by func() must equal the length of the initial conditions vector.
I understand the nature of the problem, but I do not know to get rid of this.
r differential-equations
r differential-equations
asked Nov 12 at 22:43
user3026610
124
124
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271170%2fhow-to-solve-nested-differential-equations-in-r%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown