Testing a quadratic equation
Posted
by
user1201587
on Stack Overflow
See other posts from Stack Overflow
or by user1201587
Published on 2012-04-01T23:24:25Z
Indexed on
2012/04/01
23:29 UTC
Read the original article
Hit count: 171
I'm doing a code testing for a program that calculate the results for a quadratic equation
I need to have test data for the following situation, when a is not zero and d positive there is two possibilities which are in the code below, I need to find an example for the first satiation when Math.abs(b / a - 200.0) < 1.0e-4 , all the values that I have tried, excute the second one
caption= "Two roots";
if (Math.abs(b / a - 200.0) < 1.0e-4)
{
System.out.println("first one");
x1 = (-100.0 * (1.0 + Math.sqrt(1.0 - 1.0 / (10000.0 * a))));
x2 = (-100.0 * (1.0 - Math.sqrt(1.0 - 1.0 / (10000.0 * a))));
}
else
{
System.out.println("secrst one");
x1 = (-b - Math.sqrt(d)) / (2.0 * a);
x2 = (-b + Math.sqrt(d)) / (2.0 * a);
}
}
}
© Stack Overflow or respective owner