Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

NỘI SUY

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

Bảng 1: tìm hàm nội suy của f(x), tính gần đúng f(3),f(3,5)

x 0 1 2 4 5 6 8 9 10 11
F(x) -5 10 2 -6 -8 5 10 -12 11 10
Bảng 2: tìm hàm nội suy của f(x), tính gần đúng f(-3),f(-3)

x -6 -4 -2 0 2 4 6 8 10 12
F(x) -6 11 1 -10 -6 5 12 -15 11 15
Bảng 3: tìm hàm nội suy của f(x), tính gần đúng f(1.5),f(2,5)

x 0 3 6 9 12 15 18 21 24 27
F(x) 10 -10 12 -6 -9 6 16 -10 1 15

Nội suy Lagrange:


Bảng 1:
W(x) = x(x-1)(x-2)(x-4)(x-5)(x-6)(x-8)(x-9)(x-10)(x-11)
W’(0) = (0-1)(0-2) (0-10)(0-4) (0-5)(0-6) (0-11)(0-8)(0-9) = -1900800
W’(1) = 1(1-2) ) (1-10)(1-4) (1-5)(1-6) (1-11)(1-8)(1-9) = 302400
W’(2) = 2(2-1)(2-10)(2-4)(2-5)(2-6)(2-11)(2-8)(2-9) = -142152
W’(4) = 4(4-1)(4-2) (4-5) (4-6) (4-8) (4-9) (4-10) (4-11) = 40320
W’(5) = 5(5-1)(5-2) (5-4) (5-6) (5-8) (5-9) (5-10) (5-11) = -21600
W’(6) = 6(6-1) (6-2) (6-4) (6-5) (6-8) (6-9) (6-10) (6-11) = 28800
W’(8) = 8(8-1) (8-2) (8-4) (8-5) (8-6) (8-9) (8-10) (8-11) = -48384
W’(9) = 9(9-1) (9-2) (9-4) (9-5) (9-6) (9-8) (9-10) (9-11) = 60480
W’(10) = 10(10-1) (10-2) (10-4) (10-5) (10-6) (10-8) (10-9)(10-11) = -172800
W’(11) = 11(11-1) (11-2) (11-4) (11-5) (11-6) (11-8) (11-9) (11-10) = 1247400
−5 10
L9(x) = x(x-1)(x-2)(x-4)(x-5)(x-6)(x-8)(x-9)(x-10)(x-11)( + +
x(−1900800) ( x−1)302400
2 −6 −8 5 10
+ + + + +
( x−2 ) (−142152) ( x−4)40320 ( x−5 ) (−21600) ( x−6) 28800 ( x−8 ) (−48384)
−12 11 10
+ + )
( x−9) 60480 ( x−10 ) (−172800) ( x−11)1247400

= x(x-1)(x-2)(x-4)(x-5)(x-6)(x-8)(x-9)(x-10)(x-11) *
f(3) = 3(3-1)(3-2)(3-4)(3-5)(3-6)(3-8)(3-9)(3-10)(3-11) * [(53^2 - 19283 + 945350)/(9453503(3-
1)(3-2)(3-4)(3-5)(3-6)(3-8)(3-9)(3-10)(3-11))]
= 321*(-1)(-2)(-3)(-5)(-6)(-7)(-8) * [(59 - 19283 + 945350)/(945350321(-1)(-2)(-3)(-5)(-6)(-7)(-
8))]
= -1512 * [(59 - 19283 + 945350)/(945350321(-1)(-2)(-3)(-5)(-6)(-7)(-8))]
= -1512 * [(45 - 5784 + 945350)/(945350321(-1)(-2)(-3)(-5)(-6)(-7)(-8))]
= -1512 * [939611/945350321(-1)(-2)(-3)(-5)(-6)(-7)(-8)]
= 0.49090909

