
(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 10 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 (<= x -4e+35) (not (<= x 2e-74))) (/ (* x t_0) z) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double tmp;
if ((x <= -4e+35) || !(x <= 2e-74)) {
tmp = (x * t_0) / 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 ((x <= (-4d+35)) .or. (.not. (x <= 2d-74))) then
tmp = (x * t_0) / 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 ((x <= -4e+35) || !(x <= 2e-74)) {
tmp = (x * t_0) / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y tmp = 0 if (x <= -4e+35) or not (x <= 2e-74): tmp = (x * t_0) / z else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) tmp = 0.0 if ((x <= -4e+35) || !(x <= 2e-74)) tmp = Float64(Float64(x * t_0) / 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 ((x <= -4e+35) || ~((x <= 2e-74))) tmp = (x * t_0) / 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[x, -4e+35], N[Not[LessEqual[x, 2e-74]], $MachinePrecision]], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
\mathbf{if}\;x \leq -4 \cdot 10^{+35} \lor \neg \left(x \leq 2 \cdot 10^{-74}\right):\\
\;\;\;\;\frac{x \cdot t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if x < -3.9999999999999999e35 or 1.99999999999999992e-74 < x Initial program 99.8%
if -3.9999999999999999e35 < x < 1.99999999999999992e-74Initial program 91.6%
associate-/l*99.9%
Simplified99.9%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (<= y 0.0003) (/ (+ x (* x (* y (* y -0.16666666666666666)))) z) (* (sin y) (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.0003) {
tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z;
} else {
tmp = sin(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 <= 0.0003d0) then
tmp = (x + (x * (y * (y * (-0.16666666666666666d0))))) / z
else
tmp = sin(y) * (x / (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.0003) {
tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z;
} else {
tmp = Math.sin(y) * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.0003: tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z else: tmp = math.sin(y) * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.0003) tmp = Float64(Float64(x + Float64(x * Float64(y * Float64(y * -0.16666666666666666)))) / z); else tmp = Float64(sin(y) * Float64(x / Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.0003) tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z; else tmp = sin(y) * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.0003], N[(N[(x + N[(x * N[(y * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.0003:\\
\;\;\;\;\frac{x + x \cdot \left(y \cdot \left(y \cdot -0.16666666666666666\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 2.99999999999999974e-4Initial program 95.4%
Taylor expanded in y around 0 70.1%
unpow270.1%
Simplified70.1%
distribute-rgt-in70.1%
*-un-lft-identity70.1%
associate-*r*70.1%
Applied egg-rr70.1%
if 2.99999999999999974e-4 < y Initial program 97.9%
associate-*l/95.6%
times-frac84.7%
*-commutative84.7%
associate-*r/84.7%
*-commutative84.7%
Simplified84.7%
Final simplification74.0%
(FPCore (x y z) :precision binary64 (if (<= y 2.4e-8) (/ x z) (* (/ (sin y) z) (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e-8) {
tmp = x / z;
} else {
tmp = (sin(y) / z) * (x / 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 <= 2.4d-8) then
tmp = x / z
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.4e-8) {
tmp = x / z;
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.4e-8: tmp = x / z else: tmp = (math.sin(y) / z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.4e-8) tmp = Float64(x / z); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.4e-8) tmp = x / z; else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.4e-8], N[(x / z), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 2.39999999999999998e-8Initial program 95.4%
Taylor expanded in y around 0 74.7%
if 2.39999999999999998e-8 < y Initial program 97.9%
associate-*r/97.9%
associate-/l/84.9%
*-commutative84.9%
times-frac98.0%
Simplified98.0%
Final simplification81.0%
(FPCore (x y z) :precision binary64 (if (<= y 2e+135) (/ x (/ z (/ (sin y) y))) (* (/ (sin y) z) (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+135) {
tmp = x / (z / (sin(y) / y));
} else {
tmp = (sin(y) / z) * (x / 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 <= 2d+135) then
tmp = x / (z / (sin(y) / y))
else
tmp = (sin(y) / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2e+135) {
tmp = x / (z / (Math.sin(y) / y));
} else {
tmp = (Math.sin(y) / z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e+135: tmp = x / (z / (math.sin(y) / y)) else: tmp = (math.sin(y) / z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e+135) tmp = Float64(x / Float64(z / Float64(sin(y) / y))); else tmp = Float64(Float64(sin(y) / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2e+135) tmp = x / (z / (sin(y) / y)); else tmp = (sin(y) / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e+135], N[(x / N[(z / N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[y], $MachinePrecision] / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+135}:\\
\;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sin y}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < 1.99999999999999992e135Initial program 95.9%
associate-/l*97.4%
Simplified97.4%
if 1.99999999999999992e135 < y Initial program 96.9%
associate-*r/96.9%
associate-/l/77.8%
*-commutative77.8%
times-frac97.0%
Simplified97.0%
Final simplification97.3%
(FPCore (x y z) :precision binary64 (if (<= y 8.2e+48) (/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y))))) (* (/ x (* y z)) (/ 6.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+48) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = (x / (y * z)) * (6.0 / 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 <= 8.2d+48) then
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
else
tmp = (x / (y * z)) * (6.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+48) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = (x / (y * z)) * (6.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.2e+48: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) else: tmp = (x / (y * z)) * (6.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.2e+48) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); else tmp = Float64(Float64(x / Float64(y * z)) * Float64(6.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8.2e+48) tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); else tmp = (x / (y * z)) * (6.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.2e+48], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(6.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+48}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot z} \cdot \frac{6}{y}\\
\end{array}
\end{array}
if y < 8.2000000000000005e48Initial program 95.7%
associate-/l*97.7%
Simplified97.7%
Taylor expanded in y around 0 66.6%
unpow266.6%
Simplified66.6%
if 8.2000000000000005e48 < y Initial program 97.5%
associate-/l*80.9%
associate-/r/80.8%
Simplified80.8%
Taylor expanded in y around 0 43.4%
Taylor expanded in y around inf 43.4%
*-commutative43.4%
*-commutative43.4%
Simplified43.4%
Taylor expanded in x around 0 43.4%
associate-*r/43.4%
*-commutative43.4%
times-frac43.5%
metadata-eval43.5%
associate-/r*43.5%
unpow243.5%
associate-/r*43.5%
times-frac43.4%
associate-*l/43.4%
associate-/r*43.4%
associate-*l/45.2%
associate-/r*45.2%
metadata-eval45.2%
times-frac45.2%
associate-*r/45.2%
*-lft-identity45.2%
associate-*l/45.2%
associate-*r*45.2%
*-commutative45.2%
associate-*l/45.2%
metadata-eval45.2%
Simplified45.2%
Final simplification62.1%
(FPCore (x y z) :precision binary64 (if (<= y 8.2e+48) (/ (+ x (* x (* y (* y -0.16666666666666666)))) z) (* (/ x (* y z)) (/ 6.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+48) {
tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z;
} else {
tmp = (x / (y * z)) * (6.0 / 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 <= 8.2d+48) then
tmp = (x + (x * (y * (y * (-0.16666666666666666d0))))) / z
else
tmp = (x / (y * z)) * (6.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 8.2e+48) {
tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z;
} else {
tmp = (x / (y * z)) * (6.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 8.2e+48: tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z else: tmp = (x / (y * z)) * (6.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 8.2e+48) tmp = Float64(Float64(x + Float64(x * Float64(y * Float64(y * -0.16666666666666666)))) / z); else tmp = Float64(Float64(x / Float64(y * z)) * Float64(6.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 8.2e+48) tmp = (x + (x * (y * (y * -0.16666666666666666)))) / z; else tmp = (x / (y * z)) * (6.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 8.2e+48], N[(N[(x + N[(x * N[(y * N[(y * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(6.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{+48}:\\
\;\;\;\;\frac{x + x \cdot \left(y \cdot \left(y \cdot -0.16666666666666666\right)\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot z} \cdot \frac{6}{y}\\
\end{array}
\end{array}
if y < 8.2000000000000005e48Initial program 95.7%
Taylor expanded in y around 0 66.6%
unpow266.6%
Simplified66.6%
distribute-rgt-in66.7%
*-un-lft-identity66.7%
associate-*r*66.7%
Applied egg-rr66.7%
if 8.2000000000000005e48 < y Initial program 97.5%
associate-/l*80.9%
associate-/r/80.8%
Simplified80.8%
Taylor expanded in y around 0 43.4%
Taylor expanded in y around inf 43.4%
*-commutative43.4%
*-commutative43.4%
Simplified43.4%
Taylor expanded in x around 0 43.4%
associate-*r/43.4%
*-commutative43.4%
times-frac43.5%
metadata-eval43.5%
associate-/r*43.5%
unpow243.5%
associate-/r*43.5%
times-frac43.4%
associate-*l/43.4%
associate-/r*43.4%
associate-*l/45.2%
associate-/r*45.2%
metadata-eval45.2%
times-frac45.2%
associate-*r/45.2%
*-lft-identity45.2%
associate-*l/45.2%
associate-*r*45.2%
*-commutative45.2%
associate-*l/45.2%
metadata-eval45.2%
Simplified45.2%
Final simplification62.1%
(FPCore (x y z) :precision binary64 (if (<= y 9.2e+89) (/ x z) (* (/ x (* y z)) (/ 6.0 y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 9.2e+89) {
tmp = x / z;
} else {
tmp = (x / (y * z)) * (6.0 / 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 <= 9.2d+89) then
tmp = x / z
else
tmp = (x / (y * z)) * (6.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 9.2e+89) {
tmp = x / z;
} else {
tmp = (x / (y * z)) * (6.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 9.2e+89: tmp = x / z else: tmp = (x / (y * z)) * (6.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 9.2e+89) tmp = Float64(x / z); else tmp = Float64(Float64(x / Float64(y * z)) * Float64(6.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 9.2e+89) tmp = x / z; else tmp = (x / (y * z)) * (6.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 9.2e+89], N[(x / z), $MachinePrecision], N[(N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(6.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 9.2 \cdot 10^{+89}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot z} \cdot \frac{6}{y}\\
\end{array}
\end{array}
if y < 9.1999999999999996e89Initial program 95.8%
Taylor expanded in y around 0 69.1%
if 9.1999999999999996e89 < y Initial program 97.2%
associate-/l*80.5%
associate-/r/80.5%
Simplified80.5%
Taylor expanded in y around 0 44.4%
Taylor expanded in y around inf 44.4%
*-commutative44.4%
*-commutative44.4%
Simplified44.4%
Taylor expanded in x around 0 44.5%
associate-*r/44.5%
*-commutative44.5%
times-frac44.5%
metadata-eval44.5%
associate-/r*44.5%
unpow244.5%
associate-/r*44.5%
times-frac44.5%
associate-*l/44.5%
associate-/r*44.5%
associate-*l/46.4%
associate-/r*46.4%
metadata-eval46.4%
times-frac46.4%
associate-*r/46.4%
*-lft-identity46.4%
associate-*l/46.4%
associate-*r*46.4%
*-commutative46.4%
associate-*l/46.4%
metadata-eval46.4%
Simplified46.4%
Final simplification64.9%
(FPCore (x y z) :precision binary64 (if (<= y 2e+77) (/ x z) (* y (/ x (* y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2e+77) {
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 <= 2d+77) 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 <= 2e+77) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2e+77: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2e+77) 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 <= 2e+77) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2e+77], N[(x / z), $MachinePrecision], N[(y * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2 \cdot 10^{+77}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < 1.99999999999999997e77Initial program 95.8%
Taylor expanded in y around 0 69.7%
if 1.99999999999999997e77 < y Initial program 97.4%
associate-*l/94.3%
times-frac81.6%
*-commutative81.6%
associate-*r/81.6%
*-commutative81.6%
Simplified81.6%
Taylor expanded in y around 0 43.5%
Final simplification64.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.55e-20) (/ x z) (/ y (* z (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e-20) {
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 <= 1.55d-20) 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 <= 1.55e-20) {
tmp = x / z;
} else {
tmp = y / (z * (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e-20: tmp = x / z else: tmp = y / (z * (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e-20) 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 <= 1.55e-20) tmp = x / z; else tmp = y / (z * (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e-20], N[(x / z), $MachinePrecision], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\end{array}
\end{array}
if y < 1.55e-20Initial program 95.3%
Taylor expanded in y around 0 74.1%
if 1.55e-20 < y Initial program 98.0%
associate-*r/98.0%
associate-/l/85.7%
*-commutative85.7%
times-frac98.0%
Simplified98.0%
Taylor expanded in y around 0 28.9%
*-commutative28.9%
clear-num28.9%
frac-times41.2%
*-un-lft-identity41.2%
Applied egg-rr41.2%
Final simplification64.7%
(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 96.1%
Taylor expanded in y around 0 58.8%
Final simplification58.8%
(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 2023238
(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))