1. Trang chủ
  2. » Công Nghệ Thông Tin

A textbook of Computer Based Numerical and Statiscal Techniques part 61 pdf

10 175 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 59,16 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Start of the program to interpolate the given data Step 2.. Input the value of n number of terms Step 3.. Input the array ax for data of x Step 4.. Input the array ay for data of y Step

Trang 1

for(i = 0; i < n–j; i++)

{

diff[i][j] = diff[i+1][j–1]–diff[i][j–1];

}

}

i = 0;

do

{

i++;

}while(ax[i]<x);

i– –;

p = (x–ax[i])/h;

y1 = p*diff[i–1][1];

y2 = p*(p+1)*diff[i–1][2]/2;

y3 = (p+1)*p*(p–1)*diff[i–2][3]/6;

y4 = (p+1)*p*(p-1)*(p+2)*diff[i–3][4]/24

y = ay[i] + y1 + y2 + y3 + y4;

printf(“when x = %6.4f, y = %6.8f”, x, y);

printf(“press enter to exit”);

getch();

}

OUTPUT

Enter the no of term –7

Enter the value in form of x–

Enter the value of x1 – 1.00

Enter the value of x2 – 1.05

Enter the value of x3 – 1.10

Enter the value of x4 – 1.15

Enter the value of x5 – 1.20

Enter the value of x6 – 1.25

Enter the value of x7 – 1.30

Enter the value in the form of y–

Enter the value of y1 – 2.7183

Enter the value of y2 – 2.8577

Enter the value of y3 – 3.0042

Enter the value of y4 – 3.1582

Enter the value of y5 – 3.3201

Enter the value of y6 – 3.4903

Enter the value of y7 – 3.6693

Trang 2

Enter the value of x for

Which you want the value of y – 1.35

When x = 1.35, y = 3.8483

Press enter to exit

13.20 ALGORITHM FOR STIRLING’S METHOD

Step 1 Start of the program to interpolate the given data

Step 2 Input the value of n (number of terms)

Step 3 Input the array ax for data of x

Step 4 Input the array ay for data of y

Step 5 Compute h = ax[1] – ax[0]

Step 6 For i = 0; i < n–1; i++

Step 7 diff[i] [1] = ay[i+1]–ay[i]

Step 8 End of the loop i

Step 9 for j = 2; j <= 4; j++

Step 10 for i = 0; i < n–j; i++

Step 11 diff [i][j] = diff [i+1] [j–1] – diff [i] [j–1]

Step 12 End of the loop i

Step 13 End of the loop j

Step 14 i = 0

Step 15 Repeat step 16 until ax[i] < x

Step 16 i = i+1

Step 17 i = i–1

Step 18 p = (x – ax[i])/h

Step 19 y1 = p * (diff [i][1] + diff [i – 1][1])/2

Step 20 y2 = p * p * diff[i – 2][2]/2

Step 21 y3 = p * (p *p–1)* (diff[i – 1][3] + diff[i–2][3])/6

Step 22 y4 = p * p * (p * p–1) * diff [i – 2] [4]/24

Step 23 y = ay[i] + y1 + y2 + y3 + y4

Step 24 Print the output x, y

Step 25 End of the program

13.21 PROGRAMMING FOR STIRLING’S METHOD

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<string.h>

#include<process.h>

Trang 3

void main()

{

int n;

int i, j;

float ax[10];

float ay[10];

float h;

float p;

float x, y;

float diff[20][20];

float y1, y2, y3, y4;

clrscr();

printf(“enter the no of term–“);

scanf(“%d”, & n);

printf(“enter the no in the form of x–”);

for(i = 0; i < n; i++)

{

printf(enter the value of x%d”, i+1);

scanf(“%f”, & ax[i]);

}

printf(“enter the value in the form of y”);

for(i = 0; i < n; i++)

}

printf(“enter the value of y%d “, i+1);

scanf(“%f”, & ay[i];

}

printf(“enter the value of x for”);

printf(“which you want the value of y”);

scanf(“%f”, %x);

h = ax[1] –ax[0];

for(i = 0; i < n–1; i++)

{

diff[i][1] = ay[i+1]–ay[i];

}

for(j = 2; j <= 4; j++)

{

for(i = 0; i < n–j; i++)

{

diff[i][j] = diff[i+1][j–1]–diff[i][j–1];

}

}

Trang 4

i = 0;

do

{

i++;

}while(ax[i] < x);

i– –;

p = (x–ax[i])/h;

