Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started