Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Метод Свенна / Свенна - дихотомии - Ньютона
.cpp#include<conio.h>
#include<math.h>
#include<iostream.h>
double f(double x)
{
if(x>=0) return (4*x*x*x-3*x*x*x*x);
else return (4*x*x*x+3*x*x*x*x);
//return (2*x*x-exp(x));
//return (x*x+2*x);
}
double dif(double x)
{ if(x>=0) return (12*x*x-12*x*x*x);
else return (12*x*x+12*x*x*x);
//return (4*x-exp(x));
//return (2*x+2);
}
double ddif(double x)
{ if(x>=0) return (24*x-36*x*x);
else return (24*x+36*x*x);
//return (4-exp(x));
//return (2);
}
void main()
{
//clrscr();
double a1,x,x1=-2,min,e=0.001;
int k=1; //////////////////////Niutona/////////////////
do
cout<<"\n"<<x1;
x:=x1;
x1=x-dif(x)/ddif(x);
k++;
while(fabs(x1-x)>e && fabs(dif(x1))>e);
cout<<'\n'<<x1<<'\n';
cout<<k;
getch();
}
Соседние файлы в папке Метод Свенна