✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Programul dat este la metoda injumatatirii intrervalului:
Scrieti instructiunile ce lipsesc:
#include<iostream.h>
#include<math.h>
#define eps 0.00000000001
#define iter 200
double f(double x)
{
return x*x*x-2*x*x*cos(x)+x-3;
}
void main()
{
unsigned char i;
double x,x0,x1,a,b,y;
cout<<"a=";cin>>a;cout<<"b=";cin>>b;
i=0;x0=a;x1=b;x=x0;y=f(x);
if (
Answer Question 13)
{
while ( (i<=iter) && ((y<-eps) || (y>eps)) )
{
x=(x0+x1)/2 ;
y=f(x);
if (f(x0)*y<0) x1=x; else x0=x;
cout<<"\n\nf("<<x<<")="<<f(x)<<" la iteratia "<<(int)i;
i++;
}
if (i>iter) cout<<"problema nu se poate rezolva in nr.maxim de iteratii";
} else cout<<"interval invalid";
}
Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!