y1 = p*(diff[i][1]+diff[i–1][1]/2;

y2 = p*(p)*diff[i–1][2]/2;

y3 = p*(p*p–1)*(diff[i–1][3]+diff[i–2][3])/6;

y4 = p*p*(p*p–1)*diff[i–2][4]/24;

y = ay[i] + y1 + y2 + y3 + y4;

printf(“when x = %6.4f, y = %6.8f”, x, y);

printf(“press enter to exit”);

getch();

}

OUTPUT

Enter the no of term –7

Enter the value in form of x

Enter the value of x1 – 61

Enter the value of x2 – 62

Enter the value of x3 – 63

Enter the value of x4 – 64

Enter the value of x5 – 65

Enter the value of x6 – 66

Enter the value of x7 – 67

Enter the value in the form of y–

Enter the value of y1 – 1.840431

Enter the value of y2 – 1.858928

Enter the value of y3 – 1.877610

Enter the value of y4 – 1.896481

Enter the value of y5 – 1.915541

Enter the value of y6 – 1.934792

Enter the value of y7 – 1.954237

Enter the value of x for

Which you want the value of y – 0.6440

When x = 0.6440, y = 1.90408230

Press enter to continue

Trang 5

13.22 ALGORITHM FOR BESSEL’S METHOD

Step 1 Start of the program to interpolate the given data

Step 2 Input the value of n (number of terms)

Step 3 Input the array ax for data of x

Step 4 Input the array ay for data of y

Step 5 Compute h = ax[1] – ax[0]

Step 6 For i = 0; i < n–1; i++

Step 7 diff[i] [1] = ay[i+1]–ay[i]

Step 8 End of the loop i

Step 9 for j = 2; j <= 4; j++

Step 10 for i = 0; i < n–j; i++

Step 11 diff [i][j] = diff [i+1] [j–1] – diff [i] [j–1]

Step 12 End of the loop i

Step 13 End of the loop j

Step 14 i = 0

Step 15 Repeat step 16 until ax[i] < x

Step 16 i = i+1

Step 17 i = i–1

Step 18 p = (x – ax[i])/h

Step 19 y1 = p * (diff [i][1])