f(3.5) = 3.5(3.5-1)(3.5-2)(3.5-4)(3.5-5)(3.5-6)(3.5-8)(3.5-9)(3.5-10)(3.5-11) * [(53.5^2 - 19283.5


+ 945350)/(9453503.5(3.5-1)(3.5-2)(3.5-4)(3.5-5)(3.5-6)(3.5-8)(3.5-9)(3.5-10)(3.5-11))]
= 3.52.51.5*(-0.5)(-1.5)(-2.5)(-4.5)(-5.5)(-6.5)(-7.5) * [(512.25 - 19283.5 +
945350)/(9453503.52.51.5(-0.5)(-1.5)(-2.5)(-4.5)(-5.5)(-6.5)(-7.5))]
= -5,201.875 * [(61.25 - 6748 + 945350)/(9453503.52.51.5(-0.5)(-1.5)(-2.5)(-4.5)(-5.5)(-6.5)(-
7.5))]
= -5,201.875 * [939,663/9453503.52.51.5(-0.5)(-1.5)(-2.5)(-4.5)(-5.5)(-6.5)(-7.5)]
= −2.279891

Vậy, f(3) = 0.49090909 và f(3.5) = −2.279891

Bảng 2:
W(x)=(x+6)(x+4)(x+2)(x)(x−2)(x−4)(x−6)(x−8)(x−10)(x−12)

𝑊′(−6)=(−6+4)(−6+2)(−6+0)(−6−2)(−6−4)(−6−6)(−6−8)(−6−10)(−6−12)=−10321920

𝑊′(−4)=(−4+6)(−4+2)(−4+0)(−4−2)(−4−4)(−4−6)(−4−8)(−4−10)(−4−12)=−7741440

𝑊′(−2)=(−2+6)(−2+4)(−2+0)(−2−2)(−2−4)(−2−6)(−2−8)(−2−10)(−2−12)=7741440

𝑊′(0)=(0+6)(0+4)(0+2)(0−2)(0−4)(0−6)(0−8)(0−10)(0−12)=−1900800

𝑊′(2)=(2+6)(2+4)(2+2)(2−0)(2−4)(2−6)(2−8)(2−10)(2−12)=−7741440
𝑊′(4)=(4+6)(4+4)(4+2)(4−0)(4−2)(4−4)(4−6)(4−8)(4−10)=7741440

𝑊′(6)=(6+6)(6+4)(6+2)(6−0)(6−2)(6−4)(6−6)(6−8)(6−10)=−10321920

𝑊′(8)=(8+6)(8+4)(8+2)(8−0)(8−2)(8−4)(8−6)(8−8)(8−10)=7741440

𝑊′(10)=(10+6)(10+4)(10+2)(10−0)(10−2)(10−4)(10−6)(10−8)(10−10)=−10321920

𝑊′(12)=(12+6)(12+4)(12+2)(12−0)(12−2)(12−4)(12−6)(12−8)(12−10)=7741440

