
(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 10 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 (* x (+ (/ (+ 1.0 y) z) -1.0)))
double code(double x, double y, double z) {
return x * (((1.0 + y) / z) + -1.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x * (((1.0d0 + y) / z) + (-1.0d0))
end function
public static double code(double x, double y, double z) {
return x * (((1.0 + y) / z) + -1.0);
}
def code(x, y, z): return x * (((1.0 + y) / z) + -1.0)
function code(x, y, z) return Float64(x * Float64(Float64(Float64(1.0 + y) / z) + -1.0)) end
function tmp = code(x, y, z) tmp = x * (((1.0 + y) / z) + -1.0); end
code[x_, y_, z_] := N[(x * N[(N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(\frac{1 + y}{z} + -1\right)
\end{array}
Initial program 88.2%
Taylor expanded in x around 0 88.2%
associate--l+88.2%
+-commutative88.2%
associate-*r/97.9%
+-commutative97.9%
associate--l+97.9%
div-sub97.9%
sub-neg97.9%
*-inverses97.9%
metadata-eval97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= y -1.0)
t_0
(if (<= y -1.2e-133)
(/ x z)
(if (<= y -1.7e-202) (- x) (if (<= y 1.0) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= -1.2e-133) {
tmp = x / z;
} else if (y <= -1.7e-202) {
tmp = -x;
} else if (y <= 1.0) {
tmp = x / 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 / z)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= (-1.2d-133)) then
tmp = x / z
else if (y <= (-1.7d-202)) then
tmp = -x
else if (y <= 1.0d0) then
tmp = x / 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 / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= -1.2e-133) {
tmp = x / z;
} else if (y <= -1.7e-202) {
tmp = -x;
} else if (y <= 1.0) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= -1.2e-133: tmp = x / z elif y <= -1.7e-202: tmp = -x elif y <= 1.0: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= -1.2e-133) tmp = Float64(x / z); elseif (y <= -1.7e-202) tmp = Float64(-x); elseif (y <= 1.0) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= -1.2e-133) tmp = x / z; elseif (y <= -1.7e-202) tmp = -x; elseif (y <= 1.0) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, -1.2e-133], N[(x / z), $MachinePrecision], If[LessEqual[y, -1.7e-202], (-x), If[LessEqual[y, 1.0], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.2 \cdot 10^{-133}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-202}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 85.1%
Taylor expanded in y around inf 72.5%
associate-/l*73.2%
associate-/r/72.5%
Simplified72.5%
if -1 < y < -1.2e-133 or -1.70000000000000006e-202 < y < 1Initial program 92.1%
Taylor expanded in y around 0 90.4%
associate-/l*98.3%
associate-/r/93.5%
Simplified93.5%
Taylor expanded in z around 0 64.2%
if -1.2e-133 < y < -1.70000000000000006e-202Initial program 87.2%
Taylor expanded in z around inf 65.3%
mul-1-neg65.3%
Simplified65.3%
Final simplification68.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y z))))
(if (<= y -1.0)
t_0
(if (<= y -1.45e-128)
(/ x z)
(if (<= y -1.3e-203) (- x) (if (<= y 1.0) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (y / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= -1.45e-128) {
tmp = x / z;
} else if (y <= -1.3e-203) {
tmp = -x;
} else if (y <= 1.0) {
tmp = x / 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 = x * (y / z)
if (y <= (-1.0d0)) then
tmp = t_0
else if (y <= (-1.45d-128)) then
tmp = x / z
else if (y <= (-1.3d-203)) then
tmp = -x
else if (y <= 1.0d0) then
tmp = x / z
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 / z);
double tmp;
if (y <= -1.0) {
tmp = t_0;
} else if (y <= -1.45e-128) {
tmp = x / z;
} else if (y <= -1.3e-203) {
tmp = -x;
} else if (y <= 1.0) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / z) tmp = 0 if y <= -1.0: tmp = t_0 elif y <= -1.45e-128: tmp = x / z elif y <= -1.3e-203: tmp = -x elif y <= 1.0: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / z)) tmp = 0.0 if (y <= -1.0) tmp = t_0; elseif (y <= -1.45e-128) tmp = Float64(x / z); elseif (y <= -1.3e-203) tmp = Float64(-x); elseif (y <= 1.0) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / z); tmp = 0.0; if (y <= -1.0) tmp = t_0; elseif (y <= -1.45e-128) tmp = x / z; elseif (y <= -1.3e-203) tmp = -x; elseif (y <= 1.0) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.0], t$95$0, If[LessEqual[y, -1.45e-128], N[(x / z), $MachinePrecision], If[LessEqual[y, -1.3e-203], (-x), If[LessEqual[y, 1.0], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-128}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{-203}:\\
\;\;\;\;-x\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 85.1%
Taylor expanded in y around inf 72.5%
associate-/l*73.2%
Simplified73.2%
clear-num73.1%
associate-/r/73.1%
clear-num73.2%
Applied egg-rr73.2%
if -1 < y < -1.45e-128 or -1.29999999999999988e-203 < y < 1Initial program 92.1%
Taylor expanded in y around 0 90.4%
associate-/l*98.3%
associate-/r/93.5%
Simplified93.5%
Taylor expanded in z around 0 64.2%
if -1.45e-128 < y < -1.29999999999999988e-203Initial program 87.2%
Taylor expanded in z around inf 65.3%
mul-1-neg65.3%
Simplified65.3%
Final simplification68.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* x (+ -1.0 (/ y z))) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
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 <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) 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 <= -1.0) || !(y <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 1.0)) 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 <= -1.0) || ~((y <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 1.0]], $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 -1 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 85.1%
Taylor expanded in x around 0 85.1%
associate--l+85.1%
+-commutative85.1%
associate-*r/96.0%
+-commutative96.0%
associate--l+96.0%
div-sub96.0%
sub-neg96.0%
*-inverses96.0%
metadata-eval96.0%
Simplified96.0%
Taylor expanded in y around inf 95.8%
if -1 < y < 1Initial program 91.2%
Taylor expanded in x around 0 91.2%
associate--l+91.2%
+-commutative91.2%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 98.4%
sub-neg98.4%
metadata-eval98.4%
distribute-rgt-in98.5%
associate-*l/98.6%
*-lft-identity98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
Final simplification97.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.15) (not (<= z 1.0))) (* x (+ -1.0 (/ y z))) (* (+ 1.0 y) (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (1.0 + 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 ((z <= (-1.15d0)) .or. (.not. (z <= 1.0d0))) then
tmp = x * ((-1.0d0) + (y / z))
else
tmp = (1.0d0 + y) * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15) || !(z <= 1.0)) {
tmp = x * (-1.0 + (y / z));
} else {
tmp = (1.0 + y) * (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.15) or not (z <= 1.0): tmp = x * (-1.0 + (y / z)) else: tmp = (1.0 + y) * (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.15) || !(z <= 1.0)) tmp = Float64(x * Float64(-1.0 + Float64(y / z))); else tmp = Float64(Float64(1.0 + y) * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.15) || ~((z <= 1.0))) tmp = x * (-1.0 + (y / z)); else tmp = (1.0 + y) * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.15], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(x * N[(-1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \left(-1 + \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + y\right) \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -1.1499999999999999 or 1 < z Initial program 73.4%
Taylor expanded in x around 0 73.4%
associate--l+73.4%
+-commutative73.4%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 97.2%
if -1.1499999999999999 < z < 1Initial program 99.9%
Taylor expanded in x around 0 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*r/96.5%
+-commutative96.5%
associate--l+96.5%
div-sub96.5%
sub-neg96.5%
*-inverses96.5%
metadata-eval96.5%
Simplified96.5%
Taylor expanded in z around 0 98.1%
*-commutative98.1%
associate-*r/98.1%
Simplified98.1%
Final simplification97.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -5800.0) (not (<= y 4.6e+81))) (* x (/ y z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5800.0) || !(y <= 4.6e+81)) {
tmp = x * (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 <= (-5800.0d0)) .or. (.not. (y <= 4.6d+81))) then
tmp = x * (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 <= -5800.0) || !(y <= 4.6e+81)) {
tmp = x * (y / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5800.0) or not (y <= 4.6e+81): tmp = x * (y / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5800.0) || !(y <= 4.6e+81)) tmp = Float64(x * 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 <= -5800.0) || ~((y <= 4.6e+81))) tmp = x * (y / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5800.0], N[Not[LessEqual[y, 4.6e+81]], $MachinePrecision]], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5800 \lor \neg \left(y \leq 4.6 \cdot 10^{+81}\right):\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -5800 or 4.5999999999999998e81 < y Initial program 84.7%
Taylor expanded in y around inf 74.6%
associate-/l*75.5%
Simplified75.5%
clear-num75.3%
associate-/r/75.3%
clear-num75.4%
Applied egg-rr75.4%
if -5800 < y < 4.5999999999999998e81Initial program 90.6%
Taylor expanded in x around 0 90.6%
associate--l+90.6%
+-commutative90.6%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.6%
sub-neg95.6%
metadata-eval95.6%
distribute-rgt-in95.7%
associate-*l/95.8%
*-lft-identity95.8%
neg-mul-195.8%
unsub-neg95.8%
Simplified95.8%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -20000000.0) (not (<= y 6.2e+80))) (/ x (/ z y)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -20000000.0) || !(y <= 6.2e+80)) {
tmp = x / (z / y);
} 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 <= (-20000000.0d0)) .or. (.not. (y <= 6.2d+80))) then
tmp = x / (z / y)
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 <= -20000000.0) || !(y <= 6.2e+80)) {
tmp = x / (z / y);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -20000000.0) or not (y <= 6.2e+80): tmp = x / (z / y) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -20000000.0) || !(y <= 6.2e+80)) tmp = Float64(x / Float64(z / y)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -20000000.0) || ~((y <= 6.2e+80))) tmp = x / (z / y); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -20000000.0], N[Not[LessEqual[y, 6.2e+80]], $MachinePrecision]], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -20000000 \lor \neg \left(y \leq 6.2 \cdot 10^{+80}\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -2e7 or 6.19999999999999976e80 < y Initial program 84.7%
Taylor expanded in y around inf 74.6%
associate-/l*75.5%
Simplified75.5%
if -2e7 < y < 6.19999999999999976e80Initial program 90.6%
Taylor expanded in x around 0 90.6%
associate--l+90.6%
+-commutative90.6%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.6%
sub-neg95.6%
metadata-eval95.6%
distribute-rgt-in95.7%
associate-*l/95.8%
*-lft-identity95.8%
neg-mul-195.8%
unsub-neg95.8%
Simplified95.8%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+16) (/ (* x y) z) (if (<= y 6.2e+81) (- (/ x z) x) (/ x (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+16) {
tmp = (x * y) / z;
} else if (y <= 6.2e+81) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
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 <= (-7.2d+16)) then
tmp = (x * y) / z
else if (y <= 6.2d+81) then
tmp = (x / z) - x
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+16) {
tmp = (x * y) / z;
} else if (y <= 6.2e+81) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+16: tmp = (x * y) / z elif y <= 6.2e+81: tmp = (x / z) - x else: tmp = x / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+16) tmp = Float64(Float64(x * y) / z); elseif (y <= 6.2e+81) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+16) tmp = (x * y) / z; elseif (y <= 6.2e+81) tmp = (x / z) - x; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+16], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 6.2e+81], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+16}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+81}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -7.2e16Initial program 87.5%
Taylor expanded in y around inf 74.9%
if -7.2e16 < y < 6.2e81Initial program 90.6%
Taylor expanded in x around 0 90.6%
associate--l+90.6%
+-commutative90.6%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 95.6%
sub-neg95.6%
metadata-eval95.6%
distribute-rgt-in95.7%
associate-*l/95.8%
*-lft-identity95.8%
neg-mul-195.8%
unsub-neg95.8%
Simplified95.8%
if 6.2e81 < y Initial program 80.8%
Taylor expanded in y around inf 74.3%
associate-/l*80.7%
Simplified80.7%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
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 <= 1.0d0))) 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 <= 1.0)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) 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 <= 1.0))) 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, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 73.4%
Taylor expanded in z around inf 67.6%
mul-1-neg67.6%
Simplified67.6%
if -1 < z < 1Initial program 99.9%
Taylor expanded in y around 0 67.4%
associate-/l*67.4%
associate-/r/67.4%
Simplified67.4%
Taylor expanded in z around 0 65.6%
Final simplification66.5%
(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 88.2%
Taylor expanded in z around inf 32.0%
mul-1-neg32.0%
Simplified32.0%
Final simplification32.0%
(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 2023318
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))