Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
11
Добавлен:
17.04.2015
Размер:
15.93 Кб
Скачать

// Вычисление значений полинома по схеме Горнера.

//

// a0 a1 a2 … ..an

// + b1*x b2*x .. bn-1*x

//__________________________________________________

//

// b0 b1 b2 ... bn = P(x)

#include <stdio.h>

#include <stdlib.h>

#include<math.h>

float Gorner(float a[],float b[],int n,float x);

int main()

{

int i,n;

float x,s;

printf("Ввести степень полинома N= и значение Х \n");

scanf( "%i%f",&n,&x);

float a[n],b[n];

printf("Ввести коэффициенты уравнения А \n");

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

scanf("%f",&a[i]);

s=Gorner(a,b,n,x);

printf("Значение полинома при X= %f Y= %f \n",x,s);

printf("Коэффициенты схемы Горнера\n");

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

printf("%6.2f ",b[i]);

system("pause");

return 0;

}

float Gorner(float a[],float b[],int n,float x)

{

b[0]=a[0];

for (int i=1;i<=n;i++)

b[i]=b[i-1]*x+a[i];

return (b[n]);

}

//Вводим 4 2

// 1 -2 3 4 -1

//1 0 3 10 19=P(3)

//Вводим 3 3

// 3 2 -5 7

// 3 11 28 91=P(3)

//Вычисление обратных корню квадратному величин

#include <stdio.h>

#include <stdlib.h>

int main()

{

float x,y,y1;

printf("Ввести X= Y= \n");

scanf("%f%f",&x,&y);

for (int i=1;i<10;i++){ y1=y*(3-x*y*y)/2;

y=y1;

printf("y=%f \n",y1);}

printf("Значение Функции равно %f \n",y1);

system("pause");

return 0;

}

//Вводим 3 0.25

//Ответ 0.57

//Вычисление кубического корня

//Yn+1=(2*Yn+x/Yn^2)/3

#include <stdio.h>

#include <stdlib.h>

int main()

{

float x,y,y1;

printf("Ввести X= Y= \n");

scanf("%f%f",&x,&y);

for (int i=1;i<10;i++){ y1=(2*y+x/y/y)/3;

y=y1;

printf("y=%f \n",y1);}

printf("Значение Функции равно %f \n",y1);

system("pause");

return 0;

}

//Вводим 10 3

//Ответ 2.154