Question: Write a similar Python codsyms h A = [ 1 1 1 1 1 ; - 2 - 1 0 1 2 ; 4 1
Write a similar Python codsyms h
;
;
solve the linear system of equations to obtain the coeffiecients
fdstencil :
uptrue ;
sixthderivative ;
hvals logspace ;
;
;
Eupred ;
table headings
disp
disp h
Du
Eu
for : length hvals
hvalsi;
:;
DuifdcoeffF;
rror
Eui Duiuptrue;
Eupred sixthderivative;
disp sprintf e
h Dui Eui
end
Plot errors
Clf
loglog hvalsabs Eu
hold on
logloghvalsabs Eupred
titlelog log plot of errors vs h
xlabel h
ylabelErrors Eu
legendNumerical Error','Predicted Truncation Error','Location', 'North'
hold offe of this matlab code.
clc; clear; close all;
Problem
syms h
A ;; ; ; ;
b h;
solve the linear system of equations to obtain the coeffiecients
x Ab
fdstencil:
uptrue sin;
sixthderivative sin;
hvals logspace;
Du ;
Eu ;
Eupred ;
table headings
disp
disp h Du Eu
for i:lengthhvals
h hvalsi;
xpts h:;
Dui fdcoeffFxptssinxpts;
Error
Eui Duiuptrue;
Eupred hsixthderivative;
dispsprintfe e e
hDuiEui
end
Plot errors
clf
logloghvalsabsEuo
hold on
logloghvalsabsEupred
titlelog log plot of errors vs h
xlabelh
ylabelErrors Eu
legendNumerical Error','Predicted Truncation Error','Location','North'
hold off
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
