Algebra: Topics
Algebra: Topics
29. ALGEBRA
Topics:
•
Objectives:
•
distributive/collective a ( b + c ) = ab + ac
associative a ( bc ) = ( ab )c a + (b + c) = (a + b) + c
ab = cd ∴a = cd------
b
silly mistakes
1 - 1 1
----------- ≠ --- + ---
a+b a b
• Scilab example,
b = 5;
c = 6;
d = 7;
a=c*d/b
a=c+d-b
29.1.2 Exponents
• The basic properties of exponents are so important they demand some sort of mention
page 31
1---
n m n+m 0 n n (nth root)
(x )(x ) = x x = 1 , if x is not 0 x = x
m
x
–p 1- ----
n = ---- n n m
( x ) = x n – m = ------------
1 p x = x
---------- x
m m–n
(x ) x
n
( xy ) = ( x ) ( y )
n n x-- = n------x-
n
n m n⋅m y n y
(x ) = x n
n
⎛ x--⎞ = x-----
⎝ y⎠ n
y
• Scilab example,
x = 5;
n = 2;
m = 4;
y = 6;
x^n * x^m
x^(n + m)
x**(n+m)
2
2 b ± b – 4ac
ax + bx + c = 0 = a ( x – r 1 ) ( x – r 2 ) r 1, r 2 = –--------------------------------------
2a
page 32
• e.g.,
2
2x + 4x + 2 = 0
2
4 ± 4 – 4 ( 2 ) ( 2 ) = – 1 ± 0 = – 1, – 1
x = –------------------------------------------------
2(2)
3 2
x + ax + bx + c = 0 = ( x – r 1 ) ( x – r 2 ) ( x – r 3 )
First, calculate,
2 3 3 2 3 2
Q = 3b
–a R = 9ab – 27c – 2a - S = 3
R+ Q +R T = 3
R– Q +R
----------------- --------------------------------------
9 54
Then the roots,
a S+T a j 3 S+T a j 3
r 1 = S + T – --- r 2 = ------------ – --- + --------- ( S – T ) r 3 = ------------ – --- – --------- ( S – T )
3 2 3 2 2 3 2
• On a few occasions a quartic (4th order) equation will also have to be solved. This can be done
by first reducing the equation to a quadratic,
page 33
4 3 2
x + ax + bx + cx + d = 0 = ( x – r 1 ) ( x – r 2 ) ( x – r 3 ) ( x – r 4 )
First, solve the equation below to get a real root (call it ‘y’),
3 2 2 2
y – by + ( ac – 4d )y + ( 4bd – c – a d ) = 0
• In Scilab,
x = poly(0, ’x’);
roots(3 * x^2 + 4 * x + 2)
q = [2, 4, 3];
p = poly(q, ’x’, ’coeff’); // defines a polynomial using a vector
roots(p)
2 2
x + Ax + B = ( x + C ) + D
2 2
= x + 2Cx + ( C + D )
2
A = 2C B = C +D
C = A
2
--- D = B–C
2
2
5x + 50x + 10
2
= 5 ( x + 10x + 2 )
2
= 5 ( ( x + 5 ) – 23 )
• When given an equation where an algebraic solution is not feasible, a numerical solution may be
required. One simple technique uses an instantaneous slope of the function, and takes iterative
steps towards a solution.
f ( xi )
x i + 1 = x i – ----------------------
-
d-
⎛ ----- ⎞
f(x )
⎝ dx i ⎠
• The function f(x) is supplied by the user along with an initial guess.
• This method can become divergent if the function has an inflection point near the root.
page 35
• Scilab example,
• Complex values
page 36
Complex Numbers:
a + bj where,
a and b are both real numbers
( a + bj ) – ( c + dj ) = ( a – c ) + ( b – d )j
( a + bj ) ⋅ ( c + dj ) = ( ac – bd ) + ( ad + bc )j
N- N N* a + bj c – dj bc – ad-⎞
= -------------- = ----- ⎛ -------⎞ = ⎛ --------------⎞ ⎛ -------------⎞ = ac
a + bj + bd
---- ------------------ + ⎛ ----------------- j
M c + dj M ⎝ N* ⎠ ⎝ c + dj ⎠ ⎝ c – dj ⎠ 2 2 ⎝ 2 2⎠
c +d c + d
• We can also show complex numbers graphically. These representations lead to alternative repre-
sentations. If it is not obvious above, please consider the notation uses a cartesian notation, but
a polar notation can also be very useful when doing large calculations.
page 37
CARTESIAN FORM
Ij
imaginary (j)
N = R + Ij
R
real
2 2
A = R +I R = A cos θ
I
θ = atan ⎛ ---⎞ I = A sin θ
⎝ R⎠
POLAR FORM
Ij
imaginary (j)
N = A ∠θ
θ
R
real
A = amplitude
θ = phase angle
• We can also do calculations using polar notation (this is well suited to multiplication and divi-
sion, whereas cartesian notation is easier for addition and subtraction),
jθ
A ∠θ = A ( cos θ + j sin θ ) = Ae
A + jB A jB A
e = e e = e ( cos θ + j sin θ )
( A 1 ∠θ 1 ) ( A 2 ∠θ 2 ) = ( A 1 A 2 ) ∠( θ 1 + θ 2 )
( A 1 ∠θ 1 ) A1
--------------------- = ⎛ ------⎞ ∠( θ 1 – θ 2 )
( A 2 ∠θ 2 ) ⎝ A 2⎠
n n
( A ∠θ ) = ( A ) ∠( nθ ) (DeMoivre’s theorem)
page 38
• Note that DeMoivre’s theorem can be used to find exponents (including roots) of complex num-
bers
jθ
• Euler’s formula: e = cos θ + j sin θ
• In Scilab
j = sqrt(-1);
A = (1 + 2 * j) / ( 3 + 4 * j);
A
[mag, theta] = polar(A);
mag, theta // the magnitude and angle of the complex angle A
abs(A); // the magnitude of the complex number
real(A); // the real part of the complex number
imag(A); // the imaginary part of the complex number
conj(A); // the conjugate of the complex number
atan(imag(A), real(A)); // the angle of the complex number
• Some basic relationships are illustrated below with number lines. The shaded dots indicate that
page 39
the values include the point. Unshaded dots indicate that the values approach but do not equal
the value.
a
x = a x
a
x≠a x
a
x<a x
a
x≤a x
a
x>a x
a
x≥a x
a b
a<x<b x x ∈ ( a, b )
a b
a≤x≤b x x ∈ [ a, b ]
a b
b<x<a x
a b
b≤x≤a x
a+b<5 ∴a < 5 – b
- When doing calculations there is some roundoff error that result in a number that should be zero
but has a finite value. Consider single precision floating point numbers with 7 digits, or double
precision with 14, the last digit is equality in numerical calculations using a tolerance. In these
page 40
cases a tolrance is used between the target and actual values to determine equality.
ε = val – target
• In Scilab,
if ( x > A ) | (x < B) then
// program statement
else if x == A then
// more program statements
end
29.5 Functions
• terminology,
29.6.1 Logarithms
log n ( 1 ) = 0
x
log n ⎛ --⎞ = log n ( x ) – log n ( y )
⎝ y⎠
y
log n ( x ) = ylog n ( x )
log m ( x )
log n ( x ) = ------------------
-
log m ( n )
ln ( A ∠θ ) = ln ( A ) + ( θ + 2πk )j k∈I
e.g.,
solve n
5 = 10
log ( 5 ) = n log ( 10 )
log ( 5 )-
n = ------------------
log ( 10 )
• Note: most computers use the ’log’ function for the natural logarithm. The base 10 logarithm is
normally ’log10’.
• In Scilab this is
• In general there must be the same number of equations and unknowns to solve the equations.
• In some cases the equations will not be solvable. In this case we say the equations are singular.
29.7.1 Substitution
• Substitution is the most fundamental method for solving linear equations, but it is the least rou-
tine,
Given,
x+y = 5
2x + 3y = 8
To solve for y, we substitute to eliminate x.
∴x = 5 – y
∴2 ( 5 – y ) + 3y = 8
∴y = – 2
To solve for x, we substitute the value for y into an earlier equation.
∴x = 5 – ( – 2 ) = 7
• In Scilab this is
EXAMPLE ????????????
29.7.2 Addition
• Polynomials can be added to eliminate variables (in a matrix for this is referred to as the Gauss-
Jordan row reduction method).
page 44
Given,
x+y = 5
2x + 3y = 8
0x + 1y = – 2 ∴y = – 2
x = 5 – ( –2 ) = 7
is the
order of the use long division to
numerator >= yes reduce the order of the
denominator? numerator
no
Find roots of the denominator
and break the equation into
partial fraction form with
unknown values
OR
use limits technique. use algebra technique
If there are higher order
roots (repeated terms)
then derivatives will be
required to find solutions
Done
1 - = ---- A +B C-
x ( s ) = -------------------- --- + ----------
2
s (s + 1) s
2 s s+1
1 -⎞
C = lim ( s + 1 ) ⎛ -------------------- = 1
s → –1 ⎝ 2 ⎠
s (s + 1)
1 -⎞ 1
A = lim s ⎛ --------------------
2
= lim ----------- = 1
s→0 ⎝ 2 ⎠ s→0 s + 1
s (s + 1)
d 2 1 -⎞ d 1
B = lim ----- s ⎛ -------------------- = lim ----- ⎛ -----------⎞
–2
= lim [ – ( s + 1 ) ] = – 1
s → 0 ds ⎝ 2 ⎠ s → 0 ds s + 1⎠
⎝ s→0
s (s + 1)
• Consider the example below where the order of the numerator is larger than the denominator.
3 2
5s + 3s + 8s + 6-
x ( s ) = -------------------------------------------
2
s +4
This cannot be solved using partial fractions because the numerator is 3rd order
and the denominator is only 2nd order. Therefore long division can be used to
reduce the order of the equation.
5s + 3
2 3 2
s +4 5s + 3s + 8s + 6
3
5s + 20s
2
3s – 12s + 6
2
3s + 12
– 12s – 6
This can now be used to write a new function that has a reduced portion that can be
solved with partial fractions.
x ( s ) = 5s + 3 + –---------------------
12s – 6- solve –---------------------
12s – 6- = ------------
A - + ------------
B -
2
s +4
2
s +4 s + 2j s – 2j
• When the order of the denominator terms is greater than 1 it requires an expanded partial frac-
tion form, as shown below.
page 47
5
F ( s ) = -----------------------
-
2 3
s (s + 1)
5 - = ---- A +B C - + ------------------
D - + ---------------
E -
----------------------- --- + ------------------
2 3
s
2 s (s + 1) 3
(s + 1)
2 (s + 1)
s (s + 1)
5 - = ---- A +B C - + ------------------
D - + ---------------
E -
----------------------- --- + ------------------
2 3 2 s 3 2 (s + 1)
s (s + 1) s (s + 1) (s + 1)
3 3 2 2 2 2
A ( s + 1 ) + Bs ( s + 1 ) + Cs + Ds ( s + 1 ) + Es ( s + 1 ) -
= -----------------------------------------------------------------------------------------------------------------------------------------
2 3
s (s + 1)
4 3 2
s ( B + E ) + s ( A + 3B + D + 2E ) + s ( 3A + 3B + C + D + E ) + s ( 3A + B ) + ( A -)
= --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2 3
s (s + 1)
–1
0 1 0 0 1 A 0 A 0 1 0 0 1 0 5
1 3 0 1 2 B 0 B 1 3 0 1 2 0 – 15
3 3 1 1 1 C = 0 C = 3 3 1 1 1 0 = 5
3 1 0 0 0 D 0 D 3 1 0 0 0 0 10
1 0 0 0 0 E 5 E 1 0 0 0 0 5 15
5 - = ---- 5 + –--------
15- + ------------------
5 - + ------------------
10 - + ---------------
15 -
-----------------------
2 3 2 s 3 2 (s + 1)
s (s + 1) s (s + 1) (s + 1)
• Operations on summations:
page 48
b a
∑ xi = ∑ xi
i=a i=b
b b
∑ αxi = α ∑ xi
i=a i=a
b b b
∑ xi + ∑ yj = ∑ ( xi + yi )
i=a j=a i=a
b c c
∑ xi + ∑ xi = ∑ xi
i=a i = b+1 i=a
⎛ b ⎞⎛ d ⎞ b d
⎜ x ⎟⎜ y⎟ =
⎜ ∑ i⎟ ⎜ ∑ j⎟ ∑ ∑ xi yj
⎝i = a ⎠ ⎝j = c ⎠ i=a j=c
N–1 ⎧ 1 – αN
i ⎪ ----------------, α ≠ 1
∑ α = ⎨⎪ 1 – α for both real and complex α .
i=0 ⎩ N, α = 1
∞
i 1 , α <1
∑α = ------------
1–α
for both real and complex α . For α ≥ 1 , the summation does not
i=0
converge.
page 49
• In Scilab
LOOP EXAMPLE
29.9 Limits
29.10 Problems
1. Rearrange the following equation so that only ‘y’ is on the left hand side.
y = –------------------------------
y----------
+ x- = x + 2 x + xz + 2z-
y+z ans. –x–1
4x + 2y + z = 1
n m
a) n log ( x ) + m log ( y ) – log ( z ) x y
ans. log ⎛ -----------⎞
⎝ z ⎠
5. Simplify,
( 5x + 3y ) – ( 2x – 7y ) ans. 3x + 10y
2 2
( 5x + 3y ) – ( 2x – 7y ) 5x – 2x + 4y
2
x + 5x + 6
----------------------------- x-----------
+ 2-
2
x + 7x + 12 x+4
5--- + -----7- 22
------
x 3x 3x
5 7- 8-
--- – ----- -----
x 3x 3x
5 5x -
------------ --------------
3 – 7--- 3x – 7
x
5(x + 3) – 9(x – 6) – 4x + 69
5 6
----------- = ------------ x = 27
x–2 x+3
6. Multiply,
ans. 2
( 2x + 3 ) ( 5x + 4 ) 10x + 23x + 12
2 3 2
( 2x + 3x + 4 ) ( 5x + 4 ) 10x + 23x + 32x + 16
page 51
7. Factor,
2 ans.
x –4 (x + 2)(x – 2)
2 2
x – 4y ( x + 2y ) ( x – 2y )
2
x – 4x + 4 (x – 2)(x – 2)
2
x + 5x + 6 (x + 2)(x + 3)
5x + 3y = 10
x–y = 0 ans. x=y=1.25
2 ans. – 396
x + 2x + 100 = 0 – 1 ± ----------------
4
4 2 – 396
x + 2x + 100 = 0 x = ± – 1 ± ----------------
4
14. Find x,
12
x = 1372 ans. x = 1.826
12 + x
5 = 1372
15. Simplify,
log A + log B- 1-
----------------------------- ans. --- log ( AB – D )
C log D C
page 52
3
( 10 ∠0.13rad ) ans. 924.9 + 380.2j
19. Solve,
2
x – 36 > 0 x >6
2
x + 36 > – 12x x>
20. Solve,
( 8 – 3j ) – ( 12 + 4j ) ans. – 4 – 7j
2
( 4 + 5j ) – 9 – 40j
8 – 3j-⎞
⎛ ------------- 0.415 – 1.268j
⎝ 4 + 5j⎠
2
( x – 6 – 4j ) ( x – 6 + 4j ) x – 12x + 52
page 53
a) ⎛ t3 + 5 ⎞ ans. 5
lim ⎜ ----------------⎟
t → 0⎝ 5t 3 + 1⎠
⎛ t3 + 5 ⎞
b) lim ⎜ ----------------⎟ ans. 1/5
t → ∞⎝ 5t 3 + 1⎠
sin ( t ) ans.
lim --------------
t→∞ t
sin ( t )-
lim -------------
t→0 t
lim sin ( t )
t→∞
lim sin ( t )
t→0
–t
lim te
t→∞
–t
lim te
t→0
1. Write a program (in Scilab, C, etc.) that will perform the following calculation.
n
2
y(x) = ∑ (x + i)
i=1
2. Develop a program to fit a polynomial to set set of points. In the case where the order of the
polynomial does not allow an exact fit, a least squares method should be used to obtain the best
fit.
3. Write a program in Scilab (ask if you would prefer to use another platform). The program
should use the Newton-Raphson method to find the zeros of an arbitrary function. The func-
tions below should be used for testing the program. The final program will be tested for
robustness. The final program should be structured.
2
x +x+5 = 0
3 2
– 5x + x + 10 = 0