Modeling and Simulation-02-1 PDF
Modeling and Simulation-02-1 PDF
Modeling and Simulation-02-1 PDF
For
PhD Programme
(1)
Week-02, Lecture:5-8
(2)
LINEAR MODELS
A great many practical problems can be solved using linear algebraic
equations. Such problems are usually expressed in words, rather than in
mathematical symbols but can be modeled mathematically and solved.
(3)
LINEAR MODELS
a c
Or explicitly written as y x ,
b b
( y y0) m ( x x0 )
Slope intercept form y mx d
y m (x x0 ) y0
Functional form f ( x ) mx d , polynomial of degree one.
(5)
Graphical Representation of Linear Model
Let us consider that a display is a matrix of discrete dots or pixels each one is
located at the first quadrant of Cartesian coordinate plane. The row elements
indicate the position on y axis and column elements indicate the position on y
axis.
To construct “A” we need three equations of straight line and five points.
There are many choices to choose the five points in the plane.
Let P1(20,1), P2(50,50),and P3(80,1), P4, and P5 can be obtained from the
rations of Lines L1:P1P2 and L2:P2P3 respectively.
(15)
Mathematical Formulation of the Problem 1.1
Now consider the image showing the 5 points through
which a model is required to fit
Let the data is given as
x1=20, x2=50, x3=80, x4=? X5=?
y1=1, y2=50, y3=1, y4=?, y5=?
Then L1=m1(x-x1)+y1
m1=(y2-y1)/(x2-x1) , slope of m1---(+ve)
m1=(50-1)/(50-20)=49/30=1.633
Thus, L1=1.633(x-20)+1
L1=1.633x-31.66, for 20<=x<=50
Similarly,
L2=m2(x-x2)+y2 m2=(y3-y2)/(x3-x1)=(1-50)/(80-50)
m2=-49/30=-1.633, slope is negative.
Thus L2=-1.633x+133.65, for 50<=x<=80
(16)
Mathematical Formulation of the Problem 1.1
(17)
Outcome of Problem 1.1
(18)
Outcome of Problem 1.1
Problem 2.2: Generalize the problem 1.1 for constructing “A” and also include the
shifting parameter for changing the position of A from left to right and from down to
up.
(19)
Practical Problems leading to linear equation
Problem 2.3: If one side of a triangle is one-third the perimeter, the second
side is one-fifth the perimeter, and the third side is 7 meters, what is the
perimeter of the triangle?
(20)
Practical Problems leading to linear equation
Translate mathematically and solve the following
problems
Problem 2.4: A pentagon is required to construct in such a way that the each
successive side is twice of the preceding side. If the total length of the sides of
pentagon is 200 cm then what are the dimensions of all sides of pentagon.
Problem 2.5: A car is on sale for r rupees inclusive p percent of tax. Write a
mathematical equation for finding the original price of car.
Problem 2.6: Initially there are P rupees in a university bank account. The
university invests the money at constant interest rate r for t years. What will be the
balance of university after 10 years. Translate this problem mathematically.
(21)
SYSTEMS OF LINEAR EQUATIONS
A general system of m linear equations with n unknowns can be written as
(22)
Formulation of simultaneous linear equations
Solution Methods
There are different ways to solve systems of linear equations in two or few
variables :
Graphing.
Substitution method.
Elimination method.
Gaussian elimination
Gauss Jordon elimination
Matrix Methods.
Cramer’s Rule
Inverse Matrix Method
But for large number of variables numerical methods are used:
LU Decomposition
Jacobi iterative method
Gauss-Seidel iterative method
Multigrid methods
(23)
Geometric interpretation of solution
Before diving into larger systems we will look at some familiar 2-variable cases. If the
equation has two variables we think of one of them as being dependent on the other. Thus we
have only one independent variable. A one-dimensional object is a line, so solutions to these
two-equation systems can be thought of as the intersection points of two lines. We will
generalize this concept when dealing with larger systems.
Consider the following sets of equations: 5
4 2 2 4
x y 1 Unique Solution 5
4x 2y 2 1
2x y 2 Here the lines are parallel, so never intersect. 1.0 0.5 0.5 1.0
4x 2y 4 determined) 2 1 1 2
x y z 2 Unique Solution
x y 5 If the coefficient matrix reduces to the identity matrix
x 2y z 4 there will be a unique (constant) solution to the system.
No Solution
x y z 1
2x 3y z 2 If the system is inconsistent there will be no solutions.
x 2y 2z 4 In this case there will be a contradiction that appears
during the solution process.
(25)
Geometric interpretation of solution
Unique Solution x y z 2
(26)
Geometric interpretation of solution
No Solution
x y z 1
If the system is inconsistent there will be no solutions. 2x 3y z 2
In this case there will be a contradiction that appears x 2y 2z 4
during the solution process.
(27)
Geometric interpretation of solution
(28)
Formulation of simultaneous linear equations
(29)
Formulation of simultaneous linear equations
Practice Examples
Example 1
A university would like to buy 50 laptops. The core i7
costs Rs. 60000, and the core i5 costs Rs. 40000.
University can only afford to spend Rs. 2400000. How
many of each type laptops can university buy?
Define Variables:
x: core i7 y: core i5
Equation 1 Equation 2
y=15x+10 y=-20x+150
Equation 1 Equation 2
3x+10y=102 3x+7y=84
Example 4
Person A and person B were jogging. A had a 2 mile
head start on B. If A ran at an average rate of 5 miles per
hour and B ran at an average rate of 8 miles per hour, how
long would it take for B to catch up with A?
Define Variables:
x=hours y=miles
Equation 1 Equation 2
y=5x+2 y=8x
Define Variables:
x=2 pt. questions y=3 pt. questions
Equation 1 Equation 2
x+y=38 2x+3y=100
Example 6
The perimeter of a parking lot is 310 meters. The
length is 10 more than twice the width. Find the
length and width. (Remember: P=2L+2W)
Define Variables
L=length W=width
Equation 1 Equation 2
2L+2W=310 L=2W+10
Define Variables
x=smaller number y=larger number
Equation 1 Equation 2
x+y=112 x=y-58
(36)
Formulation of simultaneous linear equations
Example 8
A total of $10,000 is invested in two funds, Fund A and
Fund B. Fund A pays 5% annual interest and Fund B
pays 7% annual interest. The combined annual interest is
$630. How much of the $10,000 is invested in each fund?
Define Variables
a=Fund A b=Fund B
Equation 1 Equation 2
a+b=10,000 .05a+.07b=630
(39)
Formulation of simultaneous linear equations
Problem 2.7: Set up a system of linear equations to represent the
network shown in the following. Then solve the system.
(40)
Formulation of simultaneous linear equations
Solution of the problem
(41)
In Problem 2.7, suppose you could control
the amount of flow along the branch labeled x5
Using the solution of Problem 2.7, you could then
control the flow represented by each of the other
variables
(42)
Formulation of simultaneous linear equations
ELECTRICAL NETWORKS
(43)
Formulation of simultaneous linear equations
Problem 2.8: Formulate the mathematical model for the electrical circuit
shown in the following Figure and determine the currents and for the
electrical network.
(44)
(45)
Problem: Formulate the mathematical model for the electrical circuit shown in
the following Figure and determine the currents and for the electrical network.
(46)
Formulation of simultaneous linear equations
(47)
Formulation of simultaneous linear equations
POLYNOMIAL CURVE FITTING
(48)
Formulation of simultaneous linear equations
Example
Formulation of system:
Solution:
(49)
Formulation of simultaneous linear equations
Problem: The temperature of Nawabshah city was recorded on a certain day from
8:00 am to 6:00 pm with an interval of two hours. The data is given in the following
Table:
Time
8:00 10:00 12:00 14:00 16:00 18:00
(Hours)
Temp
18 21 29 32 30 24
(oC)
Fit a mathematical model of degree 5 through the data and analyze for
prediction of temp at time 6:30 pm. Also determine what was the
Temperature of Nawabshah at 9:56 am, 1:00 pm and 4:15 pm.
(50)
Formulation of simultaneous linear equations
The given problem is the application of curve fitting through linear systems.
First of all we draw the plot of data and then attempt to fit the required polynomial.
(51)
Formulation of simultaneous linear equations
For polynomial of degree 5 put the time values in
P(x)=a0+a1x+a2x2+a3x3+a4x4+a5x5
This will lead to the following system of linear equations expressed in
matrix form:
Thus the required model is formulated for the prediction of temperature as given below:
P(x)=1110-427.23x+64.33x2-4.682x3+0.1667x4-0.002343x5
(52)
Formulation of simultaneous linear equations
(53)
Curve Fitting using MATLAB