ENG-102 2567 LinearEquationsPolynomial
ENG-102 2567 LinearEquationsPolynomial
ENG-102 2567 LinearEquationsPolynomial
Linear Equation
2 9 x1 5 x1 5 2 9 x1 2 9 5
= = / = \
3 −4 x2 7 x2 7 3 −4 x2 3 −4 7
Matrix notation Solving Solving
𝐀𝐱 = 𝐛 𝐱 = 𝐀/𝐛 𝐱 = 𝐀\𝐛
Size : 2x2 * 2x1 = 2x1 Size : 2x1 / 2x2 = 2x2 Size : 2x2 \ 2x1 = 2x1
>> A = [0 0 0; 0 0 0; 0 0 0];
• Linear
Equation A polynomial is a mathematical
expression consisting of variables,
• Polynomial co-efficients, and the operations of
Analysis addition, subtraction, multiplication,
and non-negative integer exponents.
5
• Polynomial (Root) : You can used roots() for convert to polynomial roots
and poly() for convert to polynomial.
• Linear
Equation Roots function results value of polynomial when equation equals to 0.
• Polynomial
a(x) : ( x2 + 3x = 0 ) ( x2 + 3x + 0 )
Analysis
>> a = [1,3,0];
>> r = roots(a)
x2 + 3x = 0
r =
0 02 + 3*0 = 0
-3 -32 + 3*-3 = 0
>> p = poly(r)
p =
1 3 0
6
• Polynomial Evaluation : A step of evaluation is simply substituting x value
and computing a result with function : polyval(p,x)
• Linear
Equation y = x2 + 2x + 1 p = [ 1 2 1 ]
• Polynomial
Analysis
>> polyval(p,0)
32 + 2*3 + 1
ans = = 16
1
02 + 2*0 + 1 = 1
>> x = [1,2,3,4];
>> y = polyval(p,x);
>> plot(x,y,'O')
>> axis([0 5 0 30])
x
7
• Example : Assume that the following polynomial represents the altitude (h(t))
in meters during the first 48 hours following the launch of a balloon:
• Linear
Equation h(t) = -0.12t4 + 12t3 – 380t2 + 4100t + 220
• Polynomial
Analysis where the units of t are hours. The corresponding polynomial model for the
velocity (v(t)) in meters per hour of the balloon is the following:
Generate plots of the altitude and the velocity for this balloon using units of
meters and meters/sec. Also determine and print the peak altitude and its
corresponding time.
8
• Example : Scrip Code (data)
%-------------------------------------------------------
• Linear % This program generates altitude and velocity plots
% using polynomial models for the altitude and velocity
% of a balloon.
Equation % ------------------------------------------------------
• Polynomial clear, clf, clc;
Analysis t = 0:0.1:48;
sph = 60 * 60; % sec per hour
[peak_alt,time] = findpeaks(alt);
max_alt = max(peak_alt);
max_time = t(find(alt == max_alt));
9
• Example : Scrip Code (Plot)
subplot(211), plot(t,alt,max_time,max_alt,'o')
• Linear title('Balloon Altitude')
Equation xlabel('t,hours')
ylabel('meters')
• Polynomial
Analysis Msg1 = ['Max Altitude: ',num2str(max_alt,'%.2f')];
text(25,16000,Msg1,'HorizontalAlignment','center')
subplot(212), plot(t,vel);
title('Balloon Velocity')
xlabel('t,hours')
ylabel('m/s')
grid
10
• Example : Result (Figure)
• Linear
Equation
• Polynomial
Analysis
11
• Curve Fitting : The process of constructing a curve or mathematical function
that best fits the data.
• Linear
Equation pN = polyfit(x,y,N)
• Polynomial
− Fits a polynomial of degree N to data described
Analysis by the vector x and y, where x is the independent
variable.
− x and y are vectors of the same size.
− pN is a row vector of length N+1 that contains
the coefficients of the optimal polynomial in
order of descending powers.
y = x2
12
• Curve Fitting :
13
• Example : Find and plot the first-degree and second-degree polynomials for
the following data:
• Linear x
-1
y
0
Equation x = [-1 0 2] and y = [0 -1 3] 0 -1
>> u - v
ans =
1 -4 -1 -6 40
16
• Polynomial Arithmetic (Multiplication) : You can be use function convolution :
conv(u,v)
• Linear
Equation u(x) * v(x)
>> conv(u,[4,-2,5,-16])
ans =
4 -2 -7 -14 83 -5 136 -384
r =
0 0 -4.0000 2.3750 26.0000
• Linear
Equation u(x) * v(x)
c = u * v q = u = c / v , r = [0 ...] % 1x8
19