Вы находитесь на странице: 1из 18

-

3
:

:
:

_______________
_____

: 14

..

__________________
" ___ " ______________ 2006 .

2006

-10
3.1. f(x)=0 g(x)=0. e = 10
,
[a, b]. .
root MATHCAD.
:
1. f(x)=0.
2. MATHCAD, f(x)=0 .
3. bisec (. 2.B), f(x)=0 e
.
4. root MATHCAD, f(x)=0 e .
5. . 1-4 g(x)=0. .

:
( )
f(x) [a,b],
f(a)*f(b)<0 (1)

, (1), ..
.
,
[a,b] e.
[a,b].
:
4

f( x) := x -

10
3

x + 1

g( x) := x - 6 x + 9

:
ORIGIN := 1
solve_square_ur ( a , b , c) :=

D b - 4ac
return 0 if D < 0
X
1

X
2

-b -

2a
-b +

2a

X
a_f := 1

b_f :=

-10
3

c_f := 1

a_g := 1 b_g := -6

X1_f := - solve_square_ur ( a_f , b_f , c_f)


X2_f := - solve_square_ur ( a_f , b_f , c_f)
X3_f :=

solve_square_ur ( a_f , b_f , c_f)

X4_f :=

solve_square_ur ( a_f , b_f , c_f)

1
2

2
1

c_g := 9

X1_g := - solve_square_ur ( a_g , b_g , c_g)


X2_g := - solve_square_ur ( a_g , b_g , c_g)
X3_g :=

solve_square_ur( a_g , b_g , c_g)

X4_g :=

solve_square_ur( a_g , b_g , c_g)

1
2

2
1

X1_f = -1.732050808

X1_g = -1.732050808

X2_f = -0.577350269

X2_g = -1.732050808

X3_f = 0.577350269

X3_g = 1.732050808

X4_f = 1.732050808

X4_g = 1.732050808

f(x)=0, g(x)=0 0<x<2:


10

3.7

7.5

2.3
f ( x)

g( x)

0.9
0.5 0

0.5

1.5

5
2.5

1.9

0.5

1.5

:
Bisec( f , a , b , e) :=

an a
bn b
k0
while ( bn - an) > 2 e
xn

an + bn
2

fa f( an)
fb f( bn)
fxn f( xn)
bn xn if fa fxn 0
an xn otherwise
kk+ 1
xn
res

an + bn
2

xn

k

res
- 10

e := 10

MathCAD:
TOL := e

f(x)=0:
Bisec( f , 0.5 , 2 , e) =

0.577350269

33

x0 := 0.5
root( f( x0) , x0) = 0.577350269

f(x)=0:
Bisec( f , 1.5 , 2 , e) =

1.732050808

32

x0 := 2
root( f( x0) , x0) = 1.732050808

g(x)=0:
Bisec( g , 1 , 2 , e) =

x0 := -2

2

33

root( g( x0) , x0) = -1.732053358

g(x)=0:
Bisec( g , 1 , 2 , e) =

x0 := 2

2

33

root( g( x0) , x0) = 1.732053358

: ,

, .
g(x)=0 .
, ,

.
-6
3.2. f(x)=0 e = 10 .
. , .
,
, , (
6-7 ). :
(
)? , ? ,
? , (
, - )

{x } . .
(n )

:
e
( ).
, y=f(x)
x0( ). x1
, ..
,
. xn :
x =x
n

n- 1

( n- 1)
f(x )
n- 1

fx
d
dx

n- 1

:
f( x) := 2 sin( x - 0.6 ) + x - 1.5

:
df ( x) :=

d
f( x)
dx

df2 ( x) :=

dx

f( x)

f(x)=0 :

3.78
2.55
f ( x)

1.33

df ( x)
4

df2( x)

0.1

1.12
2.35
3.57
4.8
x

x0 := 1
root( f( x0) , x0) = 0.903079149706601
Newton( f , b , e) :=

xb
x0 0
i1
while x - x0 > e
x0 x
x x0 -

f( x0)
d
f( x0)
dx0

ii+1

x
res i - 1

x - x0

-6

-6

Newton f , 0.6 , 10

Newton f , 0.8 , 10

-6

Newton f , 1 , 10

)
)

0.90308

3
=

9.65814 10- 7

