Sem233 LA CC02 Group12

Download as pdf or txt
Download as pdf or txt
You are on page 1of 22

VIETNAM NATIONAL UNIVERSITY HO CHI MINH CITY

HO CHI MINH CITY UNIVERSITY OF TECHNOLOGY

PROJECT OF LINEAR ALGEBRA


GROUP 12-TOPIC 8
INTERPOLATION – EXTRAPOLATION AND CLIMATE CHANGE
Subject: Linear of Algebra
Subject code: MT1007
Instructor: Mr. Đậu Thế Phiệt
Class: CC02
Semester: 233

Ho Chi Minh city, August 14, 2024

1
Table of contents

I.Group member ............................................................................................................3

II.Job role of each members & Work evaluation. ......................................................4

III.Introduction. .............................................................................................................5

IVCalculation. ................................................................................................................6

1.Theory and algorithm. .............................................................................................. 6

a.Interpolation ..........................................................................................................6

b.Extrapolation ........................................................................................................6

2.Solution-practical code .............................................................................................8

a.Introduction about MATLAB ...............................................................................8

b.Solution and code .................................................................................................8

VConclusion .................................................................................................................21

2
I.Group member
No. Full Name Student ID

1 Lê Phước Thiên Duyên 2252127

2 Nguyễn Huy Hoàng 2053015

3 Phan Quang Minh 2051052

4 Võ Phương Hồng Ngọc 2352817

5 Nguyễn Tấn Phát 2352890

6 Võ Minh Thăng 2252762

7 Dương Anh Vinh 2252908

3
II.Job role of each members & Work evaluation.
Work
No. Name Job role
evaluation

Code MATLAB,
1 Lê Phước Thiên Duyên Rearrange the data 100%

Format, Introduction,
2 Nguyễn Huy Hoàng Theory 100%

Arrange structure of
3 Phan Quang Minh report 100%

Code MATLAB,
4 Võ Phương Hồng Ngọc Rearrange the data 100%

Arrange structure of
5 Nguyễn Tấn Phát report 100%

Coordinator,
6 Võ Minh Thăng Code MATLAB 100%

Code MATLAB,
7 Dương Anh Vinh Rearrange the data 100%

4
III.Introduction.
The purpose of this study is to highlight the importance of applying linear algebra
in analyzing and predicting the development trend of a certain entity, from which it is
possible to calculate and propose appropriate directions. appropriate while still ensuring
optimization in terms of time and cost.

Lecturer Đậu Thế Phiệt suggests to us 14 topics relating to applications of Linear


Algebra:

• Basic operations with matrices in MATLAB


• Matrix operations and image manipulation
• Matrix Multiplication, inversion, and photo filters
• Solving linear systems in MATLAB
• Systems of linear equations and college football team ranking
• Convolution, inner product, and image processing revisited
• Norms, angles, and your movie choices
• Interpolation, extrapolation, and climate change
• Orthogonal matrices and 3D graphics
• Discrete Dynamical systems, linear transformations of the plane, and the
Chaos Game
• Projections, eigenvectors, Principal Component Analysis, and face
recognition algorithms
• Matrix eigenvalues and the Google PageRank algorithm
• Social Networks, clustering, and eigenvalue problems
• Singular Value Decomposition and Image Compression

In the chosen topic, we must find one practical problem and show the solution by
using the MATLAB language.

After some discussions, our group decided to choose the eighth topic:
Interpolation, Extrapolation, and climate change. Furthermore, in this report we will
illustrate the theoretical basis relating to the practical problem we collected and show
how we deal with this by using MATLAB.

5
IV.Calculation.
1.Theory and algorithm.
a.Interpolation
Definition: Within a series of known data points, researchers can estimate
unknown values using a statistical technique called interpolation.

Application: when anticipating uncertainty values, interpolation works best,


particularly when dealing with geographically connected data items like noise level, rain
forecast, and the like.

Data Range: Interpolation projects data points inside the data range. Furthermore,
interpolation operates inside the data range of two known values.

Criticism and Limitations: It cannot estimate above or below the maximum or


minimum values in the observation. Other limitations of interpolation include the
following:

