You are on page 1of 6

5.

y x
,X G2 V

fx

5- 1

y = f (x ) y x0
x1 y 0 y1

y1
y

gx

y0

g ( x ) = ax + b f ( x )

X
x0

ax0 + b = y 0

x1

5- 1

ax1 + b = y1
g ( x ) a b
A( x0 , y 0 ) B ( x1 , y1 ) y = f (x )

g ( x ) = y0 +

g ( x ) = y0 (

y1 y 0
( x x0 )
x1 x0

x x
x1 x
) + y1 ( 0
)
x1 x0
x0 x1

5- 1 x0 x1 g (x ) f (x )
x

x0 x1

x E1T),Xk.BnE,X&

x0 x1

y 0 y1 x h,X

M_GetValue: .MACRO Index


// Index=0,1,2,3,4,5,6;
//Index 0
r1=Index;
r1=r1 lsl 1;
r1+=bp;
//
r3=[r1++];
//
r4=[r1];
.ENDM
M_StoreValue:
.MACRO Index
// Index=0,1,2,3,4,5,6;
//Index 0
r3=Index;
r3=r3 lsl 1;
r3+=bp;
//
[r3++]=r1;
// r1,r2
[r3]=r2;
.ENDM
//======================================================
// :
F_LinearInsert
// :
(x-x0)x(y1-y0)/(x1-x0)+y0.
// :
x0,y0,x1,y1,x
// :
y->r1,r2
// :
r1,r2,r3,r4;
// :
r1,r2,r3,r4,bp,sp;
// :
14;
//======================================================
.public F_LinearInsert;
.public _F_LinearInsert;
.code
F_LinearInsert:
_F_LinearInsert: .proc
push bp to [sp];
bp=sp;
bp+=4;
//bp x0
M_GetValue 0;
// x0
push r3,r4 to [sp];
M_GetValue 4;
// x
push r3,r4 to [sp];
call __subf2;
// x-x0
sp+=4;

M_StoreValue 4;
M_GetValue 1;
push r3,r4 to [sp];
M_GetValue 3;
push r3,r4 to [sp];
call __subf2;
sp+=4;
M_StoreValue 3;
M_GetValue 0;
push r3,r4 to [sp];
M_GetValue 2;
push r3,r4 to [sp];
call __subf2;
sp+=4;
M_StoreValue 2;
M_GetValue 4;
push r3,r4 to [sp];
M_GetValue 3;
push r3,r4 to [sp];
call __mulf2;
sp+=4;
M_StoreValue 4;
M_GetValue 2;
push r3,r4 to [sp];
M_GetValue 4;
push r3,r4 to [sp];
call __divf2;
sp+=4;
push r1,r2 to [sp];
M_GetValue 1;
push r3,r4 to [sp];
call __addf2;
sp+=4;
pop bp from [sp];
retf;
.endp

//x-x0 x
// y0
// y1
// y1-y0
//y1-y0 y1
// x0
// x1
// x1-x0
//x1-x0 x1
// x x-x0
// y1 y1-y0
//(x-x0)x(y1-y0)
//(x-x0)x(y1-y0) x
// x1 x1-x0
// x(x-x0)x(y1-y0)
//(x-x0)x(y1-y0)/(x1-x0)

// y0
//(x-x0)x(y1-y0)/(x1-x0)+y0

5.2
521

5- 2

g (x )
A

f (x )

y = f (x )
A( x0 , y 0 ) B ( x1 , y1 )

X
x0

C ( x2 , y 2 )

x1

x2

5- 2

g (x )

g ( x ) = ax 2 + bx + c

g ( xi ) = f ( x i )

i = 0,1,2

ax02 + bx0 + c = y 0
ax12 + bx1 + c = y1
ax22 + bx 2 + c = y 2
g (x ) a b c
g (x ) g (x )
LagrangeNewton

522
( x0 , y 0 ) ( x1 , y1 ) ( x 2 , y 2 ) x "h,X

( x0 , y 0 ) ( x1 , y1 ) L01

L01 = y 0 +

y1 y 0
( x x0 )
x1 x0

8.1

( x0 , y 0 ) ( x 2 , y 2 ) L02

L02 = y 0 +

y 2 y0
( x x0 )
x 2 x0

8.2

( x1 , L01 ) ( x 2 , L02 ) L012

L012 = L01 +

L02 L01
( x x1 )
x 2 x1

8.3

8.18.28.3

L012

y 2 y 0 y1 y 0
x x x x
y1 y 0
0
1
0
( x x0 )( x x1 )
( x x0 ) + 2
= y0 +
x1 x0
x 2 x1

8.4

L012 x ,X`DJ$Cs-&G2

L012 ( xi ) = y i

(i = 0,1,2)

L012 g (x )
8.4 ( y1 y 0 ) ( x1 x 0 )
8.3 g (x )
8.1

8.28.3

x h!b

[x0 , x2 ]

//======================================================
// :
F_QuadraticInsert
// :

//
1 L01=y0+(y1-y0)(x-x0)/(x1-x0)
//
2 L02=y0+(y2-y0)(x-x0)/(x2-x0)
//
3 L012=L01+(L02-L01)(x-x1)/(x2-x1)
// :
x0,y0,x1,y1,x2,y2,x
// :
y->r1,r2
// :
r1,r2,r3,r4;
// :
r1,r2,r3,r4,bp,sp;
// :
28;
//======================================================
.public F_QuadraticInsert;
.public _F_QuadraticInsert;
F_QuadraticInsert:
_F_QuadraticInsert:
.proc
push bp to [sp];

bp=sp+4;
M_GetValue 6;
push r3,r4 to [sp];
M_GetValue 3;
push r3,r4 to [sp];
M_GetValue 2;
push r3,r4 to [sp];
M_GetValue 1;
push r3,r4 to [sp];
M_GetValue 0;
push r3,r4 to [sp];
call F_LinearInsert;
sp+=10;
M_StoreValue 3;
M_GetValue 6;
push r3,r4 to [sp];
M_GetValue 5;
push r3,r4 to [sp];
M_GetValue 4;
push r3,r4 to [sp];
M_GetValue 1;
push r3,r4 to [sp];
M_GetValue 0;
push r3,r4 to [sp];
call F_LinearInsert;
sp+=10;
M_StoreValue 5;
M_GetValue 6;
push r3,r4 to [sp];
M_GetValue 5;
push r3,r4 to [sp];
M_GetValue 4;
push r3,r4 to [sp];
M_GetValue 3;
push r3,r4 to [sp];
M_GetValue 2;
push r3,r4 to [sp];
call F_LinearInsert;
sp+=10;
pop bp from [sp];
retf;
.endp

//bp x0
// x
// y1
// x1
// y0
// x0
// L01
//L01 y1
// x
// y2
// x2
// y0
// x0
// L02
//L02 y2
// x
// L02
// x2
// L01
// x1
// L012

You might also like