Modeling and Simulation-02-1 PDF

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

MATHEMATICAL MODELING AND SIMULATION

For
PhD Programme

Shakeel Ahmed Kamboh


PhD (Computational Science)
Department of Mathematics and Statistics
QUEST, Nawabshah

(1)
Week-02, Lecture:5-8

FORMULATION OF MATHEMATICAL MODELS USING


LINEAR AND NONLINEAR EQUATIONS

(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.

Strategy for Solving Word Problems


1. Read the problem carefully—several times if necessary—that is, until you
understand the problem, know what is to be found, and know what is given.
2. Let one of the unknown quantities be represented by a variable, say x, and
try to represent all other unknown quantities in terms of x. This is an important
step and must be done carefully.
3. If appropriate, draw figures or diagrams and label known and unknown parts.
4. Look for formulas connecting the known quantities to the unknown
quantities.
5. Form an equation relating the unknown quantities to the known quantities.
6. Solve the equation and write answers to all questions asked in the problem.
7. Check and interpret all solutions in terms of the original problem—not just
the equation found in step 5—since a mistake may have been made in setting
up the equation in step 5.

(3)
LINEAR MODELS

Models of the form: ax  by  c  0 , known as linear algebraic equation.

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.

mx  d  0 is the standard form.


Linear equation is used to govern the problems in which the values of
dependent variable y continuously increases or decreases linearly when the
values of independent variable x are increased.
In other words, the problems involving the constant rate of change.
(4)
Graphical Representation of Linear Model

Figure 1: Straight line crossing at x=-1/2 and y=1.

(5)
Graphical Representation of Linear Model

Figure 2: Family of straight lines with different values of slope


m={-1.5,-1,-0.5,0,0.5,1,1.5}
(6)
Graphical Representation of Linear Model

Figure 3: Family of straight lines with different intercepts


d={-3, -2, -1, 0,1, 2, 3}
(7)
Graphical Representation of Linear Model

Figure 4: Family of straight lines with different values of


m={-1, 0, 1}, d={-1, 0, 1}.
(8)
Graphical Representation of Linear Model

Figure 5: Family of horizontal straight lines with zero slope


and different values of d={-4,-3, -2, -1, 0, 1, 2, 3, 4}.
(9)
Graphical Representation of Linear Model

Figure 6: Family of vertical straight lines with zero slope


and different values of d={-4,-3, -2, -1, 0, 1, 2, 3, 4}.
(10)
Graphical Representation of Linear Model

Figure 7: Family of horizontal and vertical straight lines with


zero slope and different values of d={-4,-3, -2, -1, 0, 1, 2, 3, 4}.
(11)
Graphical Representation of Linear Model

Figure 8: Family of straight lines with positive and negative


slop and different values of d={-10,-9,…, 0, 1,…, 10}.
(12)
Graphical Representation of Linear Model

Figure 9: Family of straight lines with positive and negative


slop and different values of d={-10,-9,…, 0, 1,…, 10}.
(13)
Graphical Representation of Linear Model

Figure 10: Family of straight lines with different orientation;


positive and negative slop and different values of d={-10,-9,…,
0, 1,…, 10}.
(14)
Practical Problems leading to linear equation

Problem 2.1: Consider a computer display consists of 100x100 pixels.


Draw an “A” any where on the screen. Write a mathematical model that
r e p r e s e n t s a n d c o n s t r u c t s “ A ” o n s c r e e n d i s p l a y.

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

Finally, to find the third segment of line L3 we use the ratio


formula for the same data:
x1=20, x2=50, x3=80, x4=? X5=?
y1=1, y2=50, y3=1, y4=?, y5=?
If the L1 and L2 are joined in a ratio of r1:r2=1:2,
x4=(r1x2+r2*x1)/(r1+r2)=(90/3)=30
Since slope of L2 is negative, so
x5=(r1x2+r2x3)/(r1+r2)=(210/3)=70,
y4=L1(x4)=17.33, y5=L2(x5)=17.33.
Then L3=m3(x-x4)+y4 –> m3=(y5-y4)/(x5-x4)=0
Thus L3=0*x+17.33 for 30<=x<=70

(17)
Outcome of Problem 1.1

The required mathematical model


for constructing “A” is obtained as
follows

L1=1.633x-31.66, for 20<=x<=50,


L2=-1.633x+133.65, for 50<=x<=80,
L3=0*x+17.33, for 30<=x<=70,

(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.

Try to solve yourself.

(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

2x  y  2 These two lines intersect in a single point. 10

No Solution (Underdetermined system)


2

4x  2y  2 1

2x  y  2 Here the lines are parallel, so never intersect. 1.0 0.5 0.5 1.0

In this case we call the system inconsistent.


1

Infinitely many solutions( Over 2

4x  2y  4 determined) 2 1 1 2

2x  y  2 The two lines coincide in this case, so they have an 2

infinite number of intersection points.


(24)
Geometric interpretation of solution

Here are some 3-variable systems.


Each equation represents a plane (a 2-dimensional subset of ℝ3).
We are looking for intersections of these planes.

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.

x  y  2z  1 Infinitely many solutions


2x  y  z  2
If, after row reduction, there are more variables than
4x  y  5z  4 nonzero rows, the system will have a family of
solutions that can be written in parametric form.

(25)
Geometric interpretation of solution

Unique Solution x  y  z  2

If the coefficient matrix reduces to the identity matrix x  y  5


there will be a unique (numerical) solution to the system. x  2y  z  4

The solution to this system


is a single point: (1,4,5)

(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.

This line is the


intersection of a pair of
the planes

This line is the intersection


of a different pair of the
planes

(27)
Geometric interpretation of solution

Infinitely many solutions


x  y  2z  1
If, after row reduction, there are more variables than 2x  y  z  2
nonzero rows, the system will have a family of
4x  y  5z  4
solutions that can be written in parametric form.

This system has a 1-parameter


solution: it is a line in ℝ3.

(28)
Formulation of simultaneous linear equations

Steps to Follow when formulating linear


systems from real world problems

• 1. Identify the Variables


• 2. Write equations
• (Use key words and reading strategies to
help)
• 3. Solve using substitution, elimination or any
other appropriate method
• 4. Write answer in a complete sentence

(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: Cost, Equation 2: laptops,


60000x+40000y=2400000 x+y=50

Best Method : Solution: (20,30)


Elimination
(30)
Formulation of simultaneous linear equations
Example 2

A hot air balloon is 10 meters above the ground and rising


at a rate of 15 meters per minute. Another balloon is 150
meters above the ground and descending at a rate of 20
meters per minute. When will the two balloons meet?
Define Variables:
x=minutes y=height in meters

Equation 1 Equation 2
y=15x+10 y=-20x+150

Best Method: Solution: (4,70)


Substitution
(31)
Formulation of simultaneous linear equations
Example 3
A group of 3 adults and 10 students paid $102 for a
tour. Another group of 3 adults and 7 students paid
$84 for the tour. Find the admission price for an adult
ticket and a student ticket.
Define Variables:
x= adult ticket price y=student ticket price

Equation 1 Equation 2
3x+10y=102 3x+7y=84

Best Method Solution (14,6)


Elimination
(32)
Formulation of simultaneous linear equations

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

Best Method Solution (2/3, 16/3)


Substitution
(33)
Formulation of simultaneous linear equations
Example 5
An Algebra Test contains 38 problems. Some of the
problems are worth 2 points each. The rest of the
questions are worth 3 points each. A perfect score is
100 points. How many problems are worth 2 points?
How many problems are worth 3 points?

Define Variables:
x=2 pt. questions y=3 pt. questions

Equation 1 Equation 2
x+y=38 2x+3y=100

Best Method Solution (14,24)


Elimination or Substitution
(34)
Formulation of simultaneous linear equations

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

Best Method Solution (106 2/3, 48 1/3)


Substitution
(35)
Formulation of simultaneous linear equations

Example 7 The sum of two numbers is 112. The


smaller is 58 less than the greater. Find the numbers.

Define Variables
x=smaller number y=larger number

Equation 1 Equation 2
x+y=112 x=y-58

Best Method Solution (27,85)


Substitution

(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

Best Method Solution (6500,3500)


Substitution
Formulation of simultaneous linear equations
Example 9
We need to rent a large truck for one week.
Rental companies charge an initial cost plus an
additional cost for each mile driven. One company,
Parco, will rent a 27 foot truck for us for $525 plus
$0.21 per mile. Another company, Opan, will rent us
the same size truck for $585 plus $0.13 per mile.
Define Variables
x=miles y=total cost
Equation 1 Equation 2
y=0.21x+525 y=0.13x+585

Best Method Solution (750,682.50)


Substitution
(38)
Formulation of simultaneous linear equations
NETWORK ANALYSIS

(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.

Formulation of mathematical model

(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:

After solving the above system we get,

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

Fitted polynomial through given data

Prediction and forecasting of Temperature.

(53)
Curve Fitting using MATLAB

You might also like