0.90308

3
=

7.11082 10- 8

0.90308

3
=

1.44354 10- 7

-6

-6

-6

Newton f , 0.7 , 10

Newton f , 0.9 , 10

Newton f , 1.2 , 10

)
)
)

0.90308

3
=

5.39574 10- 7

0.90308

2
=

9.65814 10- 7

0.90308

4
=

6.46132 10- 11

-6

Newton f , 1.5 , 10

0.90308

4
=

- 8
6.74158 10

-6

Newton f , 2 , 10

0.90308

5
=

- 9
2.68842 10



0.6
0.7
0.8
0.9
1
1.2
1.5
2


3
3
3
2
3
4
4
5

9.65814E-7
5.39574E-7
7.11082E-8
9.65814E-7
1.44354E-7
6.46133E-11
6.74158E-8
2.68842E-9

: ,
,
.
,
(0.6 1.2),
, " " f(x)*f' ''(x) ,
.
3.3. f(x)=0 e = 10 -9
.
[a, b]. , .

:
b-a
) x0 = a , x1 = a +
;
1000
b-a
b) x0 = b , x1 = b ;
1000
:
(
)? , ? ,
? ,
( , . a) b)

{ }

(n )
) x
. .

:
e
.
(. 2.2) ,
( x0, x1).
xn+ 1 :
x

n+ 1

=x n

( n) , h = x - x
n
n- 1
n
f(x + h ) - f(x )
n
n
n
h fx
n

:
x

n+ 1

-x

<e

:
5

f( x) := x - 2 sin( x) + 1

:
df ( x) :=

d
f( x)
dx

df2 ( x) :=

f( x)

dx

f(x)=0 :
10
8.13
6.25
f ( x)

4.38

df ( x)

2.5

df2( x)

0.63
1.5

1.13 0.75

0.38
0
1.25

0.38

0.75 1.13

1.5

3.13
5

x0 := -1.13
root( f( x0) , x0) = -1.23639108

f ( x)
df ( x)

1.5

1.36 1.22 1.08 0.94

df2( x)

0.8

0.66 0.52

Cutline( x0 , x1 , e) :=

x x0
1

x x1
2

h x -x
2

i2
while x - x

i-1

i+1

x i

( i)
f(x + h ) - f(x )
i
i
i
h f x
i

ii+1
h x

i-1

res

-x

xi

i

:
a := -1.5

b := -1.13

:
x0 := a

x1 := a +

-9

Cutline x0 , x1 , 10

b-a
1000

) = -1.23639108

:
x0 := b

x1 := b -

-9

Cutline x0 , x1 , 10

b-a
1000

) = -1.23639108

x0 := a
root( f( x0) , x0) = -1.23639108

:
.

,
, ,
..
.

3.4. f(x)=0
e = 10 -7 , . f(x)=0
x=j(x), .
. ,
.

x ( n +1) - x ( n ) <

1- q
e , q = max j ( x ) ,
q
x[ a ,b ]

[ a, b] - .
. ,

{ }

( n)
x
.

:
e
. f( x) = 0 x = f( x),
. , xn+ 1
:
x

n+ 1

( n)

=fx

:
x

n+ 1

-x

<

1-q
q

, q = max|f'(x)| [a,b].

:
f( x) := x - sin( 2 x) - 0.5

:
f(x)=0 :
2
1.5
1

f( z)
d
dz

0.5
f( z)

3 2.63 2.25 1.88 1.5 1.13 0.75 0.38 0 0.38 0.75 1.13 1.5 1.88 2.25 2.63 3
0.5
1
1.5
2
z

x := 1.5
root( f( x) , x) = 1.190031

,
, .

1.

f(x)=0
x=f(x) ,
f(x) 1.
f( x) := 0.5 asin( 0.5 - x) +

p
2
2
1.5

f ( z)

1
0.5

z
d
dz

3 2.63 2.25 1.88 1.5 1.13 0.75 0.38 0 0.38 0.75 1.13 1.5 1.88 2.25 2.63 3
0.5

f ( z)

1
1.5
2
z
1.5

df( x) :=
f ( z)

dz

absdf( x) := df( x)

x := 1

z
d

d
f( x)
dx

Given

f ( z)

x 0.7
x 1.34

0.5

