Skip to content
This repository has been archived by the owner on May 31, 2023. It is now read-only.

Create find_roots_of_quadratic_equation.php #7506

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
// Give the input values for the formula
$inputA = 5;
$inputB = 10;
$inputC = 2;

// $sumD is the part of the equation that is inside of the square root
$sumD = pow($inputB, 2) - 4 * $inputA * $inputC;

// The rest of the equation. Everything is put in () so it is calculated in the right order.
$outputPositive = (-$inputB + pow($sumD, 0.5)) / (2 * $inputA);
$outputNegative = (-$inputB - pow($sumD, 0.5)) / (2 * $inputA);

echo "x = $outputPositive &nbsp; or &nbsp; x = $outputNegative";