Solve one linear and one quadratic equation with our interactive calculator
Simultaneous equations involve two or more unknown variables. To solve them, you need as many equations as the number of unknown variables.
This calculator solves mixed simultaneous equations - one linear equation and one quadratic equation. The equations take the following form:
The solution is found using the substitution method. We express one variable in terms of the other from the linear equation, then substitute into the quadratic equation to solve.
Enter the coefficients for your equations and click "Solve" to get the solutions:
The solutions represent the points where the line intersects the quadratic curve
To solve the mixed simultaneous equations:
We follow these steps:
The formulas used in the solution are:
The original VB6 code for solving mixed simultaneous equations:
Private Sub Command1_Click() Dim a, b, c, d, m, n As Integer Dim x1, x2, y1, y2 As Double a = Val(Txt_a.Text) b = Val(Txt_b.Text) m = Val(Txt_m.Text) c = Val(Txt_c.Text) d = Val(Txt_d.Text) n = Val(Txt_n.Text) ' Calculate x1 and x2 x1 = (m * a * d + Sqr(m ^ 2 * a ^ 2 * d ^ 2 - _ (b ^ 2 * c + a ^ 2 * d) * (d * m ^ 2 - b ^ 2 * n))) / _ (b ^ 2 * c + a ^ 2 * d) x2 = (m * a * d - Sqr(m ^ 2 * a ^ 2 * d ^ 2 - _ (b ^ 2 * c + a ^ 2 * d) * (d * m ^ 2 - b ^ 2 * n))) / _ (b ^ 2 * c + a ^ 2 * d) ' Calculate corresponding y values y1 = (m - a * x1) / b y2 = (m - a * x2) / b ' Display results rounded to 2 decimal places Lbl_x1.Caption = Round(x1, 2) Lbl_y1.Caption = Round(y1, 2) Lbl_x2.Caption = Round(x2, 2) Lbl_y2.Caption = Round(y2, 2) End Sub
Equivalent VB.NET code with improved error handling:
Private Sub SolveButton_Click(ByVal sender As Object, _ ByVal e As EventArgs) Handles SolveButton.Click ' Parse input values with validation Dim a As Double = ParseDouble(txtA.Text) Dim b As Double = ParseDouble(txtB.Text) Dim m As Double = ParseDouble(txtM.Text) Dim c As Double = ParseDouble(txtC.Text) Dim d As Double = ParseDouble(txtD.Text) Dim n As Double = ParseDouble(txtN.Text) If b = 0 Or (b*b*c + a*a*d) = 0 Then MessageBox.Show("Invalid coefficients - division by zero") Return End If ' Calculate discriminant Dim discriminant As Double = m*m*a*a*d*d - _ (b*b*c + a*a*d) * (d*m*m - b*b*n) If discriminant < 0 Then MessageBox.Show("No real solutions exist") Return End If ' Calculate solutions Dim denominator As Double = b*b*c + a*a*d Dim x1 As Double = (m*a*d + Math.Sqrt(discriminant)) / denominator Dim x2 As Double = (m*a*d - Math.Sqrt(discriminant)) / denominator Dim y1 As Double = (m - a*x1) / b Dim y2 As Double = (m - a*x2) / b ' Display results lblX1.Text = Math.Round(x1, 2).ToString() lblY1.Text = Math.Round(y1, 2).ToString() lblX2.Text = Math.Round(x2, 2).ToString() lblY2.Text = Math.Round(y2, 2).ToString() End Sub Private Function ParseDouble(ByVal input As String) As Double Dim result As Double If Not Double.TryParse(input, result) Then MessageBox.Show("Invalid number format") Return 0 End If Return result End Function
The VB.NET version includes improved error handling, validation, and uses modern .NET math functions.
Master Visual Basic programming with this comprehensive guide that includes practical examples like this simultaneous equation solver.
Learn to build mathematical tools, financial calculators, database applications, games, and more with clear, practical code samples in both VB6 and VB.NET.
Learn MoreCopyright©2023 Math Solver | Enhanced Simultaneous Equations Calculator
Based on original VB code by Dr. Liew Voon Kiong