
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* (- 1.0 x) y) (* x z)))
double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * 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 = ((1.0d0 - x) * y) + (x * z)
end function
public static double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * z);
}
def code(x, y, z): return ((1.0 - x) * y) + (x * z)
function code(x, y, z) return Float64(Float64(Float64(1.0 - x) * y) + Float64(x * z)) end
function tmp = code(x, y, z) tmp = ((1.0 - x) * y) + (x * z); end
code[x_, y_, z_] := N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] + N[(x * 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 = (((1) - x) * y) + (x * z) END code
\left(1 - x\right) \cdot y + x \cdot z
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 :pre TRUE (+ (* (- 1.0 x) y) (* x z)))
double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * 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 = ((1.0d0 - x) * y) + (x * z)
end function
public static double code(double x, double y, double z) {
return ((1.0 - x) * y) + (x * z);
}
def code(x, y, z): return ((1.0 - x) * y) + (x * z)
function code(x, y, z) return Float64(Float64(Float64(1.0 - x) * y) + Float64(x * z)) end
function tmp = code(x, y, z) tmp = ((1.0 - x) * y) + (x * z); end
code[x_, y_, z_] := N[(N[(N[(1.0 - x), $MachinePrecision] * y), $MachinePrecision] + N[(x * 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 = (((1) - x) * y) + (x * z) END code
\left(1 - x\right) \cdot y + x \cdot z
(FPCore (x y z) :precision binary64 :pre TRUE (fma x (- z y) y))
double code(double x, double y, double z) {
return fma(x, (z - y), y);
}
function code(x, y, z) return fma(x, Float64(z - y), y) end
code[x_, y_, z_] := N[(x * N[(z - y), $MachinePrecision] + y), $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 * (z - y)) + y END code
\mathsf{fma}\left(x, z - y, y\right)
Initial program 98.0%
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x y z)
:precision binary64
:pre TRUE
(let* ((t_0 (* x (- z y))))
(if (<= x -771.6157302664199)
t_0
(if (<= x 857.8504450292068) (fma x z y) t_0))))double code(double x, double y, double z) {
double t_0 = x * (z - y);
double tmp;
if (x <= -771.6157302664199) {
tmp = t_0;
} else if (x <= 857.8504450292068) {
tmp = fma(x, z, y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y, z) t_0 = Float64(x * Float64(z - y)) tmp = 0.0 if (x <= -771.6157302664199) tmp = t_0; elseif (x <= 857.8504450292068) tmp = fma(x, z, y); else tmp = t_0; end return tmp end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -771.6157302664199], t$95$0, If[LessEqual[x, 857.8504450292068], N[(x * z + y), $MachinePrecision], t$95$0]]]
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 = LET t_0 = (x * (z - y)) IN LET tmp_1 = IF (x <= (8578504450292067531336215324699878692626953125e-43)) THEN ((x * z) + y) ELSE t_0 ENDIF IN LET tmp = IF (x <= (-771615730266419859617599286139011383056640625e-42)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x \cdot \left(z - y\right)\\
\mathbf{if}\;x \leq -771.6157302664199:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 857.8504450292068:\\
\;\;\;\;\mathsf{fma}\left(x, z, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if x < -771.61573026641986 or 857.85044502920675 < x Initial program 98.0%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around inf
Applied rewrites65.2%
if -771.61573026641986 < x < 857.85044502920675Initial program 98.0%
Taylor expanded in x around 0
Applied rewrites76.2%
Applied rewrites76.2%
(FPCore (x y z) :precision binary64 :pre TRUE (fma x z y))
double code(double x, double y, double z) {
return fma(x, z, y);
}
function code(x, y, z) return fma(x, z, y) end
code[x_, y_, z_] := N[(x * z + y), $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 * z) + y END code
\mathsf{fma}\left(x, z, y\right)
Initial program 98.0%
Taylor expanded in x around 0
Applied rewrites76.2%
Applied rewrites76.2%
(FPCore (x y z) :precision binary64 :pre TRUE (* x z))
double code(double x, double y, double z) {
return x * 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 * z
end function
public static double code(double x, double y, double z) {
return x * z;
}
def code(x, y, z): return x * z
function code(x, y, z) return Float64(x * z) end
function tmp = code(x, y, z) tmp = x * z; end
code[x_, y_, z_] := N[(x * z), $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 * z END code
x \cdot z
Initial program 98.0%
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in y around 0
Applied rewrites42.2%
herbie shell --seed 2026092
(FPCore (x y z)
:name "Diagrams.Color.HSV:lerp from diagrams-contrib-1.3.0.5"
:precision binary64
(+ (* (- 1.0 x) y) (* x z)))