• Someone, the data value resulting from interpolation isn’t very precise.
• It could lead to a huge margin of error in the observation.
• When applying interpolation to a large data set, you’d need to repeat several
calculations.
• It can demand lots of time and resources.

b.Extrapolation
Definition: extrapolation is a statistical method of predicting the value or state of
a variable based on its current state. In other words, the researcher studies the present
condition of a variable and uses these insights to arrive at a realistic estimation for the
future.

Originally, extrapolation remained within the confines of statistics and quantitative


research. However, as more fields of study infused statistical methods into their research
process, extrapolation gained relevance in areas like Psychology and Sociology. In fact,
it is useful in any subject that requires categorical data.

6
Types of extrapolations: While extrapolation passes as part of human instinct, it
requires standardized processes during research. Based on these standards, we can
identify 3 types of extrapolations - linear, conic, and polynomial.

• Linear Extrapolation:

Linear extrapolation is the process of estimating a value that is close to the existing
data. To do this, the researcher plots out a linear equation on a graph and uses the
sequence of the values to predict immediate future data points. You can draw a tangent
line at the last point and extend this line beyond the limits.

Uses of linear extrapolation:

o It serves as a long-term estimate for the data.


o Linear extrapolation can help estimate values that are either higher or lower
than the values in the data sets.
o It can be used to fill gaps in data points for surveys.

Disadvantages of Linear Extrapolation:

Estimates given by linear extrapolation are never as good as using equations from
the line of the best fit method.

• Conic Extrapolation:

Conic Extrapolation is a type of extrapolation that is done with a conic section


paper template or on a computer. Here, the researcher depends on conic sections with
known data to help them discover unknown data. To do this, the researcher creates a
conic section which could be a circle, ellipse, parabola, or hyperbola using five data
points near the end of the known variables.

• Polynomial Extrapolation:

Polynomial Extrapolation is a statistical method that involves the use of


polynomial shapes and functions to estimate the values on a graph.

Advantages of extrapolation:
• Extrapolation is a simple method of data forecasting, and it doesn’t require lots
of time or monetary resources.

7
• In human resources, extrapolation can help you determine the appropriate
compensation value for staff based on their current performance.
• Extrapolation offers an effective means for businesses to project their future
outcomes based on the current data at their disposal.
• This forecasting method has low data requirements. This means you do not
have to gather large data sets before you can predict future data points.

Disadvantages of extrapolation:

• Extrapolation is easily affected by significant fluctuations in the existing data


sets.
• Extrapolated values can be unreliable, especially when there are disparities in
the existing data sets.
• Extrapolation doesn’t account for qualitative values that can trigger changes in
future values within the same observation.
• It hardly accounts for causal factors in the observation.

2.Solution-practical code
a.Introduction about MATLAB
- MATLAB is a programming platform designed especially for engineers and
scientists to analyze and design the systems and products that transform our
world (analyze data, develop algorithms, create models and applications).
- The heart of MATLAB is the MATLAB language, a matrix-based language
allowing the most natural expression of computational mathematics.

b.Solution and code


Interpolation: task 1-6

To begin, we will use polynomial approximation to interpolate the data in


variable WeatherHigh . Frist, we generate a plot of the temperature into Matlab.

8
The plot with X-axis from 1-12 which represent for twelve months in a year and
the Y-axis form 30-95 which represent for temperature.

Figure 1: plot of temperature in a year

Asum for now, we will use the temperatures of four months: January, May,
August and December. We select the data from variable WeatherHigh and generate to
Vandermonde matrix.

The resulting vector CoefHigh contains coefficients of the cubic polynomial


approximating the average high annual temperature in Kansas.

Figure 2: Coefficients of the cubic polynomial

9
Next, we draw a graph shows the difference between the approximated values
and the exact values.

Figure 3: Approximation with the 3rd degree polynomial

We will repeat the steps above but with the approximation with the higher degree
polynomial and draw a graph.

10
Figure 4: Approximation with the 5th degree polynomial

We can see that this approximation much closer results to the exact values. We
will continue to the steps above with 12 months and draw a graph.

11
Figure 5: Approximation with the 11th degree polynomial

