Home » HOW TO: Solve quadratic equations in PowerApps

HOW TO: Solve quadratic equations in PowerApps

And after a short break, welcome to my latest blog post. Today, I will show you how to harness the power of Power Apps to solve quadratic equations; a fundamental concept in the fascinating world of Algebra. Algebra, a vital branch of mathematics, encompasses symbols, variables, and the rules that govern their manipulation to represent and solve a wide range of problems. Among the myriad of algebraic expressions, quadratic equations hold a special place. These equations involve a polynomial of degree two, meaning the highest power of the variable is two (x²).

The importance of Algebra cannot be overstated, as it serves as the foundation for various mathematical disciplines and has extensive applications in science, engineering, and everyday life. In this blog post, I’ll walk you through creating a PowerApp that simplifies solving quadratic equations, making it accessible and user-friendly for anyone interested in exploring this essential area of mathematics. So, let’s dive in and discover how PowerApps can make Algebra more engaging and fun!

So, how do we solve quadratic equations?

The Quadratic Formula!

The Quadratic Formula is a widely-used method for finding the solutions, or roots, of a quadratic equation. A quadratic equation is a polynomial equation of the form:

ax^2 + bx + c = 0

where a, b, and c are constants, and a ≠ 0 (if a = 0, it’s no longer a quadratic equation but a linear one). Quadratic equations describe parabolas and have various real-world applications, such as modeling physical systems, solving optimization problems, and analyzing projectile motion.

The Quadratic Formula is derived from completing the square technique and is expressed as follows:

x = (-b ± √(b² - 4ac)) / 2a

Here, x represents the roots of the quadratic equation, and the ± symbol indicates that there can be two distinct solutions:

x1 = (-b + √(b² - 4ac)) / 2a x2 = (-b - √(b² - 4ac)) / 2a

The term inside the square root (b² – 4ac) is called the discriminant. The discriminant determines the nature of the roots:

  1. If the discriminant is positive, the quadratic equation has two distinct real roots.
  2. If the discriminant is zero, the quadratic equation has one real and repeated root (also known as a double root).
  3. If the discriminant is negative, the quadratic equation has no real roots, but two complex roots instead.

The Quadratic Formula allows us to directly compute the roots of a quadratic equation without factoring or graphing the equation. So let’s start…

Here’s what to do…

  1. Create a new Canvas app from blank.
  2. Add three Text Input fields; one for the ‘a’ value, one for the ‘b’ value and one for the ‘c’ value, as below…

3. Rename each respectively to TextInputA, TextInputB and TextInputC.
4. Add a Button below the Text Input fields.
5. Change the OnSelect property of the button to…

UpdateContext({a: Value(TextInputA.Text), b: Value(TextInputB.Text), c: Value(TextInputC.Text), discriminant: (Value(TextInputB.Text) ^ 2) - (4 * Value(TextInputA.Text) * Value(TextInputC.Text))})

6. Add two Labels below the Button; one will show the computed roots (x1), and the other will show the computed roots (x2).
7. In Label1, change the Text property to…

If(discriminant > 0, "Root x1: " & ((-b + Sqrt(discriminant)) / (2 * a)), If(discriminant = 0, "Root x1 (Real & Repeated): " & (-b / (2 * a)), "No real roots"))

8. For Label2, change the Text property to…

If(discriminant > 0, "Root x2: " & ((-b - Sqrt(discriminant)) / (2 * a)), If(discriminant = 0, "Root x2 (Real & Repeated): " & (-b / (2 * a)), ""))

Then give it a spin!

Here are some example a, b and c values to test your app.

  1. Two distinct real roots:
    • a = 1
    • b = -3
    • c = 2
    • The quadratic equation will be: x^2 – 3x + 2 = 0
    • The roots will be: x1 = 1, x2 = 2
  2. One real and repeated root:
    • a = 1
    • b = -4
    • c = 4
    • The quadratic equation will be: x^2 – 4x + 4 = 0
    • The root will be: x1 = x2 = 2 (Real & Repeated)
  3. No real roots (complex roots):
    • a = 1
    • b = 1
    • c = 1
    • The quadratic equation will be: x^2 + x + 1 = 0
    • The PowerApp should display “No real roots” as the equation has complex roots.

See it in action!

PhilGlew-Deval

Back to top