
(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 (/ y (* z (/ x (cosh x)))))
double code(double x, double y, double z) {
return y / (z * (x / cosh(x)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y / (z * (x / cosh(x)))
end function
public static double code(double x, double y, double z) {
return y / (z * (x / Math.cosh(x)));
}
def code(x, y, z): return y / (z * (x / math.cosh(x)))
function code(x, y, z) return Float64(y / Float64(z * Float64(x / cosh(x)))) end
function tmp = code(x, y, z) tmp = y / (z * (x / cosh(x))); end
code[x_, y_, z_] := N[(y / N[(z * N[(x / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z \cdot \frac{x}{\cosh x}}
\end{array}
Initial program 84.8%
*-commutative84.8%
associate-*l/96.9%
associate-/l*96.9%
associate-/l*98.4%
associate-/r*83.2%
Simplified83.2%
clear-num83.2%
un-div-inv83.2%
*-commutative83.2%
associate-/l*98.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (x y z) :precision binary64 (if (<= y 1.42e+30) (* y (/ (cosh x) (* z x))) (+ (* 0.5 (/ (* y x) z)) (/ y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+30) {
tmp = y * (cosh(x) / (z * x));
} else {
tmp = (0.5 * ((y * x) / z)) + (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 (y <= 1.42d+30) then
tmp = y * (cosh(x) / (z * x))
else
tmp = (0.5d0 * ((y * x) / z)) + (y / (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.42e+30) {
tmp = y * (Math.cosh(x) / (z * x));
} else {
tmp = (0.5 * ((y * x) / z)) + (y / (z * x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.42e+30: tmp = y * (math.cosh(x) / (z * x)) else: tmp = (0.5 * ((y * x) / z)) + (y / (z * x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.42e+30) tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); else tmp = Float64(Float64(0.5 * Float64(Float64(y * x) / z)) + Float64(y / Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.42e+30) tmp = y * (cosh(x) / (z * x)); else tmp = (0.5 * ((y * x) / z)) + (y / (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.42e+30], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.42 \cdot 10^{+30}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{z} + \frac{y}{z \cdot x}\\
\end{array}
\end{array}
if y < 1.41999999999999991e30Initial program 81.9%
*-commutative81.9%
associate-*l/97.5%
associate-/l*97.5%
associate-/l*98.0%
associate-/r*82.9%
Simplified82.9%
if 1.41999999999999991e30 < y Initial program 94.9%
*-commutative94.9%
associate-*l/94.9%
associate-/l*94.9%
associate-/l*99.8%
associate-/r*84.0%
Simplified84.0%
Taylor expanded in x around 0 91.2%
Final simplification84.8%
(FPCore (x y z) :precision binary64 (if (<= y 5e-18) (* y (/ (cosh x) (* z x))) (* (cosh x) (/ (/ y x) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5e-18) {
tmp = y * (cosh(x) / (z * x));
} else {
tmp = cosh(x) * ((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 <= 5d-18) then
tmp = y * (cosh(x) / (z * x))
else
tmp = cosh(x) * ((y / x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5e-18) {
tmp = y * (Math.cosh(x) / (z * x));
} else {
tmp = Math.cosh(x) * ((y / x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5e-18: tmp = y * (math.cosh(x) / (z * x)) else: tmp = math.cosh(x) * ((y / x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5e-18) tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); else tmp = Float64(cosh(x) * Float64(Float64(y / x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 5e-18) tmp = y * (cosh(x) / (z * x)); else tmp = cosh(x) * ((y / x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5e-18], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5 \cdot 10^{-18}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{x}}{z}\\
\end{array}
\end{array}
if y < 5.00000000000000036e-18Initial program 81.0%
*-commutative81.0%
associate-*l/97.4%
associate-/l*97.4%
associate-/l*97.9%
associate-/r*84.1%
Simplified84.1%
if 5.00000000000000036e-18 < y Initial program 95.7%
associate-/l*88.2%
Simplified88.2%
Final simplification85.2%
(FPCore (x y z) :precision binary64 (if (<= z 1.65e+67) (* y (/ (cosh x) (* z x))) (* (/ (cosh x) z) (/ y x))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.65e+67) {
tmp = y * (cosh(x) / (z * x));
} else {
tmp = (cosh(x) / z) * (y / x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 1.65d+67) then
tmp = y * (cosh(x) / (z * x))
else
tmp = (cosh(x) / z) * (y / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.65e+67) {
tmp = y * (Math.cosh(x) / (z * x));
} else {
tmp = (Math.cosh(x) / z) * (y / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.65e+67: tmp = y * (math.cosh(x) / (z * x)) else: tmp = (math.cosh(x) / z) * (y / x) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.65e+67) tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); else tmp = Float64(Float64(cosh(x) / z) * Float64(y / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.65e+67) tmp = y * (cosh(x) / (z * x)); else tmp = (cosh(x) / z) * (y / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.65e+67], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.65 \cdot 10^{+67}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cosh x}{z} \cdot \frac{y}{x}\\
\end{array}
\end{array}
if z < 1.6500000000000001e67Initial program 83.6%
*-commutative83.6%
associate-*l/97.1%
associate-/l*97.1%
associate-/l*98.1%
associate-/r*88.9%
Simplified88.9%
if 1.6500000000000001e67 < z Initial program 89.9%
associate-*r/96.0%
associate-/l/59.0%
times-frac89.8%
Applied egg-rr89.8%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (* y (/ (/ (cosh x) x) z)))
double code(double x, double y, double z) {
return y * ((cosh(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 * ((cosh(x) / x) / z)
end function
public static double code(double x, double y, double z) {
return y * ((Math.cosh(x) / x) / z);
}
def code(x, y, z): return y * ((math.cosh(x) / x) / z)
function code(x, y, z) return Float64(y * Float64(Float64(cosh(x) / x) / z)) end
function tmp = code(x, y, z) tmp = y * ((cosh(x) / x) / z); end
code[x_, y_, z_] := N[(y * N[(N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{\frac{\cosh x}{x}}{z}
\end{array}
Initial program 84.8%
*-commutative84.8%
associate-*l/96.9%
associate-/l*96.9%
associate-/l*98.4%
associate-/r*83.2%
Simplified83.2%
clear-num83.2%
un-div-inv83.2%
*-commutative83.2%
associate-/l*98.5%
Applied egg-rr98.5%
clear-num98.2%
associate-/r/98.4%
*-commutative98.4%
associate-/r*98.4%
clear-num98.4%
Applied egg-rr98.4%
Final simplification98.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (* z x))))
(if (<= z 1.9e-36)
(+ t_0 (* y (* x (/ 0.5 z))))
(if (<= z 2.8e+68)
(/ (+ (* (* y (* x 0.5)) (* z x)) (* y z)) (* z (* z x)))
(+ (* 0.5 (/ (* y x) z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (z * x);
double tmp;
if (z <= 1.9e-36) {
tmp = t_0 + (y * (x * (0.5 / z)));
} else if (z <= 2.8e+68) {
tmp = (((y * (x * 0.5)) * (z * x)) + (y * z)) / (z * (z * x));
} else {
tmp = (0.5 * ((y * x) / z)) + 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)
if (z <= 1.9d-36) then
tmp = t_0 + (y * (x * (0.5d0 / z)))
else if (z <= 2.8d+68) then
tmp = (((y * (x * 0.5d0)) * (z * x)) + (y * z)) / (z * (z * x))
else
tmp = (0.5d0 * ((y * x) / z)) + t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (z * x);
double tmp;
if (z <= 1.9e-36) {
tmp = t_0 + (y * (x * (0.5 / z)));
} else if (z <= 2.8e+68) {
tmp = (((y * (x * 0.5)) * (z * x)) + (y * z)) / (z * (z * x));
} else {
tmp = (0.5 * ((y * x) / z)) + t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (z * x) tmp = 0 if z <= 1.9e-36: tmp = t_0 + (y * (x * (0.5 / z))) elif z <= 2.8e+68: tmp = (((y * (x * 0.5)) * (z * x)) + (y * z)) / (z * (z * x)) else: tmp = (0.5 * ((y * x) / z)) + t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(z * x)) tmp = 0.0 if (z <= 1.9e-36) tmp = Float64(t_0 + Float64(y * Float64(x * Float64(0.5 / z)))); elseif (z <= 2.8e+68) tmp = Float64(Float64(Float64(Float64(y * Float64(x * 0.5)) * Float64(z * x)) + Float64(y * z)) / Float64(z * Float64(z * x))); else tmp = Float64(Float64(0.5 * Float64(Float64(y * x) / z)) + t_0); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (z * x); tmp = 0.0; if (z <= 1.9e-36) tmp = t_0 + (y * (x * (0.5 / z))); elseif (z <= 2.8e+68) tmp = (((y * (x * 0.5)) * (z * x)) + (y * z)) / (z * (z * x)); else tmp = (0.5 * ((y * x) / z)) + t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.9e-36], N[(t$95$0 + N[(y * N[(x * N[(0.5 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.8e+68], N[(N[(N[(N[(y * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] * N[(z * x), $MachinePrecision]), $MachinePrecision] + N[(y * z), $MachinePrecision]), $MachinePrecision] / N[(z * N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{z \cdot x}\\
\mathbf{if}\;z \leq 1.9 \cdot 10^{-36}:\\
\;\;\;\;t\_0 + y \cdot \left(x \cdot \frac{0.5}{z}\right)\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+68}:\\
\;\;\;\;\frac{\left(y \cdot \left(x \cdot 0.5\right)\right) \cdot \left(z \cdot x\right) + y \cdot z}{z \cdot \left(z \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{z} + t\_0\\
\end{array}
\end{array}
if z < 1.89999999999999985e-36Initial program 83.5%
*-commutative83.5%
associate-*l/97.0%
associate-/l*97.0%
associate-/l*98.0%
associate-/r*88.5%
Simplified88.5%
Taylor expanded in x around 0 67.4%
associate-/l*66.0%
*-commutative66.0%
Applied egg-rr66.0%
associate-*l/67.4%
clear-num67.4%
associate-/l/71.6%
un-div-inv71.6%
associate-/l/67.4%
*-commutative67.4%
Applied egg-rr67.4%
associate-/r/67.4%
associate-*r*72.0%
Simplified72.0%
if 1.89999999999999985e-36 < z < 2.8e68Initial program 88.9%
*-commutative88.9%
associate-*l/100.0%
associate-/l*99.8%
associate-/l*99.7%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in x around 0 46.6%
associate-*r/46.6%
frac-add67.8%
*-commutative67.8%
*-commutative67.8%
associate-*l*67.8%
*-commutative67.8%
*-commutative67.8%
Applied egg-rr67.8%
if 2.8e68 < z Initial program 89.7%
*-commutative89.7%
associate-*l/95.9%
associate-/l*95.9%
associate-/l*99.8%
associate-/r*58.1%
Simplified58.1%
Taylor expanded in x around 0 63.3%
Final simplification70.2%
(FPCore (x y z) :precision binary64 (if (<= z 2.2e+46) (* y (/ (+ (* x 0.5) (/ 1.0 x)) z)) (+ (* 0.5 (/ (* y x) z)) (/ y (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.2e+46) {
tmp = y * (((x * 0.5) + (1.0 / x)) / z);
} else {
tmp = (0.5 * ((y * x) / z)) + (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 (z <= 2.2d+46) then
tmp = y * (((x * 0.5d0) + (1.0d0 / x)) / z)
else
tmp = (0.5d0 * ((y * x) / z)) + (y / (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.2e+46) {
tmp = y * (((x * 0.5) + (1.0 / x)) / z);
} else {
tmp = (0.5 * ((y * x) / z)) + (y / (z * x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.2e+46: tmp = y * (((x * 0.5) + (1.0 / x)) / z) else: tmp = (0.5 * ((y * x) / z)) + (y / (z * x)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.2e+46) tmp = Float64(y * Float64(Float64(Float64(x * 0.5) + Float64(1.0 / x)) / z)); else tmp = Float64(Float64(0.5 * Float64(Float64(y * x) / z)) + Float64(y / Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.2e+46) tmp = y * (((x * 0.5) + (1.0 / x)) / z); else tmp = (0.5 * ((y * x) / z)) + (y / (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.2e+46], N[(y * N[(N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] + N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.2 \cdot 10^{+46}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{z} + \frac{y}{z \cdot x}\\
\end{array}
\end{array}
if z < 2.2e46Initial program 83.5%
*-commutative83.5%
associate-*l/97.1%
associate-/l*97.1%
associate-/l*98.1%
associate-/r*88.9%
Simplified88.9%
clear-num88.8%
un-div-inv88.9%
*-commutative88.9%
associate-/l*98.1%
Applied egg-rr98.1%
clear-num98.1%
associate-/r/98.1%
*-commutative98.1%
associate-/r*98.1%
clear-num98.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 71.1%
if 2.2e46 < z Initial program 90.1%
*-commutative90.1%
associate-*l/96.1%
associate-/l*96.0%
associate-/l*99.8%
associate-/r*59.8%
Simplified59.8%
Taylor expanded in x around 0 62.9%
Final simplification69.5%
(FPCore (x y z) :precision binary64 (if (<= x 1.4) (/ y (* z x)) (* 0.5 (/ (* y x) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.4) {
tmp = y / (z * x);
} else {
tmp = 0.5 * ((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) then
tmp = y / (z * x)
else
tmp = 0.5d0 * ((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) {
tmp = y / (z * x);
} else {
tmp = 0.5 * ((y * x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.4: tmp = y / (z * x) else: tmp = 0.5 * ((y * x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.4) tmp = Float64(y / Float64(z * x)); else tmp = Float64(0.5 * Float64(Float64(y * x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.4) tmp = y / (z * x); else tmp = 0.5 * ((y * x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.4], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{z}\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 85.1%
*-commutative85.1%
associate-*l/95.8%
associate-/l*95.8%
associate-/l*97.9%
associate-/r*90.9%
Simplified90.9%
Taylor expanded in x around 0 64.9%
if 1.3999999999999999 < x Initial program 84.0%
Taylor expanded in x around 0 38.5%
Taylor expanded in x around inf 38.5%
Final simplification57.8%
(FPCore (x y z) :precision binary64 (if (<= x 1.4) (/ y (* z x)) (* y (/ (* x 0.5) z))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.4) {
tmp = y / (z * x);
} else {
tmp = y * ((x * 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 / (z * x)
else
tmp = y * ((x * 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 / (z * x);
} else {
tmp = y * ((x * 0.5) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.4: tmp = y / (z * x) else: tmp = y * ((x * 0.5) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.4) tmp = Float64(y / Float64(z * x)); else tmp = Float64(y * Float64(Float64(x * 0.5) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.4) tmp = y / (z * x); else tmp = y * ((x * 0.5) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.4], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[(x * 0.5), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\frac{y}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x \cdot 0.5}{z}\\
\end{array}
\end{array}
if x < 1.3999999999999999Initial program 85.1%
*-commutative85.1%
associate-*l/95.8%
associate-/l*95.8%
associate-/l*97.9%
associate-/r*90.9%
Simplified90.9%
Taylor expanded in x around 0 64.9%
if 1.3999999999999999 < x Initial program 84.0%
Taylor expanded in x around 0 38.5%
Taylor expanded in x around inf 38.5%
associate-*r/38.5%
associate-*r*38.5%
*-commutative38.5%
*-commutative38.5%
associate-*r/32.9%
*-commutative32.9%
Simplified32.9%
Final simplification56.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(y * Float64(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[(y * N[(N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{z}
\end{array}
Initial program 84.8%
*-commutative84.8%
associate-*l/96.9%
associate-/l*96.9%
associate-/l*98.4%
associate-/r*83.2%
Simplified83.2%
clear-num83.2%
un-div-inv83.2%
*-commutative83.2%
associate-/l*98.5%
Applied egg-rr98.5%
clear-num98.2%
associate-/r/98.4%
*-commutative98.4%
associate-/r*98.4%
clear-num98.4%
Applied egg-rr98.4%
Taylor expanded in x around 0 66.9%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (if (<= y 7e-50) (/ (/ y x) z) (/ (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e-50) {
tmp = (y / x) / z;
} else {
tmp = (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 (y <= 7d-50) then
tmp = (y / x) / z
else
tmp = (y / z) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7e-50) {
tmp = (y / x) / z;
} else {
tmp = (y / z) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e-50: tmp = (y / x) / z else: tmp = (y / z) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e-50) tmp = Float64(Float64(y / x) / z); else tmp = Float64(Float64(y / z) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7e-50) tmp = (y / x) / z; else tmp = (y / z) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e-50], N[(N[(y / x), $MachinePrecision] / z), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-50}:\\
\;\;\;\;\frac{\frac{y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\end{array}
\end{array}
if y < 6.99999999999999993e-50Initial program 79.9%
Taylor expanded in x around 0 46.0%
if 6.99999999999999993e-50 < y Initial program 96.2%
*-commutative96.2%
associate-*l/96.2%
associate-/l*96.2%
associate-/l*99.9%
associate-/r*83.0%
Simplified83.0%
Taylor expanded in x around 0 57.4%
div-inv57.5%
*-commutative57.5%
associate-/r*63.6%
Applied egg-rr63.6%
Final simplification51.3%
(FPCore (x y z) :precision binary64 (/ y (* z x)))
double code(double x, double y, double z) {
return y / (z * x);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y / (z * x)
end function
public static double code(double x, double y, double z) {
return y / (z * x);
}
def code(x, y, z): return y / (z * x)
function code(x, y, z) return Float64(y / Float64(z * x)) end
function tmp = code(x, y, z) tmp = y / (z * x); end
code[x_, y_, z_] := N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{z \cdot x}
\end{array}
Initial program 84.8%
*-commutative84.8%
associate-*l/96.9%
associate-/l*96.9%
associate-/l*98.4%
associate-/r*83.2%
Simplified83.2%
Taylor expanded in x around 0 49.9%
Final simplification49.9%
(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 2024040
(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))