float funcion(float x)
{
return pow(x,3)+(6*(pow(x,2)))+(2*(x))+(8);
}
float Biseccion(float A, float C)
{
//Variables
float B;
float Fa,Fb,Fc;
B = (A + C)/2.0;
for (int i=0;i<0.0001;i++){
//funcion a
Fa=(pow(A,3))+(6*(pow(A,2)))+(2*(A))+(8);
//funcion b
Fb=(pow(B,3))+(6*(pow(B,2)))+(2*(B))+(8);
//funcion c
Fc=(pow(C,3))+(6*(pow(C,2)))+(2*(C))+(8);
}
//mostrar el resultado en pantalla
cout<<" "<<A<<" "<<B<<" "<<C<<" "<<Fa<<" "<<Fb<<" "<<Fc<<" "<<endl<<endl;
if((C - A) > 0.0001)
{
if(funcion(A)*funcion(B) < 0)
return Biseccion(A, B);
else return Biseccion(B, C);
}
else return (B);
}
int main(int argc, char *argv[])
{
char programa;
float A=0;
float C=0;
float raiz=0;
cout<<endl;
cout<<" La funcion es f(x)= x^3 + 6x^2 + 2x + 8 "<<endl<<endl<<endl;
cout<<" Ingrese el valor de A: ";
cin>>A;
cout<<endl;
cout<<" Ingrese el valor de C: ";
cin>>C;
cout<<endl;
cout<<" a b c Fa Fb Fc"<<endl<<endl;
raiz=Biseccion(A,C);
cout<<" El valor final es: "<<raiz<<endl;
cout<<endl;
cout<<endl;
---------------------------------------------------------------------
float funcion(float x);
float derivada(float x);
float funcion(float x)
{
return (pow(x,2)-9);
}
float derivada(float x)
{
return 2*x;
}
int main()
{
float x;
float Valorinicial;
int i;
int n=5;
cout<<endl<<endl;
cout<<" f(x)= x^2+9 "<<endl<<endl<<endl;
cout<<"Indique Valorinicial X: ";
cin>>x;
cout<<endl;
cout<<" X "<<" "<<"Xn"<<" "<<"Xo+1"<<endl<<endl;
for (i=0; i<n; i++){
Valorinicial = x;
x= x-funcion(x)/derivada(x);
cout<<" "<<i<<" "<<Valorinicial<<" "<<x<<endl<<endl;
if((x==Valorinicial) > 0.0001)
break;
}
cout<<"Mi raiz para la funcion f(x)= x^2+9 es: "<<x<<endl<<endl<<endl;
----------------------------------------------------------------------
int n;
float f1,f2,h,A,a,b;
int main ()
{
cout<<"**************************************"<<endl;
cout<<"** REALIZADO POR EDUARDO CAMPOS **"<<endl;
cout<<"**************************************"<<endl<<endl;
cout<<"FUNCION: f(x)=x^3-13x-12"<<endl<<endl;
cout<<"ECUACION: A=(h/2)*((f(x1)+f(x2))/n)"<<endl<<endl;
cout<<"ingrese valor de A: ";
cin>>a;
cout<<"ingrese valor de B: ";
cin>>b;
cout<<"ingrese el numero de divisiones del area: ";
cin>>n;
{
f1=(pow(a,3))-(13*a)-12;
f2=(pow(b,3))-(13*b)-12;
h=b-a;
A=(h/2)*((f1+f2)/n);
}
cout<<"El area es: "<<A<<endl<<endl<<endl;
----------------------------------------------------------------------
int main(){
int x2=1;
int m;
int i;
float multi;
float sumayi=0;
float sumaxi=0;
float sumax2=0;
float sumaXixYi=0;
float a;
float b;
float y;
cout<<" Indique el numero de m: ";
cin>>m;
cout<<endl;
float vector[m];
for ( i=1; i<=m; i++){
cout<<" Indique dato "<<((i-1)+1)<<": ";
cin>> vector[i];
}
for ( i=1; i<=m; i++){
sumayi= sumayi+vector[i];
}
for ( i=1; i<=m; i++){
sumaxi = sumaxi+i;
}
cout<<endl<<endl;
cout<<" "<<"Xi"<<" "<<"Yi"<<" "<<"X^2"<<" "<<"Xi*Yi"<<endl;
for ( i=1; i<=m; i++){
x2= (pow(i,2));
sumax2 = sumax2+x2;
multi = ((i-1)+1)*vector[i];
sumaXixYi= sumaXixYi+multi;
cout<<endl;
cout<<" "<<((i-1)+1)<<" "<<vector[i]<<" "<<x2<<" "<<multi<<endl<<endl;
}
cout<<" *Sumatorias* "<<endl<<endl;
cout<<" "<<sumaxi<<" "<<sumayi<<" "<<sumax2<<" "<<sumaXixYi<<endl<<endl;
float suyi=sumayi;
float suxi=sumaxi;
float sux2=sumax2;
float suXixYi=sumaXixYi;
a=((m*suXixYi)-(suxi*suyi))/((m*sux2)-(pow(suxi,2)));
b=((sux2*suyi)-(suXixYi*suxi))/((m*sux2)-(pow(suxi,2)));
float X;
cout<<endl<<endl;
cout<<"indique un valor para X: ";
cin>>X;
cout<<endl<<endl;
X= 0;
y= ((b+a)*X);
cout<<"El valor de Y correspondiente a X introduzida es: "<<X<<endl<<endl;
cout<<endl<<endl;