Answered step by step
Verified Expert Solution
Link Copied!

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
A=[11111;-2-1012;41014;-8-1018;1610116];
b=[002h???200]';
% solve the linear system of equations to obtain the coeffiecients
x=A??b
fdstencil (2,-2:2)
uptrue =-4**sin(2);
sixth_derivative =-64**sin(2);
hvals = logspace (-1,-4,13);
D5u=[];
E5u=[];
E5u_pred =[];
% table headings
disp ('')
disp(' h
D5u
E5u')
for i=1 : length (hvals)
h= hvals(i);
xpts=1+h***(-2:2)';
D5u(i)=fdcoeffF(2,1,xpts)**sin(2**xpts);
rror
E5u(i)= D5u(i)-uptrue;
E5u_pred =-0.0111111**(h???4)** sixth_derivative;
disp (sprintf ('%13.8e
%15.8e
15.8e',
h, D5u(i), E5u(i)))
end
Plot errors
Clf
loglog (hvals,abs (E5u),'-')
hold on
loglog(hvals,abs (E5u_pred),'-')
title('log log plot of errors vs h')
xlabel ('h')
ylabel('Errors (E5u)')
legend('Numerical Error','Predicted Truncation Error','Location', 'North')
hold offe of this matlab code.
clc; clear; close all;
% Problem 2
syms h
A =[11111;-2-1012; 41014; -8-1018; 1610116];
b =[002/h^200]';
% solve the linear system of equations to obtain the coeffiecients
x = A\b
fdstencil(2,-2:2)
uptrue =-4*sin(2);
sixth_derivative =-64*sin(2);
hvals = logspace(-1,-4,13);
D5u =[];
E5u =[];
E5u_pred =[];
% table headings
disp('')
disp(' h D5u E5u')
for i=1:length(hvals)
h = hvals(i);
xpts =1+h*(-2:2)';
D5u(i)= fdcoeffF(2,1,xpts)*sin(2*xpts);
% Error
E5u(i)= D5u(i)-uptrue;
E5u_pred =-0.0111111*(h^4)*sixth_derivative;
disp(sprintf('%13.8e %15.8e %15.8e',
h,D5u(i),E5u(i)))
end
% Plot errors
clf
loglog(hvals,abs(E5u),'o-')
hold on
loglog(hvals,abs(E5u_pred),'-')
title('log log plot of errors vs h')
xlabel('h')
ylabel('Errors (E5u)')
legend('Numerical Error','Predicted Truncation Error','Location','North')
hold off
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago