Kvadratická funkce y=x^2 - 4x + 3
Quadratic function y = x2 - 4x + 3

Quadratic equation with one unknown is an algebraic equation of the second order. It can written in the form ax^{2} + bx + c, where x is the unknown and a, b, c are real valued constants. Provided a = 0, the equation is linear.

Quadratic equation can be visualized as a parabola. When a is positive, than the parabola is convex, when negative, the parabola is concave.

Solving quadratic equation

At first, we have to calculate so called discriminant:

D = b^{2} - 4ac

If the discriminant is negative, than the equation has no real solution (root), but has two distinct imaginary roots.

If the discriminant is equal to zero, than the equation has one real solution:

x ={-b \\over {2a}}

If the discriminant is positive, than the equation has two distinct real roots:


x_{1,2} = \\begin{cases} 
{{-b + \\sqrt D} \\over {2a}} 
\\\\
{{-b - \\sqrt D} \\over {2a}}
\\end{cases}

Example

Find roots of the equation x^2 - 4x + 3 = 0.

First of all, we calculate the discriminant.

D = b^{2} - 4ac = 4^2 - 4 \\cdot 1 \\cdot 3 = 16 - 12 = 4

Because the discriminant is positive, the equation has two real roots. By plugging the discriminant into the above mentioned formula, we get:


x_{1,2} = \\begin{cases}
{{{-b + \\sqrt D} \\over {2a}} = {{4 + \\sqrt 4} \\over 2} = 3} \\\\
{{{-b - \\sqrt D} \\over {2a}} = {{4 - \\sqrt 4} \\over 2} = 1}
\\end{cases}

Code

    /**
     * Solves quadratic equation in form
     * ax^2 + bx + c = 0
     * @param a
     * @param b
     * @param c
     * @return array of real valued roots, null - if the equation has no real valued solution
     */
    public static double[] solveQuadraticEquation(double a, double b, double c) {
        double d = b*b - 4*a*c; //discriminant
        if(d < 0) {
            return null;
        } else if (d == 0) {
            double[] result = {-b/2*a};
            return result;
        } else {
            double[] result = {(-b + Math.sqrt(d))/(2*a), (-b - Math.sqrt(d))/(2*a)};
            return result;
        }
    }
       /**
        * Solves quadratic equation in form
        * ax^2 + bx + c = 0
        * @param a
        * @param b
        * @param c
        * @return array of real valued roots, null - if the equation has no real valued solution
        */
        public static double[] SolveQuadraticEquation(double a, double b, double c)
        {
            double d = b * b - 4 * a * c; //discriminant
            if (d < 0)
            {
                return null;
            }
            else if (d == 0)
            {
                double[] result = { -b / 2 * a };
                return result;
            }
            else
            {
                double[] result = { (-b + Math.Sqrt(d)) / (2 * a), (-b - Math.Sqrt(d)) / (2 * a) };
                return result;
            }
        }
/**
 * Solves quadratic equation in form ax^2 + bx + c = 0
 * @param $a
 * @param $b
 * @param $c
 * @return array of real valued roots, NULL - if the equation has no real valued solution
 * @author Thomas (www.adamjak.net)
 */
function solve_quadratic_equation($a, $b, $c){
    $d = $b*$b - 4*$a*$c; //discriminant
    if($d < 0) {
        return NULL;
    } else if ($d == 0){
        $result = (-$b/2*$a);
        return $result;
    } else {
        $result = ((-$b + sqrt($d))/(2*$a) . (-$b - sqrt($d))/(2*$a));
        return $result;
    }
}

SEO od společnosti Digital Pylon


Online casino s algoritmem

České casino online online slot-vegas.cz

Hrajte nejlepší hry jako je GoodGame Empire.





Zajímavé články: Jak najít práci snů? Zvolte kariéru v IT!, Češi mají rádi hrací automaty online, Jak funguje algoritmické obchodování Casino, Online výuka Algoritmus a online marketing mají svá pravidla, Automaty, Matematický vliv, Ratings, Jak fungují algoritmy hazardních her online: více znalostí, více peněz, SYPWAI - nástroj pro vědecký vývoj, Vynikají na globálním trhu: Nejlepší vývojáři softwaru pro online výherní automaty, Jak si vybrat nejlepší české online casino, Proč byste měli hrát online casino VPN revoluce, Kde najdeme algoritmy v každodenním životě?, Čeká vás pracovní pohovor mimo město? Podívejte se, jak dokonale zvládnout včasný příchod, 5 úžasných technologií ze světa hazardních her, Mirror and access to Mostbet, Svou kancelář můžete mít stále po ruce, Jaké výhody má digitalizovaná firma oproti off-line konkurenci?, Jaký systém vybrat pro snadné řízení výroby?, Nahradí umělá inteligence ajťáky?, Důvody, proč používat SnapTik ke stahování videí TikTok, Dokonalý den na pláži: Co si vzít s sebou, aby byl výlet zábavný a bezpečný?, Jak přežít dlouhý let?, Go pay GoodGame Empire, Blockchain, Rozhovor, Umělá inteligence, Ochranná známka pre softvér: Prečo ju registrovať?, Role kryptografických algoritmů v zabezpečení online kasin, Jaké jsou náklady na nákup 3D tiskárny?, Jak algoritmy vylepšují online zážitky v roce 2025, Epilace laserem a péče o pokožku před a po ní, Byty k pronájmu Sokolov - výhody a rizika pronájmu bytu bez realitky, Filmy a seriály plné hádanek: kryptografie jako hlavní téma Kdy obnovit data z disku běžně dostupným softwarem a kdy už se obrátit na profesionály?>


Doporučujeme

Internet pro vaši firmu na míru

https://www.algoritmy.net