Notice that this approximation is not better than the approximation with the 5th
degree polynomial (due to large fluctuation near the end points). The reason for this is
that Vandermonde matrix is an ill-conditioned matrix. If polynomials of a high degree
on evenly spaced grids are not good for interpolation, what can be done instead? The
most common method of interpolation is through the approximation of functions with
piece-wise (typically polynomial) functions.

Extrapolation: task 7-19

Overall, we will use the least squares method to find the trend of the climate data
and then we can approximate the temperature in the future years. First of all, we will
load the matrix by using the load command.

12
Secondly, we continue to separate the data into 2 variables and display the result.

Figure 6: the years and the temps columns.

13
Then, using the plot command to procedure a graph of fluctuations of average
temperatures since 1880.

And the result is the same with the given plot:

Figure 7: Average Yearly Temperatures.

Now, we will extrapolate the data in the future. Assume that we want to know the
temperature about 10 years in the future and draw a graph to illustrates.

14
Figure 8: temperature in 10 years later.

Notice that: we can see that these approximations give us the difference answers
and this is not the correct answer because we haven’t got the tendencies. The local
fluctuations in temperature significantly affected the global predictions for the future.
However, we are not interested in the local fluctuations but rather in global tendencies.
So let us try to separate those two from each other and extrapolate based on global
tendencies only. We will use orthogonal projections to separate the global behavior
from the “noise”.And we calculate the average temperature of the data

15
In the 11 and 12 task we construct the simplest form of least square method by
using orthogonal projections on vector 1, then we can find c to minimize the norm

|| t-c1||.We have the formula of orthogonal projections:

1
𝑝𝑟𝑜𝑗1 (𝑡 ) = ( 2 11𝑇 ) 𝑡 = 𝑃𝑡
||1||

P: is the projection matrix.

t: is the temperature (or the matrix of temperature).

Then we draw a graph to illustrate the variable temp1:

16
Figure 9: Approximation of data by the constant function.

Notice that: the value of temp1is the same to the value of average temperature.
When we use the approximation of data by the constant function the value of this
function is always the average value of this data.

The code in Part 14 is used to verify whether a matrix P1 is approximately


idempotent. The norm of the difference between P1*P1 and P1 are calculated to assess
this property. If this norm is very small, it means that P1 is close to being idempotent,
which is a key property of projection matrices.

Idempotent Matrix: A matrix P1 is idempotent if P1^2 = P1. This means that


when you apply the matrix twice in succession, it has the same effect as applying it
once. In practical terms, for a projection matrix, this implies that projecting a vector
twice is the same as projecting it once.

While the previous approach of approximating the data with a constant function
may be acceptable in some cases, it is clearly not a perfect match. Let us try instead to
model the data as a linear function of temperature (with no noise).

𝑡𝑖 = 𝑏𝑦𝑒𝑎𝑟𝑠𝑖 + 𝑐

17
Given an orthonormal basis defined by the columns of Q2 for the subspace S, the
formula for the projection matrix onto the subspace S is simple and temp2=P2*temp:

𝑃2 = 𝑄2 𝑄2𝑇

Figure 10: Approximation of data by a linear function.


18
Finally, let us approximate the data by using a quadratic function with B3, Q3, P3
variables.

Figure 11: Approximation of data by a quadratic function.


19
Notice that: Observe that the quadratic function (shown by the magenta line)
appears to follow the global tendencies of the temperature graph pretty well.

Now, let us make predictions for the future. Create a new cell and run the
following code:

Figure 12: Final model predictions.

20
V.Conclusion
By applying some acknowledgment that has been already taught in our course,
we can understand the concept of using the interpolation and extrapolation in
approximating the data as we have done in this topic.

Overall, interpolation is a powerful and versatile method that is wellsuited for


solving data. It provides direct estimates of value, is flexible and easy to use, and
handle a large number of parameters.

VI.References
[1].Anna Zemlyanova.Applied projects for an introductory linear algebra class
[2]. N. J. H. Desmond J. Higham, Matlab Guide, 2016
[3]. R. Pratap, Getting Started with MATLAB 7: A Quick Introduction for Scientists
and
Engineers, Oxford University Press, 2005.

21
22

You might also like