
(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 -8e-61) (not (<= z 2.9e-53))) (* x (+ (/ (+ y 1.0) z) -1.0)) (* (/ x z) (+ y 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-61) || !(z <= 2.9e-53)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x / z) * (y + 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 ((z <= (-8d-61)) .or. (.not. (z <= 2.9d-53))) then
tmp = x * (((y + 1.0d0) / z) + (-1.0d0))
else
tmp = (x / z) * (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8e-61) || !(z <= 2.9e-53)) {
tmp = x * (((y + 1.0) / z) + -1.0);
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e-61) or not (z <= 2.9e-53): tmp = x * (((y + 1.0) / z) + -1.0) else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e-61) || !(z <= 2.9e-53)) tmp = Float64(x * Float64(Float64(Float64(y + 1.0) / z) + -1.0)); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8e-61) || ~((z <= 2.9e-53))) tmp = x * (((y + 1.0) / z) + -1.0); else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e-61], N[Not[LessEqual[z, 2.9e-53]], $MachinePrecision]], N[(x * N[(N[(N[(y + 1.0), $MachinePrecision] / z), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-61} \lor \neg \left(z \leq 2.9 \cdot 10^{-53}\right):\\
\;\;\;\;x \cdot \left(\frac{y + 1}{z} + -1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if z < -8.0000000000000003e-61 or 2.8999999999999998e-53 < z Initial program 80.7%
Taylor expanded in x around 0 80.7%
associate--l+80.7%
+-commutative80.7%
associate-*r/99.8%
+-commutative99.8%
associate--l+99.8%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
if -8.0000000000000003e-61 < z < 2.8999999999999998e-53Initial program 99.8%
Taylor expanded in z around 0 99.8%
associate-/l*91.9%
associate-/r/100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -31.0)
(- x)
(if (<= z -6.2e-180)
t_0
(if (<= z -5.3e-254) (/ x z) (if (<= z 3.55e+19) t_0 (- x)))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -31.0) {
tmp = -x;
} else if (z <= -6.2e-180) {
tmp = t_0;
} else if (z <= -5.3e-254) {
tmp = x / z;
} else if (z <= 3.55e+19) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-31.0d0)) then
tmp = -x
else if (z <= (-6.2d-180)) then
tmp = t_0
else if (z <= (-5.3d-254)) then
tmp = x / z
else if (z <= 3.55d+19) then
tmp = t_0
else
tmp = -x
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 (z <= -31.0) {
tmp = -x;
} else if (z <= -6.2e-180) {
tmp = t_0;
} else if (z <= -5.3e-254) {
tmp = x / z;
} else if (z <= 3.55e+19) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -31.0: tmp = -x elif z <= -6.2e-180: tmp = t_0 elif z <= -5.3e-254: tmp = x / z elif z <= 3.55e+19: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -31.0) tmp = Float64(-x); elseif (z <= -6.2e-180) tmp = t_0; elseif (z <= -5.3e-254) tmp = Float64(x / z); elseif (z <= 3.55e+19) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -31.0) tmp = -x; elseif (z <= -6.2e-180) tmp = t_0; elseif (z <= -5.3e-254) tmp = x / z; elseif (z <= 3.55e+19) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -31.0], (-x), If[LessEqual[z, -6.2e-180], t$95$0, If[LessEqual[z, -5.3e-254], N[(x / z), $MachinePrecision], If[LessEqual[z, 3.55e+19], t$95$0, (-x)]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -31:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -6.2 \cdot 10^{-180}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -5.3 \cdot 10^{-254}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 3.55 \cdot 10^{+19}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -31 or 3.55e19 < z Initial program 77.2%
Taylor expanded in z around inf 78.9%
mul-1-neg78.9%
Simplified78.9%
if -31 < z < -6.1999999999999998e-180 or -5.30000000000000037e-254 < z < 3.55e19Initial program 99.8%
Taylor expanded in y around inf 60.2%
associate-/l*53.8%
associate-/r/63.8%
Simplified63.8%
if -6.1999999999999998e-180 < z < -5.30000000000000037e-254Initial program 100.0%
Taylor expanded in y around 0 75.4%
associate-/l*75.4%
Simplified75.4%
Taylor expanded in z around 0 75.4%
Final simplification72.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- (* x (/ y z)) x) (* (/ x z) (+ y 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (y + 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 ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * (y + 1.0d0)
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 * (y / z)) - x;
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = (x * (y / z)) - x else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = (x * (y / z)) - x; else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 77.7%
Taylor expanded in z around 0 93.7%
mul-1-neg93.7%
+-commutative93.7%
unsub-neg93.7%
associate-/l*99.9%
associate-/r/96.1%
Simplified96.1%
Taylor expanded in y around inf 92.8%
associate-*r/98.9%
Simplified98.9%
if -1 < z < 1Initial program 99.8%
Taylor expanded in z around 0 98.9%
associate-/l*92.4%
associate-/r/98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.6e-14) (not (<= z 0.225))) (- (/ x (/ z y)) x) (* (/ x z) (+ y 1.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-14) || !(z <= 0.225)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x / z) * (y + 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 ((z <= (-5.6d-14)) .or. (.not. (z <= 0.225d0))) then
tmp = (x / (z / y)) - x
else
tmp = (x / z) * (y + 1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-14) || !(z <= 0.225)) {
tmp = (x / (z / y)) - x;
} else {
tmp = (x / z) * (y + 1.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.6e-14) or not (z <= 0.225): tmp = (x / (z / y)) - x else: tmp = (x / z) * (y + 1.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.6e-14) || !(z <= 0.225)) tmp = Float64(Float64(x / Float64(z / y)) - x); else tmp = Float64(Float64(x / z) * Float64(y + 1.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.6e-14) || ~((z <= 0.225))) tmp = (x / (z / y)) - x; else tmp = (x / z) * (y + 1.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.6e-14], N[Not[LessEqual[z, 0.225]], $MachinePrecision]], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-14} \lor \neg \left(z \leq 0.225\right):\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\end{array}
\end{array}
if z < -5.6000000000000001e-14 or 0.225000000000000006 < z Initial program 78.0%
Taylor expanded in z around 0 93.8%
mul-1-neg93.8%
+-commutative93.8%
unsub-neg93.8%
associate-/l*99.9%
associate-/r/96.2%
Simplified96.2%
*-commutative96.2%
clear-num95.6%
un-div-inv95.6%
Applied egg-rr95.6%
Taylor expanded in y around inf 92.8%
associate-/l*99.0%
Simplified99.0%
if -5.6000000000000001e-14 < z < 0.225000000000000006Initial program 99.8%
Taylor expanded in z around 0 98.8%
associate-/l*92.3%
associate-/r/98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= z -6.4) (- (/ x z) x) (if (<= z 4.6e+18) (* (/ x z) (+ y 1.0)) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -6.4) {
tmp = (x / z) - x;
} else if (z <= 4.6e+18) {
tmp = (x / z) * (y + 1.0);
} 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 <= (-6.4d0)) then
tmp = (x / z) - x
else if (z <= 4.6d+18) then
tmp = (x / z) * (y + 1.0d0)
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -6.4) {
tmp = (x / z) - x;
} else if (z <= 4.6e+18) {
tmp = (x / z) * (y + 1.0);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -6.4: tmp = (x / z) - x elif z <= 4.6e+18: tmp = (x / z) * (y + 1.0) else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -6.4) tmp = Float64(Float64(x / z) - x); elseif (z <= 4.6e+18) tmp = Float64(Float64(x / z) * Float64(y + 1.0)); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -6.4) tmp = (x / z) - x; elseif (z <= 4.6e+18) tmp = (x / z) * (y + 1.0); else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -6.4], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 4.6e+18], N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.4:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right)\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -6.4000000000000004Initial program 73.4%
Taylor expanded in z around 0 91.2%
mul-1-neg91.2%
+-commutative91.2%
unsub-neg91.2%
associate-/l*99.9%
associate-/r/95.3%
Simplified95.3%
Taylor expanded in y around 0 79.4%
if -6.4000000000000004 < z < 4.6e18Initial program 99.8%
Taylor expanded in z around 0 98.1%
associate-/l*91.8%
associate-/r/98.1%
Simplified98.1%
if 4.6e18 < z Initial program 80.7%
Taylor expanded in z around inf 79.4%
mul-1-neg79.4%
Simplified79.4%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= x 5.6e-217) (/ (* x (+ (- y z) 1.0)) z) (- (* (/ x z) (+ y 1.0)) x)))
double code(double x, double y, double z) {
double tmp;
if (x <= 5.6e-217) {
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 <= 5.6d-217) 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 <= 5.6e-217) {
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 <= 5.6e-217: 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 <= 5.6e-217) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z); else tmp = Float64(Float64(Float64(x / z) * Float64(y + 1.0)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5.6e-217) 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, 5.6e-217], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.6 \cdot 10^{-217}:\\
\;\;\;\;\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(y + 1\right) - x\\
\end{array}
\end{array}
if x < 5.6e-217Initial program 92.9%
if 5.6e-217 < x Initial program 81.4%
Taylor expanded in z around 0 93.8%
mul-1-neg93.8%
+-commutative93.8%
unsub-neg93.8%
associate-/l*99.6%
associate-/r/100.0%
Simplified100.0%
Final simplification95.8%
(FPCore (x y z) :precision binary64 (if (<= y -3e+20) (* y (/ x z)) (if (<= y 1.02e+114) (- (/ x z) x) (* x (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e+20) {
tmp = y * (x / z);
} else if (y <= 1.02e+114) {
tmp = (x / z) - x;
} else {
tmp = 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 (y <= (-3d+20)) then
tmp = y * (x / z)
else if (y <= 1.02d+114) then
tmp = (x / z) - x
else
tmp = x * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3e+20) {
tmp = y * (x / z);
} else if (y <= 1.02e+114) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3e+20: tmp = y * (x / z) elif y <= 1.02e+114: tmp = (x / z) - x else: tmp = x * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3e+20) tmp = Float64(y * Float64(x / z)); elseif (y <= 1.02e+114) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3e+20) tmp = y * (x / z); elseif (y <= 1.02e+114) tmp = (x / z) - x; else tmp = x * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3e+20], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e+114], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+20}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+114}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -3e20Initial program 94.4%
Taylor expanded in y around inf 79.6%
associate-/l*73.1%
associate-/r/81.7%
Simplified81.7%
if -3e20 < y < 1.01999999999999999e114Initial program 86.8%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
+-commutative99.9%
unsub-neg99.9%
associate-/l*99.4%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in y around 0 92.3%
if 1.01999999999999999e114 < y Initial program 84.9%
Taylor expanded in y around inf 69.9%
associate-/l*73.3%
Simplified73.3%
clear-num73.3%
associate-/r/71.8%
clear-num71.9%
Applied egg-rr71.9%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (<= y -8.6e+21) (* y (/ x z)) (if (<= y 3.3e+113) (- (/ x z) x) (/ x (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.6e+21) {
tmp = y * (x / z);
} else if (y <= 3.3e+113) {
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 <= (-8.6d+21)) then
tmp = y * (x / z)
else if (y <= 3.3d+113) 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 <= -8.6e+21) {
tmp = y * (x / z);
} else if (y <= 3.3e+113) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.6e+21: tmp = y * (x / z) elif y <= 3.3e+113: tmp = (x / z) - x else: tmp = x / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.6e+21) tmp = Float64(y * Float64(x / z)); elseif (y <= 3.3e+113) 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 <= -8.6e+21) tmp = y * (x / z); elseif (y <= 3.3e+113) tmp = (x / z) - x; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.6e+21], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e+113], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+21}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+113}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -8.6e21Initial program 94.4%
Taylor expanded in y around inf 79.6%
associate-/l*73.1%
associate-/r/81.7%
Simplified81.7%
if -8.6e21 < y < 3.3000000000000003e113Initial program 86.8%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
+-commutative99.9%
unsub-neg99.9%
associate-/l*99.4%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in y around 0 92.3%
if 3.3000000000000003e113 < y Initial program 84.9%
Taylor expanded in y around inf 69.9%
associate-/l*73.3%
Simplified73.3%
Final simplification86.8%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e+20) (/ y (/ z x)) (if (<= y 2.6e+114) (- (/ x z) x) (/ x (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+20) {
tmp = y / (z / x);
} else if (y <= 2.6e+114) {
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.5d+20)) then
tmp = y / (z / x)
else if (y <= 2.6d+114) 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.5e+20) {
tmp = y / (z / x);
} else if (y <= 2.6e+114) {
tmp = (x / z) - x;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+20: tmp = y / (z / x) elif y <= 2.6e+114: tmp = (x / z) - x else: tmp = x / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+20) tmp = Float64(y / Float64(z / x)); elseif (y <= 2.6e+114) 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.5e+20) tmp = y / (z / x); elseif (y <= 2.6e+114) tmp = (x / z) - x; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+20], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+114], 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.5 \cdot 10^{+20}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+114}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -7.5e20Initial program 94.4%
Taylor expanded in y around inf 79.6%
associate-/l*73.1%
Simplified73.1%
clear-num72.9%
associate-/r/73.0%
clear-num73.0%
Applied egg-rr73.0%
associate-*l/79.6%
associate-/l*81.7%
Applied egg-rr81.7%
if -7.5e20 < y < 2.6e114Initial program 86.8%
Taylor expanded in z around 0 99.9%
mul-1-neg99.9%
+-commutative99.9%
unsub-neg99.9%
associate-/l*99.4%
associate-/r/99.8%
Simplified99.8%
Taylor expanded in y around 0 92.3%
if 2.6e114 < y Initial program 84.9%
Taylor expanded in y around inf 69.9%
associate-/l*73.3%
Simplified73.3%
Final simplification86.8%
(FPCore (x y z) :precision binary64 (- (* (/ x z) (+ y 1.0)) x))
double code(double x, double y, double z) {
return ((x / z) * (y + 1.0)) - 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 / z) * (y + 1.0d0)) - x
end function
public static double code(double x, double y, double z) {
return ((x / z) * (y + 1.0)) - x;
}
def code(x, y, z): return ((x / z) * (y + 1.0)) - x
function code(x, y, z) return Float64(Float64(Float64(x / z) * Float64(y + 1.0)) - x) end
function tmp = code(x, y, z) tmp = ((x / z) * (y + 1.0)) - x; end
code[x_, y_, z_] := N[(N[(N[(x / z), $MachinePrecision] * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} \cdot \left(y + 1\right) - x
\end{array}
Initial program 88.1%
Taylor expanded in z around 0 96.6%
mul-1-neg96.6%
+-commutative96.6%
unsub-neg96.6%
associate-/l*96.9%
associate-/r/97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.6e-14) (not (<= z 0.225))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.6e-14) || !(z <= 0.225)) {
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 <= (-5.6d-14)) .or. (.not. (z <= 0.225d0))) 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 <= -5.6e-14) || !(z <= 0.225)) {
tmp = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.6e-14) or not (z <= 0.225): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.6e-14) || !(z <= 0.225)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.6e-14) || ~((z <= 0.225))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.6e-14], N[Not[LessEqual[z, 0.225]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{-14} \lor \neg \left(z \leq 0.225\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -5.6000000000000001e-14 or 0.225000000000000006 < z Initial program 78.0%
Taylor expanded in z around inf 76.4%
mul-1-neg76.4%
Simplified76.4%
if -5.6000000000000001e-14 < z < 0.225000000000000006Initial program 99.8%
Taylor expanded in y around 0 52.5%
associate-/l*52.5%
Simplified52.5%
Taylor expanded in z around 0 51.5%
Final simplification64.9%
(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.1%
Taylor expanded in z around inf 42.4%
mul-1-neg42.4%
Simplified42.4%
Final simplification42.4%
(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 88.1%
Taylor expanded in z around inf 32.7%
associate-*r*32.7%
mul-1-neg32.7%
Simplified32.7%
div-inv32.7%
associate-*l*42.3%
div-inv42.4%
*-inverses42.4%
*-commutative42.4%
*-un-lft-identity42.4%
neg-sub042.4%
sub-neg42.4%
add-sqr-sqrt19.9%
sqrt-unprod18.0%
sqr-neg18.0%
sqrt-unprod1.4%
add-sqr-sqrt3.0%
Applied egg-rr3.0%
+-lft-identity3.0%
Simplified3.0%
Final simplification3.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 2023322
(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))