(Regula falsi metod. To calculate the root using 4 iterations)
I need the user to pick from problem a, b or c wherein every problem has different initial guesses.ex( prob. a Xd=1 Xu=2, prob. b Xd=2 Xu=3)
same process for all problems. And also i want to show all the values of Xd,Xu,Xr,d,u,r for the 4 iterations in tabular form.What i have done so far is this:
void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
{
fd=sin(d)+cos(1 +d*d)-1;
fu=sin(u)+cos(1 +u*u)-1;
r=((u*fd - d*fu) / (fd - fu));
fr=sin(r)+cos(1 +r*r)-1;
}
void eq(int x, int y)
{
d=1;
u=2;
cout<<"The value of Xd=1 and Xu=2\n";
for (i=4;i<5;i++)
{
falsi(fd,fu,fr, d,u,r)
if (fr>0 && fd>0)
{
r=d;
else
r=u;
}
cout<<fd<<fu<<f r<<d<<u<<r;
}
int main
{
cout<<"choose letter a, b, or c";
cin<<z; // is this correct??
if (z==a)
{
void eq(1,2);
if(z==b)
{
void eq(2,3);
else
void eq(1,4);
}
}
// Is this correct?
Btw, where can i download MSdev C++ version 5.0?
I need the user to pick from problem a, b or c wherein every problem has different initial guesses.ex( prob. a Xd=1 Xu=2, prob. b Xd=2 Xu=3)
same process for all problems. And also i want to show all the values of Xd,Xu,Xr,d,u,r for the 4 iterations in tabular form.What i have done so far is this:
void falsi(double& fd, double& fu, double& fr, double d, double u, double r)
{
fd=sin(d)+cos(1 +d*d)-1;
fu=sin(u)+cos(1 +u*u)-1;
r=((u*fd - d*fu) / (fd - fu));
fr=sin(r)+cos(1 +r*r)-1;
}
void eq(int x, int y)
{
d=1;
u=2;
cout<<"The value of Xd=1 and Xu=2\n";
for (i=4;i<5;i++)
{
falsi(fd,fu,fr, d,u,r)
if (fr>0 && fd>0)
{
r=d;
else
r=u;
}
cout<<fd<<fu<<f r<<d<<u<<r;
}
int main
{
cout<<"choose letter a, b, or c";
cin<<z; // is this correct??
if (z==a)
{
void eq(1,2);
if(z==b)
{
void eq(2,3);
else
void eq(1,4);
}
}
// Is this correct?
Btw, where can i download MSdev C++ version 5.0?
Comment