
(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 (/ (cosh x) x))))
double code(double x, double y, double z) {
return y / (z / (cosh(x) / 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 / (cosh(x) / x))
end function
public static double code(double x, double y, double z) {
return y / (z / (Math.cosh(x) / x));
}
def code(x, y, z): return y / (z / (math.cosh(x) / x))
function code(x, y, z) return Float64(y / Float64(z / Float64(cosh(x) / x))) end
function tmp = code(x, y, z) tmp = y / (z / (cosh(x) / x)); end
code[x_, y_, z_] := N[(y / N[(z / N[(N[Cosh[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{\frac{z}{\frac{\cosh x}{x}}}
\end{array}
Initial program 83.8%
associate-*r/95.1%
associate-/l/83.0%
associate-*l/82.8%
*-commutative82.8%
*-commutative82.8%
Simplified82.8%
clear-num82.8%
un-div-inv83.0%
*-commutative83.0%
associate-/l*97.4%
Applied egg-rr97.4%
Final simplification97.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (cosh x) (/ (/ y z) x))))
(if (<= y -1.75e+62)
t_0
(if (<= y -4.8e-129)
(* (/ y x) (/ (cosh x) z))
(if (<= y 3e-177) (* y (/ (cosh x) (* z x))) t_0)))))
double code(double x, double y, double z) {
double t_0 = cosh(x) * ((y / z) / x);
double tmp;
if (y <= -1.75e+62) {
tmp = t_0;
} else if (y <= -4.8e-129) {
tmp = (y / x) * (cosh(x) / z);
} else if (y <= 3e-177) {
tmp = y * (cosh(x) / (z * x));
} 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 = cosh(x) * ((y / z) / x)
if (y <= (-1.75d+62)) then
tmp = t_0
else if (y <= (-4.8d-129)) then
tmp = (y / x) * (cosh(x) / z)
else if (y <= 3d-177) then
tmp = y * (cosh(x) / (z * x))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.cosh(x) * ((y / z) / x);
double tmp;
if (y <= -1.75e+62) {
tmp = t_0;
} else if (y <= -4.8e-129) {
tmp = (y / x) * (Math.cosh(x) / z);
} else if (y <= 3e-177) {
tmp = y * (Math.cosh(x) / (z * x));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = math.cosh(x) * ((y / z) / x) tmp = 0 if y <= -1.75e+62: tmp = t_0 elif y <= -4.8e-129: tmp = (y / x) * (math.cosh(x) / z) elif y <= 3e-177: tmp = y * (math.cosh(x) / (z * x)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(cosh(x) * Float64(Float64(y / z) / x)) tmp = 0.0 if (y <= -1.75e+62) tmp = t_0; elseif (y <= -4.8e-129) tmp = Float64(Float64(y / x) * Float64(cosh(x) / z)); elseif (y <= 3e-177) tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = cosh(x) * ((y / z) / x); tmp = 0.0; if (y <= -1.75e+62) tmp = t_0; elseif (y <= -4.8e-129) tmp = (y / x) * (cosh(x) / z); elseif (y <= 3e-177) tmp = y * (cosh(x) / (z * x)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e+62], t$95$0, If[LessEqual[y, -4.8e-129], N[(N[(y / x), $MachinePrecision] * N[(N[Cosh[x], $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e-177], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cosh x \cdot \frac{\frac{y}{z}}{x}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{+62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-129}:\\
\;\;\;\;\frac{y}{x} \cdot \frac{\cosh x}{z}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-177}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.74999999999999992e62 or 3.00000000000000008e-177 < y Initial program 88.7%
associate-*r/86.6%
associate-/l/86.9%
associate-/r*96.4%
Simplified96.4%
if -1.74999999999999992e62 < y < -4.79999999999999977e-129Initial program 91.4%
*-commutative91.4%
associate-*r/91.2%
Simplified91.2%
if -4.79999999999999977e-129 < y < 3.00000000000000008e-177Initial program 67.0%
associate-*r/99.8%
associate-/l/81.4%
associate-*l/81.3%
*-commutative81.3%
*-commutative81.3%
Simplified81.3%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e-32) (not (<= y 5.4e-177))) (* (cosh x) (/ (/ y z) x)) (* y (/ (cosh x) (* z x)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-32) || !(y <= 5.4e-177)) {
tmp = cosh(x) * ((y / z) / x);
} else {
tmp = y * (cosh(x) / (z * x));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1.4d-32)) .or. (.not. (y <= 5.4d-177))) then
tmp = cosh(x) * ((y / z) / x)
else
tmp = y * (cosh(x) / (z * x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e-32) || !(y <= 5.4e-177)) {
tmp = Math.cosh(x) * ((y / z) / x);
} else {
tmp = y * (Math.cosh(x) / (z * x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e-32) or not (y <= 5.4e-177): tmp = math.cosh(x) * ((y / z) / x) else: tmp = y * (math.cosh(x) / (z * x)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e-32) || !(y <= 5.4e-177)) tmp = Float64(cosh(x) * Float64(Float64(y / z) / x)); else tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.4e-32) || ~((y <= 5.4e-177))) tmp = cosh(x) * ((y / z) / x); else tmp = y * (cosh(x) / (z * x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e-32], N[Not[LessEqual[y, 5.4e-177]], $MachinePrecision]], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-32} \lor \neg \left(y \leq 5.4 \cdot 10^{-177}\right):\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\end{array}
\end{array}
if y < -1.3999999999999999e-32 or 5.4000000000000004e-177 < y Initial program 90.3%
associate-*r/85.6%
associate-/l/85.5%
associate-/r*94.0%
Simplified94.0%
if -1.3999999999999999e-32 < y < 5.4000000000000004e-177Initial program 70.8%
associate-*r/99.9%
associate-/l/76.8%
associate-*l/76.7%
*-commutative76.7%
*-commutative76.7%
Simplified76.7%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= x 1.9e+218) (* y (/ (cosh x) (* z x))) (/ y (/ (* z z) (+ (* (* z x) 0.5) (/ z x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= 1.9e+218) {
tmp = y * (cosh(x) / (z * x));
} else {
tmp = y / ((z * z) / (((z * x) * 0.5) + (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.9d+218) then
tmp = y * (cosh(x) / (z * x))
else
tmp = y / ((z * z) / (((z * x) * 0.5d0) + (z / x)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 1.9e+218) {
tmp = y * (Math.cosh(x) / (z * x));
} else {
tmp = y / ((z * z) / (((z * x) * 0.5) + (z / x)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 1.9e+218: tmp = y * (math.cosh(x) / (z * x)) else: tmp = y / ((z * z) / (((z * x) * 0.5) + (z / x))) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 1.9e+218) tmp = Float64(y * Float64(cosh(x) / Float64(z * x))); else tmp = Float64(y / Float64(Float64(z * z) / Float64(Float64(Float64(z * x) * 0.5) + Float64(z / x)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 1.9e+218) tmp = y * (cosh(x) / (z * x)); else tmp = y / ((z * z) / (((z * x) * 0.5) + (z / x))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 1.9e+218], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(N[(z * z), $MachinePrecision] / N[(N[(N[(z * x), $MachinePrecision] * 0.5), $MachinePrecision] + N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9 \cdot 10^{+218}:\\
\;\;\;\;y \cdot \frac{\cosh x}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z \cdot z}{\left(z \cdot x\right) \cdot 0.5 + \frac{z}{x}}}\\
\end{array}
\end{array}
if x < 1.90000000000000006e218Initial program 86.7%
associate-*r/94.5%
associate-/l/86.6%
associate-*l/86.5%
*-commutative86.5%
*-commutative86.5%
Simplified86.5%
if 1.90000000000000006e218 < x Initial program 59.3%
Taylor expanded in x around 0 67.9%
+-commutative67.9%
associate-/l*61.3%
*-commutative61.3%
Simplified61.3%
+-commutative61.3%
*-commutative61.3%
frac-2neg61.3%
associate-*r/61.3%
frac-add51.9%
distribute-rgt-neg-in51.9%
*-commutative51.9%
distribute-rgt-neg-in51.9%
Applied egg-rr51.9%
+-commutative51.9%
*-commutative51.9%
distribute-rgt-neg-out51.9%
unsub-neg51.9%
*-commutative51.9%
associate-*r*37.2%
*-commutative37.2%
associate-*l*52.0%
distribute-rgt-neg-in52.0%
*-commutative52.0%
associate-*r*52.0%
*-commutative52.0%
distribute-rgt-neg-in52.0%
metadata-eval52.0%
*-commutative52.0%
associate-*l*52.0%
*-commutative52.0%
associate-*l*63.3%
Simplified63.3%
Taylor expanded in y around -inf 63.4%
associate-/l*70.4%
unpow270.4%
*-commutative70.4%
*-commutative70.4%
associate-*r/70.4%
neg-mul-170.4%
Simplified70.4%
Final simplification84.8%
(FPCore (x y z)
:precision binary64
(if (<= y -1e+16)
(+ (/ y (* z x)) (* 0.5 (/ (* y x) z)))
(if (<= y 2.5e-62)
(/ (+ (/ y x) (* x (* y 0.5))) z)
(/ (+ (* z (/ y z)) (* x (* 0.5 (* y x)))) (* z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e+16) {
tmp = (y / (z * x)) + (0.5 * ((y * x) / z));
} else if (y <= 2.5e-62) {
tmp = ((y / x) + (x * (y * 0.5))) / z;
} else {
tmp = ((z * (y / z)) + (x * (0.5 * (y * x)))) / (z * x);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1d+16)) then
tmp = (y / (z * x)) + (0.5d0 * ((y * x) / z))
else if (y <= 2.5d-62) then
tmp = ((y / x) + (x * (y * 0.5d0))) / z
else
tmp = ((z * (y / z)) + (x * (0.5d0 * (y * x)))) / (z * x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1e+16) {
tmp = (y / (z * x)) + (0.5 * ((y * x) / z));
} else if (y <= 2.5e-62) {
tmp = ((y / x) + (x * (y * 0.5))) / z;
} else {
tmp = ((z * (y / z)) + (x * (0.5 * (y * x)))) / (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e+16: tmp = (y / (z * x)) + (0.5 * ((y * x) / z)) elif y <= 2.5e-62: tmp = ((y / x) + (x * (y * 0.5))) / z else: tmp = ((z * (y / z)) + (x * (0.5 * (y * x)))) / (z * x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e+16) tmp = Float64(Float64(y / Float64(z * x)) + Float64(0.5 * Float64(Float64(y * x) / z))); elseif (y <= 2.5e-62) tmp = Float64(Float64(Float64(y / x) + Float64(x * Float64(y * 0.5))) / z); else tmp = Float64(Float64(Float64(z * Float64(y / z)) + Float64(x * Float64(0.5 * Float64(y * x)))) / Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e+16) tmp = (y / (z * x)) + (0.5 * ((y * x) / z)); elseif (y <= 2.5e-62) tmp = ((y / x) + (x * (y * 0.5))) / z; else tmp = ((z * (y / z)) + (x * (0.5 * (y * x)))) / (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e+16], N[(N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-62], N[(N[(N[(y / x), $MachinePrecision] + N[(x * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision] + N[(x * N[(0.5 * N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+16}:\\
\;\;\;\;\frac{y}{z \cdot x} + 0.5 \cdot \frac{y \cdot x}{z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{\frac{y}{x} + x \cdot \left(y \cdot 0.5\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \frac{y}{z} + x \cdot \left(0.5 \cdot \left(y \cdot x\right)\right)}{z \cdot x}\\
\end{array}
\end{array}
if y < -1e16Initial program 93.1%
Taylor expanded in x around 0 79.2%
if -1e16 < y < 2.5000000000000001e-62Initial program 74.0%
Taylor expanded in x around 0 60.2%
associate-*r*60.2%
Simplified60.2%
if 2.5000000000000001e-62 < y Initial program 89.8%
Taylor expanded in x around 0 78.4%
associate-/r*78.3%
associate-*r/77.2%
frac-add80.4%
Applied egg-rr80.4%
Final simplification71.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e+15) (not (<= y 3e-62))) (+ (/ y (* z x)) (* 0.5 (/ (* y x) z))) (/ (+ (/ y x) (* x (* y 0.5))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+15) || !(y <= 3e-62)) {
tmp = (y / (z * x)) + (0.5 * ((y * x) / z));
} else {
tmp = ((y / x) + (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 ((y <= (-3d+15)) .or. (.not. (y <= 3d-62))) then
tmp = (y / (z * x)) + (0.5d0 * ((y * x) / z))
else
tmp = ((y / x) + (x * (y * 0.5d0))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+15) || !(y <= 3e-62)) {
tmp = (y / (z * x)) + (0.5 * ((y * x) / z));
} else {
tmp = ((y / x) + (x * (y * 0.5))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+15) or not (y <= 3e-62): tmp = (y / (z * x)) + (0.5 * ((y * x) / z)) else: tmp = ((y / x) + (x * (y * 0.5))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e+15) || !(y <= 3e-62)) tmp = Float64(Float64(y / Float64(z * x)) + Float64(0.5 * Float64(Float64(y * x) / z))); else tmp = Float64(Float64(Float64(y / x) + Float64(x * Float64(y * 0.5))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3e+15) || ~((y <= 3e-62))) tmp = (y / (z * x)) + (0.5 * ((y * x) / z)); else tmp = ((y / x) + (x * (y * 0.5))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e+15], N[Not[LessEqual[y, 3e-62]], $MachinePrecision]], N[(N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / x), $MachinePrecision] + N[(x * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{+15} \lor \neg \left(y \leq 3 \cdot 10^{-62}\right):\\
\;\;\;\;\frac{y}{z \cdot x} + 0.5 \cdot \frac{y \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{x} + x \cdot \left(y \cdot 0.5\right)}{z}\\
\end{array}
\end{array}
if y < -3e15 or 3.0000000000000001e-62 < y Initial program 91.4%
Taylor expanded in x around 0 78.8%
if -3e15 < y < 3.0000000000000001e-62Initial program 74.0%
Taylor expanded in x around 0 60.2%
associate-*r*60.2%
Simplified60.2%
Final simplification70.7%
(FPCore (x y z) :precision binary64 (* y (+ (/ 1.0 (* z x)) (* 0.5 (/ x z)))))
double code(double x, double y, double z) {
return y * ((1.0 / (z * x)) + (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 / (z * x)) + (0.5d0 * (x / z)))
end function
public static double code(double x, double y, double z) {
return y * ((1.0 / (z * x)) + (0.5 * (x / z)));
}
def code(x, y, z): return y * ((1.0 / (z * x)) + (0.5 * (x / z)))
function code(x, y, z) return Float64(y * Float64(Float64(1.0 / Float64(z * x)) + Float64(0.5 * Float64(x / z)))) end
function tmp = code(x, y, z) tmp = y * ((1.0 / (z * x)) + (0.5 * (x / z))); end
code[x_, y_, z_] := N[(y * N[(N[(1.0 / N[(z * x), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(\frac{1}{z \cdot x} + 0.5 \cdot \frac{x}{z}\right)
\end{array}
Initial program 83.8%
associate-*r/95.1%
associate-/l/83.0%
associate-*l/82.8%
*-commutative82.8%
*-commutative82.8%
Simplified82.8%
Taylor expanded in x around 0 66.7%
Final simplification66.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.42) (not (<= x 40000.0))) (* 0.5 (* x (/ y z))) (/ y (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.42) || !(x <= 40000.0)) {
tmp = 0.5 * (x * (y / 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 ((x <= (-1.42d0)) .or. (.not. (x <= 40000.0d0))) then
tmp = 0.5d0 * (x * (y / 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 ((x <= -1.42) || !(x <= 40000.0)) {
tmp = 0.5 * (x * (y / z));
} else {
tmp = y / (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.42) or not (x <= 40000.0): tmp = 0.5 * (x * (y / z)) else: tmp = y / (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.42) || !(x <= 40000.0)) tmp = Float64(0.5 * Float64(x * Float64(y / z))); else tmp = Float64(y / Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.42) || ~((x <= 40000.0))) tmp = 0.5 * (x * (y / z)); else tmp = y / (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.42], N[Not[LessEqual[x, 40000.0]], $MachinePrecision]], N[(0.5 * N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \lor \neg \left(x \leq 40000\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot x}\\
\end{array}
\end{array}
if x < -1.4199999999999999 or 4e4 < x Initial program 76.6%
Taylor expanded in x around 0 40.3%
associate-*r*40.3%
Simplified40.3%
Taylor expanded in x around inf 41.0%
associate-*l/34.2%
*-commutative34.2%
Simplified34.2%
if -1.4199999999999999 < x < 4e4Initial program 90.5%
Taylor expanded in x around 0 93.7%
Final simplification64.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.42) (not (<= x 40000.0))) (* 0.5 (/ (* y x) z)) (/ y (* z x))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.42) || !(x <= 40000.0)) {
tmp = 0.5 * ((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 ((x <= (-1.42d0)) .or. (.not. (x <= 40000.0d0))) then
tmp = 0.5d0 * ((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 ((x <= -1.42) || !(x <= 40000.0)) {
tmp = 0.5 * ((y * x) / z);
} else {
tmp = y / (z * x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.42) or not (x <= 40000.0): tmp = 0.5 * ((y * x) / z) else: tmp = y / (z * x) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.42) || !(x <= 40000.0)) tmp = Float64(0.5 * Float64(Float64(y * x) / z)); else tmp = Float64(y / Float64(z * x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.42) || ~((x <= 40000.0))) tmp = 0.5 * ((y * x) / z); else tmp = y / (z * x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.42], N[Not[LessEqual[x, 40000.0]], $MachinePrecision]], N[(0.5 * N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.42 \lor \neg \left(x \leq 40000\right):\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot x}\\
\end{array}
\end{array}
if x < -1.4199999999999999 or 4e4 < x Initial program 76.6%
Taylor expanded in x around 0 40.3%
associate-*r*40.3%
Simplified40.3%
Taylor expanded in x around inf 41.0%
if -1.4199999999999999 < x < 4e4Initial program 90.5%
Taylor expanded in x around 0 93.7%
Final simplification68.2%
(FPCore (x y z) :precision binary64 (/ (+ (/ y x) (* x (* y 0.5))) z))
double code(double x, double y, double z) {
return ((y / x) + (x * (y * 0.5))) / 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) + (x * (y * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return ((y / x) + (x * (y * 0.5))) / z;
}
def code(x, y, z): return ((y / x) + (x * (y * 0.5))) / z
function code(x, y, z) return Float64(Float64(Float64(y / x) + Float64(x * Float64(y * 0.5))) / z) end
function tmp = code(x, y, z) tmp = ((y / x) + (x * (y * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(N[(y / x), $MachinePrecision] + N[(x * N[(y * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{y}{x} + x \cdot \left(y \cdot 0.5\right)}{z}
\end{array}
Initial program 83.8%
Taylor expanded in x around 0 65.5%
associate-*r*65.5%
Simplified65.5%
Final simplification65.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e-20) (not (<= z 1.12e-251))) (/ y (* z x)) (/ (/ y z) x)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-20) || !(z <= 1.12e-251)) {
tmp = y / (z * x);
} 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 ((z <= (-1d-20)) .or. (.not. (z <= 1.12d-251))) then
tmp = y / (z * x)
else
tmp = (y / z) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-20) || !(z <= 1.12e-251)) {
tmp = y / (z * x);
} else {
tmp = (y / z) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-20) or not (z <= 1.12e-251): tmp = y / (z * x) else: tmp = (y / z) / x return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-20) || !(z <= 1.12e-251)) tmp = Float64(y / Float64(z * x)); else tmp = Float64(Float64(y / z) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-20) || ~((z <= 1.12e-251))) tmp = y / (z * x); else tmp = (y / z) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-20], N[Not[LessEqual[z, 1.12e-251]], $MachinePrecision]], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-20} \lor \neg \left(z \leq 1.12 \cdot 10^{-251}\right):\\
\;\;\;\;\frac{y}{z \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\
\end{array}
\end{array}
if z < -9.99999999999999945e-21 or 1.12000000000000007e-251 < z Initial program 82.3%
Taylor expanded in x around 0 52.4%
if -9.99999999999999945e-21 < z < 1.12000000000000007e-251Initial program 88.0%
associate-*r/99.9%
associate-/l/90.5%
associate-*l/90.2%
*-commutative90.2%
*-commutative90.2%
Simplified90.2%
Taylor expanded in x around 0 51.5%
div-inv51.8%
associate-/r*69.6%
Applied egg-rr69.6%
Final simplification56.9%
(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 83.8%
Taylor expanded in x around 0 52.2%
Final simplification52.2%
(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 2023195
(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))