Converting ODE to Variational Problem (for numerical solution)
This might be a stupid question, but I cannot find the answer anywhere and as an engineer I don't have the mathematical foundation to investigate this properly myself. So,
If I have a simple ODE, say for example a harmonic oscillator like $u''+u=0$, I know that I can try to convert it into a variational problem by finding a Lagrange function $F$, so that if I plug it into to the Euler-Lagrange differential equation $$frac{partial F}{partial u}-frac{mathrm{d}}{mathrm{d}x}frac{partial F}{partial u'}+frac{mathrm{d^{2}}}{mathrm{d}x^{2}}frac{partial F}{partial u''}=0$$ I get my ODE back. In this case one easily finds that e.g. $$F=left(u'right)^2-u^2$$ fulfills this condition. However now I considered the naive idea of simply just taking the following integral $$int_{x_{1}}^{x_{2}}(u''+u)^{2}mathrm{d}xrightarrowtext{min.}$$ So basically to take $F:=(text{some ODE})^2$. Naively this seems to me like in its minimum the ODE is satisfied. To test this, I implemented a numerical solver that takes a polynomial ansatz and solves the coefficients to find an approximation of the solution (here a sine) of the ODE between $0$ and $pi/2$. And it seems to actually work but the solution isn't exactly the same as for $F=left(u'right)^2-u^2$ - it is a little bit less accurate (so clearly not the optimal solution yielded by the ansatz)! However, if I take piece-wise linear functions, this native functional completely fails to provide an approximate solution, while $F=left(u'right)^2-u^2$ works perfectly. To investigate a little further I plugged in $F=(u''+u)^{2}$ into the Euler-Lagrange eq. and realize that I get $$2(u''+u)+2left(u''+uright)''=0$$ which seems to satisfy the same solution as my original problem. So my two questions that arise from all this:
1) Why is it that the naive idea of doing $F=(text{some ODE})^2$ seems to be working somewhat but not always, if I want to numerically solve an ODE via variational method?
2) Consequently: If I have an ODE of the form $f(u, u', u'', ..., x)=0$, all ODEs of the form $f(u, u', u'', ..., x) + left(f(u, u', u'', ..., x)right)' + left(f(u, u', u'', ..., x)right)'' + ... =0$ seem to have the same solution as the original ODE, but they are in fact of higher order. What is the significance of these ODEs and their solutions?
Apologies of the lengthy post but I would really appreciate any input on this. As I said, I am an engineer and quite out of my depth here. Thank you in advance!
differential-equations numerical-methods calculus-of-variations differential
add a comment |
This might be a stupid question, but I cannot find the answer anywhere and as an engineer I don't have the mathematical foundation to investigate this properly myself. So,
If I have a simple ODE, say for example a harmonic oscillator like $u''+u=0$, I know that I can try to convert it into a variational problem by finding a Lagrange function $F$, so that if I plug it into to the Euler-Lagrange differential equation $$frac{partial F}{partial u}-frac{mathrm{d}}{mathrm{d}x}frac{partial F}{partial u'}+frac{mathrm{d^{2}}}{mathrm{d}x^{2}}frac{partial F}{partial u''}=0$$ I get my ODE back. In this case one easily finds that e.g. $$F=left(u'right)^2-u^2$$ fulfills this condition. However now I considered the naive idea of simply just taking the following integral $$int_{x_{1}}^{x_{2}}(u''+u)^{2}mathrm{d}xrightarrowtext{min.}$$ So basically to take $F:=(text{some ODE})^2$. Naively this seems to me like in its minimum the ODE is satisfied. To test this, I implemented a numerical solver that takes a polynomial ansatz and solves the coefficients to find an approximation of the solution (here a sine) of the ODE between $0$ and $pi/2$. And it seems to actually work but the solution isn't exactly the same as for $F=left(u'right)^2-u^2$ - it is a little bit less accurate (so clearly not the optimal solution yielded by the ansatz)! However, if I take piece-wise linear functions, this native functional completely fails to provide an approximate solution, while $F=left(u'right)^2-u^2$ works perfectly. To investigate a little further I plugged in $F=(u''+u)^{2}$ into the Euler-Lagrange eq. and realize that I get $$2(u''+u)+2left(u''+uright)''=0$$ which seems to satisfy the same solution as my original problem. So my two questions that arise from all this:
1) Why is it that the naive idea of doing $F=(text{some ODE})^2$ seems to be working somewhat but not always, if I want to numerically solve an ODE via variational method?
2) Consequently: If I have an ODE of the form $f(u, u', u'', ..., x)=0$, all ODEs of the form $f(u, u', u'', ..., x) + left(f(u, u', u'', ..., x)right)' + left(f(u, u', u'', ..., x)right)'' + ... =0$ seem to have the same solution as the original ODE, but they are in fact of higher order. What is the significance of these ODEs and their solutions?
Apologies of the lengthy post but I would really appreciate any input on this. As I said, I am an engineer and quite out of my depth here. Thank you in advance!
differential-equations numerical-methods calculus-of-variations differential
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33
add a comment |
This might be a stupid question, but I cannot find the answer anywhere and as an engineer I don't have the mathematical foundation to investigate this properly myself. So,
If I have a simple ODE, say for example a harmonic oscillator like $u''+u=0$, I know that I can try to convert it into a variational problem by finding a Lagrange function $F$, so that if I plug it into to the Euler-Lagrange differential equation $$frac{partial F}{partial u}-frac{mathrm{d}}{mathrm{d}x}frac{partial F}{partial u'}+frac{mathrm{d^{2}}}{mathrm{d}x^{2}}frac{partial F}{partial u''}=0$$ I get my ODE back. In this case one easily finds that e.g. $$F=left(u'right)^2-u^2$$ fulfills this condition. However now I considered the naive idea of simply just taking the following integral $$int_{x_{1}}^{x_{2}}(u''+u)^{2}mathrm{d}xrightarrowtext{min.}$$ So basically to take $F:=(text{some ODE})^2$. Naively this seems to me like in its minimum the ODE is satisfied. To test this, I implemented a numerical solver that takes a polynomial ansatz and solves the coefficients to find an approximation of the solution (here a sine) of the ODE between $0$ and $pi/2$. And it seems to actually work but the solution isn't exactly the same as for $F=left(u'right)^2-u^2$ - it is a little bit less accurate (so clearly not the optimal solution yielded by the ansatz)! However, if I take piece-wise linear functions, this native functional completely fails to provide an approximate solution, while $F=left(u'right)^2-u^2$ works perfectly. To investigate a little further I plugged in $F=(u''+u)^{2}$ into the Euler-Lagrange eq. and realize that I get $$2(u''+u)+2left(u''+uright)''=0$$ which seems to satisfy the same solution as my original problem. So my two questions that arise from all this:
1) Why is it that the naive idea of doing $F=(text{some ODE})^2$ seems to be working somewhat but not always, if I want to numerically solve an ODE via variational method?
2) Consequently: If I have an ODE of the form $f(u, u', u'', ..., x)=0$, all ODEs of the form $f(u, u', u'', ..., x) + left(f(u, u', u'', ..., x)right)' + left(f(u, u', u'', ..., x)right)'' + ... =0$ seem to have the same solution as the original ODE, but they are in fact of higher order. What is the significance of these ODEs and their solutions?
Apologies of the lengthy post but I would really appreciate any input on this. As I said, I am an engineer and quite out of my depth here. Thank you in advance!
differential-equations numerical-methods calculus-of-variations differential
This might be a stupid question, but I cannot find the answer anywhere and as an engineer I don't have the mathematical foundation to investigate this properly myself. So,
If I have a simple ODE, say for example a harmonic oscillator like $u''+u=0$, I know that I can try to convert it into a variational problem by finding a Lagrange function $F$, so that if I plug it into to the Euler-Lagrange differential equation $$frac{partial F}{partial u}-frac{mathrm{d}}{mathrm{d}x}frac{partial F}{partial u'}+frac{mathrm{d^{2}}}{mathrm{d}x^{2}}frac{partial F}{partial u''}=0$$ I get my ODE back. In this case one easily finds that e.g. $$F=left(u'right)^2-u^2$$ fulfills this condition. However now I considered the naive idea of simply just taking the following integral $$int_{x_{1}}^{x_{2}}(u''+u)^{2}mathrm{d}xrightarrowtext{min.}$$ So basically to take $F:=(text{some ODE})^2$. Naively this seems to me like in its minimum the ODE is satisfied. To test this, I implemented a numerical solver that takes a polynomial ansatz and solves the coefficients to find an approximation of the solution (here a sine) of the ODE between $0$ and $pi/2$. And it seems to actually work but the solution isn't exactly the same as for $F=left(u'right)^2-u^2$ - it is a little bit less accurate (so clearly not the optimal solution yielded by the ansatz)! However, if I take piece-wise linear functions, this native functional completely fails to provide an approximate solution, while $F=left(u'right)^2-u^2$ works perfectly. To investigate a little further I plugged in $F=(u''+u)^{2}$ into the Euler-Lagrange eq. and realize that I get $$2(u''+u)+2left(u''+uright)''=0$$ which seems to satisfy the same solution as my original problem. So my two questions that arise from all this:
1) Why is it that the naive idea of doing $F=(text{some ODE})^2$ seems to be working somewhat but not always, if I want to numerically solve an ODE via variational method?
2) Consequently: If I have an ODE of the form $f(u, u', u'', ..., x)=0$, all ODEs of the form $f(u, u', u'', ..., x) + left(f(u, u', u'', ..., x)right)' + left(f(u, u', u'', ..., x)right)'' + ... =0$ seem to have the same solution as the original ODE, but they are in fact of higher order. What is the significance of these ODEs and their solutions?
Apologies of the lengthy post but I would really appreciate any input on this. As I said, I am an engineer and quite out of my depth here. Thank you in advance!
differential-equations numerical-methods calculus-of-variations differential
differential-equations numerical-methods calculus-of-variations differential
asked Dec 30 '18 at 10:20
DiscDisc
161
161
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33
add a comment |
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33
add a comment |
1 Answer
1
active
oldest
votes
Here are some comments from a theoretical (as opposed to numerical) point of view:
On one hand, the variational problem for the 1st-order Lagrangian $$F~=~frac{1}{2}(u^{prime})^2-frac{1}{2}u^2 tag{1}$$
needs 2 boundary conditions (BCs) (which OP hasn't specified) in order to deduce the Euler-Lagrange (EL) equation
$$u^{primeprime}+u~equiv~(D^2+1)u~=~0 ,tag{2}$$
which is a 2nd-order ODE.On the other hand, the variational problem for the 2nd-order Lagrangian $$F~=~frac{1}{2}(u^{primeprime}+u)^2 ~geq~ 0tag{3}$$
needs 4 BCs (which OP hasn't specified) in order to deduce the EL equation
$$(D^2+1)^2u~=~0 ,tag{4}$$ which is a 4th-order ODE.On one hand, the variational problem (1) does not make sense without BCs, because we e.g. can pick a constant function $u(x)={rm const}$ to make $F$ as negative as we would like. There is no infimum.
On the other hand, the variational problem (3) does make sense without BCs because $Fgeq 0$ is manifestly non-negative. The minimum is obviously given by solutions to eq. (2).
Clearly a solution to the ODE (2) is also a solution to the ODE (4), but not vice-versa.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "69"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fmath.stackexchange.com%2fquestions%2f3056692%2fconverting-ode-to-variational-problem-for-numerical-solution%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here are some comments from a theoretical (as opposed to numerical) point of view:
On one hand, the variational problem for the 1st-order Lagrangian $$F~=~frac{1}{2}(u^{prime})^2-frac{1}{2}u^2 tag{1}$$
needs 2 boundary conditions (BCs) (which OP hasn't specified) in order to deduce the Euler-Lagrange (EL) equation
$$u^{primeprime}+u~equiv~(D^2+1)u~=~0 ,tag{2}$$
which is a 2nd-order ODE.On the other hand, the variational problem for the 2nd-order Lagrangian $$F~=~frac{1}{2}(u^{primeprime}+u)^2 ~geq~ 0tag{3}$$
needs 4 BCs (which OP hasn't specified) in order to deduce the EL equation
$$(D^2+1)^2u~=~0 ,tag{4}$$ which is a 4th-order ODE.On one hand, the variational problem (1) does not make sense without BCs, because we e.g. can pick a constant function $u(x)={rm const}$ to make $F$ as negative as we would like. There is no infimum.
On the other hand, the variational problem (3) does make sense without BCs because $Fgeq 0$ is manifestly non-negative. The minimum is obviously given by solutions to eq. (2).
Clearly a solution to the ODE (2) is also a solution to the ODE (4), but not vice-versa.
add a comment |
Here are some comments from a theoretical (as opposed to numerical) point of view:
On one hand, the variational problem for the 1st-order Lagrangian $$F~=~frac{1}{2}(u^{prime})^2-frac{1}{2}u^2 tag{1}$$
needs 2 boundary conditions (BCs) (which OP hasn't specified) in order to deduce the Euler-Lagrange (EL) equation
$$u^{primeprime}+u~equiv~(D^2+1)u~=~0 ,tag{2}$$
which is a 2nd-order ODE.On the other hand, the variational problem for the 2nd-order Lagrangian $$F~=~frac{1}{2}(u^{primeprime}+u)^2 ~geq~ 0tag{3}$$
needs 4 BCs (which OP hasn't specified) in order to deduce the EL equation
$$(D^2+1)^2u~=~0 ,tag{4}$$ which is a 4th-order ODE.On one hand, the variational problem (1) does not make sense without BCs, because we e.g. can pick a constant function $u(x)={rm const}$ to make $F$ as negative as we would like. There is no infimum.
On the other hand, the variational problem (3) does make sense without BCs because $Fgeq 0$ is manifestly non-negative. The minimum is obviously given by solutions to eq. (2).
Clearly a solution to the ODE (2) is also a solution to the ODE (4), but not vice-versa.
add a comment |
Here are some comments from a theoretical (as opposed to numerical) point of view:
On one hand, the variational problem for the 1st-order Lagrangian $$F~=~frac{1}{2}(u^{prime})^2-frac{1}{2}u^2 tag{1}$$
needs 2 boundary conditions (BCs) (which OP hasn't specified) in order to deduce the Euler-Lagrange (EL) equation
$$u^{primeprime}+u~equiv~(D^2+1)u~=~0 ,tag{2}$$
which is a 2nd-order ODE.On the other hand, the variational problem for the 2nd-order Lagrangian $$F~=~frac{1}{2}(u^{primeprime}+u)^2 ~geq~ 0tag{3}$$
needs 4 BCs (which OP hasn't specified) in order to deduce the EL equation
$$(D^2+1)^2u~=~0 ,tag{4}$$ which is a 4th-order ODE.On one hand, the variational problem (1) does not make sense without BCs, because we e.g. can pick a constant function $u(x)={rm const}$ to make $F$ as negative as we would like. There is no infimum.
On the other hand, the variational problem (3) does make sense without BCs because $Fgeq 0$ is manifestly non-negative. The minimum is obviously given by solutions to eq. (2).
Clearly a solution to the ODE (2) is also a solution to the ODE (4), but not vice-versa.
Here are some comments from a theoretical (as opposed to numerical) point of view:
On one hand, the variational problem for the 1st-order Lagrangian $$F~=~frac{1}{2}(u^{prime})^2-frac{1}{2}u^2 tag{1}$$
needs 2 boundary conditions (BCs) (which OP hasn't specified) in order to deduce the Euler-Lagrange (EL) equation
$$u^{primeprime}+u~equiv~(D^2+1)u~=~0 ,tag{2}$$
which is a 2nd-order ODE.On the other hand, the variational problem for the 2nd-order Lagrangian $$F~=~frac{1}{2}(u^{primeprime}+u)^2 ~geq~ 0tag{3}$$
needs 4 BCs (which OP hasn't specified) in order to deduce the EL equation
$$(D^2+1)^2u~=~0 ,tag{4}$$ which is a 4th-order ODE.On one hand, the variational problem (1) does not make sense without BCs, because we e.g. can pick a constant function $u(x)={rm const}$ to make $F$ as negative as we would like. There is no infimum.
On the other hand, the variational problem (3) does make sense without BCs because $Fgeq 0$ is manifestly non-negative. The minimum is obviously given by solutions to eq. (2).
Clearly a solution to the ODE (2) is also a solution to the ODE (4), but not vice-versa.
answered 2 days ago
QmechanicQmechanic
4,87711854
4,87711854
add a comment |
add a comment |
Thanks for contributing an answer to Mathematics Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2fmath.stackexchange.com%2fquestions%2f3056692%2fconverting-ode-to-variational-problem-for-numerical-solution%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
Welcome to MSE. Nice first question!
– José Carlos Santos
Dec 30 '18 at 10:27
You can not take piecewise linear functions for a variational problem involving the second derivative. You need at least piecewise quadratic functions that are continuously differentiable. Better use cubic splines, they are somewhat natural for this situation.
– LutzL
Dec 30 '18 at 11:18
$(D^2+1)^2u=0$ will have additional solutions apart from those of $(D^2+1)u=0$. For the double roots of the characteristic equation you get also terms $xsin x$ and $xcos x$ in the solution formula.
– LutzL
Dec 30 '18 at 11:21
Thank you very much Lutz. Both comments make a lot of sense, very helpful.
– Disc
Dec 30 '18 at 13:33