View the step-by-step solution to:

How to fix my code to run the following ?

How to fix my code to run the following ?

Screen Shot 2018-04-03 at 4.07.47 PM.png

#include<iostream>


#include<cmath>


using namespace std;


int main ()


{


float a,b,x1a,x1b,x2a,x2b;


float newa,newb;

float tol = 1e-5;

x1a = (((a*a*a) - (3*a*b*b))-1);


x1b = ((3*(a*a*b))-(b*b*b));


x2a = ((3*(a*a))-(3*(b*b)));


x2b = (6*(a*b));


while ( sqrt (x1a*x1a+x1b*x1b) > tol) {


cout << "Initial guess (real and imag): ";


cin >> a >> b;



newa = a + ((x1a*x2a + x1b*x2b)/(x2a*x2a+x2b*x2b));


newb = b + ((x2a*x1b - x1a*x2b)/(x2a*x2a+x2b*x2b));



if ((a < 0) && (b == 0))


{


cout << "Initial guess z = " << newa << " converges to red root." << endl;


}


else if ((a < 0) && (b > 0))


{


cout << "Initial guess z = " << newa << "+" << newb << "j" << "converges to green root." << endl;


}


else if ((a>0) && (b>0))


{


cout << "Initial guess z = " << newa << "+" << newb << "j" << "converges to blue root." << endl;


}


else


{


cout << "ok done"<< endl;



}


}


return 0;


}

Screen Shot 2018-04-03 at 4.07.47 PM.png

Top Answer

the fixed code #include&lt;iostream&gt; #include&lt;cmath&gt; using namespace std ; int main () { float a,b,x1a,x1b,x2a,x2b;... View the full answer

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online