Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@vinci-e4PtMU • Feb 25, 2012
-
@silverscorpion-iJKtdQ • Feb 25, 2012
Use a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
@maria-flor-8cAkif • Feb 25, 2012
it doesn't workvinci![[IMG]](proxy.php?image=http%3A%2F%2Fregentsprep.org%2FRegents%2Fmath%2Falgtrig%2FATE3%2Fquadco6.gif&hash=6f1b14f9f579a556a8cc9fda6e70776f)
try this equation. let me know if it doesnt work still -
@maria-flor-8cAkif • Feb 25, 2012
i just tried it but when i try to input an equation with imaginary roots.. it doesn't give me an answer...silverscorpionUse a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
@maria-flor-8cAkif • Feb 25, 2012
thanks for that but when i try to input an equation with imaginary roots.. it still doesn't give an answer...silverscorpionUse a variable to indicate whether the delta (B[sup]2[/sup]-4AC) is positive or negative.
Instead of
pro = sqrt((b*b)-(4*a*c));
here, use
pro = sqrt(abs(B*B)-(4*A*C))
And then, if delta is positive, use it as is. If delta is negative, just print an 'i' or 'j' along with the result, to indicate that the root is imaginary... -
@silverscorpion-iJKtdQ • Feb 25, 2012
After you have calculated delta, (variable "pro" in your program), calculate the individual roots in the following way..
pro = sqrt(abs(B*B-4*A*C)) if ((B*B-4*A*C) >= 0) { x1 = (-B+pro)/2*A x2 = (-B-pro)/2*A cout << "The first root is " << x1 << endl cout << "The second root is " << x2 << endl } else { real = -B/2*A imag = pro/2*A cout << "The first root is "<<real<<"+i"<<imag<<endl cout << "The first root is "<<real<<"-i"<<imag<<endl }Try using this.. -
@vinci-e4PtMU • Feb 25, 2012
you need value of of a,b,c ?i found that equation i posted here gives complex roots . -
@maria-flor-8cAkif • Feb 25, 2012
it still don't work... when i try to run it and input values with imaginary roots it suddenly return...silverscorpionAfter you have calculated delta, (variable "pro" in your program), calculate the individual roots in the following way..
pro = sqrt(abs(B*B-4*A*C)) if ((B*B-4*A*C) >= 0) { x1 = (-B+pro)/2*A x2 = (-B-pro)/2*A cout << "The first root is " << x1 << endl cout << "The second root is " << x2 << endl } else { real = -B/2*A imag = pro/2*A cout << "The first root is "<<real<<"+i"<<imag<<endl cout << "The first root is "<<real<<"-i"<<imag<<endl }Try using this.. -
@silverscorpion-iJKtdQ • Feb 25, 2012
-
@maria-flor-8cAkif • Feb 26, 2012
here: when i input those numbers...it returns without giving any roots...