Question: Need to write matlab or python code to solve this problem Question 4: Creating Finite Difference Schemes (10 Marks) (a) Create a finite difference scheme

Need to write matlab or python code to solve this problem Question 4: Creating Finite Difference Schemes (10 Marks) (a) Create a finite difference scheme to approximate the slope of a function u at the point X; using values of the function at the points 2.1-2, 2-1, Lj, 21+1, and 21+2 that is of order O(A2). (b) Create a finite difference scheme to approximate the curvature of a function u at the point x; using values of the function at the points .3-5, 21-4, 2-3, 2-2, 2j-1, and 2, that is of order O(Ar). (c) Use these two schemes to estimate the slope and curvature of the function u(x) = sin(272) at x = 0.1 using the grid spacings Ax = 0.1, 0.1/2, 0.1/22, 0.1/23, and so-on to Ar = 0.1/210. Create a table with 5 columns showing: 1) the grid spacing Ar, 2) the slope obtained with the finite difference approximation, 3) the curvature obtained with the finite difference approximation, 4) the error between the finite difference and exact slope, 5) the error between the finite difference and exact curvature. (d) Create a log-log plot of error vs. grid spacing Ar for both the slope and curvature in part (c). What are the slopes of the lines in these plots and how do they compare to the expected/requested orders of accuracy in (a) and (b)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
