0% found this document useful (0 votes)
49 views4 pages

Solution Practice 4 - ENG2314

This document contains solutions to problems involving interpolation techniques in engineering. It discusses: 1) Using linear interpolation to estimate values within intervals and how accuracy improves with smaller intervals. 2) Applying linear and quadratic interpolation formulas to estimate values using data points. 3) Performing linear regression to find the equation for a line of best fit through data points. 4) Applying first and second order Lagrange interpolation to estimate values. 5) Calculating linear and quadratic interpolations to estimate a temperature value.

Uploaded by

Nbl Klf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views4 pages

Solution Practice 4 - ENG2314

This document contains solutions to problems involving interpolation techniques in engineering. It discusses: 1) Using linear interpolation to estimate values within intervals and how accuracy improves with smaller intervals. 2) Applying linear and quadratic interpolation formulas to estimate values using data points. 3) Performing linear regression to find the equation for a line of best fit through data points. 4) Applying first and second order Lagrange interpolation to estimate values. 5) Calculating linear and quadratic interpolations to estimate a temperature value.

Uploaded by

Nbl Klf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Taylors University

School of Engineering

Computing Applications for Engineers


(ENG2314)

Dr Thein Chung Ket

Solution Practice 4

Q1

x=1;
x0=0;
x1=5;

%when x=1
%using the interval between 0 and 5, i.e., x1=1; x2=5;

fx0=1-exp(-x0);
fx1=1-exp(-x1);
f1=fx0+(((fx1-fx0)/(x1-x0))*(x-x0))
true_value=1-exp(-x)

within the interval 0 and 5 f1 = 0.1987


within the interval 0 and 4 f1 = 0.2454
within the interval 0 and 3 f1 = 0.3167
within the interval 0 and 2 f1 = 0.4323
True Value = 0.6321
From the above calculation, if we reduce the interval, we can get the solution which is close to
the true value. It means that the error is reducing.
Q2

clc
x=1;
x0=0;
x1=3;
x2=8;
fx0=1-exp(-x0);
fx1=1-exp(-x1);
fx2=1-exp(-x2);
b0=fx0;
b1=(fx1-fx0)/(x1-x0);
b2=(((fx2-fx1)/(x2-x1))-((fx1-fx0)/(x1-x0)))/(x2-x0);

Page 1 of 4

Taylors University
School of Engineering

Computing Applications for Engineers


(ENG2314)

f2=b0+(b1*(x-x0))+(b2*(x-x0)*(x-x1))
true_value=1-exp(-x)

Solution = 0.3934
Q3
Discuss your results = similar to Q1 solution
Q4
Discuss your results = similar to Q2 solution
Q5
Lagrange first and second order solution
% 1st order Lagrange Interpolation fx1.

clc
x=18;
x0=0;
x1=20;
fx0=3.65;
fx1=0.75;
f1=(((x-x1)/(x0-x1))*fx0)+(((x-x0)/(x1-x0))*fx1)
%2nd order Lagrange Interpolation.
x2=40;
fx2=0.242;
p1=((((x-x1)*(x-x2))/((x0-x1)*(x0-x2)))*fx0);
p2=((((x-x0)*(x-x2))/((x1-x0)*(x1-x2)))*fx1);
p3=((((x-x0)*(x-x1))/((x2-x0)*(x2-x1)))*fx2);
f2=p1+p2+p3

f1 = 1.0400
f2 = 0.9324

Page 2 of 4

Dr Thein Chung Ket

Taylors University
School of Engineering

Q6.

Computing Applications for Engineers


(ENG2314)

i=2

x = 4.5

y = 1.0

i=3

x = 7.0

y = 2.5

y = mx + c
2.51.0

1.5

= 7.04.5 = 2.5 = 0.6


1 = 0.6 4.5 +

c = 1.7

The equation is y = 0.6x 1.7


When x = 5 y =1.3

Q7.
clc
%a1x^2+b1x+c1
%a2x^2+b2x+c2
%a3x^2+b3x+c3
r_1=[9 3 1
r_2=[4.5^2
r_3=[0 0 0
r_4=[0 0 0
r_5=[0 0 0
r_6=[0 0 0
r_7=[4.5*2
r_8=[0 0 0
r_9=[1 0 0

3.0<=x<=4.5
4.5<=x<=7.0
7.0<=x<=9.0

0 0 0 0 0 0];
4.5 1 0 0 0 0 0
4.5^2 4.5 1 0 0
7^2 7 1 0 0 0];
0 0 0 7^2 7 1];
0 0 0 9^2 9 1];
1 0 -4.5*2 -1 0
7*2 1 0 -7*2 -1
0 0 0 0 0 0];

0];
0];

0 0 0];
0];

A=[r_1;r_2;r_3;r_4;r_5;r_6;r_7;r_8;r_9];
S=[2.5 1.0 1.0 2.5 2.5 0.5 0 0 0]';
k=A\S
a2=k(4,1);
b2=k(5,1);
c2=k(6,1);
x=5;
y=a2*x.^2+(b2*x)+c2

Solution = 0.66

Page 3 of 4

Dr Thein Chung Ket

Taylors University
School of Engineering

Computing Applications for Engineers


(ENG2314)

Dr Thein Chung Ket

Challenging Question
8.
Linear interpolation
1 = (0 ) +
1 = 90 +

(1 ) (0 )
( 0 )
1 0

81.2 90
( 3000)
6100 3000

when x = 5000,
1 = 84.3226

Quadratic Interpolation
0 = (0 ) = 90
1 =

(1 ) (0 )
81.2 90
=
= 0.002838
1 0
6100 3000

(2 ) (1 ) (1 ) (0 )
75.6 81.2
81.2 90

6100 3000
2 1
1 0
7900

6100
2 =
=
= 5.5737 108
2 0
7900 3000

When x = 5000,
2 () = 0 + 1 ( 0 ) + 2 ( 0 )( 1 )
2 () = 90 0.002838( 3000) 5.5737 108 ( 3000)( 6100)
2 (5000) = 90 0.002838(5000 3000) 5.5737 108 (5000 3000)(5000 6100)
2 (5000) = 84.4449

Page 4 of 4

You might also like