
(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)) (t_1 (* x t_0))) (if (<= t_1 -5e-296) (/ t_1 z) (/ x (/ z t_0)))))
double code(double x, double y, double z) {
double t_0 = sin(y) / y;
double t_1 = x * t_0;
double tmp;
if (t_1 <= -5e-296) {
tmp = t_1 / 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) :: t_1
real(8) :: tmp
t_0 = sin(y) / y
t_1 = x * t_0
if (t_1 <= (-5d-296)) then
tmp = t_1 / 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 t_1 = x * t_0;
double tmp;
if (t_1 <= -5e-296) {
tmp = t_1 / z;
} else {
tmp = x / (z / t_0);
}
return tmp;
}
def code(x, y, z): t_0 = math.sin(y) / y t_1 = x * t_0 tmp = 0 if t_1 <= -5e-296: tmp = t_1 / z else: tmp = x / (z / t_0) return tmp
function code(x, y, z) t_0 = Float64(sin(y) / y) t_1 = Float64(x * t_0) tmp = 0.0 if (t_1 <= -5e-296) tmp = Float64(t_1 / 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; t_1 = x * t_0; tmp = 0.0; if (t_1 <= -5e-296) tmp = t_1 / 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]}, Block[{t$95$1 = N[(x * t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, -5e-296], N[(t$95$1 / z), $MachinePrecision], N[(x / N[(z / t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sin y}{y}\\
t_1 := x \cdot t_0\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{-296}:\\
\;\;\;\;\frac{t_1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{t_0}}\\
\end{array}
\end{array}
if (*.f64 x (/.f64 (sin.f64 y) y)) < -5.0000000000000003e-296Initial program 99.9%
if -5.0000000000000003e-296 < (*.f64 x (/.f64 (sin.f64 y) y)) Initial program 92.6%
associate-/l*98.9%
Simplified98.9%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.5e-8) (not (<= y 5e-9))) (* (sin y) (/ x (* y z))) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e-8) || !(y <= 5e-9)) {
tmp = sin(y) * (x / (y * z));
} else {
tmp = 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 <= (-2.5d-8)) .or. (.not. (y <= 5d-9))) then
tmp = sin(y) * (x / (y * z))
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.5e-8) || !(y <= 5e-9)) {
tmp = Math.sin(y) * (x / (y * z));
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.5e-8) or not (y <= 5e-9): tmp = math.sin(y) * (x / (y * z)) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.5e-8) || !(y <= 5e-9)) tmp = Float64(sin(y) * Float64(x / Float64(y * z))); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.5e-8) || ~((y <= 5e-9))) tmp = sin(y) * (x / (y * z)); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.5e-8], N[Not[LessEqual[y, 5e-9]], $MachinePrecision]], N[(N[Sin[y], $MachinePrecision] * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{-8} \lor \neg \left(y \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\sin y \cdot \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.4999999999999999e-8 or 5.0000000000000001e-9 < y Initial program 91.6%
associate-*l/92.8%
times-frac94.0%
*-commutative94.0%
associate-*r/94.1%
*-commutative94.1%
Simplified94.1%
if -2.4999999999999999e-8 < y < 5.0000000000000001e-9Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Final simplification97.1%
(FPCore (x y z) :precision binary64 (/ x (/ z (/ (sin y) y))))
double code(double x, double y, double z) {
return x / (z / (sin(y) / y));
}
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 / (sin(y) / y))
end function
public static double code(double x, double y, double z) {
return x / (z / (Math.sin(y) / y));
}
def code(x, y, z): return x / (z / (math.sin(y) / y))
function code(x, y, z) return Float64(x / Float64(z / Float64(sin(y) / y))) end
function tmp = code(x, y, z) tmp = x / (z / (sin(y) / y)); end
code[x_, y_, z_] := N[(x / N[(z / N[(N[Sin[y], $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{\frac{\sin y}{y}}}
\end{array}
Initial program 95.9%
associate-/l*97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (x y z)
:precision binary64
(if (<= y -950000000.0)
(* (/ 6.0 (* y z)) (/ x y))
(if (<= y 3e+24)
(/ x (/ z (+ 1.0 (* -0.16666666666666666 (* y y)))))
(/ (* (/ x z) 6.0) (* y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -950000000.0) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 3e+24) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = ((x / z) * 6.0) / (y * 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 <= (-950000000.0d0)) then
tmp = (6.0d0 / (y * z)) * (x / y)
else if (y <= 3d+24) then
tmp = x / (z / (1.0d0 + ((-0.16666666666666666d0) * (y * y))))
else
tmp = ((x / z) * 6.0d0) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -950000000.0) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 3e+24) {
tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y))));
} else {
tmp = ((x / z) * 6.0) / (y * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -950000000.0: tmp = (6.0 / (y * z)) * (x / y) elif y <= 3e+24: tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))) else: tmp = ((x / z) * 6.0) / (y * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -950000000.0) tmp = Float64(Float64(6.0 / Float64(y * z)) * Float64(x / y)); elseif (y <= 3e+24) tmp = Float64(x / Float64(z / Float64(1.0 + Float64(-0.16666666666666666 * Float64(y * y))))); else tmp = Float64(Float64(Float64(x / z) * 6.0) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -950000000.0) tmp = (6.0 / (y * z)) * (x / y); elseif (y <= 3e+24) tmp = x / (z / (1.0 + (-0.16666666666666666 * (y * y)))); else tmp = ((x / z) * 6.0) / (y * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -950000000.0], N[(N[(6.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+24], N[(x / N[(z / N[(1.0 + N[(-0.16666666666666666 * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * 6.0), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -950000000:\\
\;\;\;\;\frac{6}{y \cdot z} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+24}:\\
\;\;\;\;\frac{x}{\frac{z}{1 + -0.16666666666666666 \cdot \left(y \cdot y\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 6}{y \cdot y}\\
\end{array}
\end{array}
if y < -9.5e8Initial program 90.0%
associate-/l*93.3%
associate-/r/93.2%
Simplified93.2%
Taylor expanded in y around 0 29.0%
Taylor expanded in y around inf 29.0%
unpow229.0%
*-commutative29.0%
Simplified29.0%
*-un-lft-identity29.0%
times-frac29.0%
metadata-eval29.0%
associate-*r/29.0%
associate-*r*29.0%
times-frac29.1%
*-commutative29.1%
Applied egg-rr29.1%
if -9.5e8 < y < 2.99999999999999995e24Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 97.4%
unpow297.4%
Simplified97.4%
if 2.99999999999999995e24 < y Initial program 92.4%
associate-/l*94.2%
associate-/r/94.3%
Simplified94.3%
Taylor expanded in y around 0 24.7%
Taylor expanded in y around inf 24.7%
unpow224.7%
*-commutative24.7%
Simplified24.7%
*-commutative24.7%
associate-/r*29.3%
associate-*l/29.3%
Applied egg-rr29.3%
Final simplification65.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.45) (* (/ 6.0 (* y z)) (/ x y)) (if (<= y 2.45) (/ x z) (/ (* (/ x z) 6.0) (* y y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.45) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 2.45) {
tmp = x / z;
} else {
tmp = ((x / z) * 6.0) / (y * 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.45d0)) then
tmp = (6.0d0 / (y * z)) * (x / y)
else if (y <= 2.45d0) then
tmp = x / z
else
tmp = ((x / z) * 6.0d0) / (y * y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.45) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 2.45) {
tmp = x / z;
} else {
tmp = ((x / z) * 6.0) / (y * y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.45: tmp = (6.0 / (y * z)) * (x / y) elif y <= 2.45: tmp = x / z else: tmp = ((x / z) * 6.0) / (y * y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.45) tmp = Float64(Float64(6.0 / Float64(y * z)) * Float64(x / y)); elseif (y <= 2.45) tmp = Float64(x / z); else tmp = Float64(Float64(Float64(x / z) * 6.0) / Float64(y * y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.45) tmp = (6.0 / (y * z)) * (x / y); elseif (y <= 2.45) tmp = x / z; else tmp = ((x / z) * 6.0) / (y * y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.45], N[(N[(6.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45], N[(x / z), $MachinePrecision], N[(N[(N[(x / z), $MachinePrecision] * 6.0), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.45:\\
\;\;\;\;\frac{6}{y \cdot z} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.45:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 6}{y \cdot y}\\
\end{array}
\end{array}
if y < -2.4500000000000002Initial program 90.3%
associate-/l*93.5%
associate-/r/93.4%
Simplified93.4%
Taylor expanded in y around 0 28.2%
Taylor expanded in y around inf 28.2%
unpow228.2%
*-commutative28.2%
Simplified28.2%
*-un-lft-identity28.2%
times-frac28.2%
metadata-eval28.2%
associate-*r/28.2%
associate-*r*28.2%
times-frac28.2%
*-commutative28.2%
Applied egg-rr28.2%
if -2.4500000000000002 < y < 2.4500000000000002Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 99.6%
if 2.4500000000000002 < y Initial program 92.6%
associate-/l*94.3%
associate-/r/94.4%
Simplified94.4%
Taylor expanded in y around 0 23.9%
Taylor expanded in y around inf 23.9%
unpow223.9%
*-commutative23.9%
Simplified23.9%
*-commutative23.9%
associate-/r*28.3%
associate-*l/28.3%
Applied egg-rr28.3%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.1e+82) (not (<= y 3.65e-6))) (* y (/ x (* y z))) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e+82) || !(y <= 3.65e-6)) {
tmp = y * (x / (y * z));
} else {
tmp = 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 <= (-1.1d+82)) .or. (.not. (y <= 3.65d-6))) then
tmp = y * (x / (y * z))
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.1e+82) || !(y <= 3.65e-6)) {
tmp = y * (x / (y * z));
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.1e+82) or not (y <= 3.65e-6): tmp = y * (x / (y * z)) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.1e+82) || !(y <= 3.65e-6)) tmp = Float64(y * Float64(x / Float64(y * z))); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.1e+82) || ~((y <= 3.65e-6))) tmp = y * (x / (y * z)); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.1e+82], N[Not[LessEqual[y, 3.65e-6]], $MachinePrecision]], N[(y * N[(x / N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+82} \lor \neg \left(y \leq 3.65 \cdot 10^{-6}\right):\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -1.1000000000000001e82 or 3.65000000000000021e-6 < y Initial program 91.3%
associate-*l/93.6%
times-frac93.2%
*-commutative93.2%
associate-*r/93.3%
*-commutative93.3%
Simplified93.3%
Taylor expanded in y around 0 31.1%
if -1.1000000000000001e82 < y < 3.65000000000000021e-6Initial program 99.3%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in y around 0 90.3%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (<= y -2e+29) (* y (/ (/ x y) z)) (if (<= y 1.12e-5) (/ x z) (* y (/ x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+29) {
tmp = y * ((x / y) / z);
} else if (y <= 1.12e-5) {
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+29)) then
tmp = y * ((x / y) / z)
else if (y <= 1.12d-5) 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+29) {
tmp = y * ((x / y) / z);
} else if (y <= 1.12e-5) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+29: tmp = y * ((x / y) / z) elif y <= 1.12e-5: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+29) tmp = Float64(y * Float64(Float64(x / y) / z)); elseif (y <= 1.12e-5) 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+29) tmp = y * ((x / y) / z); elseif (y <= 1.12e-5) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+29], N[(y * N[(N[(x / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.12e-5], 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^{+29}:\\
\;\;\;\;y \cdot \frac{\frac{x}{y}}{z}\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < -1.99999999999999983e29Initial program 89.5%
associate-*l/92.8%
times-frac93.0%
*-commutative93.0%
associate-*r/93.0%
*-commutative93.0%
Simplified93.0%
Taylor expanded in y around 0 29.6%
expm1-log1p-u27.1%
expm1-udef27.7%
associate-/r*27.7%
Applied egg-rr27.7%
expm1-def27.1%
expm1-log1p29.6%
Simplified29.6%
if -1.99999999999999983e29 < y < 1.11999999999999995e-5Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.3%
if 1.11999999999999995e-5 < y Initial program 92.7%
associate-*l/92.2%
times-frac94.5%
*-commutative94.5%
associate-*r/94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in y around 0 28.6%
Final simplification65.3%
(FPCore (x y z) :precision binary64 (if (<= y -2e+29) (/ y (* z (/ y x))) (if (<= y 4.9e-5) (/ x z) (* y (/ x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+29) {
tmp = y / (z * (y / x));
} else if (y <= 4.9e-5) {
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+29)) then
tmp = y / (z * (y / x))
else if (y <= 4.9d-5) 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+29) {
tmp = y / (z * (y / x));
} else if (y <= 4.9e-5) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+29: tmp = y / (z * (y / x)) elif y <= 4.9e-5: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+29) tmp = Float64(y / Float64(z * Float64(y / x))); elseif (y <= 4.9e-5) 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+29) tmp = y / (z * (y / x)); elseif (y <= 4.9e-5) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+29], N[(y / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.9e-5], 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^{+29}:\\
\;\;\;\;\frac{y}{z \cdot \frac{y}{x}}\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < -1.99999999999999983e29Initial program 89.5%
associate-*r/89.3%
associate-/l/93.0%
*-commutative93.0%
times-frac89.3%
Simplified89.3%
Taylor expanded in y around 0 20.7%
*-commutative20.7%
clear-num20.8%
frac-times29.7%
*-un-lft-identity29.7%
Applied egg-rr29.7%
if -1.99999999999999983e29 < y < 4.9e-5Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 96.3%
if 4.9e-5 < y Initial program 92.7%
associate-*l/92.2%
times-frac94.5%
*-commutative94.5%
associate-*r/94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in y around 0 28.6%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.45) (* 6.0 (/ x (* z (* y y)))) (if (<= y 2.35e-8) (/ x z) (* y (/ x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.45) {
tmp = 6.0 * (x / (z * (y * y)));
} else if (y <= 2.35e-8) {
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 <= (-2.45d0)) then
tmp = 6.0d0 * (x / (z * (y * y)))
else if (y <= 2.35d-8) 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 <= -2.45) {
tmp = 6.0 * (x / (z * (y * y)));
} else if (y <= 2.35e-8) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.45: tmp = 6.0 * (x / (z * (y * y))) elif y <= 2.35e-8: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.45) tmp = Float64(6.0 * Float64(x / Float64(z * Float64(y * y)))); elseif (y <= 2.35e-8) 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 <= -2.45) tmp = 6.0 * (x / (z * (y * y))); elseif (y <= 2.35e-8) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.45], N[(6.0 * N[(x / N[(z * N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.35e-8], 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.45:\\
\;\;\;\;6 \cdot \frac{x}{z \cdot \left(y \cdot y\right)}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < -2.4500000000000002Initial program 90.3%
associate-/l*93.5%
associate-/r/93.4%
Simplified93.4%
Taylor expanded in y around 0 28.2%
Taylor expanded in y around inf 28.2%
unpow228.2%
*-commutative28.2%
Simplified28.2%
if -2.4500000000000002 < y < 2.3499999999999999e-8Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
if 2.3499999999999999e-8 < y Initial program 92.8%
associate-*l/92.3%
times-frac94.6%
*-commutative94.6%
associate-*r/94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in y around 0 29.4%
Final simplification65.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.45) (* (/ 6.0 (* y z)) (/ x y)) (if (<= y 4e-8) (/ x z) (* y (/ x (* y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.45) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 4e-8) {
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 <= (-2.45d0)) then
tmp = (6.0d0 / (y * z)) * (x / y)
else if (y <= 4d-8) 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 <= -2.45) {
tmp = (6.0 / (y * z)) * (x / y);
} else if (y <= 4e-8) {
tmp = x / z;
} else {
tmp = y * (x / (y * z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.45: tmp = (6.0 / (y * z)) * (x / y) elif y <= 4e-8: tmp = x / z else: tmp = y * (x / (y * z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.45) tmp = Float64(Float64(6.0 / Float64(y * z)) * Float64(x / y)); elseif (y <= 4e-8) 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 <= -2.45) tmp = (6.0 / (y * z)) * (x / y); elseif (y <= 4e-8) tmp = x / z; else tmp = y * (x / (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.45], N[(N[(6.0 / N[(y * z), $MachinePrecision]), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e-8], 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.45:\\
\;\;\;\;\frac{6}{y \cdot z} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y \cdot z}\\
\end{array}
\end{array}
if y < -2.4500000000000002Initial program 90.3%
associate-/l*93.5%
associate-/r/93.4%
Simplified93.4%
Taylor expanded in y around 0 28.2%
Taylor expanded in y around inf 28.2%
unpow228.2%
*-commutative28.2%
Simplified28.2%
*-un-lft-identity28.2%
times-frac28.2%
metadata-eval28.2%
associate-*r/28.2%
associate-*r*28.2%
times-frac28.2%
*-commutative28.2%
Applied egg-rr28.2%
if -2.4500000000000002 < y < 4.0000000000000001e-8Initial program 100.0%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
if 4.0000000000000001e-8 < y Initial program 92.8%
associate-*l/92.3%
times-frac94.6%
*-commutative94.6%
associate-*r/94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in y around 0 29.4%
Final simplification65.5%
(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 95.9%
associate-/l*97.1%
Simplified97.1%
Taylor expanded in y around 0 60.4%
Final simplification60.4%
(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 2023174
(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))