
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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 - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / 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 - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -5e-17) (not (<= z 7e-23))) (* x (+ (/ (+ y 1.0) z) -1.0)) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-17) || !(z <= 7e-23)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x + (x * y)) / 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 ((z <= (-5d-17)) .or. (.not. (z <= 7d-23))) then
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5e-17) || !(z <= 7e-23)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e-17) or not (z <= 7e-23): tmp = x * (((y + 1.0) / z) + -1.0) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e-17) || !(z <= 7e-23)) tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5e-17) || ~((z <= 7e-23))) tmp = x * (((y + 1.0) / z) + -1.0); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e-17], N[Not[LessEqual[z, 7e-23]], $MachinePrecision]], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-17} \lor \neg \left(z \leq 7 \cdot 10^{-23}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -4.9999999999999999e-17 or 6.99999999999999987e-23 < z Initial program 70.8%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
if -4.9999999999999999e-17 < z < 6.99999999999999987e-23Initial program 99.9%
distribute-lft-in99.9%
fma-define99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= x 0.1) (/ (fma x (- y z) x) z) (- (/ x (/ z (+ y 1.0))) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.1) {
tmp = fma(x, (y - z), x) / z;
} else {
tmp = (x / (z / (y + 1.0))) - x;
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (x <= 0.1) tmp = Float64(fma(x, Float64(y - z), x) / z); else tmp = Float64(Float64(x / Float64(z / Float64(y + 1.0))) - x); end return tmp end
code[x_, y_, z_] := If[LessEqual[x, 0.1], N[(N[(x * N[(y - z), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(z / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y - z, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y + 1}} - x\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 88.3%
distribute-lft-in88.4%
fma-define88.4%
*-rgt-identity88.4%
Simplified88.4%
if 0.10000000000000001 < x Initial program 73.5%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
distribute-lft-in99.9%
clear-num99.9%
un-div-inv100.0%
*-commutative100.0%
mul-1-neg100.0%
Applied egg-rr100.0%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 1.5e-23) (/ x z) (if (<= z 4.8e+31) (* x (/ y z)) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.5e-23) {
tmp = x / z;
} else if (z <= 4.8e+31) {
tmp = x * (y / z);
} 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 (z <= (-1.0d0)) then
tmp = -x
else if (z <= 1.5d-23) then
tmp = x / z
else if (z <= 4.8d+31) then
tmp = x * (y / z)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.5e-23) {
tmp = x / z;
} else if (z <= 4.8e+31) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 1.5e-23: tmp = x / z elif z <= 4.8e+31: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 1.5e-23) tmp = Float64(x / z); elseif (z <= 4.8e+31) tmp = Float64(x * Float64(y / z)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 1.5e-23) tmp = x / z; elseif (z <= 4.8e+31) tmp = x * (y / z); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 1.5e-23], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.8e+31], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+31}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 4.79999999999999965e31 < z Initial program 67.9%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 75.1%
neg-mul-175.1%
Simplified75.1%
if -1 < z < 1.50000000000000001e-23Initial program 99.9%
associate-/l*92.8%
+-commutative92.8%
associate-+r-92.8%
div-sub92.8%
*-inverses92.8%
sub-neg92.8%
+-commutative92.8%
metadata-eval92.8%
Simplified92.8%
Taylor expanded in y around 0 64.5%
sub-neg64.5%
metadata-eval64.5%
distribute-rgt-in64.5%
associate-*l/64.7%
*-lft-identity64.7%
neg-mul-164.7%
unsub-neg64.7%
Simplified64.7%
Taylor expanded in z around 0 64.3%
if 1.50000000000000001e-23 < z < 4.79999999999999965e31Initial program 93.8%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 70.1%
associate-/l*70.2%
Simplified70.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (* x (+ -1.0 (/ y z))) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x + (x * y)) / 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 70.1%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 98.6%
if -1 < z < 1Initial program 99.9%
distribute-lft-in99.9%
fma-define99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.5%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.05) (not (<= z 1.0))) (* x (+ -1.0 (/ y z))) (* (+ y 1.0) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (y + 1.0) * (x / 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 ((z <= (-1.05d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (y + 1.0d0) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.05) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (y + 1.0) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.05) or not (z <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (y + 1.0) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.05) || !(z <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(y + 1.0) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.05) || ~((z <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (y + 1.0) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.05], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y + 1.0), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.05 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(y + 1\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -1.05000000000000004 or 1 < z Initial program 70.1%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 98.6%
if -1.05000000000000004 < z < 1Initial program 99.9%
distribute-lft-in99.9%
fma-define99.9%
*-rgt-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 99.5%
*-un-lft-identity99.5%
*-commutative99.5%
distribute-rgt-out99.5%
+-commutative99.5%
associate-*l/99.5%
Applied egg-rr99.5%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.2e+16) (not (<= y 0.0034))) (* x (+ -1.0 (/ y z))) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+16) || !(y <= 0.0034)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x / z) - 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 ((y <= (-5.2d+16)) .or. (.not. (y <= 0.0034d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+16) || !(y <= 0.0034)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.2e+16) or not (y <= 0.0034): tmp = x * (-1.0 + (y / z)) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.2e+16) || !(y <= 0.0034)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -5.2e+16) || ~((y <= 0.0034))) tmp = x * (-1.0 + (y / z)); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e+16], N[Not[LessEqual[y, 0.0034]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+16} \lor \neg \left(y \leq 0.0034\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -5.2e16 or 0.00339999999999999981 < y Initial program 81.0%
associate-/l*92.5%
+-commutative92.5%
associate-+r-92.5%
div-sub92.6%
*-inverses92.6%
sub-neg92.6%
+-commutative92.6%
metadata-eval92.6%
Simplified92.6%
Taylor expanded in y around inf 91.4%
if -5.2e16 < y < 0.00339999999999999981Initial program 87.2%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.3%
sub-neg99.3%
metadata-eval99.3%
distribute-rgt-in99.3%
associate-*l/99.4%
*-lft-identity99.4%
neg-mul-199.4%
unsub-neg99.4%
Simplified99.4%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -9e+17) (not (<= y 1.55e+68))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+17) || !(y <= 1.55e+68)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - 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 ((y <= (-9d+17)) .or. (.not. (y <= 1.55d+68))) then
tmp = y * (x / z)
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9e+17) || !(y <= 1.55e+68)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9e+17) or not (y <= 1.55e+68): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9e+17) || !(y <= 1.55e+68)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9e+17) || ~((y <= 1.55e+68))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9e+17], N[Not[LessEqual[y, 1.55e+68]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+17} \lor \neg \left(y \leq 1.55 \cdot 10^{+68}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -9e17 or 1.5499999999999999e68 < y Initial program 83.1%
distribute-lft-in83.1%
fma-define83.1%
*-rgt-identity83.1%
Simplified83.1%
Taylor expanded in z around 0 79.9%
*-un-lft-identity79.9%
*-commutative79.9%
distribute-rgt-out79.9%
+-commutative79.9%
associate-*l/80.0%
Applied egg-rr80.0%
Taylor expanded in y around inf 80.0%
if -9e17 < y < 1.5499999999999999e68Initial program 85.2%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.4%
sub-neg95.4%
metadata-eval95.4%
distribute-rgt-in95.4%
associate-*l/95.5%
*-lft-identity95.5%
neg-mul-195.5%
unsub-neg95.5%
Simplified95.5%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= y -5.2e+16) (/ (* x y) z) (if (<= y 1.26e+65) (- (/ x z) x) (* y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e+16) {
tmp = (x * y) / z;
} else if (y <= 1.26e+65) {
tmp = (x / z) - x;
} else {
tmp = y * (x / 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 <= (-5.2d+16)) then
tmp = (x * y) / z
else if (y <= 1.26d+65) then
tmp = (x / z) - x
else
tmp = y * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e+16) {
tmp = (x * y) / z;
} else if (y <= 1.26e+65) {
tmp = (x / z) - x;
} else {
tmp = y * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.2e+16: tmp = (x * y) / z elif y <= 1.26e+65: tmp = (x / z) - x else: tmp = y * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.2e+16) tmp = Float64(Float64(x * y) / z); elseif (y <= 1.26e+65) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.2e+16) tmp = (x * y) / z; elseif (y <= 1.26e+65) tmp = (x / z) - x; else tmp = y * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.2e+16], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.26e+65], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+16}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{+65}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -5.2e16Initial program 84.5%
associate-/l*88.6%
+-commutative88.6%
associate-+r-88.6%
div-sub88.6%
*-inverses88.6%
sub-neg88.6%
+-commutative88.6%
metadata-eval88.6%
Simplified88.6%
Taylor expanded in y around inf 84.2%
if -5.2e16 < y < 1.2599999999999999e65Initial program 85.2%
associate-/l*99.8%
+-commutative99.8%
associate-+r-99.8%
div-sub99.8%
*-inverses99.8%
sub-neg99.8%
+-commutative99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.4%
sub-neg95.4%
metadata-eval95.4%
distribute-rgt-in95.4%
associate-*l/95.5%
*-lft-identity95.5%
neg-mul-195.5%
unsub-neg95.5%
Simplified95.5%
if 1.2599999999999999e65 < y Initial program 81.7%
distribute-lft-in81.7%
fma-define81.7%
*-rgt-identity81.7%
Simplified81.7%
Taylor expanded in z around 0 75.3%
*-un-lft-identity75.3%
*-commutative75.3%
distribute-rgt-out75.3%
+-commutative75.3%
associate-*l/78.8%
Applied egg-rr78.8%
Taylor expanded in y around inf 78.8%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= x 0.1) (/ (* x (+ (- y z) 1.0)) z) (- (/ x (/ z (+ y 1.0))) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 0.1) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = (x / (z / (y + 1.0))) - 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 <= 0.1d0) then
tmp = (x * ((y - z) + 1.0d0)) / z
else
tmp = (x / (z / (y + 1.0d0))) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 0.1) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = (x / (z / (y + 1.0))) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 0.1: tmp = (x * ((y - z) + 1.0)) / z else: tmp = (x / (z / (y + 1.0))) - x return tmp
function code(x, y, z) tmp = 0.0 if (x <= 0.1) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(Float64(x / Float64(z / Float64(y + 1.0))) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 0.1) tmp = (x * ((y - z) + 1.0)) / z; else tmp = (x / (z / (y + 1.0))) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 0.1], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(z / N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.1:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y + 1}} - x\\
\end{array}
\end{array}
if x < 0.10000000000000001Initial program 88.3%
if 0.10000000000000001 < x Initial program 73.5%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
distribute-lft-in99.9%
clear-num99.9%
un-div-inv100.0%
*-commutative100.0%
mul-1-neg100.0%
Applied egg-rr100.0%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (<= x 1e-5) (/ (* x (+ (- y z) 1.0)) z) (* x (+ (/ (+ y 1.0) z) -1.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1e-5) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.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) :: tmp
if (x <= 1d-5) then
tmp = (x * ((y - z) + 1.0d0)) / z
else
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1e-5) {
tmp = (x * ((y - z) + 1.0)) / z;
} else {
tmp = x * (((y + 1.0) / z) + -1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1e-5: tmp = (x * ((y - z) + 1.0)) / z else: tmp = x * (((y + 1.0) / z) + -1.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1e-5) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1e-5) tmp = (x * ((y - z) + 1.0)) / z; else tmp = x * (((y + 1.0) / z) + -1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1e-5], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-5}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\end{array}
\end{array}
if x < 1.00000000000000008e-5Initial program 88.3%
if 1.00000000000000008e-5 < x Initial program 73.9%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 3.5))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 3.5)) {
tmp = -x;
} else {
tmp = x / 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 ((z <= (-1.0d0)) .or. (.not. (z <= 3.5d0))) then
tmp = -x
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 3.5)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 3.5): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 3.5)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 3.5))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 3.5]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 3.5\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 3.5 < z Initial program 69.9%
associate-/l*99.9%
+-commutative99.9%
associate-+r-99.9%
div-sub99.9%
*-inverses99.9%
sub-neg99.9%
+-commutative99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 70.9%
neg-mul-170.9%
Simplified70.9%
if -1 < z < 3.5Initial program 99.9%
associate-/l*93.0%
+-commutative93.0%
associate-+r-93.0%
div-sub93.0%
*-inverses93.0%
sub-neg93.0%
+-commutative93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in y around 0 63.3%
sub-neg63.3%
metadata-eval63.3%
distribute-rgt-in63.3%
associate-*l/63.4%
*-lft-identity63.4%
neg-mul-163.4%
unsub-neg63.4%
Simplified63.4%
Taylor expanded in z around 0 63.1%
Final simplification67.1%
(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 Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 84.4%
associate-/l*96.6%
+-commutative96.6%
associate-+r-96.6%
div-sub96.6%
*-inverses96.6%
sub-neg96.6%
+-commutative96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in z around inf 38.2%
neg-mul-138.2%
Simplified38.2%
(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 84.4%
associate-/l*96.6%
+-commutative96.6%
associate-+r-96.6%
div-sub96.6%
*-inverses96.6%
sub-neg96.6%
+-commutative96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in z around inf 38.2%
neg-mul-138.2%
Simplified38.2%
neg-sub038.2%
sub-neg38.2%
add-sqr-sqrt19.4%
sqrt-unprod19.0%
sqr-neg19.0%
sqrt-unprod1.4%
add-sqr-sqrt2.9%
Applied egg-rr2.9%
Taylor expanded in x around 0 2.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / 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 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
herbie shell --seed 2024182
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))