L9(x) = W(x)=(x+6)(x+4)(x+2)(x)(x−2)(x−4)(x−6)(x−8)(x−10)(x−12)
−6 11 1 −6 5
( + + + + +
( x +6)(−10321920) ( x +4 )(−7741440) ( x ∓ 2 ) 7741440 ( x−2) 7741440 ( x−4 ) 7741440
+12 −15 11 12
+ + +
( x−6 ) (−10321920) ( x−8) 7741440 ( x−10 ) (−10321920) ( x−12)7741440

F(-3) = 11.24
F(-3.5) = 13.40
Phương pháp Largrange cách đều:
Bảng 2:
x+6
Đặt t = => x = 2t-6.
2

t(t−1)(t−2)(t−3)(t−4 )(t−5)( t−6)(t−7)(t−8)(t−9)


L9(2t-6) = (
9!
−6∗9 C 0 11∗9 C 1 1∗9 C 2 −10∗9 C 3 −6∗9 C 4 5∗9C 6 12∗9 C 6 −15∗9 C 7 11∗9 C 8 −6∗9
− + − + − + − + −
t−0 t−1 t−2 t−3 t−4 t−5 t−6 t−7 t−8 t−9
99 36 840 756 630 1008 540 99 6
+
( ) ( )( )( ) ( ) ( )( ) ( )
L9(x) = -6 - x +6 x +6 + x+ 6 - x+ 6 - x+ 6 + x+ 6 + x+ 6 - x+ 6 + x+ 6
2 3 4 5 6 7 8 9

2 2 2 2 2 2 2 2 2

L9(-3) = 11.24
L9(-3.5 = 13.40
Bảng 3:
x
Đặt t = => x= 3t
3
L9(2t) = t(t-1)(t-2)(t-3)(t-4)(t-5)(t-6)(t-7)(t-8)(t-9)(
10∗9C 0 −10∗9 C 1 12∗9 C 2 −6∗9 C 3 −9∗9 C 4 6∗9C 6 16∗9 C 6 −10∗9 C 7 1∗9C 8 15∗9 C
− + − + − + − + −
t−0 t−1 t−2 t−3 t−4 t−5 t−6 t−7 t−8 t−9
L9(x) =

F(1.5) = -42.359947
Nội suy Anken:
Bảng 1: f(3.5)

3.50 -1.00 -2.00 -4.00 -5.00 -6.00 -8.00 -9.00 -10.00 -11.00 -6652800.00
1.00 2.50 -1.00 -3.00 -4.00 -5.00 -7.00 -8.00 -9.00 -10.00 756000.00
2.00 1.00 1.50 -2.00 -3.00 -4.00 -6.00 -7.00 -8.00 -9.00 -217728.00
4.00 3.00 2.00 -0.50 -1.00 -2.00 -4.00 -5.00 -6.00 -7.00 -20160.00
5.00 4.00 3.00 1.00 -1.50 -1.00 -3.00 -4.00 -5.00 -6.00 32400.00
6.00 5.00 4.00 2.00 1.00 -2.50 -2.00 -3.00 -4.00 -5.00 -72000.00
8.00 7.00 6.00 4.00 3.00 2.00 -4.50 -1.00 -2.00 -3.00 217728.00
9.00 8.00 7.00 5.00 4.00 3.00 1.00 -5.50 -1.00 -2.00 -332640.00
10.00 9.00 8.00 6.00 5.00 4.00 2.00 1.00 -6.50 -1.00 1123200.00
11.00 10.00 9.00 7.00 6.00 5.00 3.00 2.00 1.00 -7.50 -9355500.00
f(3.500000) = (0.000001 + 0.000013 + -0.000009 + 0.000298 + -0.000247 + -0.000069 +
0.000046 + 0.000036 + 0.000010 + -0.000001 ) * -29692.750000 = -2.279892
Bảng 3:

1.50 -3.00 -6.00 -9.00 -12.00 -15.00 -18.00 -21.00 -24.00 -27.00 -10713850880.00
3.00 -1.50 -3.00 -6.00 -9.00 -12.00 -15.00 -18.00 -21.00 -24.00 -1190427904.00
6.00 3.00 -4.50 -3.00 -6.00 -9.00 -12.00 -15.00 -18.00 -21.00 892820864.00
9.00 6.00 3.00 -7.50 -3.00 -6.00 -9.00 -12.00 -15.00 -18.00 -637729216.00
12.00 9.00 6.00 3.00 -10.50 -3.00 -6.00 -9.00 -12.00 -15.00 595213952.00
15.00 12.00 9.00 6.00 3.00 -13.50 -3.00 -6.00 -9.00 -12.00 -765275008.00
18.00 15.00 12.00 9.00 6.00 3.00 -16.50 -3.00 -6.00 -9.00 1403004288.00
21.00 18.00 15.00 12.00 9.00 6.00 3.00 -19.50 -3.00 -6.00 -3868890624.00
24.00 21.00 18.00 15.00 12.00 9.00 6.00 3.00 -22.50 -3.00 17856417792.00
27.00 24.00 21.00 18.00 15.00 12.00 9.00 6.00 3.00 -25.50 -182135472128.00

f(1.5) = (-0.000000 + 0.000000 + 0.000000 + 0.000000 + -0.000000 + -0.000000 + 0.000000 +


0.000000 + 0.000000 + -0.000000 ) * -1987104000.000000 = -42.359947

#include <stdio.h>
#include <math.h>

#define EPS 1e-3

float table[10], value[10], result[10][10], temp[10];


int n;
float c;

void Input(float data[]) {


for (int i = 0; i < n; i++) {
scanf("%f", &data[i]);
}
}

void PrintTable() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
printf("%.2f ", result[i][j]);
}
printf("\n");
}
printf("\n");
}

void PrintCol() {
for (int i = 0; i < n; i++) {
printf("%.2f\n", temp[i]);
}
printf("\n");
}

void FinalCol() {
float multi = 1.0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
multi *= result[i][j];
}
temp[i] = multi;
multi = 1.0;
}
}

