quadratic2 <- function ( a, b, c ) #*****************************************************************************80 # ## quadratic2 computes the roots of a quadratic equation ax^2+bx+c=0. # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 07 February 2020 # # Author: # # Original R version by James Howard. # Modifications by John Burkardt. # # Reference: # # James Howard, # Computational Methods for Numerical Analysis with R, # CRC Press, 2017 # ISBN13: 978-1-4987-2363-3. # # Input: # # real A, B, C: the coefficients. # # Output: # # real X1, X2: the roots. { t1 <- sqrt ( b^2 - 4.0 * a * c ) t2 <- 2.0 * c x1 <- t2 / ( - b + t1 ) x2 <- t2 / ( - b - t1 ) return ( c ( x1, x2 ) ) }