二次方程式の解を求める計算機

解の公式で ax² + bx + c = 0 を解きます。根号または複素数による厳密な解、判別式、頂点、対称軸、グラフを表示します。

更新日 検証済みの例:7

試す
Roots
x = 2 ± √3
Roots: x = 2 ± √3
Smaller root x₁
0.2679491924
Larger root x₂
3.7320508076
Discriminant b² − 4ac
12
Kind of roots
Two distinct real roots
Vertex x (axis of symmetry)
2
Vertex y (minimum or maximum)
−3

The discriminant is positive (12), so the parabola crosses the x-axis twice: x = 2 ± √3. It opens upward with a minimum of −3 at x = 2.

y = x² − 4x + 1

-2.502.55024xyaxis x = 2vertex (2, −3)x₁ = 0.267949x₂ = 3.73205
計算方法 S
  1. Discriminant

    Δ=b2−4ac=(−4)2−4(1)(1)=12\Delta = b^2 - 4ac = (-4)^2 - 4(1)(1) = 12
  2. Quadratic formula

    x=−b±Δ2a=4±122x = \frac{-b \pm \sqrt{\Delta}}{2a} = \frac{4 \pm \sqrt{12}}{2}
  3. Simplify the square root

    12=23\sqrt{12} = 2\sqrt{3}
  4. Roots

    x=2±3  ⇒  x1≈0.267949192431, x2≈3.73205080757x = 2 \pm \sqrt{3} \;\Rightarrow\; x_1 \approx 0.267949192431,\ x_2 \approx 3.73205080757
  5. Vertex

    h=−b2a=2,k=c−b24a=−3h = -\frac{b}{2a} = 2,\qquad k = c - \frac{b^2}{4a} = -3

二次方程式の解を求める計算機について

A quadratic equation ax² + bx + c = 0, with a ≠ 0, has the roots x = (−b ± √(b² − 4ac)) / 2a. The discriminant Δ = b² − 4ac decides their kind: two real roots when Δ > 0, one repeated root when Δ = 0, and a pair of complex conjugates when Δ < 0. The vertex of the parabola y = ax² + bx + c sits on its axis of symmetry, x = −b/2a.

Projectile heights, areas with one unknown side and break-even points all lead to quadratics. The default, x² − 4x + 1 = 0, has Δ = 12, so its roots are x = 2 ± √3, about 0.2679 and 3.7321, and its vertex is (2, −3).

Roots are given exactly, as fractions, simplified surds or complex numbers, and as decimals to 10 places. The decimals use the cancellation-free form from Numerical Recipes, so a tiny root next to a large one keeps its accuracy. With a = 0 the equation is linear, not quadratic.

Where the quadratic formula comes from

The formula is what you get by completing the square on the general equation ax² + bx + c = 0 once, with letters instead of numbers:

  1. Divide by a, which is allowed because a ≠ 0: x² + (b/a)x + c/a = 0.
  2. Move the constant across: x² + (b/a)x = −c/a.
  3. Add (b/2a)² to both sides, which turns the left side into a perfect square: (x + b/2a)² = (b² − 4ac)/4a².
  4. Take the square root of both sides, keeping both signs: x + b/2a = ±√(b² − 4ac)/2a.
  5. Subtract b/2a: x = (−b ± √(b² − 4ac))/2a.

Step 4 is where the discriminant enters. The right side of step 3 has a positive denominator, 4a², so the sign of b² − 4ac alone decides whether a real square root exists.

What the discriminant tells you

For whole-number or fractional coefficients, Δ = b² − 4ac sorts every quadratic into one of four cases.

Discriminant ΔRootsGraph of y = ax² + bx + cExampleΔRoots of the example
Positive perfect squareTwo rational rootsCrosses the x-axis twice3x² − 5x − 249−1/3 and 2
Positive, not a perfect squareTwo irrational roots, a ± √ pairCrosses the x-axis twicex² + 6x + 420−3 ± √5
ZeroOne repeated rootTouches the x-axis at the vertex4x² − 12x + 903/2
NegativeTwo complex conjugate rootsStays on one side of the x-axisx² − 4x + 13−362 ± 3i

The first row is the one worth checking before reaching for the formula: a perfect-square discriminant means the quadratic factors over the integers or fractions. With decimal coefficients that come from measurements, the perfect-square case is rare and the formula is the practical route.

Worked example: a garden with a known area

A rectangular garden is 3 m longer than it is wide and covers 40 m². Calling the width w, the area gives w(w + 3) = 40, and moving everything to one side puts it in standard form: w² + 3w − 40 = 0, so a = 1, b = 3 and c = −40.

  1. Discriminant: Δ = 3² − 4 × 1 × (−40) = 9 + 160 = 169.
  2. Square root: √169 = 13, a whole number, so the roots are rational.
  3. Formula: w = (−3 ± 13)/2, giving w = 10/2 = 5 or w = −16/2 = −8.
  4. Interpret: a width cannot be negative, so the garden is 5 m wide and 8 m long. Check: 5 × 8 = 40.

