
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / 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 = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / 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 = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (sin y) y)))
(if (or (<= z -3e+82) (not (<= z 1e-109)))
(* t_0 (/ x z))
(/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if ((z <= -3e+82) || !(z <= 1e-109)) {
tmp = t_0 * (x / z);
} else {
tmp = 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 = sin(y) / y
if ((z <= (-3d+82)) .or. (.not. (z <= 1d-109))) then
tmp = t_0 * (x / z)
else
tmp = x / (z / t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = Math.sin(y) / y;
double tmp;
if ((z <= -3e+82) || !(z <= 1e-109)) {
tmp = t_0 * (x / z);
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if (z <= -3e+82) or not (z <= 1e-109): tmp = t_0 * (x / z) else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if ((z <= -3e+82) || !(z <= 1e-109)) tmp = Float64(t_0 * Float64(x / z)); else tmp = Float64(x / Float64(z / t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = sin(y) / y; tmp = 0.0; if ((z <= -3e+82) || ~((z <= 1e-109))) tmp = t_0 * (x / z); else tmp = x / (z / t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]}, If[Or[LessEqual[z, -3e+82], N[Not[LessEqual[z, 1e-109]], $MachinePrecision]], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;z \leq -3 \cdot 10^{+82} \lor \neg \left(z \leq 10^{-109}\right):\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if z < -2.99999999999999989e82 or 9.9999999999999999e-110 < z Initial program 98.6%
clear-num98.6%
associate-/r/98.6%
Applied egg-rr98.6%
associate-/l*88.5%
associate-/r/99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if -2.99999999999999989e82 < z < 9.9999999999999999e-110Initial program 95.6%
associate-/l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+16) (not (<= z 5.2e-107))) (* (/ (sin y) y) (/ x z)) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+16) || !(z <= 5.2e-107)) {
tmp = (sin(y) / y) * (x / z);
} else {
tmp = x * ((sin(y) / z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-2d+16)) .or. (.not. (z <= 5.2d-107))) then
tmp = (sin(y) / y) * (x / z)
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+16) || !(z <= 5.2e-107)) {
tmp = (Math.sin(y) / y) * (x / z);
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+16) or not (z <= 5.2e-107): tmp = (math.sin(y) / y) * (x / z) else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2e+16) || !(z <= 5.2e-107)) tmp = Float64(Float64(sin(y) / y) * Float64(x / z)); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2e+16) || ~((z <= 5.2e-107))) tmp = (sin(y) / y) * (x / z); else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2e+16], N[Not[LessEqual[z, 5.2e-107]], $MachinePrecision]], N[(N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+16} \lor \neg \left(z \leq 5.2 \cdot 10^{-107}\right):\\
\;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if z < -2e16 or 5.2000000000000001e-107 < z Initial program 98.8%
clear-num98.8%
associate-/r/98.8%
Applied egg-rr98.8%
associate-/l*90.3%
associate-/r/99.8%
associate-*l/99.8%
*-un-lft-identity99.8%
Applied egg-rr99.8%
if -2e16 < z < 5.2000000000000001e-107Initial program 94.6%
associate-*r/99.6%
associate-/l/80.6%
associate-/r*99.6%
Simplified99.6%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (<= y 4.5e-20) (/ x z) (* x (/ (/ (sin y) z) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.5e-20) {
tmp = x / z;
} else {
tmp = x * ((sin(y) / z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 4.5d-20) then
tmp = x / z
else
tmp = x * ((sin(y) / z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 4.5e-20) {
tmp = x / z;
} else {
tmp = x * ((Math.sin(y) / z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.5e-20: tmp = x / z else: tmp = x * ((math.sin(y) / z) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.5e-20) tmp = Float64(x / z); else tmp = Float64(x * Float64(Float64(sin(y) / z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 4.5e-20) tmp = x / z; else tmp = x * ((sin(y) / z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.5e-20], N[(x / z), $MachinePrecision], N[(x * N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.5 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{\sin y}{z}}{y}\\
\end{array}
\end{array}
if y < 4.5000000000000001e-20Initial program 98.5%
associate-*r/94.7%
associate-/l/84.1%
associate-/r*85.7%
Simplified85.7%
Taylor expanded in y around 0 69.8%
if 4.5000000000000001e-20 < y Initial program 93.6%
associate-*r/92.2%
associate-/l/91.8%
associate-/r*92.1%
Simplified92.1%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (/ (* x (/ (sin y) y)) z))
double code(double x, double y, double z) {
return (x * (sin(y) / 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 = (x * (sin(y) / y)) / z
end function
public static double code(double x, double y, double z) {
return (x * (Math.sin(y) / y)) / z;
}
def code(x, y, z): return (x * (math.sin(y) / y)) / z
function code(x, y, z) return Float64(Float64(x * Float64(sin(y) / y)) / z) end
function tmp = code(x, y, z) tmp = (x * (sin(y) / y)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \frac{\sin y}{y}}{z}
\end{array}
Initial program 97.1%
Final simplification97.1%
(FPCore (x y z) :precision binary64 (if (<= y 2e-8) (/ x z) (/ y (/ 1.0 (/ x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-8) {
tmp = x / z;
} else {
tmp = y / (1.0 / (x / (y * z)));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2d-8) then
tmp = x / z
else
tmp = y / (1.0d0 / (x / (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e-8) {
tmp = x / z;
} else {
tmp = y / (1.0 / (x / (y * z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e-8: tmp = x / z else: tmp = y / (1.0 / (x / (y * z))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(1.0 / Float64(x / Float64(y * z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e-8) tmp = x / z; else tmp = y / (1.0 / (x / (y * z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e-8], N[(x / z), $MachinePrecision], N[(y / N[(1.0 / N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{1}{\frac{x}{y \cdot z}}}\\
\end{array}
\end{array}
if y < 2e-8Initial program 98.5%
associate-*r/94.8%
associate-/l/84.3%
associate-/r*85.8%
Simplified85.8%
Taylor expanded in y around 0 70.1%
if 2e-8 < y Initial program 93.4%
associate-*r/92.0%
associate-/l/91.6%
associate-/r*91.9%
Simplified91.9%
Taylor expanded in y around 0 19.8%
*-un-lft-identity19.8%
div-inv19.8%
*-inverses19.8%
times-frac22.9%
associate-/l*33.8%
*-commutative33.8%
*-un-lft-identity33.8%
times-frac33.7%
/-rgt-identity33.7%
Applied egg-rr33.7%
associate-*r/33.8%
clear-num33.8%
*-commutative33.8%
Applied egg-rr33.8%
Final simplification60.0%
(FPCore (x y z) :precision binary64 (if (<= y 100000.0) (/ x z) (* x (/ y (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 100000.0) {
tmp = x / z;
} else {
tmp = x * (y / (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 100000.0d0) then
tmp = x / z
else
tmp = x * (y / (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 100000.0) {
tmp = x / z;
} else {
tmp = x * (y / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 100000.0: tmp = x / z else: tmp = x * (y / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 100000.0) tmp = Float64(x / z); else tmp = Float64(x * Float64(y / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 100000.0) tmp = x / z; else tmp = x * (y / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 100000.0], N[(x / z), $MachinePrecision], N[(x * N[(y / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 100000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{y \cdot z}\\
\end{array}
\end{array}
if y < 1e5Initial program 98.5%
associate-*r/94.9%
associate-/l/84.7%
associate-/r*86.2%
Simplified86.2%
Taylor expanded in y around 0 70.1%
if 1e5 < y Initial program 92.9%
associate-*r/91.4%
associate-/l/91.0%
associate-/r*91.3%
Simplified91.3%
Taylor expanded in y around 0 15.9%
div-inv15.9%
Applied egg-rr15.9%
un-div-inv15.9%
associate-/l/21.6%
Applied egg-rr21.6%
Final simplification57.6%
(FPCore (x y z) :precision binary64 (if (<= y 1e+18) (/ x z) (* y (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1e+18) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1d+18) then
tmp = x / z
else
tmp = y * (x / (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1e+18) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1e+18: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1e+18) tmp = Float64(x / z); else tmp = Float64(y * Float64(x / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1e+18) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1e+18], N[(x / z), $MachinePrecision], N[(y * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 10^{+18}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 1e18Initial program 98.5%
associate-*r/94.9%
associate-/l/84.7%
associate-/r*86.2%
Simplified86.2%
Taylor expanded in y around 0 70.1%
if 1e18 < y Initial program 92.9%
associate-*r/91.4%
associate-/l/91.0%
associate-/r*91.3%
Simplified91.3%
Taylor expanded in y around 0 16.0%
div-inv16.0%
clear-num17.1%
Applied egg-rr17.1%
clear-num17.1%
associate-/r/17.1%
clear-num16.0%
rgt-mult-inverse16.0%
un-div-inv16.0%
times-frac19.4%
div-inv19.4%
*-commutative19.4%
associate-*r*30.0%
associate-*l/30.0%
*-un-lft-identity30.0%
*-commutative30.0%
Applied egg-rr30.0%
Final simplification59.7%
(FPCore (x y z) :precision binary64 (if (<= y 3.5e-8) (/ x z) (/ y (* y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e-8) {
tmp = x / z;
} else {
tmp = y / (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 <= 3.5d-8) then
tmp = x / z
else
tmp = y / (y * (z / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 3.5e-8) {
tmp = x / z;
} else {
tmp = y / (y * (z / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 3.5e-8: tmp = x / z else: tmp = y / (y * (z / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 3.5e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(y * Float64(z / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 3.5e-8) tmp = x / z; else tmp = y / (y * (z / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 3.5e-8], N[(x / z), $MachinePrecision], N[(y / N[(y * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y \cdot \frac{z}{x}}\\
\end{array}
\end{array}
if y < 3.50000000000000024e-8Initial program 98.5%
associate-*r/94.8%
associate-/l/84.3%
associate-/r*85.8%
Simplified85.8%
Taylor expanded in y around 0 70.1%
if 3.50000000000000024e-8 < y Initial program 93.4%
associate-*r/92.0%
associate-/l/91.6%
associate-/r*91.9%
Simplified91.9%
Taylor expanded in y around 0 19.8%
*-un-lft-identity19.8%
*-inverses19.8%
div-inv19.8%
clear-num21.1%
frac-times33.5%
*-rgt-identity33.5%
Applied egg-rr33.5%
Final simplification60.0%
(FPCore (x y z) :precision binary64 (if (<= y 2e-8) (/ x z) (/ y (* z (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e-8) {
tmp = x / z;
} else {
tmp = y / (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 (y <= 2d-8) then
tmp = x / z
else
tmp = y / (z * (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e-8) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e-8: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e-8) tmp = Float64(x / z); else tmp = Float64(y / Float64(z * Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e-8) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e-8], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 2e-8Initial program 98.5%
associate-*r/94.8%
associate-/l/84.3%
associate-/r*85.8%
Simplified85.8%
Taylor expanded in y around 0 70.1%
if 2e-8 < y Initial program 93.4%
associate-*r/92.0%
associate-/l/91.6%
associate-/r*91.9%
Simplified91.9%
Taylor expanded in y around 0 19.8%
*-un-lft-identity19.8%
div-inv19.8%
*-inverses19.8%
times-frac22.9%
associate-/l*33.8%
*-commutative33.8%
*-un-lft-identity33.8%
times-frac33.7%
/-rgt-identity33.7%
Applied egg-rr33.7%
Final simplification60.0%
(FPCore (x y z) :precision binary64 (/ 1.0 (/ z x)))
double code(double x, double y, double z) {
return 1.0 / (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 = 1.0d0 / (z / x)
end function
public static double code(double x, double y, double z) {
return 1.0 / (z / x);
}
def code(x, y, z): return 1.0 / (z / x)
function code(x, y, z) return Float64(1.0 / Float64(z / x)) end
function tmp = code(x, y, z) tmp = 1.0 / (z / x); end
code[x_, y_, z_] := N[(1.0 / N[(z / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{z}{x}}
\end{array}
Initial program 97.1%
associate-*r/94.0%
associate-/l/86.3%
associate-/r*87.5%
Simplified87.5%
Taylor expanded in y around 0 56.0%
div-inv56.1%
clear-num56.6%
Applied egg-rr56.6%
Final simplification56.6%
(FPCore (x y z) :precision binary64 (/ x z))
double code(double x, double y, double z) {
return 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 = x / z
end function
public static double code(double x, double y, double z) {
return x / z;
}
def code(x, y, z): return x / z
function code(x, y, z) return Float64(x / z) end
function tmp = code(x, y, z) tmp = x / z; end
code[x_, y_, z_] := N[(x / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z}
\end{array}
Initial program 97.1%
associate-*r/94.0%
associate-/l/86.3%
associate-/r*87.5%
Simplified87.5%
Taylor expanded in y around 0 56.1%
Final simplification56.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (sin y))) (t_1 (/ (* x (/ 1.0 t_0)) z)))
(if (< z -4.2173720203427147e-29)
t_1
(if (< z 4.446702369113811e+64) (/ x (* z t_0)) t_1))))
double code(double x, double y, double z) {
double t_0 = y / sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
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) :: tmp
t_0 = y / sin(y)
t_1 = (x * (1.0d0 / t_0)) / z
if (z < (-4.2173720203427147d-29)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x / (z * t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / Math.sin(y);
double t_1 = (x * (1.0 / t_0)) / z;
double tmp;
if (z < -4.2173720203427147e-29) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x / (z * t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / math.sin(y) t_1 = (x * (1.0 / t_0)) / z tmp = 0 if z < -4.2173720203427147e-29: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x / (z * t_0) else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / sin(y)) t_1 = Float64(Float64(x * Float64(1.0 / t_0)) / z) tmp = 0.0 if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x / Float64(z * t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / sin(y); t_1 = (x * (1.0 / t_0)) / z; tmp = 0.0; if (z < -4.2173720203427147e-29) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x / (z * t_0); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[Sin[y], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Less[z, -4.2173720203427147e-29], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x / N[(z * t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\sin y}\\
t_1 := \frac{x \cdot \frac{1}{t_0}}{z}\\
\mathbf{if}\;z < -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
herbie shell --seed 2023336
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))
(/ (* x (/ (sin y) y)) z))