0% found this document useful (0 votes)
18 views

Lab 4 Solving Simultaneous Linear Algebraic Equation

This document discusses using Excel and MATLAB to solve simultaneous linear equations and find roots of functions. In Excel, the trial and error method and Goal Seek tool can be used to locate roots of a single function by varying the input values. The Solver function can find the roots of two functions simultaneously by setting their formulations equal to zero and varying the input values. MATLAB's fzero function finds one root of a single function given initial guesses. Roots of polynomials can be determined by creating a coefficient vector, evaluating the polynomial and derivative, and using the roots function. Exercises 7.12-7.15 are listed for practice.

Uploaded by

Amirah Abidin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lab 4 Solving Simultaneous Linear Algebraic Equation

This document discusses using Excel and MATLAB to solve simultaneous linear equations and find roots of functions. In Excel, the trial and error method and Goal Seek tool can be used to locate roots of a single function by varying the input values. The Solver function can find the roots of two functions simultaneously by setting their formulations equal to zero and varying the input values. MATLAB's fzero function finds one root of a single function given initial guesses. Roots of polynomials can be determined by creating a coefficient vector, evaluating the polynomial and derivative, and using the roots function. Exercises 7.12-7.15 are listed for practice.

Uploaded by

Amirah Abidin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

LAB 4

Solving simultaneous linear


algebraic equation

EXCELL

use EXCELL to locate roots of function by trial and error.

Examples 1;
1.) determine roots of f(x) = x cos x
Step 1. enter the x value in a cell of the spreadsheet.
Step 2. Introduce f(x) formulation in the cell
and used the listed x value from the first cell to determine
the f(x) value.
Step 3. Varies the x value until f(x) cell approaches zero.
Step 4. use Goal Seek function to locate the roots.

Examples 1;
1.) determine roots of U(x,y) and V(x,y)
simultaneously using solver function.
U(x,y) = x2 + xy -10 = 0
V(x,y) = y + 3xy2 -57 = 0
initial values of x = 1 and y = 3.5
True value x = 2 and y = 3

Exercises;
7.12, 7.13, 7.11

MATLAB

The fzero function is used to locate one root of a


single function.

fzero (f, xo, options)


f is the function
xo is the initial guesses
options is the optimization parameter (that
are changed using the function optimset)

Use Matlab to locate root


Example:
Use fzero function to finad roots of
f(x) = x10 1
Using the initial guesses 0 to 1.3;
Solution:
>>xo = [0 1.3]
>> x = fzero(inline(x^10-1),xo)
x=

Using Matlab to determine roots of polynomials

Example;
Determine roots of the polynomial;

f 5 ( x) x5 3.5x 4 2.75x3 2.125x 2 3.875x 1.25


Solution;
Create vector a based on the coefficient of the
polynomial;
>> a = [1 -3.5 2.75 2.125 -3.875 1.25]

Manipulate the polynomial:


Evaluate the polynomial when x = 1;
>> polyval (a,1)
ans =
-0.2500
With the result of

f 5 (1) 15 3.5(1) 4 2.75(1)3 2.125(1) 2 3.875(1) 1.25 0.25

Evaluate derivative of f(x):


Evaluate the polynomial when x = 1;
>> polyder (a)
ans =
5.0000 -14.0000 8.2500 4.2500 -3.8750
f 5 ( x) x5 3.5x 4 2.75x3 2.125x 2 3.875x 1.25

f 5 ' ( x) 5x 4 14 x3 8.25x 2 4.25x 3.875

To determine roots of the polynomial:


>> r = roots(a)
r=
-1.0000
2.0000
1.0000 + 0.5000i
1.0000 0.5000i
0.5000
Exercises:
7.14, 7.15

You might also like