#include <iostream>
using namespace std;
double polynome3(double a0,double a1,double a2, double a3)
`
double y[21];
double z[21];
for (int k=0;k<21;k++)
{
y[0]=1;
y[1]=1;
y[2]=1;
/* Bernoulli's algorithm */
y[k+3]=-(((a1*y[k+2])+(a2*y[k+1])+(a3*y[k]))/a0);
// cout<<y[10]/y[9]<<endl;
}
double alpha1=y[20]/y[19];
cout<< "The first solution is alpha1 = " << alpha1<<endl;
double b0=a0;
double b1=a1+alpha1*b0;
double b2=-(a3/alpha1);
cout<<b0<<" " <<b1<<" "<<b2<<endl;
for(int j=0;j<21;j++)
{
z[0]=0;
z[1]=1;
z[j+2]=-((b1*z[j+1]+b2*z[j])/b0);
}
double alpha2=(z[20]/z[19]);
cout<<" The second solution is alpha2= " <<alpha2<<endl;
double c0=b0;
double c1=-(b2/alpha2);
double alpha3=-(c1/c0);
cout<<c0<<" " <<c1<<endl;
cout<<" The third solution will be alpha3 = "<< alpha3<< "\n"<<endl;
return 0;
}
int main()
{
cout<<"Enter your coefficient : "<<endl;
double x,y,z,t;
cin>>x;
cin>>y;
cin>>z;
cin>>t;
polynome3(x,y,z,t);
/* methode de Bernoulli */
return 0;
}
# Heading Here #
Luisa_1 0 Newbie Poster
Recommended Answers
Jump to PostAnd?
Jump to PostSome of the things you will see are that you have looped over the end of your arrays. e.g. line 18 and 36. You have written:
double y[21]; // stuff... for(int k=0;k<21;k++) { y[k+3]=-((a1*y[k+2])+(a2*y[k+1])+(a3*y[k]))/a0); }
Note that k+3 means that k goes to 24. That will …
All 7 Replies
NathanOliver 429 Veteran Poster Featured Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
Luisa_1 0 Newbie Poster
NathanOliver 429 Veteran Poster Featured Poster
Luisa_1 0 Newbie Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
StuXYZ 731 Practically a Master Poster
ddanbe commented: Deep insights. +15
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.