
(FPCore (x y) :precision binary64 :pre TRUE (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x + (((1) - x) * ((1) - y)) END code
x + \left(1 - x\right) \cdot \left(1 - y\right)
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (+ x (* (- 1.0 x) (- 1.0 y))))
double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + ((1.0d0 - x) * (1.0d0 - y))
end function
public static double code(double x, double y) {
return x + ((1.0 - x) * (1.0 - y));
}
def code(x, y): return x + ((1.0 - x) * (1.0 - y))
function code(x, y) return Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) end
function tmp = code(x, y) tmp = x + ((1.0 - x) * (1.0 - y)); end
code[x_, y_] := N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x + (((1) - x) * ((1) - y)) END code
x + \left(1 - x\right) \cdot \left(1 - y\right)
(FPCore (x y) :precision binary64 :pre TRUE (fma y (- x 1.0) 1.0))
double code(double x, double y) {
return fma(y, (x - 1.0), 1.0);
}
function code(x, y) return fma(y, Float64(x - 1.0), 1.0) end
code[x_, y_] := N[(y * N[(x - 1.0), $MachinePrecision] + 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (y * (x - (1))) + (1) END code
\mathsf{fma}\left(y, x - 1, 1\right)
Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites100.0%
Applied rewrites100.0%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (+ x (* (- 1.0 x) (- 1.0 y)))) (t_1 (* y (- x 1.0))))
(if (<= t_0 -5e+15)
t_1
(if (<= t_0 2000000000000.0) (fma y -1.0 1.0) t_1))))double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double t_1 = y * (x - 1.0);
double tmp;
if (t_0 <= -5e+15) {
tmp = t_1;
} else if (t_0 <= 2000000000000.0) {
tmp = fma(y, -1.0, 1.0);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) t_1 = Float64(y * Float64(x - 1.0)) tmp = 0.0 if (t_0 <= -5e+15) tmp = t_1; elseif (t_0 <= 2000000000000.0) tmp = fma(y, -1.0, 1.0); else tmp = t_1; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+15], t$95$1, If[LessEqual[t$95$0, 2000000000000.0], N[(y * -1.0 + 1.0), $MachinePrecision], t$95$1]]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = (x + (((1) - x) * ((1) - y))) IN LET t_1 = (y * (x - (1))) IN LET tmp_1 = IF (t_0 <= (2e12)) THEN ((y * (-1)) + (1)) ELSE t_1 ENDIF IN LET tmp = IF (t_0 <= (-5e15)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := x + \left(1 - x\right) \cdot \left(1 - y\right)\\
t_1 := y \cdot \left(x - 1\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 2000000000000:\\
\;\;\;\;\mathsf{fma}\left(y, -1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < -5e15 or 2e12 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites62.9%
if -5e15 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 2e12Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites62.5%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= x -9663365479874.781) (* x y) (if (<= x 2.0258055932687762e+38) (fma y -1.0 1.0) (* x y))))
double code(double x, double y) {
double tmp;
if (x <= -9663365479874.781) {
tmp = x * y;
} else if (x <= 2.0258055932687762e+38) {
tmp = fma(y, -1.0, 1.0);
} else {
tmp = x * y;
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= -9663365479874.781) tmp = Float64(x * y); elseif (x <= 2.0258055932687762e+38) tmp = fma(y, -1.0, 1.0); else tmp = Float64(x * y); end return tmp end
code[x_, y_] := If[LessEqual[x, -9663365479874.781], N[(x * y), $MachinePrecision], If[LessEqual[x, 2.0258055932687762e+38], N[(y * -1.0 + 1.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF (x <= (202580559326877620351318635225240567808)) THEN ((y * (-1)) + (1)) ELSE (x * y) ENDIF IN LET tmp = IF (x <= (-966336547987478125e-5)) THEN (x * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -9663365479874.781:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;x \leq 2.0258055932687762 \cdot 10^{+38}:\\
\;\;\;\;\mathsf{fma}\left(y, -1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if x < -9663365479874.7812 or 2.0258055932687762e38 < x Initial program 77.9%
Taylor expanded in x around -inf
Applied rewrites38.9%
if -9663365479874.7812 < x < 2.0258055932687762e38Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in x around 0
Applied rewrites62.5%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (+ x (* (- 1.0 x) (- 1.0 y)))))
(if (<= t_0 (- INFINITY))
(* x y)
(if (<= t_0 -5e+15)
(* y -1.0)
(if (<= t_0 2.0)
(+ 0.0 1.0)
(if (<= t_0 1e+97) (* y -1.0) (* x y)))))))double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = x * y;
} else if (t_0 <= -5e+15) {
tmp = y * -1.0;
} else if (t_0 <= 2.0) {
tmp = 0.0 + 1.0;
} else if (t_0 <= 1e+97) {
tmp = y * -1.0;
} else {
tmp = x * y;
}
return tmp;
}
public static double code(double x, double y) {
double t_0 = x + ((1.0 - x) * (1.0 - y));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = x * y;
} else if (t_0 <= -5e+15) {
tmp = y * -1.0;
} else if (t_0 <= 2.0) {
tmp = 0.0 + 1.0;
} else if (t_0 <= 1e+97) {
tmp = y * -1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): t_0 = x + ((1.0 - x) * (1.0 - y)) tmp = 0 if t_0 <= -math.inf: tmp = x * y elif t_0 <= -5e+15: tmp = y * -1.0 elif t_0 <= 2.0: tmp = 0.0 + 1.0 elif t_0 <= 1e+97: tmp = y * -1.0 else: tmp = x * y return tmp
function code(x, y) t_0 = Float64(x + Float64(Float64(1.0 - x) * Float64(1.0 - y))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(x * y); elseif (t_0 <= -5e+15) tmp = Float64(y * -1.0); elseif (t_0 <= 2.0) tmp = Float64(0.0 + 1.0); elseif (t_0 <= 1e+97) tmp = Float64(y * -1.0); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) t_0 = x + ((1.0 - x) * (1.0 - y)); tmp = 0.0; if (t_0 <= -Inf) tmp = x * y; elseif (t_0 <= -5e+15) tmp = y * -1.0; elseif (t_0 <= 2.0) tmp = 0.0 + 1.0; elseif (t_0 <= 1e+97) tmp = y * -1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x + N[(N[(1.0 - x), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x * y), $MachinePrecision], If[LessEqual[t$95$0, -5e+15], N[(y * -1.0), $MachinePrecision], If[LessEqual[t$95$0, 2.0], N[(0.0 + 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1e+97], N[(y * -1.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := x + \left(1 - x\right) \cdot \left(1 - y\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;t\_0 \leq -5 \cdot 10^{+15}:\\
\;\;\;\;y \cdot -1\\
\mathbf{elif}\;t\_0 \leq 2:\\
\;\;\;\;0 + 1\\
\mathbf{elif}\;t\_0 \leq 10^{+97}:\\
\;\;\;\;y \cdot -1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < -inf.0 or 1.0000000000000001e97 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) Initial program 77.9%
Taylor expanded in x around -inf
Applied rewrites38.9%
if -inf.0 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < -5e15 or 2 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 1.0000000000000001e97Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites100.0%
Applied rewrites100.0%
Taylor expanded in y around inf
Applied rewrites62.9%
Taylor expanded in x around 0
Applied rewrites26.4%
if -5e15 < (+.f64 x (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 1 binary64) y))) < 2Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites27.7%
Taylor expanded in x around 0
Applied rewrites26.7%
Taylor expanded in undef-var around zero
Applied rewrites38.1%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= y -7.398787557941889e-77) (* x y) (if (<= y 1.1233019634679706e-7) (+ 0.0 1.0) (* x y))))
double code(double x, double y) {
double tmp;
if (y <= -7.398787557941889e-77) {
tmp = x * y;
} else if (y <= 1.1233019634679706e-7) {
tmp = 0.0 + 1.0;
} else {
tmp = x * y;
}
return tmp;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-7.398787557941889d-77)) then
tmp = x * y
else if (y <= 1.1233019634679706d-7) then
tmp = 0.0d0 + 1.0d0
else
tmp = x * y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -7.398787557941889e-77) {
tmp = x * y;
} else if (y <= 1.1233019634679706e-7) {
tmp = 0.0 + 1.0;
} else {
tmp = x * y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -7.398787557941889e-77: tmp = x * y elif y <= 1.1233019634679706e-7: tmp = 0.0 + 1.0 else: tmp = x * y return tmp
function code(x, y) tmp = 0.0 if (y <= -7.398787557941889e-77) tmp = Float64(x * y); elseif (y <= 1.1233019634679706e-7) tmp = Float64(0.0 + 1.0); else tmp = Float64(x * y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -7.398787557941889e-77) tmp = x * y; elseif (y <= 1.1233019634679706e-7) tmp = 0.0 + 1.0; else tmp = x * y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -7.398787557941889e-77], N[(x * y), $MachinePrecision], If[LessEqual[y, 1.1233019634679706e-7], N[(0.0 + 1.0), $MachinePrecision], N[(x * y), $MachinePrecision]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp_1 = IF (y <= (1123301963467970569704454451669117798218167081358842551708221435546875e-76)) THEN ((0) + (1)) ELSE (x * y) ENDIF IN LET tmp = IF (y <= (-7398787557941888617686517894584122973779347148046538069064001885703742276403949176133255639575237768262726293578554447494614506223845400053473003812654436033228776958978170144012492632991546959164708141543087549507617950439453125e-305)) THEN (x * y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;y \leq -7.398787557941889 \cdot 10^{-77}:\\
\;\;\;\;x \cdot y\\
\mathbf{elif}\;y \leq 1.1233019634679706 \cdot 10^{-7}:\\
\;\;\;\;0 + 1\\
\mathbf{else}:\\
\;\;\;\;x \cdot y\\
\end{array}
if y < -7.3987875579418886e-77 or 1.1233019634679706e-7 < y Initial program 77.9%
Taylor expanded in x around -inf
Applied rewrites38.9%
if -7.3987875579418886e-77 < y < 1.1233019634679706e-7Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites27.7%
Taylor expanded in x around 0
Applied rewrites26.7%
Taylor expanded in undef-var around zero
Applied rewrites38.1%
(FPCore (x y) :precision binary64 :pre TRUE (+ 0.0 1.0))
double code(double x, double y) {
return 0.0 + 1.0;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.0d0 + 1.0d0
end function
public static double code(double x, double y) {
return 0.0 + 1.0;
}
def code(x, y): return 0.0 + 1.0
function code(x, y) return Float64(0.0 + 1.0) end
function tmp = code(x, y) tmp = 0.0 + 1.0; end
code[x_, y_] := N[(0.0 + 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = (0) + (1) END code
0 + 1
Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites27.7%
Taylor expanded in x around 0
Applied rewrites26.7%
Taylor expanded in undef-var around zero
Applied rewrites38.1%
(FPCore (x y) :precision binary64 :pre TRUE (+ x 1.0))
double code(double x, double y) {
return x + 1.0;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x + 1.0d0
end function
public static double code(double x, double y) {
return x + 1.0;
}
def code(x, y): return x + 1.0
function code(x, y) return Float64(x + 1.0) end
function tmp = code(x, y) tmp = x + 1.0; end
code[x_, y_] := N[(x + 1.0), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = x + (1) END code
x + 1
Initial program 77.9%
Taylor expanded in y around 0
Applied rewrites27.7%
Taylor expanded in x around 0
Applied rewrites26.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Graphics.Rendering.Chart.Plot.Vectors:renderPlotVectors from Chart-1.5.3"
:precision binary64
(+ x (* (- 1.0 x) (- 1.0 y))))