
(FPCore (x y) :precision binary64 :pre TRUE (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (2)) * y) / (x - y) END code
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 :pre TRUE (/ (* (* x 2.0) y) (- x y)))
double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * 2.0d0) * y) / (x - y)
end function
public static double code(double x, double y) {
return ((x * 2.0) * y) / (x - y);
}
def code(x, y): return ((x * 2.0) * y) / (x - y)
function code(x, y) return Float64(Float64(Float64(x * 2.0) * y) / Float64(x - y)) end
function tmp = code(x, y) tmp = ((x * 2.0) * y) / (x - y); end
code[x_, y_] := N[(N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision] / N[(x - y), $MachinePrecision]), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = ((x * (2)) * y) / (x - y) END code
\frac{\left(x \cdot 2\right) \cdot y}{x - y}
(FPCore (x y)
:precision binary64
:pre TRUE
(if (<= x -13996.61964560276)
(* (+ y y) (/ x (- x y)))
(if (<= x 1.6822977259161094e-10)
(* (+ x x) (/ y (- x y)))
(/ y (- 0.5 (/ y (+ x x)))))))double code(double x, double y) {
double tmp;
if (x <= -13996.61964560276) {
tmp = (y + y) * (x / (x - y));
} else if (x <= 1.6822977259161094e-10) {
tmp = (x + x) * (y / (x - y));
} else {
tmp = y / (0.5 - (y / (x + x)));
}
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 (x <= (-13996.61964560276d0)) then
tmp = (y + y) * (x / (x - y))
else if (x <= 1.6822977259161094d-10) then
tmp = (x + x) * (y / (x - y))
else
tmp = y / (0.5d0 - (y / (x + x)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -13996.61964560276) {
tmp = (y + y) * (x / (x - y));
} else if (x <= 1.6822977259161094e-10) {
tmp = (x + x) * (y / (x - y));
} else {
tmp = y / (0.5 - (y / (x + x)));
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -13996.61964560276: tmp = (y + y) * (x / (x - y)) elif x <= 1.6822977259161094e-10: tmp = (x + x) * (y / (x - y)) else: tmp = y / (0.5 - (y / (x + x))) return tmp
function code(x, y) tmp = 0.0 if (x <= -13996.61964560276) tmp = Float64(Float64(y + y) * Float64(x / Float64(x - y))); elseif (x <= 1.6822977259161094e-10) tmp = Float64(Float64(x + x) * Float64(y / Float64(x - y))); else tmp = Float64(y / Float64(0.5 - Float64(y / Float64(x + x)))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -13996.61964560276) tmp = (y + y) * (x / (x - y)); elseif (x <= 1.6822977259161094e-10) tmp = (x + x) * (y / (x - y)); else tmp = y / (0.5 - (y / (x + x))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -13996.61964560276], N[(N[(y + y), $MachinePrecision] * N[(x / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.6822977259161094e-10], N[(N[(x + x), $MachinePrecision] * N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(0.5 - N[(y / N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 <= (168229772591610942516408030476620337478887989846043637953698635101318359375e-84)) THEN ((x + x) * (y / (x - y))) ELSE (y / ((5e-1) - (y / (x + x)))) ENDIF IN LET tmp = IF (x <= (-13996619645602759192115627229213714599609375e-39)) THEN ((y + y) * (x / (x - y))) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -13996.61964560276:\\
\;\;\;\;\left(y + y\right) \cdot \frac{x}{x - y}\\
\mathbf{elif}\;x \leq 1.6822977259161094 \cdot 10^{-10}:\\
\;\;\;\;\left(x + x\right) \cdot \frac{y}{x - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{0.5 - \frac{y}{x + x}}\\
\end{array}
if x < -13996.619645602759Initial program 77.3%
Applied rewrites88.2%
if -13996.619645602759 < x < 1.6822977259161094e-10Initial program 77.3%
Applied rewrites89.0%
if 1.6822977259161094e-10 < x Initial program 77.3%
Applied rewrites77.1%
Applied rewrites87.5%
Applied rewrites87.6%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (* (+ x x) (/ y (- x y)))))
(if (<= y -1.712317240886347e+24)
t_0
(if (<= y 4.528461901083382e+77) (* (+ y y) (/ x (- x y))) t_0))))double code(double x, double y) {
double t_0 = (x + x) * (y / (x - y));
double tmp;
if (y <= -1.712317240886347e+24) {
tmp = t_0;
} else if (y <= 4.528461901083382e+77) {
tmp = (y + y) * (x / (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 = (x + x) * (y / (x - y))
if (y <= (-1.712317240886347d+24)) then
tmp = t_0
else if (y <= 4.528461901083382d+77) then
tmp = (y + y) * (x / (x - y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = (x + x) * (y / (x - y));
double tmp;
if (y <= -1.712317240886347e+24) {
tmp = t_0;
} else if (y <= 4.528461901083382e+77) {
tmp = (y + y) * (x / (x - y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = (x + x) * (y / (x - y)) tmp = 0 if y <= -1.712317240886347e+24: tmp = t_0 elif y <= 4.528461901083382e+77: tmp = (y + y) * (x / (x - y)) else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(Float64(x + x) * Float64(y / Float64(x - y))) tmp = 0.0 if (y <= -1.712317240886347e+24) tmp = t_0; elseif (y <= 4.528461901083382e+77) tmp = Float64(Float64(y + y) * Float64(x / Float64(x - y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = (x + x) * (y / (x - y)); tmp = 0.0; if (y <= -1.712317240886347e+24) tmp = t_0; elseif (y <= 4.528461901083382e+77) tmp = (y + y) * (x / (x - y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + x), $MachinePrecision] * N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.712317240886347e+24], t$95$0, If[LessEqual[y, 4.528461901083382e+77], N[(N[(y + y), $MachinePrecision] * N[(x / N[(x - y), $MachinePrecision]), $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 t_0 = ((x + x) * (y / (x - y))) IN LET tmp_1 = IF (y <= (452846190108338205639346410490344069348877864692958048651167311389807469395968)) THEN ((y + y) * (x / (x - y))) ELSE t_0 ENDIF IN LET tmp = IF (y <= (-1712317240886347050254336)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \left(x + x\right) \cdot \frac{y}{x - y}\\
\mathbf{if}\;y \leq -1.712317240886347 \cdot 10^{+24}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.528461901083382 \cdot 10^{+77}:\\
\;\;\;\;\left(y + y\right) \cdot \frac{x}{x - y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.7123172408863471e24 or 4.5284619010833821e77 < y Initial program 77.3%
Applied rewrites89.0%
if -1.7123172408863471e24 < y < 4.5284619010833821e77Initial program 77.3%
Applied rewrites88.2%
(FPCore (x y)
:precision binary64
:pre TRUE
(let* ((t_0 (* (+ x x) (/ y (- x y)))))
(if (<= y -1.1475811057250325e-242)
t_0
(if (<= y 3.3003929900051086e-162)
(* 2.0 (fma y (/ y x) y))
t_0))))double code(double x, double y) {
double t_0 = (x + x) * (y / (x - y));
double tmp;
if (y <= -1.1475811057250325e-242) {
tmp = t_0;
} else if (y <= 3.3003929900051086e-162) {
tmp = 2.0 * fma(y, (y / x), y);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, y) t_0 = Float64(Float64(x + x) * Float64(y / Float64(x - y))) tmp = 0.0 if (y <= -1.1475811057250325e-242) tmp = t_0; elseif (y <= 3.3003929900051086e-162) tmp = Float64(2.0 * fma(y, Float64(y / x), y)); else tmp = t_0; end return tmp end
code[x_, y_] := Block[{t$95$0 = N[(N[(x + x), $MachinePrecision] * N[(y / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.1475811057250325e-242], t$95$0, If[LessEqual[y, 3.3003929900051086e-162], N[(2.0 * N[(y * N[(y / x), $MachinePrecision] + 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 t_0 = ((x + x) * (y / (x - y))) IN LET tmp_1 = IF (y <= (33003929900051086347633598244156977954691151604997871907467177159832261398428432006018386061616764705292641951582290021070506605369882130874562431347736456645566339031447937487061916350476490439019324430673195347128433523832131311258936944110662937357325319337185152867380509671240634025926589954312950667530949858050817133788838994739852497957907901976772319859700447651883054226546430898192596714579849503934383392333984375e-586)) THEN ((2) * ((y * (y / x)) + y)) ELSE t_0 ENDIF IN LET tmp = IF (y <= (-114758110572503251141730386607988073827233731336094270904548315016248603744169163772647436088509301026416197194398379093526382737549206915285146415828362700843542498130083997403840439276482232652111888735691617304148039009900291961400231508412249614303588035984396211956383739474470627363590810685403534313467749475416057269045303588270493753328734396097084524629770525191062035924065657671862236091119307639050151711710238199316014633732709504747714518442602818925504881832045587457928815500522681107907329061881305551446435885618696033397517038479632377185429558619981886546934646275985869579017162322998046875e-853)) THEN t_0 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_0 := \left(x + x\right) \cdot \frac{y}{x - y}\\
\mathbf{if}\;y \leq -1.1475811057250325 \cdot 10^{-242}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.3003929900051086 \cdot 10^{-162}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, \frac{y}{x}, y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if y < -1.1475811057250325e-242 or 3.3003929900051086e-162 < y Initial program 77.3%
Applied rewrites89.0%
if -1.1475811057250325e-242 < y < 3.3003929900051086e-162Initial program 77.3%
Taylor expanded in y around 0
Applied rewrites50.1%
Applied rewrites50.1%
(FPCore (x y) :precision binary64 :pre TRUE (if (<= x -5.039907711792451e-56) (+ y y) (if (<= x 4.1876733463546205e+30) (* -2.0 x) (+ y y))))
double code(double x, double y) {
double tmp;
if (x <= -5.039907711792451e-56) {
tmp = y + y;
} else if (x <= 4.1876733463546205e+30) {
tmp = -2.0 * x;
} else {
tmp = y + 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 (x <= (-5.039907711792451d-56)) then
tmp = y + y
else if (x <= 4.1876733463546205d+30) then
tmp = (-2.0d0) * x
else
tmp = y + y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -5.039907711792451e-56) {
tmp = y + y;
} else if (x <= 4.1876733463546205e+30) {
tmp = -2.0 * x;
} else {
tmp = y + y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -5.039907711792451e-56: tmp = y + y elif x <= 4.1876733463546205e+30: tmp = -2.0 * x else: tmp = y + y return tmp
function code(x, y) tmp = 0.0 if (x <= -5.039907711792451e-56) tmp = Float64(y + y); elseif (x <= 4.1876733463546205e+30) tmp = Float64(-2.0 * x); else tmp = Float64(y + y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -5.039907711792451e-56) tmp = y + y; elseif (x <= 4.1876733463546205e+30) tmp = -2.0 * x; else tmp = y + y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -5.039907711792451e-56], N[(y + y), $MachinePrecision], If[LessEqual[x, 4.1876733463546205e+30], N[(-2.0 * x), $MachinePrecision], N[(y + 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 <= (4187673346354620473416423047168)) THEN ((-2) * x) ELSE (y + y) ENDIF IN LET tmp = IF (x <= (-503990771179245087994483158180417636751518472116048142633389048672491776078072589798927984249697471122399245012078916984904270611085258329241154395816693067899905145168304443359375e-235)) THEN (y + y) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;x \leq -5.039907711792451 \cdot 10^{-56}:\\
\;\;\;\;y + y\\
\mathbf{elif}\;x \leq 4.1876733463546205 \cdot 10^{+30}:\\
\;\;\;\;-2 \cdot x\\
\mathbf{else}:\\
\;\;\;\;y + y\\
\end{array}
if x < -5.0399077117924509e-56 or 4.1876733463546205e30 < x Initial program 77.3%
Taylor expanded in x around inf
Applied rewrites50.5%
Applied rewrites50.5%
if -5.0399077117924509e-56 < x < 4.1876733463546205e30Initial program 77.3%
Taylor expanded in x around 0
Applied rewrites50.9%
(FPCore (x y) :precision binary64 :pre TRUE (+ y y))
double code(double x, double y) {
return y + y;
}
real(8) function code(x, y)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = y + y
end function
public static double code(double x, double y) {
return y + y;
}
def code(x, y): return y + y
function code(x, y) return Float64(y + y) end
function tmp = code(x, y) tmp = y + y; end
code[x_, y_] := N[(y + y), $MachinePrecision]
f(x, y): x in [-inf, +inf], y in [-inf, +inf] code: THEORY BEGIN f(x, y: real): real = y + y END code
y + y
Initial program 77.3%
Taylor expanded in x around inf
Applied rewrites50.5%
Applied rewrites50.5%
herbie shell --seed 2026092
(FPCore (x y)
:name "Linear.Projection:perspective from linear-1.19.1.3, B"
:precision binary64
(/ (* (* x 2.0) y) (- x y)))