
(FPCore (x y) :precision binary64 :pre TRUE (- (- 1.0 x) y))
double code(double x, double y) {
return (1.0 - x) - y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) - y
end function
public static double code(double x, double y) {
return (1.0 - x) - y;
}
def code(x, y): return (1.0 - x) - y
function code(x, y) return Float64(Float64(1.0 - x) - y) end
function tmp = code(x, y) tmp = (1.0 - x) - y; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((1) - x) - y END code
\left(1 - x\right) - y
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (- (- 1.0 x) y))
double code(double x, double y) {
return (1.0 - x) - y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) - y
end function
public static double code(double x, double y) {
return (1.0 - x) - y;
}
def code(x, y): return (1.0 - x) - y
function code(x, y) return Float64(Float64(1.0 - x) - y) end
function tmp = code(x, y) tmp = (1.0 - x) - y; end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] - y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((1) - x) - y END code
\left(1 - x\right) - y
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (- 1.0 (fmin x y))))
(if (<= (- t_0 (fmax x y)) 0.9999999999999998)
(- 1.0 (fmax x y))
t_0)))double code(double x, double y) {
double t_0 = 1.0 - fmin(x, y);
double tmp;
if ((t_0 - fmax(x, y)) <= 0.9999999999999998) {
tmp = 1.0 - fmax(x, y);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - fmin(x, y)
if ((t_0 - fmax(x, y)) <= 0.9999999999999998d0) then
tmp = 1.0d0 - fmax(x, y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - fmin(x, y);
double tmp;
if ((t_0 - fmax(x, y)) <= 0.9999999999999998) {
tmp = 1.0 - fmax(x, y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = 1.0 - fmin(x, y) tmp = 0 if (t_0 - fmax(x, y)) <= 0.9999999999999998: tmp = 1.0 - fmax(x, y) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(1.0 - fmin(x, y)) tmp = 0.0 if (Float64(t_0 - fmax(x, y)) <= 0.9999999999999998) tmp = Float64(1.0 - fmax(x, y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - min(x, y); tmp = 0.0; if ((t_0 - max(x, y)) <= 0.9999999999999998) tmp = 1.0 - max(x, y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[Min[x, y], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Max[x, y], $MachinePrecision]), $MachinePrecision], 0.9999999999999998], N[(1.0 - N[Max[x, y], $MachinePrecision]), $MachinePrecision], t$95$0]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (x < y) THEN x ELSE y ENDIF IN LET t_0 = ((1) - tmp) IN LET tmp_3 = IF (x > y) THEN x ELSE y ENDIF IN LET tmp_4 = IF (x > y) THEN x ELSE y ENDIF IN LET tmp_2 = IF ((t_0 - tmp_3) <= (9999999999999997779553950749686919152736663818359375e-52)) THEN ((1) - tmp_4) ELSE t_0 ENDIF IN tmp_2 END code
\begin{array}{l}
t_0 := 1 - \mathsf{min}\left(x, y\right)\\
\mathbf{if}\;t\_0 - \mathsf{max}\left(x, y\right) \leq 0.9999999999999998:\\
\;\;\;\;1 - \mathsf{max}\left(x, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if (-.f64 (-.f64 #s(literal 1 binary64) x) y) < 0.99999999999999978Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites62.9%
if 0.99999999999999978 < (-.f64 (-.f64 #s(literal 1 binary64) x) y) Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites62.8%
(FPCore (x y) :precision binary64 :pre TRUE (- 1.0 (fmin x y)))
double code(double x, double y) {
return 1.0 - fmin(x, y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - fmin(x, y)
end function
public static double code(double x, double y) {
return 1.0 - fmin(x, y);
}
def code(x, y): return 1.0 - fmin(x, y)
function code(x, y) return Float64(1.0 - fmin(x, y)) end
function tmp = code(x, y) tmp = 1.0 - min(x, y); end
code[x_, y_] := N[(1.0 - N[Min[x, y], $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (x < y) THEN x ELSE y ENDIF IN (1) - tmp END code
1 - \mathsf{min}\left(x, y\right)
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites62.8%
(FPCore (x y) :precision binary64 :pre TRUE 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = 1 END code
1
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites62.8%
Taylor expanded in x around 0
Applied rewrites26.4%
herbie shell --seed 2026092
(FPCore (x y)
:name "Data.Colour.CIE.Chromaticity:chromaCoords from colour-2.3.3"
:precision binary64
(- (- 1.0 x) y))