First derivative approximation using function values in equidistant points
$begingroup$
Given a function $f: [x_0,x_4] → Bbb R$ and equidistant points $x_0, x_1, x_2, x_3, x_4$ so that $h=x_{i+1} - x_i > 0$.
Normally I would do, $f'(x) approx dfrac{f(x+h)-f(x)}{h}$, but here I want to find approximation for $f'(x_2)$ as linear combination of function values in these points as $f'(x_2) approx sum_{j=0}^4 alpha_j f(x_j)$. There are no boundary conditions so I can't make a system of linear equations, at least I see no straight forward way.
Are there any standard methods of how to determine alphas related to the finite elements method, so that the formula will be as precise as possible for polynomials of as high order as possible?
I see that this is closely related to the five-point midpoint formula
https://www3.nd.edu/~zxu2/acms40390F15/Lec-4.1.pdf if one sets x_0= x_2 -2h and so on, but how to derive this formula?
How does that generalise to higher order derivatives?
finite-element-method numerical-calculus
$endgroup$
add a comment |
$begingroup$
Given a function $f: [x_0,x_4] → Bbb R$ and equidistant points $x_0, x_1, x_2, x_3, x_4$ so that $h=x_{i+1} - x_i > 0$.
Normally I would do, $f'(x) approx dfrac{f(x+h)-f(x)}{h}$, but here I want to find approximation for $f'(x_2)$ as linear combination of function values in these points as $f'(x_2) approx sum_{j=0}^4 alpha_j f(x_j)$. There are no boundary conditions so I can't make a system of linear equations, at least I see no straight forward way.
Are there any standard methods of how to determine alphas related to the finite elements method, so that the formula will be as precise as possible for polynomials of as high order as possible?
I see that this is closely related to the five-point midpoint formula
https://www3.nd.edu/~zxu2/acms40390F15/Lec-4.1.pdf if one sets x_0= x_2 -2h and so on, but how to derive this formula?
How does that generalise to higher order derivatives?
finite-element-method numerical-calculus
$endgroup$
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23
add a comment |
$begingroup$
Given a function $f: [x_0,x_4] → Bbb R$ and equidistant points $x_0, x_1, x_2, x_3, x_4$ so that $h=x_{i+1} - x_i > 0$.
Normally I would do, $f'(x) approx dfrac{f(x+h)-f(x)}{h}$, but here I want to find approximation for $f'(x_2)$ as linear combination of function values in these points as $f'(x_2) approx sum_{j=0}^4 alpha_j f(x_j)$. There are no boundary conditions so I can't make a system of linear equations, at least I see no straight forward way.
Are there any standard methods of how to determine alphas related to the finite elements method, so that the formula will be as precise as possible for polynomials of as high order as possible?
I see that this is closely related to the five-point midpoint formula
https://www3.nd.edu/~zxu2/acms40390F15/Lec-4.1.pdf if one sets x_0= x_2 -2h and so on, but how to derive this formula?
How does that generalise to higher order derivatives?
finite-element-method numerical-calculus
$endgroup$
Given a function $f: [x_0,x_4] → Bbb R$ and equidistant points $x_0, x_1, x_2, x_3, x_4$ so that $h=x_{i+1} - x_i > 0$.
Normally I would do, $f'(x) approx dfrac{f(x+h)-f(x)}{h}$, but here I want to find approximation for $f'(x_2)$ as linear combination of function values in these points as $f'(x_2) approx sum_{j=0}^4 alpha_j f(x_j)$. There are no boundary conditions so I can't make a system of linear equations, at least I see no straight forward way.
Are there any standard methods of how to determine alphas related to the finite elements method, so that the formula will be as precise as possible for polynomials of as high order as possible?
I see that this is closely related to the five-point midpoint formula
https://www3.nd.edu/~zxu2/acms40390F15/Lec-4.1.pdf if one sets x_0= x_2 -2h and so on, but how to derive this formula?
How does that generalise to higher order derivatives?
finite-element-method numerical-calculus
finite-element-method numerical-calculus
edited Jan 13 at 15:33
random guy
asked Jan 13 at 12:35
random guyrandom guy
302110
302110
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23
add a comment |
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23
add a comment |
1 Answer
1
active
oldest
votes
$begingroup$
Use Taylor series for small values of $h$
$$f(x)=f(x+(k-2) h)=f(x)+h (k-2) f'(x)+frac{1}{2} h^2 (k-2)^2 f''(x)+frac{1}{6} h^3 (k-2)^3
f^{(3)}(x)+frac{1}{24} h^4 (k-2)^4 f^{(4)}(x)+frac{1}{120} h^5 (k-2)^5
f^{(5)}(x)+Oleft(h^6right)$$
Now, write $$h f'(x)=a f(x-2h)+b f(x-h)+c f(x)+d f(x+h)+e f(x+2h)$$ and replace to get
$$h f'(x)=f(x) (a+b+c+d+e)+h f'(x) (-2 a-b+d+2 e)+frac{1}{2} h^2 f''(x) (4 a+b+d+4
e)+frac{1}{6} h^3 f^{(3)}(x) (-8 a-b+d+8 e)+frac{1}{24} h^4 f^{(4)}(x) (16
a+b+d+16 e)+frac{1}{120} h^5 f^{(5)}(x) (-32 a-b+d+32 e)+Oleft(h^6right)$$
Then, you have the equations
$$a+b+c+d+e=0 tag 1$$
$$-2 a-b+d+2 e=1 tag 2$$
$$4 a+b+d+4 e=0 tag 3$$
$$-8 a-b+d+8 e=0 tag 4$$
$$16 a+b+d+16 e=0 tag 5$$
from which $a=frac 1 {12}$, $b=-frac 2 {3}$, $c=0$, $d=frac 2 {3}$, $e=frac 1 {12}$.
So, using your notations
$$f'(x_2)=frac{f(x_0)-8f(x_1)+8f(x_3)-f(x_4) }{12 h}$$ and the "error" is $frac 1 {30} h^4 f^{(5)}(x_2)$
Let us try for $$f(x)=e^x tan (x) log (sin (x)+1)$$ at $x=2$ using $h=0.1$. This would give for the derivative $f'(2)=20.671695$ while the exact value would be $20.671717$
$endgroup$
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%2f3071969%2ffirst-derivative-approximation-using-function-values-in-equidistant-points%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
$begingroup$
Use Taylor series for small values of $h$
$$f(x)=f(x+(k-2) h)=f(x)+h (k-2) f'(x)+frac{1}{2} h^2 (k-2)^2 f''(x)+frac{1}{6} h^3 (k-2)^3
f^{(3)}(x)+frac{1}{24} h^4 (k-2)^4 f^{(4)}(x)+frac{1}{120} h^5 (k-2)^5
f^{(5)}(x)+Oleft(h^6right)$$
Now, write $$h f'(x)=a f(x-2h)+b f(x-h)+c f(x)+d f(x+h)+e f(x+2h)$$ and replace to get
$$h f'(x)=f(x) (a+b+c+d+e)+h f'(x) (-2 a-b+d+2 e)+frac{1}{2} h^2 f''(x) (4 a+b+d+4
e)+frac{1}{6} h^3 f^{(3)}(x) (-8 a-b+d+8 e)+frac{1}{24} h^4 f^{(4)}(x) (16
a+b+d+16 e)+frac{1}{120} h^5 f^{(5)}(x) (-32 a-b+d+32 e)+Oleft(h^6right)$$
Then, you have the equations
$$a+b+c+d+e=0 tag 1$$
$$-2 a-b+d+2 e=1 tag 2$$
$$4 a+b+d+4 e=0 tag 3$$
$$-8 a-b+d+8 e=0 tag 4$$
$$16 a+b+d+16 e=0 tag 5$$
from which $a=frac 1 {12}$, $b=-frac 2 {3}$, $c=0$, $d=frac 2 {3}$, $e=frac 1 {12}$.
So, using your notations
$$f'(x_2)=frac{f(x_0)-8f(x_1)+8f(x_3)-f(x_4) }{12 h}$$ and the "error" is $frac 1 {30} h^4 f^{(5)}(x_2)$
Let us try for $$f(x)=e^x tan (x) log (sin (x)+1)$$ at $x=2$ using $h=0.1$. This would give for the derivative $f'(2)=20.671695$ while the exact value would be $20.671717$
$endgroup$
add a comment |
$begingroup$
Use Taylor series for small values of $h$
$$f(x)=f(x+(k-2) h)=f(x)+h (k-2) f'(x)+frac{1}{2} h^2 (k-2)^2 f''(x)+frac{1}{6} h^3 (k-2)^3
f^{(3)}(x)+frac{1}{24} h^4 (k-2)^4 f^{(4)}(x)+frac{1}{120} h^5 (k-2)^5
f^{(5)}(x)+Oleft(h^6right)$$
Now, write $$h f'(x)=a f(x-2h)+b f(x-h)+c f(x)+d f(x+h)+e f(x+2h)$$ and replace to get
$$h f'(x)=f(x) (a+b+c+d+e)+h f'(x) (-2 a-b+d+2 e)+frac{1}{2} h^2 f''(x) (4 a+b+d+4
e)+frac{1}{6} h^3 f^{(3)}(x) (-8 a-b+d+8 e)+frac{1}{24} h^4 f^{(4)}(x) (16
a+b+d+16 e)+frac{1}{120} h^5 f^{(5)}(x) (-32 a-b+d+32 e)+Oleft(h^6right)$$
Then, you have the equations
$$a+b+c+d+e=0 tag 1$$
$$-2 a-b+d+2 e=1 tag 2$$
$$4 a+b+d+4 e=0 tag 3$$
$$-8 a-b+d+8 e=0 tag 4$$
$$16 a+b+d+16 e=0 tag 5$$
from which $a=frac 1 {12}$, $b=-frac 2 {3}$, $c=0$, $d=frac 2 {3}$, $e=frac 1 {12}$.
So, using your notations
$$f'(x_2)=frac{f(x_0)-8f(x_1)+8f(x_3)-f(x_4) }{12 h}$$ and the "error" is $frac 1 {30} h^4 f^{(5)}(x_2)$
Let us try for $$f(x)=e^x tan (x) log (sin (x)+1)$$ at $x=2$ using $h=0.1$. This would give for the derivative $f'(2)=20.671695$ while the exact value would be $20.671717$
$endgroup$
add a comment |
$begingroup$
Use Taylor series for small values of $h$
$$f(x)=f(x+(k-2) h)=f(x)+h (k-2) f'(x)+frac{1}{2} h^2 (k-2)^2 f''(x)+frac{1}{6} h^3 (k-2)^3
f^{(3)}(x)+frac{1}{24} h^4 (k-2)^4 f^{(4)}(x)+frac{1}{120} h^5 (k-2)^5
f^{(5)}(x)+Oleft(h^6right)$$
Now, write $$h f'(x)=a f(x-2h)+b f(x-h)+c f(x)+d f(x+h)+e f(x+2h)$$ and replace to get
$$h f'(x)=f(x) (a+b+c+d+e)+h f'(x) (-2 a-b+d+2 e)+frac{1}{2} h^2 f''(x) (4 a+b+d+4
e)+frac{1}{6} h^3 f^{(3)}(x) (-8 a-b+d+8 e)+frac{1}{24} h^4 f^{(4)}(x) (16
a+b+d+16 e)+frac{1}{120} h^5 f^{(5)}(x) (-32 a-b+d+32 e)+Oleft(h^6right)$$
Then, you have the equations
$$a+b+c+d+e=0 tag 1$$
$$-2 a-b+d+2 e=1 tag 2$$
$$4 a+b+d+4 e=0 tag 3$$
$$-8 a-b+d+8 e=0 tag 4$$
$$16 a+b+d+16 e=0 tag 5$$
from which $a=frac 1 {12}$, $b=-frac 2 {3}$, $c=0$, $d=frac 2 {3}$, $e=frac 1 {12}$.
So, using your notations
$$f'(x_2)=frac{f(x_0)-8f(x_1)+8f(x_3)-f(x_4) }{12 h}$$ and the "error" is $frac 1 {30} h^4 f^{(5)}(x_2)$
Let us try for $$f(x)=e^x tan (x) log (sin (x)+1)$$ at $x=2$ using $h=0.1$. This would give for the derivative $f'(2)=20.671695$ while the exact value would be $20.671717$
$endgroup$
Use Taylor series for small values of $h$
$$f(x)=f(x+(k-2) h)=f(x)+h (k-2) f'(x)+frac{1}{2} h^2 (k-2)^2 f''(x)+frac{1}{6} h^3 (k-2)^3
f^{(3)}(x)+frac{1}{24} h^4 (k-2)^4 f^{(4)}(x)+frac{1}{120} h^5 (k-2)^5
f^{(5)}(x)+Oleft(h^6right)$$
Now, write $$h f'(x)=a f(x-2h)+b f(x-h)+c f(x)+d f(x+h)+e f(x+2h)$$ and replace to get
$$h f'(x)=f(x) (a+b+c+d+e)+h f'(x) (-2 a-b+d+2 e)+frac{1}{2} h^2 f''(x) (4 a+b+d+4
e)+frac{1}{6} h^3 f^{(3)}(x) (-8 a-b+d+8 e)+frac{1}{24} h^4 f^{(4)}(x) (16
a+b+d+16 e)+frac{1}{120} h^5 f^{(5)}(x) (-32 a-b+d+32 e)+Oleft(h^6right)$$
Then, you have the equations
$$a+b+c+d+e=0 tag 1$$
$$-2 a-b+d+2 e=1 tag 2$$
$$4 a+b+d+4 e=0 tag 3$$
$$-8 a-b+d+8 e=0 tag 4$$
$$16 a+b+d+16 e=0 tag 5$$
from which $a=frac 1 {12}$, $b=-frac 2 {3}$, $c=0$, $d=frac 2 {3}$, $e=frac 1 {12}$.
So, using your notations
$$f'(x_2)=frac{f(x_0)-8f(x_1)+8f(x_3)-f(x_4) }{12 h}$$ and the "error" is $frac 1 {30} h^4 f^{(5)}(x_2)$
Let us try for $$f(x)=e^x tan (x) log (sin (x)+1)$$ at $x=2$ using $h=0.1$. This would give for the derivative $f'(2)=20.671695$ while the exact value would be $20.671717$
edited Jan 13 at 14:58
answered Jan 13 at 14:44
Claude LeiboviciClaude Leibovici
121k1157133
121k1157133
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.
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%2f3071969%2ffirst-derivative-approximation-using-function-values-in-equidistant-points%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
$begingroup$
What about $f'(x_2) approx frac{f(x_3)-f(x_1)}{2h}$
$endgroup$
– Jakobian
Jan 13 at 12:54
$begingroup$
This only uses two points.
$endgroup$
– random guy
Jan 13 at 13:00
$begingroup$
And it makes sense, considering how derivative is a local property
$endgroup$
– Jakobian
Jan 13 at 13:49
$begingroup$
But still, how can this be derived?
$endgroup$
– random guy
Jan 13 at 14:23