
(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 8 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 (if (<= v -1e+156) (atan -1.0) (if (<= v 5.2e+58) (atan (/ v (sqrt (- (* v v) (* 19.6 H))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1e+156) {
tmp = atan(-1.0);
} else if (v <= 5.2e+58) {
tmp = atan((v / sqrt(((v * v) - (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 <= (-1d+156)) then
tmp = atan((-1.0d0))
else if (v <= 5.2d+58) then
tmp = atan((v / sqrt(((v * v) - (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 <= -1e+156) {
tmp = Math.atan(-1.0);
} else if (v <= 5.2e+58) {
tmp = Math.atan((v / Math.sqrt(((v * v) - (19.6 * H)))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1e+156: tmp = math.atan(-1.0) elif v <= 5.2e+58: tmp = math.atan((v / math.sqrt(((v * v) - (19.6 * H))))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1e+156) tmp = atan(-1.0); elseif (v <= 5.2e+58) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(19.6 * H))))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1e+156) tmp = atan(-1.0); elseif (v <= 5.2e+58) tmp = atan((v / sqrt(((v * v) - (19.6 * H))))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1e+156], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 5.2e+58], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(19.6 * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+156}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 5.2 \cdot 10^{+58}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - 19.6 \cdot H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -9.9999999999999998e155Initial program 3.1%
sqr-neg3.1%
sqr-neg3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in v around -inf 100.0%
if -9.9999999999999998e155 < v < 5.19999999999999976e58Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
if 5.19999999999999976e58 < v Initial program 41.1%
sqr-neg41.1%
sqr-neg41.1%
metadata-eval41.1%
Simplified41.1%
Taylor expanded in v around inf 100.0%
(FPCore (v H)
:precision binary64
(let* ((t_0 (* -9.8 (/ H v))))
(if (<= v -2.2e-53)
(atan (+ -1.0 (/ t_0 v)))
(if (<= v 1.86e-112)
(atan (/ v (sqrt (* H -19.6))))
(atan (/ v (+ v t_0)))))))
double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -2.2e-53) {
tmp = atan((-1.0 + (t_0 / v)));
} else if (v <= 1.86e-112) {
tmp = atan((v / sqrt((H * -19.6))));
} else {
tmp = atan((v / (v + t_0)));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: t_0
real(8) :: tmp
t_0 = (-9.8d0) * (h / v)
if (v <= (-2.2d-53)) then
tmp = atan(((-1.0d0) + (t_0 / v)))
else if (v <= 1.86d-112) then
tmp = atan((v / sqrt((h * (-19.6d0)))))
else
tmp = atan((v / (v + t_0)))
end if
code = tmp
end function
public static double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -2.2e-53) {
tmp = Math.atan((-1.0 + (t_0 / v)));
} else if (v <= 1.86e-112) {
tmp = Math.atan((v / Math.sqrt((H * -19.6))));
} else {
tmp = Math.atan((v / (v + t_0)));
}
return tmp;
}
def code(v, H): t_0 = -9.8 * (H / v) tmp = 0 if v <= -2.2e-53: tmp = math.atan((-1.0 + (t_0 / v))) elif v <= 1.86e-112: tmp = math.atan((v / math.sqrt((H * -19.6)))) else: tmp = math.atan((v / (v + t_0))) return tmp
function code(v, H) t_0 = Float64(-9.8 * Float64(H / v)) tmp = 0.0 if (v <= -2.2e-53) tmp = atan(Float64(-1.0 + Float64(t_0 / v))); elseif (v <= 1.86e-112) tmp = atan(Float64(v / sqrt(Float64(H * -19.6)))); else tmp = atan(Float64(v / Float64(v + t_0))); end return tmp end
function tmp_2 = code(v, H) t_0 = -9.8 * (H / v); tmp = 0.0; if (v <= -2.2e-53) tmp = atan((-1.0 + (t_0 / v))); elseif (v <= 1.86e-112) tmp = atan((v / sqrt((H * -19.6)))); else tmp = atan((v / (v + t_0))); end tmp_2 = tmp; end
code[v_, H_] := Block[{t$95$0 = N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -2.2e-53], N[ArcTan[N[(-1.0 + N[(t$95$0 / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.86e-112], N[ArcTan[N[(v / N[Sqrt[N[(H * -19.6), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -9.8 \cdot \frac{H}{v}\\
\mathbf{if}\;v \leq -2.2 \cdot 10^{-53}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{t\_0}{v}\right)\\
\mathbf{elif}\;v \leq 1.86 \cdot 10^{-112}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{H \cdot -19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + t\_0}\right)\\
\end{array}
\end{array}
if v < -2.20000000000000018e-53Initial program 46.1%
sqr-neg46.1%
sqr-neg46.1%
metadata-eval46.1%
Simplified46.1%
Taylor expanded in v around -inf 90.6%
associate-*r/90.6%
unpow290.6%
associate-/r*90.6%
associate-*r/90.6%
Applied egg-rr90.6%
if -2.20000000000000018e-53 < v < 1.86e-112Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in v around 0 90.3%
*-commutative90.3%
Simplified90.3%
if 1.86e-112 < v Initial program 59.9%
sqr-neg59.9%
sqr-neg59.9%
metadata-eval59.9%
Simplified59.9%
Taylor expanded in H around 0 91.6%
Final simplification91.0%
(FPCore (v H)
:precision binary64
(let* ((t_0 (* -9.8 (/ H v))))
(if (<= v -1.32e-51)
(atan (+ -1.0 (/ t_0 v)))
(if (<= v 1.86e-112)
(atan (* v (sqrt (/ -0.05102040816326531 H))))
(atan (/ v (+ v t_0)))))))
double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -1.32e-51) {
tmp = atan((-1.0 + (t_0 / v)));
} else if (v <= 1.86e-112) {
tmp = atan((v * sqrt((-0.05102040816326531 / H))));
} else {
tmp = atan((v / (v + t_0)));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: t_0
real(8) :: tmp
t_0 = (-9.8d0) * (h / v)
if (v <= (-1.32d-51)) then
tmp = atan(((-1.0d0) + (t_0 / v)))
else if (v <= 1.86d-112) then
tmp = atan((v * sqrt(((-0.05102040816326531d0) / h))))
else
tmp = atan((v / (v + t_0)))
end if
code = tmp
end function
public static double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -1.32e-51) {
tmp = Math.atan((-1.0 + (t_0 / v)));
} else if (v <= 1.86e-112) {
tmp = Math.atan((v * Math.sqrt((-0.05102040816326531 / H))));
} else {
tmp = Math.atan((v / (v + t_0)));
}
return tmp;
}
def code(v, H): t_0 = -9.8 * (H / v) tmp = 0 if v <= -1.32e-51: tmp = math.atan((-1.0 + (t_0 / v))) elif v <= 1.86e-112: tmp = math.atan((v * math.sqrt((-0.05102040816326531 / H)))) else: tmp = math.atan((v / (v + t_0))) return tmp
function code(v, H) t_0 = Float64(-9.8 * Float64(H / v)) tmp = 0.0 if (v <= -1.32e-51) tmp = atan(Float64(-1.0 + Float64(t_0 / v))); elseif (v <= 1.86e-112) tmp = atan(Float64(v * sqrt(Float64(-0.05102040816326531 / H)))); else tmp = atan(Float64(v / Float64(v + t_0))); end return tmp end
function tmp_2 = code(v, H) t_0 = -9.8 * (H / v); tmp = 0.0; if (v <= -1.32e-51) tmp = atan((-1.0 + (t_0 / v))); elseif (v <= 1.86e-112) tmp = atan((v * sqrt((-0.05102040816326531 / H)))); else tmp = atan((v / (v + t_0))); end tmp_2 = tmp; end
code[v_, H_] := Block[{t$95$0 = N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1.32e-51], N[ArcTan[N[(-1.0 + N[(t$95$0 / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.86e-112], N[ArcTan[N[(v * N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -9.8 \cdot \frac{H}{v}\\
\mathbf{if}\;v \leq -1.32 \cdot 10^{-51}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{t\_0}{v}\right)\\
\mathbf{elif}\;v \leq 1.86 \cdot 10^{-112}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{-0.05102040816326531}{H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + t\_0}\right)\\
\end{array}
\end{array}
if v < -1.31999999999999998e-51Initial program 46.1%
sqr-neg46.1%
sqr-neg46.1%
metadata-eval46.1%
Simplified46.1%
Taylor expanded in v around -inf 90.6%
associate-*r/90.6%
unpow290.6%
associate-/r*90.6%
associate-*r/90.6%
Applied egg-rr90.6%
if -1.31999999999999998e-51 < v < 1.86e-112Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
clear-num94.9%
associate-/r/99.8%
pow1/299.8%
pow-flip99.8%
sub-neg99.8%
+-commutative99.8%
*-commutative99.8%
distribute-rgt-neg-in99.8%
fma-define99.8%
metadata-eval99.8%
pow299.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in H around inf 90.3%
*-commutative90.3%
Simplified90.3%
add-sqr-sqrt90.0%
sqrt-unprod90.3%
pow-prod-up90.4%
metadata-eval90.4%
Applied egg-rr90.4%
unpow-190.4%
*-commutative90.4%
rem-square-sqrt0.0%
unpow20.0%
associate-/r*0.0%
unpow20.0%
rem-square-sqrt90.2%
metadata-eval90.2%
Simplified90.2%
if 1.86e-112 < v Initial program 59.9%
sqr-neg59.9%
sqr-neg59.9%
metadata-eval59.9%
Simplified59.9%
Taylor expanded in H around 0 91.6%
Final simplification90.9%
(FPCore (v H)
:precision binary64
(if (<= v -1.8e-143)
(atan (+ -1.0 (/ (* -9.8 (/ H v)) v)))
(if (<= v 4.2e-123)
(atan (* v (* -0.10204081632653061 (/ v H))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1.8e-143) {
tmp = atan((-1.0 + ((-9.8 * (H / v)) / v)));
} else if (v <= 4.2e-123) {
tmp = atan((v * (-0.10204081632653061 * (v / 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.8d-143)) then
tmp = atan(((-1.0d0) + (((-9.8d0) * (h / v)) / v)))
else if (v <= 4.2d-123) then
tmp = atan((v * ((-0.10204081632653061d0) * (v / 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.8e-143) {
tmp = Math.atan((-1.0 + ((-9.8 * (H / v)) / v)));
} else if (v <= 4.2e-123) {
tmp = Math.atan((v * (-0.10204081632653061 * (v / H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.8e-143: tmp = math.atan((-1.0 + ((-9.8 * (H / v)) / v))) elif v <= 4.2e-123: tmp = math.atan((v * (-0.10204081632653061 * (v / H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.8e-143) tmp = atan(Float64(-1.0 + Float64(Float64(-9.8 * Float64(H / v)) / v))); elseif (v <= 4.2e-123) tmp = atan(Float64(v * Float64(-0.10204081632653061 * Float64(v / H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.8e-143) tmp = atan((-1.0 + ((-9.8 * (H / v)) / v))); elseif (v <= 4.2e-123) tmp = atan((v * (-0.10204081632653061 * (v / H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.8e-143], N[ArcTan[N[(-1.0 + N[(N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 4.2e-123], N[ArcTan[N[(v * N[(-0.10204081632653061 * N[(v / H), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.8 \cdot 10^{-143}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{-9.8 \cdot \frac{H}{v}}{v}\right)\\
\mathbf{elif}\;v \leq 4.2 \cdot 10^{-123}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \left(-0.10204081632653061 \cdot \frac{v}{H}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.7999999999999999e-143Initial program 55.9%
sqr-neg55.9%
sqr-neg55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in v around -inf 80.9%
associate-*r/80.9%
unpow280.9%
associate-/r*80.9%
associate-*r/80.9%
Applied egg-rr80.9%
if -1.7999999999999999e-143 < v < 4.1999999999999998e-123Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in H around 0 27.6%
Taylor expanded in v around 0 27.6%
associate-*r/27.6%
*-commutative27.6%
Simplified27.6%
associate-/r/27.6%
*-un-lft-identity27.6%
*-commutative27.6%
times-frac27.6%
metadata-eval27.6%
Applied egg-rr27.6%
if 4.1999999999999998e-123 < v Initial program 59.9%
sqr-neg59.9%
sqr-neg59.9%
metadata-eval59.9%
Simplified59.9%
Taylor expanded in v around inf 90.2%
Final simplification74.9%
(FPCore (v H)
:precision binary64
(if (<= v -8.6e-153)
(atan -1.0)
(if (<= v 4.2e-123)
(atan (* v (* -0.10204081632653061 (/ v H))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -8.6e-153) {
tmp = atan(-1.0);
} else if (v <= 4.2e-123) {
tmp = atan((v * (-0.10204081632653061 * (v / 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 <= (-8.6d-153)) then
tmp = atan((-1.0d0))
else if (v <= 4.2d-123) then
tmp = atan((v * ((-0.10204081632653061d0) * (v / h))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -8.6e-153) {
tmp = Math.atan(-1.0);
} else if (v <= 4.2e-123) {
tmp = Math.atan((v * (-0.10204081632653061 * (v / H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -8.6e-153: tmp = math.atan(-1.0) elif v <= 4.2e-123: tmp = math.atan((v * (-0.10204081632653061 * (v / H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -8.6e-153) tmp = atan(-1.0); elseif (v <= 4.2e-123) tmp = atan(Float64(v * Float64(-0.10204081632653061 * Float64(v / H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -8.6e-153) tmp = atan(-1.0); elseif (v <= 4.2e-123) tmp = atan((v * (-0.10204081632653061 * (v / H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -8.6e-153], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 4.2e-123], N[ArcTan[N[(v * N[(-0.10204081632653061 * N[(v / H), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -8.6 \cdot 10^{-153}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 4.2 \cdot 10^{-123}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \left(-0.10204081632653061 \cdot \frac{v}{H}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -8.6000000000000001e-153Initial program 55.9%
sqr-neg55.9%
sqr-neg55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in v around -inf 80.8%
if -8.6000000000000001e-153 < v < 4.1999999999999998e-123Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in H around 0 27.6%
Taylor expanded in v around 0 27.6%
associate-*r/27.6%
*-commutative27.6%
Simplified27.6%
associate-/r/27.6%
*-un-lft-identity27.6%
*-commutative27.6%
times-frac27.6%
metadata-eval27.6%
Applied egg-rr27.6%
if 4.1999999999999998e-123 < v Initial program 59.9%
sqr-neg59.9%
sqr-neg59.9%
metadata-eval59.9%
Simplified59.9%
Taylor expanded in v around inf 90.2%
Final simplification74.8%
(FPCore (v H) :precision binary64 (let* ((t_0 (* -9.8 (/ H v)))) (if (<= v -3.3e-142) (atan (+ -1.0 (/ t_0 v))) (atan (/ v (+ v t_0))))))
double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -3.3e-142) {
tmp = atan((-1.0 + (t_0 / v)));
} else {
tmp = atan((v / (v + t_0)));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: t_0
real(8) :: tmp
t_0 = (-9.8d0) * (h / v)
if (v <= (-3.3d-142)) then
tmp = atan(((-1.0d0) + (t_0 / v)))
else
tmp = atan((v / (v + t_0)))
end if
code = tmp
end function
public static double code(double v, double H) {
double t_0 = -9.8 * (H / v);
double tmp;
if (v <= -3.3e-142) {
tmp = Math.atan((-1.0 + (t_0 / v)));
} else {
tmp = Math.atan((v / (v + t_0)));
}
return tmp;
}
def code(v, H): t_0 = -9.8 * (H / v) tmp = 0 if v <= -3.3e-142: tmp = math.atan((-1.0 + (t_0 / v))) else: tmp = math.atan((v / (v + t_0))) return tmp
function code(v, H) t_0 = Float64(-9.8 * Float64(H / v)) tmp = 0.0 if (v <= -3.3e-142) tmp = atan(Float64(-1.0 + Float64(t_0 / v))); else tmp = atan(Float64(v / Float64(v + t_0))); end return tmp end
function tmp_2 = code(v, H) t_0 = -9.8 * (H / v); tmp = 0.0; if (v <= -3.3e-142) tmp = atan((-1.0 + (t_0 / v))); else tmp = atan((v / (v + t_0))); end tmp_2 = tmp; end
code[v_, H_] := Block[{t$95$0 = N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -3.3e-142], N[ArcTan[N[(-1.0 + N[(t$95$0 / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -9.8 \cdot \frac{H}{v}\\
\mathbf{if}\;v \leq -3.3 \cdot 10^{-142}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{t\_0}{v}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + t\_0}\right)\\
\end{array}
\end{array}
if v < -3.2999999999999997e-142Initial program 55.9%
sqr-neg55.9%
sqr-neg55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in v around -inf 80.9%
associate-*r/80.9%
unpow280.9%
associate-/r*80.9%
associate-*r/80.9%
Applied egg-rr80.9%
if -3.2999999999999997e-142 < v Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in H around 0 72.0%
Final simplification75.5%
(FPCore (v H) :precision binary64 (if (<= v -1e-310) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= -1e-310) {
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 <= (-1d-310)) 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 <= -1e-310) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1e-310: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1e-310) tmp = atan(-1.0); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1e-310) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1e-310], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{-310}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -9.999999999999969e-311Initial program 65.6%
sqr-neg65.6%
sqr-neg65.6%
metadata-eval65.6%
Simplified65.6%
Taylor expanded in v around -inf 63.8%
if -9.999999999999969e-311 < v Initial program 66.1%
sqr-neg66.1%
sqr-neg66.1%
metadata-eval66.1%
Simplified66.1%
Taylor expanded in v around inf 76.9%
(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 65.8%
sqr-neg65.8%
sqr-neg65.8%
metadata-eval65.8%
Simplified65.8%
Taylor expanded in v around -inf 32.5%
herbie shell --seed 2024172
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))