
(FPCore (v H) :precision binary64 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))
double code(double v, double H) {
return atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
code = atan((v / sqrt(((v * v) - ((2.0d0 * 9.8d0) * h)))))
end function
public static double code(double v, double H) {
return Math.atan((v / Math.sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
def code(v, H): return math.atan((v / math.sqrt(((v * v) - ((2.0 * 9.8) * H)))))
function code(v, H) return atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H))))) end
function tmp = code(v, H) tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H))))); end
code[v_, H_] := N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (v H) :precision binary64 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))
double code(double v, double H) {
return atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
code = atan((v / sqrt(((v * v) - ((2.0d0 * 9.8d0) * h)))))
end function
public static double code(double v, double H) {
return Math.atan((v / Math.sqrt(((v * v) - ((2.0 * 9.8) * H)))));
}
def code(v, H): return math.atan((v / math.sqrt(((v * v) - ((2.0 * 9.8) * H)))))
function code(v, H) return atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H))))) end
function tmp = code(v, H) tmp = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H))))); end
code[v_, H_] := N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)
\end{array}
(FPCore (v H)
:precision binary64
(let* ((t_0 (sqrt (/ v (fma -19.6 (/ H v) v)))))
(if (<= v -3.5e+41)
(atan (- t_0))
(if (<= v 8e-68) (atan (/ v (sqrt (fma H -19.6 (* v v))))) (atan t_0)))))
double code(double v, double H) {
double t_0 = sqrt((v / fma(-19.6, (H / v), v)));
double tmp;
if (v <= -3.5e+41) {
tmp = atan(-t_0);
} else if (v <= 8e-68) {
tmp = atan((v / sqrt(fma(H, -19.6, (v * v)))));
} else {
tmp = atan(t_0);
}
return tmp;
}
function code(v, H) t_0 = sqrt(Float64(v / fma(-19.6, Float64(H / v), v))) tmp = 0.0 if (v <= -3.5e+41) tmp = atan(Float64(-t_0)); elseif (v <= 8e-68) tmp = atan(Float64(v / sqrt(fma(H, -19.6, Float64(v * v))))); else tmp = atan(t_0); end return tmp end
code[v_, H_] := Block[{t$95$0 = N[Sqrt[N[(v / N[(-19.6 * N[(H / v), $MachinePrecision] + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[v, -3.5e+41], N[ArcTan[(-t$95$0)], $MachinePrecision], If[LessEqual[v, 8e-68], N[ArcTan[N[(v / N[Sqrt[N[(H * -19.6 + N[(v * v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{v}{\mathsf{fma}\left(-19.6, \frac{H}{v}, v\right)}}\\
\mathbf{if}\;v \leq -3.5 \cdot 10^{+41}:\\
\;\;\;\;\tan^{-1} \left(-t\_0\right)\\
\mathbf{elif}\;v \leq 8 \cdot 10^{-68}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} t\_0\\
\end{array}
\end{array}
if v < -3.4999999999999999e41Initial program 40.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval40.9
Applied rewrites40.9%
Taylor expanded in v around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6440.9
Applied rewrites40.9%
Taylor expanded in v around -inf
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-sqrt.f64N/A
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
if -3.4999999999999999e41 < v < 8.00000000000000053e-68Initial program 99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval99.6
Applied rewrites99.6%
if 8.00000000000000053e-68 < v Initial program 57.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval57.1
Applied rewrites57.1%
Taylor expanded in v around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Taylor expanded in v around 0
+-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-atan.f64N/A
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-sqrt.f64N/A
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
Applied rewrites100.0%
(FPCore (v H)
:precision binary64
(if (<= v -2e+155)
(atan -1.0)
(if (<= v 8e-68)
(atan (/ v (sqrt (fma H -19.6 (* v v)))))
(atan (sqrt (/ v (fma -19.6 (/ H v) v)))))))
double code(double v, double H) {
double tmp;
if (v <= -2e+155) {
tmp = atan(-1.0);
} else if (v <= 8e-68) {
tmp = atan((v / sqrt(fma(H, -19.6, (v * v)))));
} else {
tmp = atan(sqrt((v / fma(-19.6, (H / v), v))));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -2e+155) tmp = atan(-1.0); elseif (v <= 8e-68) tmp = atan(Float64(v / sqrt(fma(H, -19.6, Float64(v * v))))); else tmp = atan(sqrt(Float64(v / fma(-19.6, Float64(H / v), v)))); end return tmp end
code[v_, H_] := If[LessEqual[v, -2e+155], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 8e-68], N[ArcTan[N[(v / N[Sqrt[N[(H * -19.6 + N[(v * v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sqrt[N[(v / N[(-19.6 * N[(H / v), $MachinePrecision] + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2 \cdot 10^{+155}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 8 \cdot 10^{-68}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{v}{\mathsf{fma}\left(-19.6, \frac{H}{v}, v\right)}}\right)\\
\end{array}
\end{array}
if v < -2.00000000000000001e155Initial program 3.1%
Taylor expanded in v around -inf
Applied rewrites100.0%
if -2.00000000000000001e155 < v < 8.00000000000000053e-68Initial program 99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval99.6
Applied rewrites99.6%
if 8.00000000000000053e-68 < v Initial program 57.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval57.1
Applied rewrites57.1%
Taylor expanded in v around inf
unpow2N/A
associate-*l*N/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6457.1
Applied rewrites57.1%
Taylor expanded in v around 0
+-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-atan.f64N/A
sub-negN/A
mul-1-negN/A
remove-double-negN/A
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-sqrt.f64N/A
lower-/.f64N/A
cancel-sign-sub-invN/A
metadata-evalN/A
Applied rewrites100.0%
(FPCore (v H) :precision binary64 (if (<= v -2e+155) (atan -1.0) (if (<= v 1e+137) (atan (/ v (sqrt (fma H -19.6 (* v v))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -2e+155) {
tmp = atan(-1.0);
} else if (v <= 1e+137) {
tmp = atan((v / sqrt(fma(H, -19.6, (v * v)))));
} else {
tmp = atan(1.0);
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -2e+155) tmp = atan(-1.0); elseif (v <= 1e+137) tmp = atan(Float64(v / sqrt(fma(H, -19.6, Float64(v * v))))); else tmp = atan(1.0); end return tmp end
code[v_, H_] := If[LessEqual[v, -2e+155], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1e+137], N[ArcTan[N[(v / N[Sqrt[N[(H * -19.6 + N[(v * v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2 \cdot 10^{+155}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 10^{+137}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(H, -19.6, v \cdot v\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -2.00000000000000001e155Initial program 3.1%
Taylor expanded in v around -inf
Applied rewrites100.0%
if -2.00000000000000001e155 < v < 1e137Initial program 99.7%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval99.7
Applied rewrites99.7%
if 1e137 < v Initial program 15.9%
Taylor expanded in v around inf
Applied rewrites100.0%
(FPCore (v H)
:precision binary64
(if (<= v -0.000135)
(atan -1.0)
(if (<= v 2.3e-62)
(atan (/ v (sqrt (* -19.6 H))))
(atan (/ v (fma H (/ -9.8 v) v))))))
double code(double v, double H) {
double tmp;
if (v <= -0.000135) {
tmp = atan(-1.0);
} else if (v <= 2.3e-62) {
tmp = atan((v / sqrt((-19.6 * H))));
} else {
tmp = atan((v / fma(H, (-9.8 / v), v)));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -0.000135) tmp = atan(-1.0); elseif (v <= 2.3e-62) tmp = atan(Float64(v / sqrt(Float64(-19.6 * H)))); else tmp = atan(Float64(v / fma(H, Float64(-9.8 / v), v))); end return tmp end
code[v_, H_] := If[LessEqual[v, -0.000135], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.3e-62], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(H * N[(-9.8 / v), $MachinePrecision] + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -0.000135:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 2.3 \cdot 10^{-62}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(H, \frac{-9.8}{v}, v\right)}\right)\\
\end{array}
\end{array}
if v < -1.35000000000000002e-4Initial program 45.9%
Taylor expanded in v around -inf
Applied rewrites89.6%
if -1.35000000000000002e-4 < v < 2.3e-62Initial program 99.6%
Taylor expanded in v around 0
lower-*.f6490.7
Applied rewrites90.7%
if 2.3e-62 < v Initial program 56.3%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6493.8
Applied rewrites93.8%
(FPCore (v H) :precision binary64 (if (<= v -0.000135) (atan -1.0) (if (<= v 2.3e-62) (atan (/ v (sqrt (* -19.6 H)))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -0.000135) {
tmp = atan(-1.0);
} else if (v <= 2.3e-62) {
tmp = atan((v / sqrt((-19.6 * H))));
} else {
tmp = atan(1.0);
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-0.000135d0)) then
tmp = atan((-1.0d0))
else if (v <= 2.3d-62) then
tmp = atan((v / sqrt(((-19.6d0) * h))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -0.000135) {
tmp = Math.atan(-1.0);
} else if (v <= 2.3e-62) {
tmp = Math.atan((v / Math.sqrt((-19.6 * H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -0.000135: tmp = math.atan(-1.0) elif v <= 2.3e-62: tmp = math.atan((v / math.sqrt((-19.6 * H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -0.000135) tmp = atan(-1.0); elseif (v <= 2.3e-62) tmp = atan(Float64(v / sqrt(Float64(-19.6 * H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -0.000135) tmp = atan(-1.0); elseif (v <= 2.3e-62) tmp = atan((v / sqrt((-19.6 * H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -0.000135], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.3e-62], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -0.000135:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 2.3 \cdot 10^{-62}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.35000000000000002e-4Initial program 45.9%
Taylor expanded in v around -inf
Applied rewrites89.6%
if -1.35000000000000002e-4 < v < 2.3e-62Initial program 99.6%
Taylor expanded in v around 0
lower-*.f6490.7
Applied rewrites90.7%
if 2.3e-62 < v Initial program 56.3%
Taylor expanded in v around inf
Applied rewrites93.7%
(FPCore (v H)
:precision binary64
(if (<= v -0.000135)
(atan -1.0)
(if (<= v 2.3e-62)
(atan (* v (sqrt (/ -0.05102040816326531 H))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -0.000135) {
tmp = atan(-1.0);
} else if (v <= 2.3e-62) {
tmp = atan((v * sqrt((-0.05102040816326531 / H))));
} else {
tmp = atan(1.0);
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-0.000135d0)) then
tmp = atan((-1.0d0))
else if (v <= 2.3d-62) then
tmp = atan((v * sqrt(((-0.05102040816326531d0) / h))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -0.000135) {
tmp = Math.atan(-1.0);
} else if (v <= 2.3e-62) {
tmp = Math.atan((v * Math.sqrt((-0.05102040816326531 / H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -0.000135: tmp = math.atan(-1.0) elif v <= 2.3e-62: tmp = math.atan((v * math.sqrt((-0.05102040816326531 / H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -0.000135) tmp = atan(-1.0); elseif (v <= 2.3e-62) tmp = atan(Float64(v * sqrt(Float64(-0.05102040816326531 / H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -0.000135) tmp = atan(-1.0); elseif (v <= 2.3e-62) tmp = atan((v * sqrt((-0.05102040816326531 / H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -0.000135], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 2.3e-62], N[ArcTan[N[(v * N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -0.000135:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 2.3 \cdot 10^{-62}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{-0.05102040816326531}{H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.35000000000000002e-4Initial program 45.9%
Taylor expanded in v around -inf
Applied rewrites89.6%
if -1.35000000000000002e-4 < v < 2.3e-62Initial program 99.6%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-sqrt.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
Applied rewrites99.6%
Taylor expanded in v around 0
rem-square-sqrtN/A
unpow2N/A
lower-/.f64N/A
unpow2N/A
rem-square-sqrt90.7
Applied rewrites90.7%
if 2.3e-62 < v Initial program 56.3%
Taylor expanded in v around inf
Applied rewrites93.7%
Final simplification91.6%
(FPCore (v H)
:precision binary64
(if (<= v -1.9e-136)
(atan -1.0)
(if (<= v 1.1e-128)
(atan (* (* v v) (/ -0.10204081632653061 H)))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1.9e-136) {
tmp = atan(-1.0);
} else if (v <= 1.1e-128) {
tmp = atan(((v * v) * (-0.10204081632653061 / H)));
} else {
tmp = atan(1.0);
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-1.9d-136)) then
tmp = atan((-1.0d0))
else if (v <= 1.1d-128) then
tmp = atan(((v * v) * ((-0.10204081632653061d0) / h)))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.9e-136) {
tmp = Math.atan(-1.0);
} else if (v <= 1.1e-128) {
tmp = Math.atan(((v * v) * (-0.10204081632653061 / H)));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.9e-136: tmp = math.atan(-1.0) elif v <= 1.1e-128: tmp = math.atan(((v * v) * (-0.10204081632653061 / H))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.9e-136) tmp = atan(-1.0); elseif (v <= 1.1e-128) tmp = atan(Float64(Float64(v * v) * Float64(-0.10204081632653061 / H))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.9e-136) tmp = atan(-1.0); elseif (v <= 1.1e-128) tmp = atan(((v * v) * (-0.10204081632653061 / H))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.9e-136], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1.1e-128], N[ArcTan[N[(N[(v * v), $MachinePrecision] * N[(-0.10204081632653061 / H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.9 \cdot 10^{-136}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 1.1 \cdot 10^{-128}:\\
\;\;\;\;\tan^{-1} \left(\left(v \cdot v\right) \cdot \frac{-0.10204081632653061}{H}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.9000000000000001e-136Initial program 57.8%
Taylor expanded in v around -inf
Applied rewrites76.2%
if -1.9000000000000001e-136 < v < 1.10000000000000005e-128Initial program 99.6%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6431.5
Applied rewrites31.5%
Taylor expanded in v around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.5
Applied rewrites31.5%
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6431.5
Applied rewrites31.5%
if 1.10000000000000005e-128 < v Initial program 59.4%
Taylor expanded in v around inf
Applied rewrites89.9%
Final simplification72.3%
(FPCore (v H)
:precision binary64
(if (<= v -1.9e-136)
(atan -1.0)
(if (<= v 1.1e-128)
(atan (* v (* v (/ -0.10204081632653061 H))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1.9e-136) {
tmp = atan(-1.0);
} else if (v <= 1.1e-128) {
tmp = atan((v * (v * (-0.10204081632653061 / H))));
} else {
tmp = atan(1.0);
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-1.9d-136)) then
tmp = atan((-1.0d0))
else if (v <= 1.1d-128) then
tmp = atan((v * (v * ((-0.10204081632653061d0) / h))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.9e-136) {
tmp = Math.atan(-1.0);
} else if (v <= 1.1e-128) {
tmp = Math.atan((v * (v * (-0.10204081632653061 / H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.9e-136: tmp = math.atan(-1.0) elif v <= 1.1e-128: tmp = math.atan((v * (v * (-0.10204081632653061 / H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.9e-136) tmp = atan(-1.0); elseif (v <= 1.1e-128) tmp = atan(Float64(v * Float64(v * Float64(-0.10204081632653061 / H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.9e-136) tmp = atan(-1.0); elseif (v <= 1.1e-128) tmp = atan((v * (v * (-0.10204081632653061 / H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.9e-136], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1.1e-128], N[ArcTan[N[(v * N[(v * N[(-0.10204081632653061 / H), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.9 \cdot 10^{-136}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 1.1 \cdot 10^{-128}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \left(v \cdot \frac{-0.10204081632653061}{H}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.9000000000000001e-136Initial program 57.8%
Taylor expanded in v around -inf
Applied rewrites76.2%
if -1.9000000000000001e-136 < v < 1.10000000000000005e-128Initial program 99.6%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
associate-*l/N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f6431.5
Applied rewrites31.5%
Taylor expanded in v around 0
associate-*r/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6431.5
Applied rewrites31.5%
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f6431.5
Applied rewrites31.5%
if 1.10000000000000005e-128 < v Initial program 59.4%
Taylor expanded in v around inf
Applied rewrites89.9%
Final simplification72.3%
(FPCore (v H) :precision binary64 (if (<= v 1.7e-306) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= 1.7e-306) {
tmp = atan(-1.0);
} else {
tmp = atan(1.0);
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= 1.7d-306) then
tmp = atan((-1.0d0))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= 1.7e-306) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= 1.7e-306: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= 1.7e-306) tmp = atan(-1.0); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= 1.7e-306) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, 1.7e-306], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.7 \cdot 10^{-306}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < 1.6999999999999999e-306Initial program 68.3%
Taylor expanded in v around -inf
Applied rewrites58.1%
if 1.6999999999999999e-306 < v Initial program 67.1%
Taylor expanded in v around inf
Applied rewrites73.5%
(FPCore (v H) :precision binary64 (atan -1.0))
double code(double v, double H) {
return atan(-1.0);
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
code = atan((-1.0d0))
end function
public static double code(double v, double H) {
return Math.atan(-1.0);
}
def code(v, H): return math.atan(-1.0)
function code(v, H) return atan(-1.0) end
function tmp = code(v, H) tmp = atan(-1.0); end
code[v_, H_] := N[ArcTan[-1.0], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1} -1
\end{array}
Initial program 67.7%
Taylor expanded in v around -inf
Applied rewrites28.2%
herbie shell --seed 2024219
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))