
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + y) / (1.0d0 - (y / z))
end function
public static double code(double x, double y, double z) {
return (x + y) / (1.0 - (y / z));
}
def code(x, y, z): return (x + y) / (1.0 - (y / z))
function code(x, y, z) return Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) end
function tmp = code(x, y, z) tmp = (x + y) / (1.0 - (y / z)); end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y}{1 - \frac{y}{z}}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x y) (- 1.0 (/ y z)))))
(if (<= t_0 -5e-255)
t_0
(if (<= t_0 0.0) (- 0.0 (* z (/ (+ x y) y))) t_0))))
double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if (t_0 <= -5e-255) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = 0.0 - (z * ((x + y) / y));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x + y) / (1.0d0 - (y / z))
if (t_0 <= (-5d-255)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = 0.0d0 - (z * ((x + y) / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x + y) / (1.0 - (y / z));
double tmp;
if (t_0 <= -5e-255) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = 0.0 - (z * ((x + y) / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x + y) / (1.0 - (y / z)) tmp = 0 if t_0 <= -5e-255: tmp = t_0 elif t_0 <= 0.0: tmp = 0.0 - (z * ((x + y) / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))) tmp = 0.0 if (t_0 <= -5e-255) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(0.0 - Float64(z * Float64(Float64(x + y) / y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + y) / (1.0 - (y / z)); tmp = 0.0; if (t_0 <= -5e-255) tmp = t_0; elseif (t_0 <= 0.0) tmp = 0.0 - (z * ((x + y) / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-255], t$95$0, If[LessEqual[t$95$0, 0.0], N[(0.0 - N[(z * N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-255}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;0 - z \cdot \frac{x + y}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < -4.9999999999999996e-255 or 0.0 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) Initial program 99.8%
if -4.9999999999999996e-255 < (/.f64 (+.f64 x y) (-.f64 #s(literal 1 binary64) (/.f64 y z))) < 0.0Initial program 9.2%
div-invN/A
flip3--N/A
clear-numN/A
*-commutativeN/A
*-lowering-*.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f649.2%
Applied egg-rr9.2%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64100.0%
Simplified100.0%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f64100.0%
Applied egg-rr100.0%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ y z))) (t_1 (/ y t_0)))
(if (<= y -1.6e+275)
(- 0.0 z)
(if (<= y -3400000000000.0)
t_1
(if (<= y 2.3e-36) (/ x t_0) (if (<= y 8.5e+162) t_1 (- 0.0 z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double tmp;
if (y <= -1.6e+275) {
tmp = 0.0 - z;
} else if (y <= -3400000000000.0) {
tmp = t_1;
} else if (y <= 2.3e-36) {
tmp = x / t_0;
} else if (y <= 8.5e+162) {
tmp = t_1;
} else {
tmp = 0.0 - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (y / z)
t_1 = y / t_0
if (y <= (-1.6d+275)) then
tmp = 0.0d0 - z
else if (y <= (-3400000000000.0d0)) then
tmp = t_1
else if (y <= 2.3d-36) then
tmp = x / t_0
else if (y <= 8.5d+162) then
tmp = t_1
else
tmp = 0.0d0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (y / z);
double t_1 = y / t_0;
double tmp;
if (y <= -1.6e+275) {
tmp = 0.0 - z;
} else if (y <= -3400000000000.0) {
tmp = t_1;
} else if (y <= 2.3e-36) {
tmp = x / t_0;
} else if (y <= 8.5e+162) {
tmp = t_1;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (y / z) t_1 = y / t_0 tmp = 0 if y <= -1.6e+275: tmp = 0.0 - z elif y <= -3400000000000.0: tmp = t_1 elif y <= 2.3e-36: tmp = x / t_0 elif y <= 8.5e+162: tmp = t_1 else: tmp = 0.0 - z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(y / z)) t_1 = Float64(y / t_0) tmp = 0.0 if (y <= -1.6e+275) tmp = Float64(0.0 - z); elseif (y <= -3400000000000.0) tmp = t_1; elseif (y <= 2.3e-36) tmp = Float64(x / t_0); elseif (y <= 8.5e+162) tmp = t_1; else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (y / z); t_1 = y / t_0; tmp = 0.0; if (y <= -1.6e+275) tmp = 0.0 - z; elseif (y <= -3400000000000.0) tmp = t_1; elseif (y <= 2.3e-36) tmp = x / t_0; elseif (y <= 8.5e+162) tmp = t_1; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y / t$95$0), $MachinePrecision]}, If[LessEqual[y, -1.6e+275], N[(0.0 - z), $MachinePrecision], If[LessEqual[y, -3400000000000.0], t$95$1, If[LessEqual[y, 2.3e-36], N[(x / t$95$0), $MachinePrecision], If[LessEqual[y, 8.5e+162], t$95$1, N[(0.0 - z), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{y}{z}\\
t_1 := \frac{y}{t\_0}\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{+275}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;y \leq -3400000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-36}:\\
\;\;\;\;\frac{x}{t\_0}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+162}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if y < -1.59999999999999987e275 or 8.5000000000000003e162 < y Initial program 59.6%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6476.8%
Simplified76.8%
sub0-negN/A
neg-lowering-neg.f6476.8%
Applied egg-rr76.8%
if -1.59999999999999987e275 < y < -3.4e12 or 2.29999999999999996e-36 < y < 8.5000000000000003e162Initial program 93.2%
Taylor expanded in x around 0
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6465.8%
Simplified65.8%
if -3.4e12 < y < 2.29999999999999996e-36Initial program 99.8%
Taylor expanded in x around inf
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6479.5%
Simplified79.5%
Final simplification74.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 0.0 (* z (/ (+ x y) y)))))
(if (<= y -3.5e-40)
t_0
(if (<= y -2.55e-135)
(+ x y)
(if (<= y 2.6e-50) (/ x (- 1.0 (/ y z))) t_0)))))
double code(double x, double y, double z) {
double t_0 = 0.0 - (z * ((x + y) / y));
double tmp;
if (y <= -3.5e-40) {
tmp = t_0;
} else if (y <= -2.55e-135) {
tmp = x + y;
} else if (y <= 2.6e-50) {
tmp = x / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = 0.0d0 - (z * ((x + y) / y))
if (y <= (-3.5d-40)) then
tmp = t_0
else if (y <= (-2.55d-135)) then
tmp = x + y
else if (y <= 2.6d-50) then
tmp = x / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 0.0 - (z * ((x + y) / y));
double tmp;
if (y <= -3.5e-40) {
tmp = t_0;
} else if (y <= -2.55e-135) {
tmp = x + y;
} else if (y <= 2.6e-50) {
tmp = x / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 0.0 - (z * ((x + y) / y)) tmp = 0 if y <= -3.5e-40: tmp = t_0 elif y <= -2.55e-135: tmp = x + y elif y <= 2.6e-50: tmp = x / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(0.0 - Float64(z * Float64(Float64(x + y) / y))) tmp = 0.0 if (y <= -3.5e-40) tmp = t_0; elseif (y <= -2.55e-135) tmp = Float64(x + y); elseif (y <= 2.6e-50) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.0 - (z * ((x + y) / y)); tmp = 0.0; if (y <= -3.5e-40) tmp = t_0; elseif (y <= -2.55e-135) tmp = x + y; elseif (y <= 2.6e-50) tmp = x / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.0 - N[(z * N[(N[(x + y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.5e-40], t$95$0, If[LessEqual[y, -2.55e-135], N[(x + y), $MachinePrecision], If[LessEqual[y, 2.6e-50], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0 - z \cdot \frac{x + y}{y}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.55 \cdot 10^{-135}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -3.5000000000000002e-40 or 2.6000000000000001e-50 < y Initial program 84.3%
div-invN/A
flip3--N/A
clear-numN/A
*-commutativeN/A
*-lowering-*.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6484.2%
Applied egg-rr84.2%
Taylor expanded in z around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
associate-/l*N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f6471.7%
Simplified71.7%
sub0-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
+-commutativeN/A
+-lowering-+.f6471.7%
Applied egg-rr71.7%
if -3.5000000000000002e-40 < y < -2.5500000000000001e-135Initial program 100.0%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6481.8%
Simplified81.8%
if -2.5500000000000001e-135 < y < 2.6000000000000001e-50Initial program 99.8%
Taylor expanded in x around inf
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6486.8%
Simplified86.8%
Final simplification78.3%
(FPCore (x y z)
:precision binary64
(if (<= y -9e+130)
(- 0.0 z)
(if (<= y -6e-136)
(+ x y)
(if (<= y 6.6e+77) (/ x (- 1.0 (/ y z))) (- 0.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e+130) {
tmp = 0.0 - z;
} else if (y <= -6e-136) {
tmp = x + y;
} else if (y <= 6.6e+77) {
tmp = x / (1.0 - (y / z));
} else {
tmp = 0.0 - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-9d+130)) then
tmp = 0.0d0 - z
else if (y <= (-6d-136)) then
tmp = x + y
else if (y <= 6.6d+77) then
tmp = x / (1.0d0 - (y / z))
else
tmp = 0.0d0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9e+130) {
tmp = 0.0 - z;
} else if (y <= -6e-136) {
tmp = x + y;
} else if (y <= 6.6e+77) {
tmp = x / (1.0 - (y / z));
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9e+130: tmp = 0.0 - z elif y <= -6e-136: tmp = x + y elif y <= 6.6e+77: tmp = x / (1.0 - (y / z)) else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9e+130) tmp = Float64(0.0 - z); elseif (y <= -6e-136) tmp = Float64(x + y); elseif (y <= 6.6e+77) tmp = Float64(x / Float64(1.0 - Float64(y / z))); else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9e+130) tmp = 0.0 - z; elseif (y <= -6e-136) tmp = x + y; elseif (y <= 6.6e+77) tmp = x / (1.0 - (y / z)); else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9e+130], N[(0.0 - z), $MachinePrecision], If[LessEqual[y, -6e-136], N[(x + y), $MachinePrecision], If[LessEqual[y, 6.6e+77], N[(x / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+130}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;y \leq -6 \cdot 10^{-136}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{x}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if y < -9.00000000000000078e130 or 6.5999999999999996e77 < y Initial program 73.7%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6474.2%
Simplified74.2%
sub0-negN/A
neg-lowering-neg.f6474.2%
Applied egg-rr74.2%
if -9.00000000000000078e130 < y < -5.9999999999999996e-136Initial program 98.1%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6456.2%
Simplified56.2%
if -5.9999999999999996e-136 < y < 6.5999999999999996e77Initial program 99.1%
Taylor expanded in x around inf
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6477.1%
Simplified77.1%
Final simplification71.9%
(FPCore (x y z) :precision binary64 (if (<= y -4e+132) (- 0.0 z) (if (<= y 3.4e+86) (+ x y) (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+132) {
tmp = 0.0 - z;
} else if (y <= 3.4e+86) {
tmp = x + y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-4d+132)) then
tmp = 0.0d0 - z
else if (y <= 3.4d+86) then
tmp = x + y
else
tmp = 0.0d0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e+132) {
tmp = 0.0 - z;
} else if (y <= 3.4e+86) {
tmp = x + y;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+132: tmp = 0.0 - z elif y <= 3.4e+86: tmp = x + y else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+132) tmp = Float64(0.0 - z); elseif (y <= 3.4e+86) tmp = Float64(x + y); else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+132) tmp = 0.0 - z; elseif (y <= 3.4e+86) tmp = x + y; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+132], N[(0.0 - z), $MachinePrecision], If[LessEqual[y, 3.4e+86], N[(x + y), $MachinePrecision], N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+132}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+86}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if y < -3.99999999999999996e132 or 3.3999999999999998e86 < y Initial program 73.7%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6474.2%
Simplified74.2%
sub0-negN/A
neg-lowering-neg.f6474.2%
Applied egg-rr74.2%
if -3.99999999999999996e132 < y < 3.3999999999999998e86Initial program 98.8%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6466.4%
Simplified66.4%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (if (<= y -2e-39) (- 0.0 z) (if (<= y 2.55e-52) x (- 0.0 z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-39) {
tmp = 0.0 - z;
} else if (y <= 2.55e-52) {
tmp = x;
} else {
tmp = 0.0 - z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2d-39)) then
tmp = 0.0d0 - z
else if (y <= 2.55d-52) then
tmp = x
else
tmp = 0.0d0 - z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e-39) {
tmp = 0.0 - z;
} else if (y <= 2.55e-52) {
tmp = x;
} else {
tmp = 0.0 - z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-39: tmp = 0.0 - z elif y <= 2.55e-52: tmp = x else: tmp = 0.0 - z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-39) tmp = Float64(0.0 - z); elseif (y <= 2.55e-52) tmp = x; else tmp = Float64(0.0 - z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-39) tmp = 0.0 - z; elseif (y <= 2.55e-52) tmp = x; else tmp = 0.0 - z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-39], N[(0.0 - z), $MachinePrecision], If[LessEqual[y, 2.55e-52], x, N[(0.0 - z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-39}:\\
\;\;\;\;0 - z\\
\mathbf{elif}\;y \leq 2.55 \cdot 10^{-52}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0 - z\\
\end{array}
\end{array}
if y < -1.99999999999999986e-39 or 2.54999999999999995e-52 < y Initial program 84.3%
Taylor expanded in y around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f6452.5%
Simplified52.5%
sub0-negN/A
neg-lowering-neg.f6452.5%
Applied egg-rr52.5%
if -1.99999999999999986e-39 < y < 2.54999999999999995e-52Initial program 99.9%
Taylor expanded in y around 0
Simplified65.2%
Final simplification58.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.6e-215) x (if (<= x 3.6e-155) y x)))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e-215) {
tmp = x;
} else if (x <= 3.6e-155) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-1.6d-215)) then
tmp = x
else if (x <= 3.6d-155) then
tmp = y
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.6e-215) {
tmp = x;
} else if (x <= 3.6e-155) {
tmp = y;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.6e-215: tmp = x elif x <= 3.6e-155: tmp = y else: tmp = x return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.6e-215) tmp = x; elseif (x <= 3.6e-155) tmp = y; else tmp = x; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.6e-215) tmp = x; elseif (x <= 3.6e-155) tmp = y; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.6e-215], x, If[LessEqual[x, 3.6e-155], y, x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{-215}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.6 \cdot 10^{-155}:\\
\;\;\;\;y\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -1.6000000000000001e-215 or 3.59999999999999989e-155 < x Initial program 91.0%
Taylor expanded in y around 0
Simplified42.0%
if -1.6000000000000001e-215 < x < 3.59999999999999989e-155Initial program 92.8%
Taylor expanded in z around inf
+-commutativeN/A
+-lowering-+.f6458.9%
Simplified58.9%
Taylor expanded in y around inf
Simplified51.7%
(FPCore (x y z) :precision binary64 x)
double code(double x, double y, double z) {
return x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x
end function
public static double code(double x, double y, double z) {
return x;
}
def code(x, y, z): return x
function code(x, y, z) return x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 91.3%
Taylor expanded in y around 0
Simplified35.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (+ y x) (- y)) z)))
(if (< y -3.7429310762689856e+171)
t_0
(if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((y + x) / -y) * z
if (y < (-3.7429310762689856d+171)) then
tmp = t_0
else if (y < 3.5534662456086734d+168) then
tmp = (x + y) / (1.0d0 - (y / z))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((y + x) / -y) * z;
double tmp;
if (y < -3.7429310762689856e+171) {
tmp = t_0;
} else if (y < 3.5534662456086734e+168) {
tmp = (x + y) / (1.0 - (y / z));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y + x) / -y) * z tmp = 0 if y < -3.7429310762689856e+171: tmp = t_0 elif y < 3.5534662456086734e+168: tmp = (x + y) / (1.0 - (y / z)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y + x) / Float64(-y)) * z) tmp = 0.0 if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = Float64(Float64(x + y) / Float64(1.0 - Float64(y / z))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y + x) / -y) * z; tmp = 0.0; if (y < -3.7429310762689856e+171) tmp = t_0; elseif (y < 3.5534662456086734e+168) tmp = (x + y) / (1.0 - (y / z)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y + x), $MachinePrecision] / (-y)), $MachinePrecision] * z), $MachinePrecision]}, If[Less[y, -3.7429310762689856e+171], t$95$0, If[Less[y, 3.5534662456086734e+168], N[(N[(x + y), $MachinePrecision] / N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y + x}{-y} \cdot z\\
\mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\
\;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024150
(FPCore (x y z)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
:precision binary64
:alt
(! :herbie-platform default (if (< y -3742931076268985600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (/ (+ y x) (- y)) z) (if (< y 3553466245608673400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ x y) (- 1 (/ y z))) (* (/ (+ y x) (- y)) z))))
(/ (+ x y) (- 1.0 (/ y z))))