The solver returns x₁ = −8 and x₂ = 5 for a = 1, b = 3, c = −40. It reports both roots because both solve the equation; which one to discard depends on the problem, not the algebra.

A projectile gives a second case where one root is thrown away. A ball thrown upward at 14 m/s from a height of 1.5 m, taking g as 9.8 m/s², has height h = −4.9t² + 14t + 1.5 metres after t seconds. Setting h = 0 gives Δ = 14² − 4 × (−4.9) × 1.5 = 225.4, and the solver shows the roots exactly as (10 ± √115)/7, about −0.1034 and 2.9605. The negative time lies before the throw, so the ball lands after 2.96 s. The vertex, at t = 1.4286 and h = 11.5, is the top of the flight: 11.5 m after 1.43 s.

Factoring and completing the square

When the discriminant is a perfect square, factoring is often quicker than the formula. The ac method handles a leading coefficient other than 1. For 6x² + x − 2 = 0:

  1. Multiply a and c: 6 × (−2) = −12.
  2. Find two numbers with product −12 and sum b = 1: 4 and −3.
  3. Split the middle term with them: 6x² + 4x − 3x − 2.
  4. Factor in pairs: 2x(3x + 2) − 1(3x + 2) = (2x − 1)(3x + 2).
  5. Set each factor to zero: x = 1/2 or x = −2/3.

Completing the square works on any quadratic and is quickest when a = 1 and b is even. For x² + 6x − 7 = 0, move the constant to get x² + 6x = 7, add (6/2)² = 9 to both sides to get (x + 3)² = 16, and take roots: x + 3 = ±4, so x = 1 or x = −7. It is the same procedure as the derivation above, applied to numbers.

Vertex form and the axis of symmetry

Completing the square without setting the expression to zero rewrites y = ax² + bx + c in vertex form, y = a(x − h)² + k, where h = −b/2a and k = c − b²/4a. For y = 2x² − 8x + 3:

  • h = −(−8)/(2 × 2) = 2
  • k = 3 − (−8)²/(4 × 2) = 3 − 8 = −5
  • so y = 2(x − 2)² − 5, which expands back to 2x² − 8x + 3.

Vertex form reads off three facts at once. The vertex is (2, −5); a = 2 is positive, so the parabola opens upward and −5 is its minimum; and the axis of symmetry is the line x = 2. The roots follow by setting y = 0: 2(x − 2)² = 5, so x = 2 ± √(5/2), which the solver writes as (4 ± √10)/2, about 0.4189 and 3.5811. Both sit 1.5811 either side of the axis, as every pair of real roots does.

Two quick checks catch most arithmetic slips. The roots of any quadratic add up to −b/a and multiply to c/a. Here 0.4189 + 3.5811 = 4 = 8/2 and 0.4189 × 3.5811 = 1.5 = 3/2. To see the parabola itself alongside other curves, plot it in the graphing calculator.

Mistakes and edge cases

  • Leaving the equation out of standard form. x² = 3x + 4 must become x² − 3x − 4 = 0 before reading off a, b and c; its roots are −1 and 4. Reading b as +3 from the original gives the wrong pair.
  • Losing the sign of b. When b is negative, −b is positive: for 2x² − 8x + 3, −b = 8. And b² is always positive: (−8)² = 64. Typing -8^2 into a calculator gives −64, because the minus sign applies after the power, so bracket it as (-8)^2 in the scientific calculator.
  • Dividing only part of the numerator by 2a. The whole of −b ± √Δ sits over 2a. Writing −b ± √Δ/2a halves only the root.
  • Setting a to 0. Without an x² term the equation is linear, bx + c = 0, with the single root −c/b. The solver stops and says so rather than dividing by zero.
  • Rounding a tiny root next to a large one. For x² + 100000000x + 1 = 0 the roots are about −100000000 and −0.00000001. Evaluating −b + √Δ in standard double-precision arithmetic subtracts two nearly equal numbers, and the small root comes out as −7.45 × 10⁻⁹, 25% too small. David Goldberg's survey of floating-point arithmetic (ACM Computing Surveys, 1991) explains the cancellation and the rearranged formula that avoids it. The solver uses that rearrangement with 50-digit decimals, and its small root, −1.0000000000000001 × 10⁻⁸, is correct to every digit shown.

Complex roots, such as 2 ± 3i above, can be carried into further arithmetic with the complex number calculator. For cubic to sixth-degree equations, the polynomial root finder returns every real and complex root.

計算例

