
(FPCore (x y) :precision binary64 :pre TRUE (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = ((y * (4)) * y) IN ((x * x) - t_0) / ((x * x) + t_0) END code
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
Herbie found 3 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (let* ((t_0 (* (* y 4.0) y))) (/ (- (* x x) t_0) (+ (* x x) t_0))))
double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
t_0 = (y * 4.0d0) * y
code = ((x * x) - t_0) / ((x * x) + t_0)
end function
public static double code(double x, double y) {
double t_0 = (y * 4.0) * y;
return ((x * x) - t_0) / ((x * x) + t_0);
}
def code(x, y): t_0 = (y * 4.0) * y return ((x * x) - t_0) / ((x * x) + t_0)
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) return Float64(Float64(Float64(x * x) - t_0) / Float64(Float64(x * x) + t_0)) end
function tmp = code(x, y) t_0 = (y * 4.0) * y; tmp = ((x * x) - t_0) / ((x * x) + t_0); end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, N[(N[(N[(x * x), $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = ((y * (4)) * y) IN ((x * x) - t_0) / ((x * x) + t_0) END code
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\frac{x \cdot x - t\_0}{x \cdot x + t\_0}
\end{array}
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (* (* y 4.0) y)))
(if (<= t_0 2e-207)
1.0
(if (<= t_0 1e+270)
(/ (fma y (* -4.0 y) (* x x)) (fma (* 4.0 y) y (* x x)))
-1.0))))double code(double x, double y) {
double t_0 = (y * 4.0) * y;
double tmp;
if (t_0 <= 2e-207) {
tmp = 1.0;
} else if (t_0 <= 1e+270) {
tmp = fma(y, (-4.0 * y), (x * x)) / fma((4.0 * y), y, (x * x));
} else {
tmp = -1.0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(y * 4.0) * y) tmp = 0.0 if (t_0 <= 2e-207) tmp = 1.0; elseif (t_0 <= 1e+270) tmp = Float64(fma(y, Float64(-4.0 * y), Float64(x * x)) / fma(Float64(4.0 * y), y, Float64(x * x))); else tmp = -1.0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-207], 1.0, If[LessEqual[t$95$0, 1e+270], N[(N[(y * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(4.0 * y), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET t_0 = ((y * (4)) * y) IN LET tmp_1 = IF (t_0 <= (1000000000000000046753818885456127989189605431330410286841364872744016439394555894610368258180303336939076888134044950289326168184662430331474313277416979816387389279864637935586997520238352311022660078293728671385192933261062303434752638026781377548741967884639283445760)) THEN (((y * ((-4) * y)) + (x * x)) / ((((4) * y) * y) + (x * x))) ELSE (-1) ENDIF IN LET tmp = IF (t_0 <= (19999999999999998500057988813309052158878670450379984832068198023382673287842269034781394828896796779433247043788236241482444063890001975599707774292971993779901934784385820134175074030084732147960592089873240346543356281598004867966117982185940517430870992813877962560518850311709787416505414965043679965885414329927709509480949808390423899621647146240513041589180574625500794646704022904591156621969054121565133570036450400610544364643046101101917584504075654207402340596223998362723049009893883098953892840654589235782623291015625e-739)) THEN (1) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \left(y \cdot 4\right) \cdot y\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-207}:\\
\;\;\;\;1\\
\mathbf{elif}\;t\_0 \leq 10^{+270}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, -4 \cdot y, x \cdot x\right)}{\mathsf{fma}\left(4 \cdot y, y, x \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1.9999999999999999e-207Initial program 50.6%
Taylor expanded in x around inf
Applied rewrites50.8%
if 1.9999999999999999e-207 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 1e270Initial program 50.6%
Applied rewrites50.5%
Applied rewrites50.6%
if 1e270 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 50.6%
Taylor expanded in x around 0
Applied rewrites49.7%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= (* (* y 4.0) y) 171156406.40053666) 1.0 -1.0))
double code(double x, double y) {
double tmp;
if (((y * 4.0) * y) <= 171156406.40053666) {
tmp = 1.0;
} else {
tmp = -1.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) :: tmp
if (((y * 4.0d0) * y) <= 171156406.40053666d0) then
tmp = 1.0d0
else
tmp = -1.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (((y * 4.0) * y) <= 171156406.40053666) {
tmp = 1.0;
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y): tmp = 0 if ((y * 4.0) * y) <= 171156406.40053666: tmp = 1.0 else: tmp = -1.0 return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(y * 4.0) * y) <= 171156406.40053666) tmp = 1.0; else tmp = -1.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (((y * 4.0) * y) <= 171156406.40053666) tmp = 1.0; else tmp = -1.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(y * 4.0), $MachinePrecision] * y), $MachinePrecision], 171156406.40053666], 1.0, -1.0]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = LET tmp = IF (((y * (4)) * y) <= (17115640640053665637969970703125e-23)) THEN (1) ELSE (-1) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left(y \cdot 4\right) \cdot y \leq 171156406.40053666:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
if (*.f64 (*.f64 y #s(literal 4 binary64)) y) < 171156406.40053666Initial program 50.6%
Taylor expanded in x around inf
Applied rewrites50.8%
if 171156406.40053666 < (*.f64 (*.f64 y #s(literal 4 binary64)) y) Initial program 50.6%
Taylor expanded in x around 0
Applied rewrites49.7%
(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 50.6%
Taylor expanded in x around 0
Applied rewrites49.7%
herbie shell --seed 2026092
(FPCore (x y)
:name "Diagrams.TwoD.Arc:arcBetween from diagrams-lib-1.3.0.3"
:precision binary64
(/ (- (* x x) (* (* y 4.0) y)) (+ (* x x) (* (* y 4.0) y))))