Posted under PHP & Programming
Ever wanted to solve quadratic equations with php? When I started to learn php, I wanted to see if I could make a script that solved quadratic equations. In a course I participated in, we made a MATLAB-script that did just that. A quadratic equation is on the form aX2+bX+c=0, and the solutions can be found with the quadratic formula:

I have some problems with the formatting this article, I would appreciate any help.
To solve a quadratic equation with php, you need an input, and then the script produces the output. You can get input through a simple form, something like this:
which turns into to this:
What happens here, is that you enter three variables, a, b and c. These are stored as a, b and c. The form then sends the variables to the script solvequadratic.php located in the folder files for processing. So what is in solvequadratic.php?
For some reason, wordpress won’t let me use the
Anyway, if you are somewhat familiar with php, you should see what happens in the script. You are free to use this script for whatever you want, though I do doubt there is a need for this. However it is a good exercise to get to know php better, if you’re a beginner, like myself. As you might have noticed, you can try the script by using the form above. And yeah, I know the output page look like shit, but I’m to laze to do anything about it. This script can be expanded to solve quadratic equations with complex solutions as well, but I haven’t done that yet.
Fan#? on 26 Nov 2008 at 6:16 pm #
I just wanna thank you, your script helped me understand how to make 2 solutions appear!!
Lai Alexander on 26 Nov 2008 at 6:50 pm #
You are most welcome. I’m happy to see that this is actually of use to somebody.