x² − 4x + 1 (irrational roots)

a (x² coefficient)
1
b (x coefficient)
-4
c (constant)
1
Roots
x = 2 ± √3
Smaller root x₁
0.2679491924
Larger root x₂
3.7320508076
Discriminant b² − 4ac
12
Vertex y (minimum or maximum)
-3

照合元:Python decimal (60 digits): 2 ± Decimal(3).sqrt()

2x² + 3x − 5 (rational roots)

a (x² coefficient)
2
b (x coefficient)
3
c (constant)
-5
Roots
x₁ = −5/2, x₂ = 1
Smaller root x₁
-2.5
Larger root x₂
1
Discriminant b² − 4ac
49

照合元:Δ = 9 + 40 = 49, (−3 ± 7)/4 (Python fractions)

x² + 2x + 5 (complex roots)

a (x² coefficient)
1
b (x coefficient)
2
c (constant)
5
Roots
x = −1 ± 2i
Real part (complex roots)
-1
Imaginary part (±)
2
Kind of roots
Two complex conjugate roots

照合元:Python cmath: (-2 ± cmath.sqrt(-16)) / 2 = -1 ± 2j

x² − 6x + 9 (double root, edge case)

a (x² coefficient)
1
b (x coefficient)
-6
c (constant)
9
Roots
x = 3 (double root)
Smaller root x₁
3
Larger root x₂
3
Discriminant b² − 4ac
0
Kind of roots
One repeated real root

照合元:(x − 3)² expanded by hand

よくある質問

What is the quadratic formula?

x = (−b ± √(b² − 4ac)) / 2a gives both solutions of ax² + bx + c = 0. For 2x² + 3x − 5 = 0, a = 2, b = 3 and c = −5, so x = (−3 ± √49)/4 = (−3 ± 7)/4, giving x = 1 and x = −5/2. The formula comes from completing the square and works for every quadratic with a ≠ 0.

What does the discriminant tell you?

The discriminant b² − 4ac counts the real roots. Positive means two different real roots (x² − 4x + 1 has Δ = 12); zero means one repeated root where the parabola touches the x-axis (x² − 6x + 9 has Δ = 0 and root 3); negative means two complex roots (x² + 2x + 5 has Δ = −16). With whole-number coefficients, a perfect-square discriminant such as 49 means the roots are rational.

How do you find the vertex of a parabola?

The vertex x-coordinate is −b/2a; substituting it back gives the y-coordinate, which equals c − b²/4a. For y = x² − 4x + 1 the vertex is at x = 4/2 = 2 and y = 1 − 16/4 = −3. If a > 0 the parabola opens upward and the vertex is its minimum; if a < 0 it opens downward and the vertex is its maximum.

What are complex roots of a quadratic?

When b² − 4ac is negative the square root in the formula is imaginary, so the roots take the form p ± qi, where i = √−1. For x² + 2x + 5 = 0, Δ = 4 − 20 = −16 and √−16 = 4i, so x = (−2 ± 4i)/2 = −1 ± 2i. The parabola never crosses the x-axis, and the real part, −1, is the x-coordinate of its vertex.

Can you solve a quadratic by factoring instead?

Yes, when the roots are rational. x² − 6x + 9 factors as (x − 3)², so x = 3 twice, and 2x² + 3x − 5 factors as (2x + 5)(x − 1), giving −5/2 and 1. x² − 4x + 1 does not factor over whole numbers because its discriminant, 12, is not a perfect square, so the formula's answer 2 ± √3 is needed.

「二次方程式の解を求める計算機」の精度はどのくらいですか?

精度は入力値と計算方法の前提に依存します。十進演算には有効数字50桁を使いますが、推定、数値計算手法、元データの精度はそれより低い場合があります。表示の丸め処理でこれらの制約がなくなるわけではありません。 独立した出典の解答と照合した計算例:7。 例えば、「x² − 4x + 1 (irrational roots)」はPython decimal (60 digits): 2 ± Decimal(3).sqrt()と照合しています。

この計算方法の出典は何ですか?

Wolfram MathWorld — Quadratic Equation; Press et al., Numerical Recipes (3rd ed.) §5.6 — cancellation-free quadratic roots.

この計算機について

x=−b±b2−4ac2avertex (−b2a, c−b24a)\begin{gathered} x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} \\[10pt] \text{vertex } \left(-\frac{b}{2a},\ c - \frac{b^2}{4a}\right) \end{gathered}

出典

  1. Wolfram MathWorld — Quadratic Equation
  2. Press et al., Numerical Recipes (3rd ed.) §5.6 — cancellation-free quadratic roots

出典と照合済み

この計算機には、独立した出典の解答を使った計算例が 7 件あります。テストに組み込まれており、ここでも実行できます。

関連する計算ツール