float FindW() {
float multi = 1.0;
for (int i = 0; i < n; i++) {
multi *= result[i][i];
}
return multi;
}

void NoisuyAyken() {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j == i) {
result[i][j] = c - table[i];
} else {
result[i][j] = table[i] - table[j];
}
}
}
PrintTable();
FinalCol();
PrintCol();
float W = FindW();
float sum = 0;
printf("f(%f) = (", c);
for (int i = 0; i < n; i++) {
sum += value[i] / temp[i];
printf("%f ", value[i] / temp[i]);
if (i < n - 1) {
printf("+ ");
}
}
printf(") * %f = %f", W, sum * W);
}

int main() {
printf("nhap n : ");
scanf("%d", &n);
printf("nhap c: ");
scanf("%f", &c);
printf("nhap x: ");
Input(table);
printf("nhap f(x): ");
Input(value);
NoisuyAyken();
return 0;
}
Nội suy Newton:
Bảng 2:
Bảng sai phân:

xi f(xi) ∆2f(xi) ∆3f(xi) ∆4f(xi) ∆2f(xi) ∆2f(xi) ∆2f(xi) ∆2f(xi) ∆2f(xi) ∆2f(xi)
-6 -6
-4 11 17
-2 1 -10 -27
0 -10 -11 -1 26
2 -6 4 15 16 -10
4 5 1 7 -8 -24 -14
6 12 7 -4 -11 -3 21 35
8 -15 -27 -34 -30 -19 -16 -37 -72
10 11 26 53 87 117 136 152 189 261
12 15 4 22 75 -162 -279 -415 -567 -756 -1017

x+6 ( x +6)(x +4 ) ( x +6)(x +4 )(x+2) ( x +6)(x +4 )(x+2) x


L(x) = -6 + 17( ¿-27( ¿+26( ¿ -10( ¿-14(
1! 2! 3! 4!
( x +6)(x +4 )(x+2) x( x−2) ( x +6)(x +4 )(x+2) x( x−2)(x −4)
¿+35( ¿-72(
5! 6!
( x +6)(x +4 )(x+2) x( x−2)(x −4)( x −6)
¿+261(
7!
( x +6)(x +4 )(x+2) x( x−2)(x −4)( x −6)( x−8)
¿-1017(
8!
( x +6)(x +4 )(x+2) x( x−2)(x −4)( x −6)( x−10)
¿
9!
#include <stdio.h>
#include <math.h>
#define EPS 1e-3

float table[10], value[10], result[10][10];


int n;

void Input( float data[] ) {


for( int i = 0; i < n; i++ ) {
scanf("%f", &data[i] );
}
}

void IN() {
int k = 0;
for( int i = 0 ; i < n; i++ ) {
for( int j = 0; j < n; j++ ) {
printf("%d\t ", (int)result[i][j] );
}
printf("\n");
}
}

void Newton() {
int cnt = 0;
int k = 0;
do {
for( int i = 0; i < n; i++ ) {
if ( cnt == 0 ) {
result[i][k] = value[i];
} else if ( i < cnt ) {
result[i][k] = 0;
} else {
result[i][k] = result[i][k-1] - result[i-1][k-1];
}
}
cnt++;
k++;
} while( cnt < n );
}

int main() {
printf("nhap n : ");
scanf("%d", &n );
printf("nhap cac gia tri cua x: ");
Input( table );
printf("nhap gia tri cua f(x): ");
Input( value );
Newton();
IN();
}

You might also like