Finite difference for non-uniform unstructured mesh/stencilHow to obtain (prove) 5-stencil formula for 2nd...

Calculate Levenshtein distance between two strings in Python

Is "plugging out" electronic devices an American expression?

Is ipsum/ipsa/ipse a third person pronoun, or can it serve other functions?

What is the meaning of "of trouble" in the following sentence?

How could a lack of term limits lead to a "dictatorship?"

What happens when a metallic dragon and a chromatic dragon mate?

Need help identifying/translating a plaque in Tangier, Morocco

What do you call something that goes against the spirit of the law, but is legal when interpreting the law to the letter?

Does it makes sense to buy a new cycle to learn riding?

How can I fix this gap between bookcases I made?

How to make particles emit from certain parts of a 3D object?

How can I plot a Farey diagram?

Where else does the Shulchan Aruch quote an authority by name?

Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore

Why did the Germans forbid the possession of pet pigeons in Rostov-on-Don in 1941?

Doomsday-clock for my fantasy planet

What does 'script /dev/null' do?

New order #4: World

Can the Produce Flame cantrip be used to grapple, or as an unarmed strike, in the right circumstances?

What is the offset in a seaplane's hull?

Lied on resume at previous job

Why do we use polarized capacitors?

Typesetting a double Over Dot on top of a symbol

Why airport relocation isn't done gradually?



Finite difference for non-uniform unstructured mesh/stencil


How to obtain (prove) 5-stencil formula for 2nd derivative?Finite difference implicit schema for wave equation 1d not unconditionally stable?Calculating gradient from finite difference resultsDiscretization of the Anisotropic Diffusion Operator for Finite Difference MethodNumerically Solving a Poisson Equation with Neumann Boundary Conditionsfinite difference method with non-uniform meshFinite-Difference Approximation of Mixed Derivative in Spherical Coordinates?Stiffness Matrix for Galerkin Method (Finite Element Approx)Finite difference method for non-uniform gridApproximating finite differences by higher order derivatives of continuous functions













0












$begingroup$


Below I have shown my non-uniform unstructured mesh (as in there is no pattern between the relative size of $h_i$ and $h_{i+1}$ etc.



NU-US-M



I've made the following equations using nodes $i-1$, $i$, and $i+1$.




  1. $phi_{i-1}=phi_i+h_{i-1}frac{dphi}{dx}|_i+frac{h_{i-1}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i-1}^3}{3!}frac{d^3phi}{dx^3}|_i+...$

  2. $phi_{i+1}=phi_i+h_{i}frac{dphi}{dx}|_i+frac{h_{i}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i}^3}{3!}frac{d^3phi}{dx^3}|_i+...$


Combining these in a linear combination, then solving for the first derivative
$$frac{dphi}{dx}|_i=frac{Aphi_{i-1}+Bphi_{i+1}-(A+B)phi_i}{Ah_{i-1}+Bh_i}-frac{1}{2}left(frac{Ah_{i-1}^2+Bh_i^2}{Ah_{i-1}+Bh_i}right)frac{d^2phi}{dx^2}|_i-frac{1}{6}left(frac{Ah_{i-1}^3+Bh_i^3}{Ah_{i-1}+Bh_i}right)frac{d^3phi}{dx^3}|_i+/-...$$



According to my notes from class, I should be getting a final answer of
$$frac{dphi}{dx}|_i=frac{phi_{i+1}-phi_{i-1}}{x_{i+1}-x_{i-1}}-frac{left(h_iright)^2-left(h_{i-1}right)^2}{2left(x_{i+1}-x_{i-1}right)}frac{d^2phi}{dx^2}|_i-frac{left(h_iright)^3-left(h_{i-1}right)^3}{6left(x_{i+1}-x_{i-1}right)}frac{d^3phi}{dx^3}|_i+O(h^3).$$



Based on what I am expecting to get, and the fact that I want a second order accurate final equation I can say the following.




  1. $Ah_{i-1}^2+Bh_i^2=0$

  2. $A+B=0$


However, I can't get the expected answer. Can I get some help with the error I'm making?










share|cite|improve this question









