
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
double code(double x, double y, double z) {
return (cosh(x) * (y / x)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (cosh(x) * (y / x)) / z
end function
public static double code(double x, double y, double z) {
return (Math.cosh(x) * (y / x)) / z;
}
def code(x, y, z): return (math.cosh(x) * (y / x)) / z
function code(x, y, z) return Float64(Float64(cosh(x) * Float64(y / x)) / z) end
function tmp = code(x, y, z) tmp = (cosh(x) * (y / x)) / z; end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cosh x \cdot \frac{y}{x}}{z}
\end{array}
(FPCore (x y z) :precision binary64 (/ (* (/ (cosh x) x) y) z))
double code(double x, double y, double z) {
return ((cosh(x) / x) * 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 = ((cosh(x) / x) * y) / z
end function
public static double code(double x, double y, double z) {
return ((Math.cosh(x) / x) * y) / z;
}
def code(x, y, z): return ((math.cosh(x) / x) * y) / z
function code(x, y, z) return Float64(Float64(Float64(cosh(x) / x) * y) / z) end
function tmp = code(x, y, z) tmp = ((cosh(x) / x) * y) / z; end
code[x_, y_, z_] := N[(N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\cosh x}{x} \cdot y}{z}
\end{array}
Initial program 88.6%
associate-*l/88.6%
Simplified88.6%
associate-/r/82.3%
associate-/l*77.8%
*-commutative77.8%
expm1-log1p-u42.2%
expm1-udef29.0%
associate-/l*31.7%
times-frac38.6%
Applied egg-rr38.6%
expm1-def47.1%
expm1-log1p87.7%
associate-*r/99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cosh x) (/ y x))))
(if (<= t_0 INFINITY)
(/ t_0 z)
(/ (* (+ (/ z (* x 0.5)) (* x z)) (- y)) (* x (* z (* -2.0 (/ z x))))))))
double code(double x, double y, double z) {
double t_0 = cosh(x) * (y / x);
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0 / z;
} else {
tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x))));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * (y / x);
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0 / z;
} else {
tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x))));
}
return tmp;
}
def code(x, y, z): t_0 = math.cosh(x) * (y / x) tmp = 0 if t_0 <= math.inf: tmp = t_0 / z else: tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x)))) return tmp
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(y / x)) tmp = 0.0 if (t_0 <= Inf) tmp = Float64(t_0 / z); else tmp = Float64(Float64(Float64(Float64(z / Float64(x * 0.5)) + Float64(x * z)) * Float64(-y)) / Float64(x * Float64(z * Float64(-2.0 * Float64(z / x))))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * (y / x); tmp = 0.0; if (t_0 <= Inf) tmp = t_0 / z; else tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x)))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], N[(t$95$0 / z), $MachinePrecision], N[(N[(N[(N[(z / N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] * (-y)), $MachinePrecision] / N[(x * N[(z * N[(-2.0 * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
\mathbf{if}\;t_0 \leq \infty:\\
\;\;\;\;\frac{t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{z}{x \cdot 0.5} + x \cdot z\right) \cdot \left(-y\right)}{x \cdot \left(z \cdot \left(-2 \cdot \frac{z}{x}\right)\right)}\\
\end{array}
\end{array}
if (*.f64 (cosh.f64 x) (/.f64 y x)) < +inf.0Initial program 99.0%
if +inf.0 < (*.f64 (cosh.f64 x) (/.f64 y x)) Initial program 0.0%
associate-*l/0.0%
Simplified0.0%
Taylor expanded in x around 0 10.4%
div-inv10.4%
associate-*l*10.2%
*-commutative10.2%
associate-*l/10.2%
*-un-lft-identity10.2%
Applied egg-rr10.2%
*-commutative10.2%
associate-*r/10.4%
*-commutative10.4%
associate-/r/10.4%
associate-/l*31.3%
frac-2neg31.3%
frac-add22.6%
distribute-rgt-neg-in22.6%
associate-/l/22.6%
*-commutative22.6%
associate-/l/22.6%
*-commutative22.6%
distribute-rgt-neg-in22.6%
Applied egg-rr22.6%
*-commutative22.6%
associate-*l*44.8%
Simplified44.8%
Final simplification93.3%
(FPCore (x y z) :precision binary64 (if (<= x -1.4e+187) (/ (+ (* (/ y z) 2.0) (* x (* x (/ y z)))) (* x 2.0)) (* (/ y x) (/ (cosh x) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e+187) {
tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0);
} else {
tmp = (y / x) * (cosh(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 (x <= (-1.4d+187)) then
tmp = (((y / z) * 2.0d0) + (x * (x * (y / z)))) / (x * 2.0d0)
else
tmp = (y / x) * (cosh(x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.4e+187) {
tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0);
} else {
tmp = (y / x) * (Math.cosh(x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.4e+187: tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0) else: tmp = (y / x) * (math.cosh(x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.4e+187) tmp = Float64(Float64(Float64(Float64(y / z) * 2.0) + Float64(x * Float64(x * Float64(y / z)))) / Float64(x * 2.0)); else tmp = Float64(Float64(y / x) * Float64(cosh(x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.4e+187) tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0); else tmp = (y / x) * (cosh(x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.4e+187], N[(N[(N[(N[(y / z), $MachinePrecision] * 2.0), $MachinePrecision] + N[(x * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] * N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+187}:\\
\;\;\;\;\frac{\frac{y}{z} \cdot 2 + x \cdot \left(x \cdot \frac{y}{z}\right)}{x \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{\cosh x}{z}\\
\end{array}
\end{array}
if x < -1.39999999999999995e187Initial program 48.0%
associate-*l/48.0%
Simplified48.0%
Taylor expanded in x around 0 46.3%
*-commutative46.3%
associate-/l*38.7%
associate-*l/38.7%
Applied egg-rr38.7%
+-commutative38.7%
associate-/l/38.7%
div-inv38.7%
clear-num38.7%
*-commutative38.7%
metadata-eval38.7%
div-inv38.7%
associate-*r/38.7%
frac-add72.6%
Applied egg-rr72.6%
if -1.39999999999999995e187 < x Initial program 93.0%
associate-*l/93.0%
Simplified93.0%
Final simplification91.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.6e+18) (not (<= x 3.4e+48))) (/ (* (+ (/ z (* x 0.5)) (* x z)) (- y)) (* x (* z (* -2.0 (/ z x))))) (/ (+ (/ y x) (* 0.5 (* x y))) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.6e+18) || !(x <= 3.4e+48)) {
tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x))));
} else {
tmp = ((y / x) + (0.5 * (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 ((x <= (-3.6d+18)) .or. (.not. (x <= 3.4d+48))) then
tmp = (((z / (x * 0.5d0)) + (x * z)) * -y) / (x * (z * ((-2.0d0) * (z / x))))
else
tmp = ((y / x) + (0.5d0 * (x * y))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.6e+18) || !(x <= 3.4e+48)) {
tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x))));
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.6e+18) or not (x <= 3.4e+48): tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x)))) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.6e+18) || !(x <= 3.4e+48)) tmp = Float64(Float64(Float64(Float64(z / Float64(x * 0.5)) + Float64(x * z)) * Float64(-y)) / Float64(x * Float64(z * Float64(-2.0 * Float64(z / x))))); else tmp = Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.6e+18) || ~((x <= 3.4e+48))) tmp = (((z / (x * 0.5)) + (x * z)) * -y) / (x * (z * (-2.0 * (z / x)))); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.6e+18], N[Not[LessEqual[x, 3.4e+48]], $MachinePrecision]], N[(N[(N[(N[(z / N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + N[(x * z), $MachinePrecision]), $MachinePrecision] * (-y)), $MachinePrecision] / N[(x * N[(z * N[(-2.0 * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+18} \lor \neg \left(x \leq 3.4 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{\left(\frac{z}{x \cdot 0.5} + x \cdot z\right) \cdot \left(-y\right)}{x \cdot \left(z \cdot \left(-2 \cdot \frac{z}{x}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if x < -3.6e18 or 3.4000000000000003e48 < x Initial program 78.5%
associate-*l/78.5%
Simplified78.5%
Taylor expanded in x around 0 41.3%
div-inv41.3%
associate-*l*34.2%
*-commutative34.2%
associate-*l/34.2%
*-un-lft-identity34.2%
Applied egg-rr34.2%
*-commutative34.2%
associate-*r/41.3%
*-commutative41.3%
associate-/r/41.3%
associate-/l*42.0%
frac-2neg42.0%
frac-add44.0%
distribute-rgt-neg-in44.0%
associate-/l/44.0%
*-commutative44.0%
associate-/l/44.0%
*-commutative44.0%
distribute-rgt-neg-in44.0%
Applied egg-rr44.0%
*-commutative44.0%
associate-*l*58.5%
Simplified58.5%
if -3.6e18 < x < 3.4000000000000003e48Initial program 97.6%
Taylor expanded in x around 0 87.6%
Final simplification73.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.8e+132) (not (<= z 1.5e-92))) (+ (* 0.5 (/ (* x y) z)) (/ y (* x z))) (/ (+ (* (/ y z) 2.0) (* x (* x (/ y z)))) (* x 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+132) || !(z <= 1.5e-92)) {
tmp = (0.5 * ((x * y) / z)) + (y / (x * z));
} else {
tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.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 <= (-4.8d+132)) .or. (.not. (z <= 1.5d-92))) then
tmp = (0.5d0 * ((x * y) / z)) + (y / (x * z))
else
tmp = (((y / z) * 2.0d0) + (x * (x * (y / z)))) / (x * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.8e+132) || !(z <= 1.5e-92)) {
tmp = (0.5 * ((x * y) / z)) + (y / (x * z));
} else {
tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.8e+132) or not (z <= 1.5e-92): tmp = (0.5 * ((x * y) / z)) + (y / (x * z)) else: tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.8e+132) || !(z <= 1.5e-92)) tmp = Float64(Float64(0.5 * Float64(Float64(x * y) / z)) + Float64(y / Float64(x * z))); else tmp = Float64(Float64(Float64(Float64(y / z) * 2.0) + Float64(x * Float64(x * Float64(y / z)))) / Float64(x * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.8e+132) || ~((z <= 1.5e-92))) tmp = (0.5 * ((x * y) / z)) + (y / (x * z)); else tmp = (((y / z) * 2.0) + (x * (x * (y / z)))) / (x * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.8e+132], N[Not[LessEqual[z, 1.5e-92]], $MachinePrecision]], N[(N[(0.5 * N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(y / z), $MachinePrecision] * 2.0), $MachinePrecision] + N[(x * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.8 \cdot 10^{+132} \lor \neg \left(z \leq 1.5 \cdot 10^{-92}\right):\\
\;\;\;\;0.5 \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z} \cdot 2 + x \cdot \left(x \cdot \frac{y}{z}\right)}{x \cdot 2}\\
\end{array}
\end{array}
if z < -4.8000000000000002e132 or 1.50000000000000007e-92 < z Initial program 87.1%
associate-*l/87.1%
Simplified87.1%
Taylor expanded in x around 0 58.9%
if -4.8000000000000002e132 < z < 1.50000000000000007e-92Initial program 89.8%
associate-*l/89.8%
Simplified89.8%
Taylor expanded in x around 0 63.9%
*-commutative63.9%
associate-/l*62.6%
associate-*l/62.6%
Applied egg-rr62.6%
+-commutative62.6%
associate-/l/71.2%
div-inv71.2%
clear-num71.2%
*-commutative71.2%
metadata-eval71.2%
div-inv71.2%
associate-*r/71.2%
frac-add83.2%
Applied egg-rr83.2%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4) (not (<= x 1.4))) (* x (* y (/ 0.5 z))) (/ (/ y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4) || !(x <= 1.4)) {
tmp = x * (y * (0.5 / z));
} 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 ((x <= (-1.4d0)) .or. (.not. (x <= 1.4d0))) then
tmp = x * (y * (0.5d0 / z))
else
tmp = (y / x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4) || !(x <= 1.4)) {
tmp = x * (y * (0.5 / z));
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4) or not (x <= 1.4): tmp = x * (y * (0.5 / z)) else: tmp = (y / x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4) || !(x <= 1.4)) tmp = Float64(x * Float64(y * Float64(0.5 / z))); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4) || ~((x <= 1.4))) tmp = x * (y * (0.5 / z)); else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.4], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(x * N[(y * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;x \cdot \left(y \cdot \frac{0.5}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if x < -1.3999999999999999 or 1.3999999999999999 < x Initial program 80.7%
associate-*l/80.7%
Simplified80.7%
Taylor expanded in x around 0 39.0%
Taylor expanded in x around inf 39.0%
associate-*r/39.0%
*-commutative39.0%
associate-/l*39.0%
*-commutative39.0%
Simplified39.0%
div-inv39.0%
*-commutative39.0%
associate-*l*32.3%
clear-num32.3%
Applied egg-rr32.3%
if -1.3999999999999999 < x < 1.3999999999999999Initial program 98.1%
Taylor expanded in x around 0 97.4%
Final simplification61.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4) (not (<= x 1.4))) (* y (* x (/ 0.5 z))) (/ (/ y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4) || !(x <= 1.4)) {
tmp = y * (x * (0.5 / z));
} 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 ((x <= (-1.4d0)) .or. (.not. (x <= 1.4d0))) then
tmp = y * (x * (0.5d0 / z))
else
tmp = (y / x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4) || !(x <= 1.4)) {
tmp = y * (x * (0.5 / z));
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4) or not (x <= 1.4): tmp = y * (x * (0.5 / z)) else: tmp = (y / x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4) || !(x <= 1.4)) tmp = Float64(y * Float64(x * Float64(0.5 / z))); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4) || ~((x <= 1.4))) tmp = y * (x * (0.5 / z)); else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.4], N[Not[LessEqual[x, 1.4]], $MachinePrecision]], N[(y * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if x < -1.3999999999999999 or 1.3999999999999999 < x Initial program 80.7%
associate-*l/80.7%
Simplified80.7%
Taylor expanded in x around 0 39.0%
Taylor expanded in x around inf 39.0%
associate-*r/39.0%
*-commutative39.0%
associate-/l*39.0%
*-commutative39.0%
Simplified39.0%
div-inv39.0%
associate-*l*39.6%
clear-num39.6%
Applied egg-rr39.6%
if -1.3999999999999999 < x < 1.3999999999999999Initial program 98.1%
Taylor expanded in x around 0 97.4%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (if (<= x -1.4) (* y (* x (/ 0.5 z))) (if (<= x 1.4) (/ (/ y x) z) (* (* x y) (/ 0.5 z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.4) {
tmp = y * (x * (0.5 / z));
} else if (x <= 1.4) {
tmp = (y / x) / z;
} else {
tmp = (x * y) * (0.5 / 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 (x <= (-1.4d0)) then
tmp = y * (x * (0.5d0 / z))
else if (x <= 1.4d0) then
tmp = (y / x) / z
else
tmp = (x * y) * (0.5d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.4) {
tmp = y * (x * (0.5 / z));
} else if (x <= 1.4) {
tmp = (y / x) / z;
} else {
tmp = (x * y) * (0.5 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.4: tmp = y * (x * (0.5 / z)) elif x <= 1.4: tmp = (y / x) / z else: tmp = (x * y) * (0.5 / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.4) tmp = Float64(y * Float64(x * Float64(0.5 / z))); elseif (x <= 1.4) tmp = Float64(Float64(y / x) / z); else tmp = Float64(Float64(x * y) * Float64(0.5 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.4) tmp = y * (x * (0.5 / z)); elseif (x <= 1.4) tmp = (y / x) / z; else tmp = (x * y) * (0.5 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.4], N[(y * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(x * y), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4:\\
\;\;\;\;y \cdot \left(x \cdot \frac{0.5}{z}\right)\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{z}\\
\end{array}
\end{array}
if x < -1.3999999999999999Initial program 79.5%
associate-*l/79.5%
Simplified79.5%
Taylor expanded in x around 0 37.3%
Taylor expanded in x around inf 37.3%
associate-*r/37.3%
*-commutative37.3%
associate-/l*37.3%
*-commutative37.3%
Simplified37.3%
div-inv37.3%
associate-*l*39.6%
clear-num39.6%
Applied egg-rr39.6%
if -1.3999999999999999 < x < 1.3999999999999999Initial program 98.1%
Taylor expanded in x around 0 97.4%
if 1.3999999999999999 < x Initial program 82.2%
associate-*l/82.3%
Simplified82.3%
Taylor expanded in x around 0 41.2%
Taylor expanded in x around inf 41.2%
associate-*r/41.2%
*-commutative41.2%
associate-/l*41.2%
*-commutative41.2%
Simplified41.2%
clear-num41.2%
associate-/r/41.2%
clear-num41.2%
*-commutative41.2%
Applied egg-rr41.2%
Final simplification66.2%
(FPCore (x y z) :precision binary64 (/ (* y (+ (* x 0.5) (/ 1.0 x))) z))
double code(double x, double y, double z) {
return (y * ((x * 0.5) + (1.0 / x))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * ((x * 0.5d0) + (1.0d0 / x))) / z
end function
public static double code(double x, double y, double z) {
return (y * ((x * 0.5) + (1.0 / x))) / z;
}
def code(x, y, z): return (y * ((x * 0.5) + (1.0 / x))) / z
function code(x, y, z) return Float64(Float64(y * Float64(Float64(x * 0.5) + Float64(1.0 / x))) / z) end
function tmp = code(x, y, z) tmp = (y * ((x * 0.5) + (1.0 / x))) / z; end
code[x_, y_, z_] := N[(N[(y * N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)}{z}
\end{array}
Initial program 88.6%
associate-*l/88.6%
Simplified88.6%
associate-/r/82.3%
associate-/l*77.8%
*-commutative77.8%
expm1-log1p-u42.2%
expm1-udef29.0%
associate-/l*31.7%
times-frac38.6%
Applied egg-rr38.6%
expm1-def47.1%
expm1-log1p87.7%
associate-*r/99.1%
Simplified99.1%
Taylor expanded in x around 0 65.3%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (/ (+ (/ y x) (* 0.5 (* x y))) z))
double code(double x, double y, double z) {
return ((y / x) + (0.5 * (x * 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 = ((y / x) + (0.5d0 * (x * y))) / z
end function
public static double code(double x, double y, double z) {
return ((y / x) + (0.5 * (x * y))) / z;
}
def code(x, y, z): return ((y / x) + (0.5 * (x * y))) / z
function code(x, y, z) return Float64(Float64(Float64(y / x) + Float64(0.5 * Float64(x * y))) / z) end
function tmp = code(x, y, z) tmp = ((y / x) + (0.5 * (x * y))) / z; end
code[x_, y_, z_] := N[(N[(N[(y / x), $MachinePrecision] + N[(0.5 * N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}
\end{array}
Initial program 88.6%
Taylor expanded in x around 0 65.7%
Final simplification65.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+38) (not (<= y 4e+86))) (/ (/ y z) x) (/ (/ y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+38) || !(y <= 4e+86)) {
tmp = (y / 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 <= (-1d+38)) .or. (.not. (y <= 4d+86))) then
tmp = (y / 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 <= -1e+38) || !(y <= 4e+86)) {
tmp = (y / z) / x;
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+38) or not (y <= 4e+86): tmp = (y / z) / x else: tmp = (y / x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+38) || !(y <= 4e+86)) tmp = Float64(Float64(y / z) / x); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e+38) || ~((y <= 4e+86))) tmp = (y / z) / x; else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+38], N[Not[LessEqual[y, 4e+86]], $MachinePrecision]], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+38} \lor \neg \left(y \leq 4 \cdot 10^{+86}\right):\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if y < -9.99999999999999977e37 or 4.0000000000000001e86 < y Initial program 98.0%
associate-*l/98.0%
Simplified98.0%
associate-*r/99.8%
associate-*l/99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 58.0%
if -9.99999999999999977e37 < y < 4.0000000000000001e86Initial program 82.8%
Taylor expanded in x around 0 50.8%
Final simplification53.5%
(FPCore (x y z) :precision binary64 (/ y (* x z)))
double code(double x, double y, double z) {
return y / (x * z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y / (x * z)
end function
public static double code(double x, double y, double z) {
return y / (x * z);
}
def code(x, y, z): return y / (x * z)
function code(x, y, z) return Float64(y / Float64(x * z)) end
function tmp = code(x, y, z) tmp = y / (x * z); end
code[x_, y_, z_] := N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{x \cdot z}
\end{array}
Initial program 88.6%
associate-*l/88.6%
Simplified88.6%
Taylor expanded in x around 0 43.1%
Final simplification43.1%
(FPCore (x y z) :precision binary64 (/ (/ y x) z))
double code(double x, double y, double z) {
return (y / x) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y / x) / z
end function
public static double code(double x, double y, double z) {
return (y / x) / z;
}
def code(x, y, z): return (y / x) / z
function code(x, y, z) return Float64(Float64(y / x) / z) end
function tmp = code(x, y, z) tmp = (y / x) / z; end
code[x_, y_, z_] := N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x}}{z}
\end{array}
Initial program 88.6%
Taylor expanded in x around 0 47.3%
Final simplification47.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ (/ y z) x) (cosh x))))
(if (< y -4.618902267687042e-52)
t_0
(if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) t_0))))
double code(double x, double y, double z) {
double t_0 = ((y / z) / x) * cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((cosh(x) * y) / 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 / z) / x) * cosh(x)
if (y < (-4.618902267687042d-52)) then
tmp = t_0
else if (y < 1.038530535935153d-39) then
tmp = ((cosh(x) * y) / 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 / z) / x) * Math.cosh(x);
double tmp;
if (y < -4.618902267687042e-52) {
tmp = t_0;
} else if (y < 1.038530535935153e-39) {
tmp = ((Math.cosh(x) * y) / x) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((y / z) / x) * math.cosh(x) tmp = 0 if y < -4.618902267687042e-52: tmp = t_0 elif y < 1.038530535935153e-39: tmp = ((math.cosh(x) * y) / x) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(y / z) / x) * cosh(x)) tmp = 0.0 if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = Float64(Float64(Float64(cosh(x) * y) / x) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((y / z) / x) * cosh(x); tmp = 0.0; if (y < -4.618902267687042e-52) tmp = t_0; elseif (y < 1.038530535935153e-39) tmp = ((cosh(x) * y) / x) / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision] * N[Cosh[x], $MachinePrecision]), $MachinePrecision]}, If[Less[y, -4.618902267687042e-52], t$95$0, If[Less[y, 1.038530535935153e-39], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{y}{z}}{x} \cdot \cosh x\\
\mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y < 1.038530535935153 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023320
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))