Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace QuadraticSolverSharp
- {
- public static class Solver
- {
- public static Tuple<double, double> QuadraticFormula(double a, double b, double c)
- {
- // Compute the discriminant
- // /\ = b^2 - 4ac
- double disc = Math.Pow(b, 2) - 4 * a * c;
- // Compute the two roots
- double root1 = (-b + Math.Sqrt(disc)) / (2 * a);
- double root2 = (-b - Math.Sqrt(disc)) / (2 * a);
- return new Tuple<double, double>(root1, root2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement