Microsoft Excel is such a flexible and powerful tool that you can use in all manner of situations. Below, is a screen shot of an Excel spreadsheet application we have developed that encapsulates the quadratic equation. It plots the quadratic graph over a specified range, and displays the chart data. The coefficient input for the quadratic is entered by the user and also displayed. Then, immediately after the user has entered the coefficient data, the graph updates and the solutions for the quadratic equation are calculated and shown in spreadsheet cells B6, and C6. There is also a button control on the spreadsheet to take you to the developers home page which, in this case, is us, at gwycon.com!
![]() |
| Quadratic equation spreadsheet. Layout of controls, data, and chart. |
As mentioned above, whenever the spreadsheet updates automatically the quadratic equation solutions are calculated immediately and displayed to the user. This happens by means of a custom programmed spreadsheet function to calculate the solutions to a quadratic equation. If the solutions turn out to be complex, the function returns the string “Err!”.
The full function VBA code is given below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | '=================================================================== ' Quadratic Equation Solver v1.0 - 25/01/2009 ' http://www.gwycon.com Function QuadraticES(a As Double, b As Double, c As Double, sol As Integer) As Variant Dim discr As Double ' discriminant Dim numerator As Double ' top half of the solution Dim denominator As Double ' bottom half of the solution discr = b ^ 2 - 4 * a * c denominator = 2 * a If discr >= 0 Then 'only calculate solution if not complex If sol = 1 Then ' return 1st solution numerator = -b + (discr) ^ (1 / 2) QuadraticES = numerator / denominator Else ' if sol = 2 (or any other value) return 2nd solution numerator = -b - (discr) ^ (1 / 2) QuadraticES = numerator / denominator End If Else ' complex solution! QuadraticES = "Err!" End If End Function '=================================================================== |
This could be easily extended to calculate the quadratic solutions even they are of complex type. This would require further code to calculate the complex values, and display them in a custom format as complex numbers have real and complex parts; they are not just made up of a single number!
This application (and much more complicated ones) are just the sort of spreadsheet we specialise in for clients. It is an excellent example of abstracting a task (in this a quadratic equation, and corresponding solutions) into an interactive single environment – which is easily deployed to the user. These types of spreadsheet applications are ideal as educational demonstration tools, or for use in a more formal business or research settings.