Step 20 y2 = p * (p–1) * (diff [i] [2] + diff [i – 1] [2]/4

Step 21 y3 = p * (p-1) * (p–0.5) * (diff [i – 1] [3])/6

Step 22 y4 = p * (p+1) * (p–2) * (p–1) * (diff [i – 2] [4] + diff [i – 1][4])/48

Step 23 y = ay[i] + y1 + y2 + y3 + y4

Step 24 Print the output x, y

Step 25 End of the program

13.23 PROGRAMMING FOR BESSEL’S METHOD

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<string.h>

#include<process.h>

void main()

{

int n;

int i, j;

Trang 6

float ax[10];

float ay[10];

float h;

float p;

float x, y;

float diff[20][20];

float y1, y2, y3, y4;

clrscr();

printf(“enter the no of term–“);

scanf(“%d”, & n);

printf(“enter the no in the form of x–”);

for(i = 0; i < n; i++)

{

printf(enter the value of x%d”, i+1);

scanf(“%f’, & ax[i]);

}

printf(“enter the value in the form of y”);

for(i = 0; i < n; i++)

{

printf(“enter the value of y%d “, i+1);

scanf(“%f”, & ay[i]);

}

printf(“enter the value of x for”);

printf(“which you want the value of y”);

scanf(“%f”,%x);

h = ax[1]–ax[0];

for(i = 0; i < n–1; i++)

{

diff[i][1] = ay[i+1]–ay[i];

}

for(j = 2; j <= 4; j++)

{

for(i = 0; i < n–j; i++)

{

diff[i][j] = diff[i+1][j–1]–diff[i][j–1];

}

}

i=0;

do

{

Trang 7

}while(ax[i] < x);

i– –;

p = (x–ax[i])/h;

y1 = p*(diff[i][1]);

y2 = p*(p–1)*(diff[i][2]+diff[i–1][2])/4/2;

y3 = p*(p–1)*(p–.5)*(diff[i–1][3])/6;

y4 = (p+1)*p*(p–1)*(p–2)*(diff[i–2][4]+diff[i–1][4])/48;

y = ay[i] + y1 + y2 + y3 + y4;

printf(“when x = %6.4f, y = %6.8f”, x, y);

printf(“press enter to exit”);

getch();

}

OUTPUT

Enter the no of term –7

Enter the value in form of x–

Enter the value of x1 – 61

Enter the value of x2 – 62

Enter the value of x3 – 63

Enter the value of x4 – 64

Enter the value of x5 – 65

Enter the value of x6 – 66

Enter the value of x7 – 67

Enter the value in the form of y–

Enter the value of y1 – 1.840431

Enter the value of y2 – 1.858928

Enter the value of y3 – 1.877610

Enter the value of y4 – 1.896481

Enter the value of y5 – 1.915541

Enter the value of y6 – 1.934792

Enter the value of y7 – 1.954237

Enter the value of x for

Which you want the value of y – 0.6440

When x = 0.6440, y = 1.90408230

Press enter to continue

13.24 ALGORITHM FOR LAPLACE EVERETT METHOD

Step 1 Start of the program to interpolate the given data

Step 2 Input the value of n (number of terms)

Trang 8

Step 3 Input the array ax for data of x

Step 4 Input the array ay for data of y

Step 5 Compute h = ax[1] – ax[0]

Step 6 For i = 0; i < n–1; i++

Step 7 diff[i] [1] = ay[i+1]–ay[i]

Step 8 End of the loop i

Step 9 for j = 2; j <= 4; j++

Step 10 for i = 0; i < n–j; i++

Step 11 diff [i][j] = diff [i+1] [j-1] – diff [i] [j-1]

Step 12 End of the loop i

Step 13 End of the loop j

Step 14 i = 0

Step 15 Repeat step 16 until ax[i] < x

Step 16 i = i+1

Step 17 i = i–1

Step 18 p = (x –ax[i])/h

Step 19 q = 1–p

Step 20 y1 = q * (ay [i])

Step 21 y2 = q * (q * q–1) * (diff [i–1] [2])/6

Step 22 y3 = q * (q * q–1) * (q *q–4) * (diff [i–2] [4])/120

Step 23 py 1 = p * ay [i + 1]

Step 24 py2 = ay[i] + y1 + y2 + y3 + y4

Step 25 Print the output x, y

Step 26 End of the program

13.25 PROGRAMMING FOR LAPLACE EVERETT METHOD

#include<stdio.h>

#include<conio.h>

#include<math.h>

#include<string.h>

#include<process.h>

void main()

{

int n;

int i, j;

float ax[10];

float ay[10];

float h;

Trang 9

float p, q;

float x, y = 0;

float nr, dr;

float diff[20][20];

float y1, y2, y3, y4;

float py1, py2, py3, py4;

clrscr();

printf(“enter the no of term–“);

scanf(“%d”, & n);

printf(“enter the value in the form of x–”);

for(i = 0; i < n; i++)

{

printf(“enter the value of x%d”, i+1);

scanf(“%f”, & ax[i]);

}

printf(“enter the value in the form of y”);

for(i = 0; i < n; i++)

{

printf(“enter the value of y%d “, i+1);

scanf(“%f”,& ay[i]);

{

printf(“enter the value of x for”);

printf(“which you want the value of y”);

scanf(“%f”, %x);

h = ax[1]–ax[0];

for(i = 0; i < n–1; i++)

{

diff[i][1] = ay[i+1]–ay[i];

}

for(j = 2; j < = 4; j++)

{

for(i = 0; i < n–j; i++)

{

diff[i][j] = diff[i+1][j–1]–diff[i][j–1];

}

}

i = 0;

do

{

i++;

Trang 10

}while(ax[i] < x);

i– –;

p = (x–ax[i])/h;

q = 1–p;

y1 = q*(ay[i]);

y2 = q*(q*q–1)*(diff[i–1][2])/6;

y3 = q*(q*q–1)*(q*q–4)*(diff[i–2][4])/120;

py1 = p*ay[i+1];

py2 = p*(p*p–1)*diff[i][2]/6;

py3 = p*(p*p–1)*(p*p–4)*(diff[i–1][4])/120

y = y1 + y2 + y3 + y4 + py1 + py2 + py3;

printf(“when x = %6.4f, y = %6.8f”, x, y);

printf(“press enter to exit”);

getch();

}

OUTPUT

Enter the no of term –7

Enter the value in form of x–

Enter the value of x1 – 1.72

Enter the value of x2 – 1.73

Enter the value of x3 – 1.74

Enter the value of x4 – 1.75

Enter the value of x5 – 1.76

Enter the value of x6 – 1.78

Enter the value of x7 – 1.79

Enter the value in the form of y–

Enter the value of y1 – 1790661479

Enter the value of y2 – 1772844100

Enter the value of y3 – 1755204006

Enter the value of y4 – 1737739435

Enter the value of y5 – 1720448638

Enter the value of y6 – 1703329888

Enter the value of y7 – 1686381473

Enter the value of x for

Which you want the value of y – 1.7475

When x = 1.7475, y = 17420892

Press enter to exit

Ngày đăng: 04/07/2014, 15:20

TỪ KHÓA LIÊN QUAN