
(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 12 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
(let* ((t_0 (/ (* (cosh x) (/ y x)) z)))
(if (or (<= t_0 -2e+180) (not (<= t_0 1e-68)))
(/ (/ (* (cosh x) y) z) x)
(/ (/ y x) z))))
double code(double x, double y, double z) {
double t_0 = (cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -2e+180) || !(t_0 <= 1e-68)) {
tmp = ((cosh(x) * 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) :: t_0
real(8) :: tmp
t_0 = (cosh(x) * (y / x)) / z
if ((t_0 <= (-2d+180)) .or. (.not. (t_0 <= 1d-68))) then
tmp = ((cosh(x) * 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 t_0 = (Math.cosh(x) * (y / x)) / z;
double tmp;
if ((t_0 <= -2e+180) || !(t_0 <= 1e-68)) {
tmp = ((Math.cosh(x) * y) / z) / x;
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): t_0 = (math.cosh(x) * (y / x)) / z tmp = 0 if (t_0 <= -2e+180) or not (t_0 <= 1e-68): tmp = ((math.cosh(x) * y) / z) / x else: tmp = (y / x) / z return tmp
function code(x, y, z) t_0 = Float64(Float64(cosh(x) * Float64(y / x)) / z) tmp = 0.0 if ((t_0 <= -2e+180) || !(t_0 <= 1e-68)) tmp = Float64(Float64(Float64(cosh(x) * y) / z) / x); else tmp = Float64(Float64(y / x) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (cosh(x) * (y / x)) / z; tmp = 0.0; if ((t_0 <= -2e+180) || ~((t_0 <= 1e-68))) tmp = ((cosh(x) * y) / z) / x; else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e+180], N[Not[LessEqual[t$95$0, 1e-68]], $MachinePrecision]], N[(N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / z), $MachinePrecision] / x), $MachinePrecision], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -2 \cdot 10^{+180} \lor \neg \left(t_0 \leq 10^{-68}\right):\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -2e180 or 1.00000000000000007e-68 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 80.2%
associate-*r/73.3%
associate-/r*76.8%
Simplified76.8%
associate-*r/84.2%
*-commutative84.2%
associate-/r*99.9%
Applied egg-rr99.9%
if -2e180 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.00000000000000007e-68Initial program 99.8%
associate-*r/99.8%
associate-/r*94.6%
Simplified94.6%
Taylor expanded in x around 0 94.6%
*-commutative94.6%
associate-/r*99.8%
Simplified99.8%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (* (cosh x) (/ y x)) z))) (if (<= t_0 1e-68) t_0 (* (/ (cosh x) x) (/ y z)))))
double code(double x, double y, double z) {
double t_0 = (cosh(x) * (y / x)) / z;
double tmp;
if (t_0 <= 1e-68) {
tmp = t_0;
} else {
tmp = (cosh(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) :: t_0
real(8) :: tmp
t_0 = (cosh(x) * (y / x)) / z
if (t_0 <= 1d-68) then
tmp = t_0
else
tmp = (cosh(x) / x) * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (Math.cosh(x) * (y / x)) / z;
double tmp;
if (t_0 <= 1e-68) {
tmp = t_0;
} else {
tmp = (Math.cosh(x) / x) * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = (math.cosh(x) * (y / x)) / z tmp = 0 if t_0 <= 1e-68: tmp = t_0 else: tmp = (math.cosh(x) / x) * (y / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(cosh(x) * Float64(y / x)) / z) tmp = 0.0 if (t_0 <= 1e-68) tmp = t_0; else tmp = Float64(Float64(cosh(x) / x) * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (cosh(x) * (y / x)) / z; tmp = 0.0; if (t_0 <= 1e-68) tmp = t_0; else tmp = (cosh(x) / x) * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, 1e-68], t$95$0, N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq 10^{-68}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.00000000000000007e-68Initial program 95.5%
if 1.00000000000000007e-68 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) Initial program 71.7%
associate-/l*65.6%
Simplified65.6%
associate-/r/71.6%
frac-times83.1%
*-commutative83.1%
times-frac93.1%
Applied egg-rr93.1%
Final simplification94.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4e-103) (not (<= y 5.5e-285))) (* (/ (cosh x) x) (/ y z)) (* y (/ (cosh x) (* x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4e-103) || !(y <= 5.5e-285)) {
tmp = (cosh(x) / x) * (y / z);
} else {
tmp = y * (cosh(x) / (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 <= (-4d-103)) .or. (.not. (y <= 5.5d-285))) then
tmp = (cosh(x) / x) * (y / z)
else
tmp = y * (cosh(x) / (x * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -4e-103) || !(y <= 5.5e-285)) {
tmp = (Math.cosh(x) / x) * (y / z);
} else {
tmp = y * (Math.cosh(x) / (x * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4e-103) or not (y <= 5.5e-285): tmp = (math.cosh(x) / x) * (y / z) else: tmp = y * (math.cosh(x) / (x * z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4e-103) || !(y <= 5.5e-285)) tmp = Float64(Float64(cosh(x) / x) * Float64(y / z)); else tmp = Float64(y * Float64(cosh(x) / Float64(x * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -4e-103) || ~((y <= 5.5e-285))) tmp = (cosh(x) / x) * (y / z); else tmp = y * (cosh(x) / (x * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4e-103], N[Not[LessEqual[y, 5.5e-285]], $MachinePrecision]], N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-103} \lor \neg \left(y \leq 5.5 \cdot 10^{-285}\right):\\
\;\;\;\;\frac{\cosh x}{x} \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\
\end{array}
\end{array}
if y < -3.99999999999999983e-103 or 5.5000000000000001e-285 < y Initial program 87.8%
associate-/l*81.4%
Simplified81.4%
associate-/r/87.7%
frac-times84.7%
*-commutative84.7%
times-frac96.2%
Applied egg-rr96.2%
if -3.99999999999999983e-103 < y < 5.5000000000000001e-285Initial program 63.9%
associate-*r/59.9%
associate-/r*75.9%
Simplified75.9%
associate-/r*59.9%
associate-*r/63.9%
add-log-exp33.6%
*-un-lft-identity33.6%
log-prod33.6%
metadata-eval33.6%
add-log-exp63.9%
associate-*r/99.9%
associate-/r*89.9%
times-frac69.0%
Applied egg-rr69.0%
+-lft-identity69.0%
times-frac89.9%
*-rgt-identity89.9%
associate-*r/89.8%
*-commutative89.8%
associate-/l/91.8%
associate-*r*91.8%
associate-/l/89.8%
associate-*r/89.8%
*-rgt-identity89.8%
*-commutative89.8%
Simplified89.8%
Final simplification94.9%
(FPCore (x y z) :precision binary64 (if (<= x 4.5e+246) (* y (/ (cosh x) (* x z))) (/ (+ (/ y x) (* 0.5 (* x y))) z)))
double code(double x, double y, double z) {
double tmp;
if (x <= 4.5e+246) {
tmp = y * (cosh(x) / (x * z));
} 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 <= 4.5d+246) then
tmp = y * (cosh(x) / (x * z))
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 <= 4.5e+246) {
tmp = y * (Math.cosh(x) / (x * z));
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 4.5e+246: tmp = y * (math.cosh(x) / (x * z)) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) tmp = 0.0 if (x <= 4.5e+246) tmp = Float64(y * Float64(cosh(x) / Float64(x * z))); 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 <= 4.5e+246) tmp = y * (cosh(x) / (x * z)); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 4.5e+246], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(x * z), $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 4.5 \cdot 10^{+246}:\\
\;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if x < 4.5e246Initial program 83.4%
associate-*r/78.0%
associate-/r*82.0%
Simplified82.0%
associate-/r*78.0%
associate-*r/83.4%
add-log-exp59.2%
*-un-lft-identity59.2%
log-prod59.2%
metadata-eval59.2%
add-log-exp83.4%
associate-*r/94.1%
associate-/r*88.2%
times-frac90.7%
Applied egg-rr90.7%
+-lft-identity90.7%
times-frac88.2%
*-rgt-identity88.2%
associate-*r/88.0%
*-commutative88.0%
associate-/l/90.9%
associate-*r*90.9%
associate-/l/88.0%
associate-*r/88.1%
*-rgt-identity88.1%
*-commutative88.1%
Simplified88.1%
if 4.5e246 < x Initial program 78.6%
Taylor expanded in x around 0 79.4%
Final simplification87.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* 0.5 (* x x))))
(t_1 (* (/ y x) (/ t_0 z)))
(t_2 (/ (- (/ 1.0 x) (* x -0.5)) (/ z y))))
(if (<= y -1.12e+107)
t_2
(if (<= y -5.6e-93)
t_1
(if (<= y 2.2e-286)
(* y (/ t_0 (* x z)))
(if (<= y 8e+181) t_1 t_2))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (0.5 * (x * x));
double t_1 = (y / x) * (t_0 / z);
double t_2 = ((1.0 / x) - (x * -0.5)) / (z / y);
double tmp;
if (y <= -1.12e+107) {
tmp = t_2;
} else if (y <= -5.6e-93) {
tmp = t_1;
} else if (y <= 2.2e-286) {
tmp = y * (t_0 / (x * z));
} else if (y <= 8e+181) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 1.0d0 + (0.5d0 * (x * x))
t_1 = (y / x) * (t_0 / z)
t_2 = ((1.0d0 / x) - (x * (-0.5d0))) / (z / y)
if (y <= (-1.12d+107)) then
tmp = t_2
else if (y <= (-5.6d-93)) then
tmp = t_1
else if (y <= 2.2d-286) then
tmp = y * (t_0 / (x * z))
else if (y <= 8d+181) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (0.5 * (x * x));
double t_1 = (y / x) * (t_0 / z);
double t_2 = ((1.0 / x) - (x * -0.5)) / (z / y);
double tmp;
if (y <= -1.12e+107) {
tmp = t_2;
} else if (y <= -5.6e-93) {
tmp = t_1;
} else if (y <= 2.2e-286) {
tmp = y * (t_0 / (x * z));
} else if (y <= 8e+181) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (0.5 * (x * x)) t_1 = (y / x) * (t_0 / z) t_2 = ((1.0 / x) - (x * -0.5)) / (z / y) tmp = 0 if y <= -1.12e+107: tmp = t_2 elif y <= -5.6e-93: tmp = t_1 elif y <= 2.2e-286: tmp = y * (t_0 / (x * z)) elif y <= 8e+181: tmp = t_1 else: tmp = t_2 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(0.5 * Float64(x * x))) t_1 = Float64(Float64(y / x) * Float64(t_0 / z)) t_2 = Float64(Float64(Float64(1.0 / x) - Float64(x * -0.5)) / Float64(z / y)) tmp = 0.0 if (y <= -1.12e+107) tmp = t_2; elseif (y <= -5.6e-93) tmp = t_1; elseif (y <= 2.2e-286) tmp = Float64(y * Float64(t_0 / Float64(x * z))); elseif (y <= 8e+181) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (0.5 * (x * x)); t_1 = (y / x) * (t_0 / z); t_2 = ((1.0 / x) - (x * -0.5)) / (z / y); tmp = 0.0; if (y <= -1.12e+107) tmp = t_2; elseif (y <= -5.6e-93) tmp = t_1; elseif (y <= 2.2e-286) tmp = y * (t_0 / (x * z)); elseif (y <= 8e+181) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(y / x), $MachinePrecision] * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(1.0 / x), $MachinePrecision] - N[(x * -0.5), $MachinePrecision]), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.12e+107], t$95$2, If[LessEqual[y, -5.6e-93], t$95$1, If[LessEqual[y, 2.2e-286], N[(y * N[(t$95$0 / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8e+181], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + 0.5 \cdot \left(x \cdot x\right)\\
t_1 := \frac{y}{x} \cdot \frac{t_0}{z}\\
t_2 := \frac{\frac{1}{x} - x \cdot -0.5}{\frac{z}{y}}\\
\mathbf{if}\;y \leq -1.12 \cdot 10^{+107}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;y \leq -5.6 \cdot 10^{-93}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-286}:\\
\;\;\;\;y \cdot \frac{t_0}{x \cdot z}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+181}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if y < -1.11999999999999997e107 or 7.9999999999999993e181 < y Initial program 83.9%
Taylor expanded in x around 0 77.0%
Taylor expanded in y around -inf 77.0%
mul-1-neg77.0%
associate-/l*82.3%
*-commutative82.3%
Simplified82.3%
if -1.11999999999999997e107 < y < -5.59999999999999997e-93 or 2.1999999999999999e-286 < y < 7.9999999999999993e181Initial program 90.2%
associate-*r/81.9%
associate-/r*76.2%
Simplified76.2%
associate-/r*81.9%
associate-*r/90.2%
add-log-exp63.6%
*-un-lft-identity63.6%
log-prod63.6%
metadata-eval63.6%
add-log-exp90.2%
associate-*r/97.8%
associate-/r*83.0%
times-frac94.8%
Applied egg-rr94.8%
+-lft-identity94.8%
times-frac83.0%
*-rgt-identity83.0%
associate-*r/82.8%
*-commutative82.8%
associate-/l/85.8%
associate-*r*85.8%
associate-/l/82.8%
associate-*r/82.8%
*-rgt-identity82.8%
*-commutative82.8%
Simplified82.8%
Taylor expanded in x around 0 58.6%
associate-*r/58.6%
*-commutative58.6%
frac-add56.5%
*-un-lft-identity56.5%
Applied egg-rr56.5%
Taylor expanded in z around 0 61.3%
times-frac71.9%
unpow271.9%
Simplified71.9%
if -5.59999999999999997e-93 < y < 2.1999999999999999e-286Initial program 64.7%
associate-*r/59.1%
associate-/r*74.0%
Simplified74.0%
associate-/r*59.1%
associate-*r/64.7%
add-log-exp33.1%
*-un-lft-identity33.1%
log-prod33.1%
metadata-eval33.1%
add-log-exp64.7%
associate-*r/99.9%
associate-/r*86.9%
times-frac69.5%
Applied egg-rr69.5%
+-lft-identity69.5%
times-frac86.9%
*-rgt-identity86.9%
associate-*r/86.9%
*-commutative86.9%
associate-/l/90.5%
associate-*r*90.5%
associate-/l/86.9%
associate-*r/86.9%
*-rgt-identity86.9%
*-commutative86.9%
Simplified86.9%
Taylor expanded in x around 0 62.0%
associate-*r/62.0%
*-commutative62.0%
frac-add67.0%
*-un-lft-identity67.0%
Applied egg-rr67.0%
Taylor expanded in z around 0 72.5%
unpow272.5%
*-commutative72.5%
Simplified72.5%
Final simplification74.9%
(FPCore (x y z) :precision binary64 (if (<= z -4.5e+235) (* y (/ (/ 1.0 x) z)) (/ (+ (/ y x) (* 0.5 (* x y))) z)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+235) {
tmp = y * ((1.0 / x) / z);
} 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 (z <= (-4.5d+235)) then
tmp = y * ((1.0d0 / x) / z)
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 (z <= -4.5e+235) {
tmp = y * ((1.0 / x) / z);
} else {
tmp = ((y / x) + (0.5 * (x * y))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.5e+235: tmp = y * ((1.0 / x) / z) else: tmp = ((y / x) + (0.5 * (x * y))) / z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.5e+235) tmp = Float64(y * Float64(Float64(1.0 / x) / z)); 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 (z <= -4.5e+235) tmp = y * ((1.0 / x) / z); else tmp = ((y / x) + (0.5 * (x * y))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.5e+235], N[(y * N[(N[(1.0 / x), $MachinePrecision] / z), $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}\;z \leq -4.5 \cdot 10^{+235}:\\
\;\;\;\;y \cdot \frac{\frac{1}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\
\end{array}
\end{array}
if z < -4.5e235Initial program 71.0%
associate-*r/66.0%
associate-/r*89.7%
Simplified89.7%
Taylor expanded in x around 0 85.0%
clear-num84.8%
associate-/r/85.1%
*-commutative85.1%
associate-/r*85.2%
Applied egg-rr85.2%
if -4.5e235 < z Initial program 84.1%
Taylor expanded in x around 0 63.5%
Final simplification65.2%
(FPCore (x y z) :precision binary64 (* y (+ (/ 1.0 (* x z)) (* 0.5 (/ x z)))))
double code(double x, double y, double z) {
return y * ((1.0 / (x * z)) + (0.5 * (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 * ((1.0d0 / (x * z)) + (0.5d0 * (x / z)))
end function
public static double code(double x, double y, double z) {
return y * ((1.0 / (x * z)) + (0.5 * (x / z)));
}
def code(x, y, z): return y * ((1.0 / (x * z)) + (0.5 * (x / z)))
function code(x, y, z) return Float64(y * Float64(Float64(1.0 / Float64(x * z)) + Float64(0.5 * Float64(x / z)))) end
function tmp = code(x, y, z) tmp = y * ((1.0 / (x * z)) + (0.5 * (x / z))); end
code[x_, y_, z_] := N[(y * N[(N[(1.0 / N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(\frac{1}{x \cdot z} + 0.5 \cdot \frac{x}{z}\right)
\end{array}
Initial program 83.1%
associate-*r/77.2%
associate-/r*79.5%
Simplified79.5%
associate-/r*77.2%
associate-*r/83.1%
add-log-exp60.2%
*-un-lft-identity60.2%
log-prod60.2%
metadata-eval60.2%
add-log-exp83.1%
associate-*r/94.4%
associate-/r*85.7%
times-frac90.8%
Applied egg-rr90.8%
+-lft-identity90.8%
times-frac85.7%
*-rgt-identity85.7%
associate-*r/85.6%
*-commutative85.6%
associate-/l/88.3%
associate-*r*88.3%
associate-/l/85.6%
associate-*r/85.6%
*-rgt-identity85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in x around 0 65.8%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (* y (/ (+ 1.0 (* 0.5 (* x x))) (* x z))))
double code(double x, double y, double z) {
return y * ((1.0 + (0.5 * (x * x))) / (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 * ((1.0d0 + (0.5d0 * (x * x))) / (x * z))
end function
public static double code(double x, double y, double z) {
return y * ((1.0 + (0.5 * (x * x))) / (x * z));
}
def code(x, y, z): return y * ((1.0 + (0.5 * (x * x))) / (x * z))
function code(x, y, z) return Float64(y * Float64(Float64(1.0 + Float64(0.5 * Float64(x * x))) / Float64(x * z))) end
function tmp = code(x, y, z) tmp = y * ((1.0 + (0.5 * (x * x))) / (x * z)); end
code[x_, y_, z_] := N[(y * N[(N[(1.0 + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{1 + 0.5 \cdot \left(x \cdot x\right)}{x \cdot z}
\end{array}
Initial program 83.1%
associate-*r/77.2%
associate-/r*79.5%
Simplified79.5%
associate-/r*77.2%
associate-*r/83.1%
add-log-exp60.2%
*-un-lft-identity60.2%
log-prod60.2%
metadata-eval60.2%
add-log-exp83.1%
associate-*r/94.4%
associate-/r*85.7%
times-frac90.8%
Applied egg-rr90.8%
+-lft-identity90.8%
times-frac85.7%
*-rgt-identity85.7%
associate-*r/85.6%
*-commutative85.6%
associate-/l/88.3%
associate-*r*88.3%
associate-/l/85.6%
associate-*r/85.6%
*-rgt-identity85.6%
*-commutative85.6%
Simplified85.6%
Taylor expanded in x around 0 65.8%
associate-*r/65.8%
*-commutative65.8%
frac-add61.0%
*-un-lft-identity61.0%
Applied egg-rr61.0%
Taylor expanded in z around 0 68.8%
unpow268.8%
*-commutative68.8%
Simplified68.8%
Final simplification68.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.4) (not (<= x 1.4))) (* 0.5 (/ y (/ z x))) (/ y (* x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4) || !(x <= 1.4)) {
tmp = 0.5 * (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 ((x <= (-1.4d0)) .or. (.not. (x <= 1.4d0))) then
tmp = 0.5d0 * (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 ((x <= -1.4) || !(x <= 1.4)) {
tmp = 0.5 * (y / (z / x));
} else {
tmp = y / (x * z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4) or not (x <= 1.4): tmp = 0.5 * (y / (z / x)) else: tmp = y / (x * z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4) || !(x <= 1.4)) tmp = Float64(0.5 * Float64(y / Float64(z / x))); else tmp = Float64(y / Float64(x * z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4) || ~((x <= 1.4))) tmp = 0.5 * (y / (z / x)); 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[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \lor \neg \left(x \leq 1.4\right):\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\end{array}
\end{array}
if x < -1.3999999999999999 or 1.3999999999999999 < x Initial program 77.7%
Taylor expanded in x around 0 38.8%
Taylor expanded in x around inf 38.8%
associate-/l*38.0%
Simplified38.0%
if -1.3999999999999999 < x < 1.3999999999999999Initial program 88.7%
associate-*r/88.7%
associate-/r*94.0%
Simplified94.0%
Taylor expanded in x around 0 93.6%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (<= x -1.42) (* (* x y) (/ 0.5 z)) (if (<= x 1.4) (/ y (* x z)) (* 0.5 (/ y (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.42) {
tmp = (x * y) * (0.5 / z);
} else if (x <= 1.4) {
tmp = y / (x * z);
} else {
tmp = 0.5 * (y / (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 (x <= (-1.42d0)) then
tmp = (x * y) * (0.5d0 / z)
else if (x <= 1.4d0) then
tmp = y / (x * z)
else
tmp = 0.5d0 * (y / (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.42) {
tmp = (x * y) * (0.5 / z);
} else if (x <= 1.4) {
tmp = y / (x * z);
} else {
tmp = 0.5 * (y / (z / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.42: tmp = (x * y) * (0.5 / z) elif x <= 1.4: tmp = y / (x * z) else: tmp = 0.5 * (y / (z / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.42) tmp = Float64(Float64(x * y) * Float64(0.5 / z)); elseif (x <= 1.4) tmp = Float64(y / Float64(x * z)); else tmp = Float64(0.5 * Float64(y / Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.42) tmp = (x * y) * (0.5 / z); elseif (x <= 1.4) tmp = y / (x * z); else tmp = 0.5 * (y / (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.42], N[(N[(x * y), $MachinePrecision] * N[(0.5 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42:\\
\;\;\;\;\left(x \cdot y\right) \cdot \frac{0.5}{z}\\
\mathbf{elif}\;x \leq 1.4:\\
\;\;\;\;\frac{y}{x \cdot z}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if x < -1.4199999999999999Initial program 74.6%
associate-*r/68.3%
associate-/r*69.8%
Simplified69.8%
associate-/r*68.3%
associate-*r/74.6%
add-log-exp74.6%
*-un-lft-identity74.6%
log-prod74.6%
metadata-eval74.6%
add-log-exp74.6%
associate-*r/100.0%
associate-/r*79.4%
times-frac90.5%
Applied egg-rr90.5%
+-lft-identity90.5%
times-frac79.4%
*-rgt-identity79.4%
associate-*r/79.4%
*-commutative79.4%
associate-/l/84.1%
associate-*r*84.1%
associate-/l/79.4%
associate-*r/79.4%
*-rgt-identity79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in x around 0 30.0%
associate-*r/30.0%
*-commutative30.0%
frac-add37.8%
*-un-lft-identity37.8%
Applied egg-rr37.8%
Taylor expanded in x around inf 33.1%
associate-*r/33.1%
/-rgt-identity33.1%
associate-/r/33.1%
associate-*l/33.1%
*-commutative33.1%
associate-/r/33.1%
/-rgt-identity33.1%
*-commutative33.1%
Simplified33.1%
if -1.4199999999999999 < x < 1.3999999999999999Initial program 88.7%
associate-*r/88.7%
associate-/r*94.0%
Simplified94.0%
Taylor expanded in x around 0 93.6%
if 1.3999999999999999 < x Initial program 80.6%
Taylor expanded in x around 0 44.2%
Taylor expanded in x around inf 44.2%
associate-/l*46.9%
Simplified46.9%
Final simplification66.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e+26) (not (<= y 2.6e+71))) (/ (/ y z) x) (/ (/ y x) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+26) || !(y <= 2.6e+71)) {
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 <= (-3d+26)) .or. (.not. (y <= 2.6d+71))) 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 <= -3e+26) || !(y <= 2.6e+71)) {
tmp = (y / z) / x;
} else {
tmp = (y / x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+26) or not (y <= 2.6e+71): tmp = (y / z) / x else: tmp = (y / x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e+26) || !(y <= 2.6e+71)) 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 <= -3e+26) || ~((y <= 2.6e+71))) tmp = (y / z) / x; else tmp = (y / x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e+26], N[Not[LessEqual[y, 2.6e+71]], $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 -3 \cdot 10^{+26} \lor \neg \left(y \leq 2.6 \cdot 10^{+71}\right):\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if y < -2.99999999999999997e26 or 2.59999999999999991e71 < y Initial program 87.4%
associate-*r/84.7%
associate-/r*88.3%
Simplified88.3%
associate-*r/88.3%
*-commutative88.3%
associate-/r*99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 62.5%
if -2.99999999999999997e26 < y < 2.59999999999999991e71Initial program 79.7%
associate-*r/71.4%
associate-/r*72.6%
Simplified72.6%
Taylor expanded in x around 0 44.4%
*-commutative44.4%
associate-/r*49.4%
Simplified49.4%
Final simplification55.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(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 83.1%
associate-*r/77.2%
associate-/r*79.5%
Simplified79.5%
Taylor expanded in x around 0 49.0%
Final simplification49.0%
(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 2023268
(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))