THE BORE
General => The Superdeep Borehole => Topic started by: T234 on February 19, 2008, 04:48:46 PM
-
How does one go about solving a quadratic equation using perl?
We are completely baffled as to even what the structure of the structure of the program would be.
PLZ HELP
-
PERL
Reminds me of projects involving Cleo :(
-
you guys suck. crack open a numerical methods book! anyhow:
ax^2 + bx + c = 0;
solving for x, x = (-b + sqrt(b^2 - 4*a*c))/2*a
--
print "gimme the value of a: ";
$a = <STDIN>;
print "gimme the value of b: ";
$b = <STDIN>;
print "gimme the value of c: ";
$c = <STDIN>;
# x = (-b + sqrt(b^2 - 4*a*c))/2*a
$x_pos = (-$b + sqrt($b^2 - (4*$a*$c)))/(2*$a);
$x_neg = (-$b - sqrt($b^2 - (4*$a*$c)))/(2*$a);
print: "lol perl wut! x = either $x_pos or $x_neg\r\n";
or somesuch; check the parentheses to make sure i got 'em right, i gotta run to a meeting
edit: fixed to include negative case, lol me, math is for jerx
-
sweet god, solving quadratics is something you learn in like 8-9th grade. It's a FORMULA, you can pretty much punch in the two quadratic solutions for a given a,b, and c like prole posted.
-
Some of our educations up until this point really sucked, like mine. Never solved a quadratic equation until I hit college, even that was a few years ago.
Prole: :bow :bow :bow :bow
-
You never did a quadratic equation until highschool?
Homeschool>The South
-
Part of that WAS home school, PD.
-
BAIL OUT :-\
-
It's like being back in high school with a TI-81 (had the 92 in college).
-
wouldn't you have to have a couple algebra classes before taking coding? seems important to it.
-
wouldn't you have to have a couple algebra classes before taking coding? seems important to it.
One. And that was forever ago.
-
I see.
-
yeah fuck coding in the ass i can't do this shit