MATLAB: Finite difference method for second order ode – iTecTec
itectec.com › matlab › matlab-finite-differenceMATLAB: Finite difference method for second order ode. fd method finite difference method second order ode. Hi everyone. I have written this code to solve this equation: y"+2y'+y=x^2 the problem is when I put X as for example X=0:0.25:1, it gives me fairly good answers for y. but when I change X as X=0:0.1:1, the answers for y are not correct. the more I reduce the delta x, the bigger the error become. can anyone tell me what I am doing wrong? this is the code:
Finite Difference Methods
web.mit.edu › course › 161 % This Matlab script solves the one-dimensional convection 2 % equation using a finite difference algorithm. The 3 % discretization uses central differences in space and forward 4 % Euler in time. 5 6 clear all; 7 close all; 8 9 % Number of points 10 Nx = 50; 11 x = linspace(0,1,Nx+1); 12 dx = 1/Nx; 13 14 % velocity 15 u = 1; 16 17 % Set final time 18 tfinal = 10.0; 19
Numerical Solution of 2nd Order, Linear, ODEs.
www.ees.nmt.edu › outside › coursessecond derivatives results in higher order terms of order ∆x2. (If the step size were to vary in x, then the truncation error is not as good. It’s of order ∆x.) Finite Difference Approximations We can truncate all of our expansions and write finite difference approximations, indicating the order of the approximation (truncation error).