Non-linear equations
Non-linear equations:
algebraic one: quadratic, cubic, and polynomial
equations
ax2+bx+c = 0 x3+ax2+bx+c = 0 a0+a1x+a2x2+a3x3++anxn =0
non-algebraic ones: exponential (ex),
logarithmic (logx), trigonometric (sinx), and
hyperbolic functions (sinhx)
They are transcendental equations (i.e., they
transcend the realm of algebraic equations)
They involve complex numbers: Even the
simplest
of algebraic
equations, namely,
Solution
to non-linear
equations
quadratic equations, may produce a complex
solution
2
Contents
Lecture 5
Introduction to complex numbers
Solution to quadratic and cubic equations
The many roots of a real or complex number
Lecture 6
Polynomials and solutions to polynomial equations
Solution of a single non-linear equation
The
complex conjugate of a complex number z = x + iy
= rei, is
= x iy = re-i
The complex conjugate of z can be thought of as the
reflection of z about the real (x-) axis.
Examples of basic complex number operations in
SCILAB
The unit imaginary number, i = (-1), is represented in SCILAB by the
symbol %i. A sequence of the first 10 powers of I can obtained by
using:
The magnitude and argument of the complex number z are obtained as:
The magnitude of
the complex
number z:
r = |z|= (x2+y2)1/2
The argument of
the complex
number z:
= Arg(z) =
SCILAB provides the function polar to obtain the magnitude and argument of
a complex
number. The following example illustrates its application:
To obtain the magnitude of the elements of the matrix just defined we simply
apply the
function abs to the matrix name, i.e.,
10
11
12
The following SCILAB command attempts to find one cubic root of z1:
13
14
15
16
i(1+2k)(/4)
= 2e
i(1+2k)(/4)
, k = 0, 1, 2, 3
Thus,
For k = 0,
r1= 2e
i(1+20)(/4)
For k = 1,
r2 = 2e
=2e
i3/4
= 2e
i5/4
i(1+21)(/4)
For k = 2,
r3= 2e
i(1+22)(/4)
For k = 3,
r4= 2e
i(1+23)(/4)
= 2e
i7/4
17
19
1/3
i/3
21
22
Quadratic equations
Quadratic equations are those algebraic equations with one unknown that
can be reduced to
the form:
ax2+bx+c = 0
where a, b, and c are real numbers.
The roots:
x = [-b (b2-4ac)1/2]/(2a)
23
Quadratic equations
Quadratic equations are those algebraic equations with one unknown that
can be reduced to
the form:
ax2+bx+c = 0
where a, b, and c are real numbers.
The roots:
x = [-b (b2-4ac)1/2]/(2a)
The quantity under the square root in this result is known as the discriminant
of the equation,
i.e.,
D = b2-4ac.
Possible solutions:
If D>0, the quadratic equation has two distinct real solutions:
x1,2= (-b D1/2)/(2a).
If D=0, the quadratic equation has one real (double) solution,
x1= x2= -b/(2a).
If D<0, the quadratic equation has two conjugate complex solutions,
x1,2= (-b i(-D)1/2)/(2a),
24
Cubic equations
The canonical (simplest)form of the cubic equation is
x3+ax2+bx+c = 0,
where a, b, c are real numbers.
Substituting the auxiliary variable
y = x + a/3
leads to the reduced form
y3+py+q = 0,
with
p = (3b-a2)/3,
and
q = c + 2a3/27 ab/3.
A discriminant for the reduced cubic equation is given by
D = (q/2)2+(p/3)3.
An Italian mathematician, Gierolimo Cardano, proposed the following
solutions to the cubic
equation:
x1= -(a/3)+u+v
x2,3= -(a/3)-(u+v)/2 i3(u-v)/2
where
Depending on the sign of the discriminant, D, the solutions to the cubic
equation can be
26
where
27
28
29
HW-5
Due: 9am, Oct 12, 2015
Late policy: 10% off per day
To be submitted online to Canvas:
Save all your codes (*.sci files) into one folder to submit;
Do use // to add comments clearly which question you
are referring to, when we execute your codes, answers
shall be shown on the screen.
30
31
Exercise 2
Write a Scilab program quadroots to compute and print the roots of a
quadratic equation ax2+ bx + c = 0 according to the previous pseudo-code.
It should run with a command like
quadroots(1,3,2)
for the case of x2+ 3x + 2 = 0.
Test quadroots on the following examples, checking the results in each case.
1.
2.
3.
4.
x2+ 1 = 0
0x2+ 2x + 1 = 0
x2+ 3x + 2 = 0
4x2+ 24x + 36 = 0
Note:
Save the script file into yourstudentno_lecture7&8_exe2.sci file
Intermediate results recorded using Print Screen
Save your test results and submit them in your pdf file
32
Exercise 3
Write a Scilab program cubicroots to compute and print the roots of a
quadratic equation ax3+ bx2 + c +d = 0 according to the previous pseudocode.
It should run with a command like
cubicroots(4,5,1,2)
for the case of 4x3+5x2+ 1x + 2 = 0.
Test cubicroots on the following examples, checking the results in each case.
1.
2.
3.
4.
x3+ 1 = 0
3x3+ 5x2+ 2x + 6 = 0
x3+ x2+ x + 1 = 0
9x3+ 3x2+ 4x + 6 = 0
Note:
Save the script file into yourstudentno_lecture7&8_exe3.sci file,
Intermediate results recorded using Print Screen
Save your test results and submit them in your pdf file.
33
34
35
36
37
40
In the first case, f(a)f(c) < 0, while f(b)f(c) > 0, and x R is contained in the
interval (a,c). In the second case, f(a)f(c) > 0, while f(b)f(c) < 0, and x R is
contained in the interval (c,b).
41
43
half.sci function
//
44
We will produce a plot of the function to check possible solutions visually, for
example:
45
The function does not evaluates to zero. However, the error involved is in the
order of 5x10-6,
small enough to accept the solution provided.
46
e Newton-Raphson method
Consider the Taylor-series expansion of the function f(x) about a value x = x o:
f(x)= f(xo)+f'(xo)(x-xo)+(f"(xo)/2!)(x-xo)2+.
Using only the first two terms of the expansion, a first approximation to the
root of the equation
f(x) = 0
can be obtained from
f(x) = 0 f(xo)+f'(xo)(x1 -xo)
Such approximation is given by,
x1= xo- f(xo)/f'(xo).
The Newton-Raphson method consists in obtaining improved values of the
approximate root
through the recurrent application of equation. For example, the second and
third approximations to that root will be given by
x2= x1- f(x1)/f'(x1),
and
x3= x2- f(x2)/f'(x2),
respectively.
This iterative procedure can be generalized by writing the following equation,
47
where i
48
49
50
To have an idea of the location of the roots of this polynomial we'll plot the
function using the
following SCILAB commands:
51
52
HW-6
Due: 9am, Oct 26, 2015
Late policy: 10% off per day
To be submitted online to Canvas:
Save all your codes (*.sci files) into one folder to submit;
Do use // to add comments clearly which question you
are referring to, when we execute your codes, answers
shall be shown on the screen.
53
Note:
Intermediate results recorded using Print Screen
Save your results and submit them in your pdf file.
54
Note:
Intermediate results recorded using Print Screen
Save your results and submit them in your pdf file.
55