$endgroup$












  • $begingroup$
    The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
    $endgroup$
    – ekkilop
    Apr 3 at 13:52
















0












$begingroup$


Below I have shown my non-uniform unstructured mesh (as in there is no pattern between the relative size of $h_i$ and $h_{i+1}$ etc.



NU-US-M



I've made the following equations using nodes $i-1$, $i$, and $i+1$.




  1. $phi_{i-1}=phi_i+h_{i-1}frac{dphi}{dx}|_i+frac{h_{i-1}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i-1}^3}{3!}frac{d^3phi}{dx^3}|_i+...$

  2. $phi_{i+1}=phi_i+h_{i}frac{dphi}{dx}|_i+frac{h_{i}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i}^3}{3!}frac{d^3phi}{dx^3}|_i+...$


Combining these in a linear combination, then solving for the first derivative
$$frac{dphi}{dx}|_i=frac{Aphi_{i-1}+Bphi_{i+1}-(A+B)phi_i}{Ah_{i-1}+Bh_i}-frac{1}{2}left(frac{Ah_{i-1}^2+Bh_i^2}{Ah_{i-1}+Bh_i}right)frac{d^2phi}{dx^2}|_i-frac{1}{6}left(frac{Ah_{i-1}^3+Bh_i^3}{Ah_{i-1}+Bh_i}right)frac{d^3phi}{dx^3}|_i+/-...$$



According to my notes from class, I should be getting a final answer of
$$frac{dphi}{dx}|_i=frac{phi_{i+1}-phi_{i-1}}{x_{i+1}-x_{i-1}}-frac{left(h_iright)^2-left(h_{i-1}right)^2}{2left(x_{i+1}-x_{i-1}right)}frac{d^2phi}{dx^2}|_i-frac{left(h_iright)^3-left(h_{i-1}right)^3}{6left(x_{i+1}-x_{i-1}right)}frac{d^3phi}{dx^3}|_i+O(h^3).$$



Based on what I am expecting to get, and the fact that I want a second order accurate final equation I can say the following.




  1. $Ah_{i-1}^2+Bh_i^2=0$

  2. $A+B=0$


However, I can't get the expected answer. Can I get some help with the error I'm making?










share|cite|improve this question









$endgroup$












  • $begingroup$
    The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
    $endgroup$
    – ekkilop
    Apr 3 at 13:52














0












0








0





$begingroup$


Below I have shown my non-uniform unstructured mesh (as in there is no pattern between the relative size of $h_i$ and $h_{i+1}$ etc.



NU-US-M



I've made the following equations using nodes $i-1$, $i$, and $i+1$.




  1. $phi_{i-1}=phi_i+h_{i-1}frac{dphi}{dx}|_i+frac{h_{i-1}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i-1}^3}{3!}frac{d^3phi}{dx^3}|_i+...$

  2. $phi_{i+1}=phi_i+h_{i}frac{dphi}{dx}|_i+frac{h_{i}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i}^3}{3!}frac{d^3phi}{dx^3}|_i+...$


Combining these in a linear combination, then solving for the first derivative
$$frac{dphi}{dx}|_i=frac{Aphi_{i-1}+Bphi_{i+1}-(A+B)phi_i}{Ah_{i-1}+Bh_i}-frac{1}{2}left(frac{Ah_{i-1}^2+Bh_i^2}{Ah_{i-1}+Bh_i}right)frac{d^2phi}{dx^2}|_i-frac{1}{6}left(frac{Ah_{i-1}^3+Bh_i^3}{Ah_{i-1}+Bh_i}right)frac{d^3phi}{dx^3}|_i+/-...$$



According to my notes from class, I should be getting a final answer of
$$frac{dphi}{dx}|_i=frac{phi_{i+1}-phi_{i-1}}{x_{i+1}-x_{i-1}}-frac{left(h_iright)^2-left(h_{i-1}right)^2}{2left(x_{i+1}-x_{i-1}right)}frac{d^2phi}{dx^2}|_i-frac{left(h_iright)^3-left(h_{i-1}right)^3}{6left(x_{i+1}-x_{i-1}right)}frac{d^3phi}{dx^3}|_i+O(h^3).$$



Based on what I am expecting to get, and the fact that I want a second order accurate final equation I can say the following.




  1. $Ah_{i-1}^2+Bh_i^2=0$

  2. $A+B=0$


However, I can't get the expected answer. Can I get some help with the error I'm making?










share|cite|improve this question









$endgroup$




Below I have shown my non-uniform unstructured mesh (as in there is no pattern between the relative size of $h_i$ and $h_{i+1}$ etc.



NU-US-M



I've made the following equations using nodes $i-1$, $i$, and $i+1$.




  1. $phi_{i-1}=phi_i+h_{i-1}frac{dphi}{dx}|_i+frac{h_{i-1}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i-1}^3}{3!}frac{d^3phi}{dx^3}|_i+...$

  2. $phi_{i+1}=phi_i+h_{i}frac{dphi}{dx}|_i+frac{h_{i}^2}{2!}frac{d^2phi}{dx^2}|_i+frac{h_{i}^3}{3!}frac{d^3phi}{dx^3}|_i+...$


Combining these in a linear combination, then solving for the first derivative
$$frac{dphi}{dx}|_i=frac{Aphi_{i-1}+Bphi_{i+1}-(A+B)phi_i}{Ah_{i-1}+Bh_i}-frac{1}{2}left(frac{Ah_{i-1}^2+Bh_i^2}{Ah_{i-1}+Bh_i}right)frac{d^2phi}{dx^2}|_i-frac{1}{6}left(frac{Ah_{i-1}^3+Bh_i^3}{Ah_{i-1}+Bh_i}right)frac{d^3phi}{dx^3}|_i+/-...$$



According to my notes from class, I should be getting a final answer of
$$frac{dphi}{dx}|_i=frac{phi_{i+1}-phi_{i-1}}{x_{i+1}-x_{i-1}}-frac{left(h_iright)^2-left(h_{i-1}right)^2}{2left(x_{i+1}-x_{i-1}right)}frac{d^2phi}{dx^2}|_i-frac{left(h_iright)^3-left(h_{i-1}right)^3}{6left(x_{i+1}-x_{i-1}right)}frac{d^3phi}{dx^3}|_i+O(h^3).$$



Based on what I am expecting to get, and the fact that I want a second order accurate final equation I can say the following.




  1. $Ah_{i-1}^2+Bh_i^2=0$

  2. $A+B=0$


However, I can't get the expected answer. Can I get some help with the error I'm making?







numerical-methods finite-differences finite-difference-methods






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Mar 20 at 18:37









WnGatRC456WnGatRC456

10811




10811












  • $begingroup$
    The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
    $endgroup$
    – ekkilop
    Apr 3 at 13:52


















  • $begingroup$
    The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
    $endgroup$
    – ekkilop
    Apr 3 at 13:52
















$begingroup$
The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
$endgroup$
– ekkilop
Apr 3 at 13:52




$begingroup$
The Taylor expansion for $phi_{i-1}$ is incorrect. The distance between between the points $x_{i-1}$ and $x_i$ is $x_{i-1} - x_i = -h_{i-1}$, so you need to replace $h_{i-1}$ by $-h_{i-1}$ everywhere in this expansion. Does this get you to the final answer?
$endgroup$
– ekkilop
Apr 3 at 13:52










0






active

oldest

votes












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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3155853%2ffinite-difference-for-non-uniform-unstructured-mesh-stencil%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3155853%2ffinite-difference-for-non-uniform-unstructured-mesh-stencil%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Nidaros erkebispedøme

Birsay

Where did Arya get these scars? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Favourite questions and answers from the 1st quarter of 2019Why did Arya refuse to end it?Has the pronunciation of Arya Stark's name changed?Has Arya forgiven people?Why did Arya Stark lose her vision?Why can Arya still use the faces?Has the Narrow Sea become narrower?Does Arya Stark know how to make poisons outside of the House of Black and White?Why did Nymeria leave Arya?Why did Arya not kill the Lannister soldiers she encountered in the Riverlands?What is the current canonical age of Sansa, Bran and Arya Stark?