Solving Numerical Differentiation Problem using Scilab Programming

Veröffentlicht am: 19 Januar 2023
auf dem Kanal: Annie GB Teaching Videos
1,013
11

Given f(x)=exp(-x^2), find f'(x).
In this video, solution to differentiation problem using D1 dan D2 formula and the best estimation using extrapolation.

The computation is shown using Scilab.
I recorded this video during my lecture so you can hear me speaking Bahasa Melayu and English.

The full code is given here.

// This code performs NUMERICAL DIFFERENTIATION

// The name of this function file is f.sci
function y=f(x)
y=exp(-x^2);
endfunction

// The name of this function file is D1.sci
// This is D1 formula
function d1=D1(x,h)
d1=(f(x+h)-f(x))/h;
endfunction

// The name of this function file is D2.sci
// This is D2 formula
function y=D2(x,h)
y=(f(x+h)-f(x-h))/(2*h);
endfunction

x=1;
h=0.2;

disp("The D1 approximation is:")
y1=D1(x,h);
disp(y1);
disp("The D2 approximation is:")
y2=D2(x,h);
disp(y2);

// Extrapolation
T11=2(x,h); //h
T21=D2(x,h/2); // h/2
T31=D2(x,h/4); // h/4
T22=(4*T21-T11)/3;
T32=(4*T31-T21)/3;
T33=(16*T32-T22)/15;
disp("The best approximation using h/2 and h is")
disp(T22)
disp("The best approximation using h/4, h/2 and h is")
disp(T33)

// Exact Solution
function yp=exact(x)
yp=-2*x*exp(-x^2); // EXACT FOR y=exp(-x^2)
endfunction

// Finding the numerical errors
E1=abs(exact(x)-T22);
E2=abs(exact(x)-T33);
disp("The error for T22 is: ")
disp(E1);

disp("The error for T33 is: ")
disp(E2);


Auf dieser Seite können Sie das Online-Video Solving Numerical Differentiation Problem using Scilab Programming mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Annie GB Teaching Videos 19 Januar 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 1,013 Mal angesehen und es wurde von 11 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!