
(FPCore (x y z) :precision binary64 :pre TRUE (- (* x x) (* (* y 4.0) z)))
double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * x) - ((y * 4.0d0) * z)
end function
public static double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
def code(x, y, z): return (x * x) - ((y * 4.0) * z)
function code(x, y, z) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * z)) end
function tmp = code(x, y, z) tmp = (x * x) - ((y * 4.0) * z); end
code[x_, y_, z_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * x) - ((y * (4)) * z) END code
x \cdot x - \left(y \cdot 4\right) \cdot z
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (- (* x x) (* (* y 4.0) z)))
double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * x) - ((y * 4.0d0) * z)
end function
public static double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
def code(x, y, z): return (x * x) - ((y * 4.0) * z)
function code(x, y, z) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * z)) end
function tmp = code(x, y, z) tmp = (x * x) - ((y * 4.0) * z); end
code[x_, y_, z_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (x * x) - ((y * (4)) * z) END code
x \cdot x - \left(y \cdot 4\right) \cdot z
(FPCore (x y z) :precision binary64 :pre TRUE (fma y (* -4.0 z) (* x x)))
double code(double x, double y, double z) {
return fma(y, (-4.0 * z), (x * x));
}
function code(x, y, z) return fma(y, Float64(-4.0 * z), Float64(x * x)) end
code[x_, y_, z_] := N[(y * N[(-4.0 * z), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (y * ((-4) * z)) + (x * x) END code
\mathsf{fma}\left(y, -4 \cdot z, x \cdot x\right)
Initial program 98.5%
Applied rewrites99.5%
(FPCore (x y z) :precision binary64 :pre TRUE (* -4.0 (* y z)))
double code(double x, double y, double z) {
return -4.0 * (y * z);
}
real(8) function code(x, y, z)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (y * z)
end function
public static double code(double x, double y, double z) {
return -4.0 * (y * z);
}
def code(x, y, z): return -4.0 * (y * z)
function code(x, y, z) return Float64(-4.0 * Float64(y * z)) end
function tmp = code(x, y, z) tmp = -4.0 * (y * z); end
code[x_, y_, z_] := N[(-4.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]
f(x, y, z): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf] code: THEORY BEGIN f(x, y, z: real): real = (-4) * (y * z) END code
-4 \cdot \left(y \cdot z\right)
Initial program 98.5%
Taylor expanded in x around 0
Applied rewrites53.3%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Graphics.Rasterific.QuadraticFormula:discriminant from Rasterific-0.6.1"
:precision binary64
(- (* x x) (* (* y 4.0) z)))