q := absdf( Maximize( absdf, x) )


0.7 0.79 0.89 0.98 1.08 1.17 1.26 1.36 1.45

q = 0.921512

,
, ,
1 (q= 0.921512), .

SimpleIter ( f , q , x0 , e) :=

x x0
1

( 1)

x fx
2

i2
while
x

1-q
x -x
i i - 1 q e

i+1

( i)

fx

ii+1
x

res i - 2
x -x
i i-1

-7

SimpleIter f , q , 1 , 10

1.190031

48
=

6.093824 10- 9

-7

-7

SimpleIter f , q , 0.7 , 10

SimpleIter f , q , 0.9 , 10

-7

-7

SimpleIter f , q , 1.1 , 10

SimpleIter f , q , 1.3 , 10

)
)
)
)

1.190031

51
=

6.374842 10- 9

1.190031

49
=

6.573035 10- 9

1.190031

46
=

6.065536 10- 9

1.190031

46
=

8.092077 10- 9

-7

SimpleIter f , q , 0.8 , 10

-7

SimpleIter f , q , 1 , 10

-7

SimpleIter f , q , 1.2 , 10

1.190031

50
=

6.46335 10- 9

1.190031

48
=

6.093824 10- 9

1.190031

40
=

6.35404 10- 9



0.7
0.8
0.9
1
1.1
1.2
1.3


51
50
49
48
46
40
46

6.374842E-9
6.46335E-9
6.573035E-9
6.093824E-9
6.065536E-9
6.35404E-9
8.092077E-9

:
,
,
.
3.5.
.
( x * , y * ) e = 10 -5 .
:
x = j1 ( x, y )

y = j 2 ( x, y )

( x ( 0) , y ( 0) ) ,
( 4-5
). :
(
)? ,
( , -
) ( x ( n ) , y ( n ) )
. .

( n +1)

-x

( n)

<

( n)
1- q
e , x = ( x ( n ) , y ( n ) ) .
q

q, 0< q<1
(
*
*
( x, y ) ( x , y ) ):
j 1
j 1
( x, y ) +
( x, y ) q
x
y
j 2
j 2
( x, y ) +
( x, y ) q
x
y

:
, :
f( x, y) := 5 x - 6 y + 20 log( x) + 16
g( x , y) := 2 x + y - 10 log( y) - 4


f(x,y)=const g(x,y)=const
[ax,bx] x [ay,by] ,
( N M).
Contour Plot.
Fi,j Gi,j f(x,y) g(x,y)
(xi, yj ). i=0..N, j=0..M.
[ax,bx] x [ay,by] ,
,
(f(x,y)=0 g(x,y)=0).
ax := 0.1

bx := 1

ay := 0.1

by := 1

N M
y . , ,
.
N := 250

M := 200

i j :
i := 1 .. N

j := 1 .. M

hx hy :
hx :=

bx - ax
N

hy :=

by - ay
M

:
x := ax + hx i
i

y := ay + hy j
j

:
F

i, j

( i j)

:= f x , y

i, j

( i j)

:= g x , y

CreateMesh( f , 0.1 , 1 , 0.1 , 1 , 10 , 10)

CreateMesh( g , 0.1 , 1 , 0.1 , 1 , 10 , 10)

0.1<x<0.33, 0.4<y<0.6
=f1(x,y), y=g1(x,y)
6y- 5x- 16
20

f1 ( x , y) := 10

2x+ y- 4

g1( x , y) := 10

10

f1 g1 :
dxg1 ( x , y) :=

d
g1( x , y)
dx

absdxg1 ( x, y) := dxg1( x , y)

dxf1( x , y) :=

d
f1 ( x , y)
dx

absdxf1 ( x , y) := dxf1( x , y)

dyg1( x , y) :=

d
g1( x , y)
dy

absdyg1 ( x , y) := dyg1( x , y)

dyf1 ( x , y) :=

d
f1 ( x , y)
dy

absdyf1( x , y) := dyf1 ( x, y)

f1 g1:
Q1

i, j

( i j ) + absdyf1(xi , yj)

:= absdxf1 x , y

q1( x , y) := absdxf1( x , y) + absdyf1( x , y)

CreateMesh( q1 , 0.1 , 1 , 0.1 , 1 , 10 , 10)

Q2

i, j

( i j) + absdyg1(xi , yj)

:= absdxg1 x , y

q2( x , y) := absdxg1 ( x , y) + absdyg1( x , y)

CreateMesh( q2 , 0.1 , 1 , 0.1 , 1 , 10 , 10)

0.1<x<0.33, 0.4<y<0.6
,
f1(x):
absdxf1 ( 0.1 , 0.4 ) + absdyf1( 0.1 , 0.4 ) = 0.249791915409332
absdxf1 ( 0.1 , 0.6 ) + absdyf1( 0.1 , 0.6 ) = 0.286799492297872
absdxf1 ( 0.33 , 0.4 ) + absdyf1( 0.33 , 0.4 ) = 0.218815649030289
absdxf1 ( 0.33 , 0.6 ) + absdyf1( 0.33 , 0.6 ) = 0.251233979874316

< 1, ..
.
,
g1(x):
absdxg1 ( 0.1 , 0.4 ) + absdyg1 ( 0.1 , 0.4 ) = 0.315745335477254
absdxg1 ( 0.1 , 0.6 ) + absdyg1 ( 0.1 , 0.6 ) = 0.33062595469214
absdxg1 ( 0.33 , 0.4 ) + absdyg1( 0.33 , 0.4 ) = 0.351024107191239
absdxg1 ( 0.33 , 0.6 ) + absdyg1( 0.33 , 0.6 ) = 0.367567363694017

< 1, ..
.

Iter ( f , g, a , b , q , e) :=

xold 0
yold 0
xnew a
ynew b
k0
1-q

while xnew - xold + ynew - yold >

xold xnew
yold ynew
xnew f( xold , yold)
ynew g( xold , yold)
kk+ 1
xnew

ynew
res
xnew - xold + ynew - yold

res

-5

Iter f1 , g1 , 0.1 , 0.4 , 0.37 , 10

-5

Iter f1 , g1 , 0.33 , 0.4 , 0.37 , 10

0.1981

0.488

=
1.1937 10- 5

0.1981

0.488

=
4.6698 10- 6

-5

Iter f1 , g1 , 0.1 , 0.6 , 0.37 , 10

-5

Iter f1 , g1 , 0.33 , 0.6 , 0.37 , 10

0.1981
0.488

=
4.019 10- 6

0.1981
0.488

=
3.808 10- 6

-5

-5

f Iter f1 , g1 , 0.1 , 0.4 , 0.37 , 10


f Iter f1 , g1 , 0.1 , 0.6 , 0.37 , 10

)1 , Iter(f1 , g1 , 0.1 , 0.4 , 0.37 , 10- 5)2 = 1.31375935286115 10- 5


)1 , Iter(f1 , g1 , 0.1 , 0.6 , 0.37 , 10- 5)2 = -2.13393924965999 10- 5

-5

-5

f Iter f1 , g1 , 0.33 , 0.4 , 0.37 , 10


f Iter f1 , g1 , 0.33 , 0.6 , 0.37 , 10

)1 , Iter(f1 , g1 , 0.33 , 0.4 , 0.37 , 10- 5)2 = 2.53782046133466 10- 5


)1 , Iter(f1 , g1 , 0.33 , 0.6 , 0.37 , 10- 5)2 = 2.22947364765247 10- 5

-5

)1 , Iter(f1 , g1 , 0.1 , 0.4 , 0.37 , 10- 5)2 = 1.96420551201726 10- 5

-5

g Iter f1 , g1 , 0.1 , 0.4 , 0.37 , 10

)1 , Iter(f1 , g1 , 0.1 , 0.6 , 0.37 , 10- 5)2 = -4.30491950487166 10- 6

g Iter f1 , g1 , 0.1 , 0.6 , 0.37 , 10

-5

-5

g Iter f1 , g1 , 0.33 , 0.4 , 0.37 , 10


g Iter f1 , g1 , 0.33 , 0.6 , 0.37 , 10

)1 , Iter(f1 , g1 , 0.33 , 0.4 , 0.37 , 10- 5)2 = 3.25167641523905 10- 6


)1 , Iter(f1 , g1 , 0.33 , 0.6 , 0.37 , 10- 5)2 = -2.1477335474529 10- 6

:
. ,
.

Оценить