
(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 -7.6e-75)
(atan (- (sqrt (/ 1.0 (+ 1.0 (* -19.6 (/ H (pow v 2.0))))))))
(if (<= v 6.5e-41)
(atan (/ v (sqrt (- (* v v) (* H 19.6)))))
(atan (sqrt (/ 1.0 (- 1.0 (* 19.6 (/ (/ H v) v)))))))))
double code(double v, double H) {
double tmp;
if (v <= -7.6e-75) {
tmp = atan(-sqrt((1.0 / (1.0 + (-19.6 * (H / pow(v, 2.0)))))));
} else if (v <= 6.5e-41) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = atan(sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v))))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-7.6d-75)) then
tmp = atan(-sqrt((1.0d0 / (1.0d0 + ((-19.6d0) * (h / (v ** 2.0d0)))))))
else if (v <= 6.5d-41) then
tmp = atan((v / sqrt(((v * v) - (h * 19.6d0)))))
else
tmp = atan(sqrt((1.0d0 / (1.0d0 - (19.6d0 * ((h / v) / v))))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -7.6e-75) {
tmp = Math.atan(-Math.sqrt((1.0 / (1.0 + (-19.6 * (H / Math.pow(v, 2.0)))))));
} else if (v <= 6.5e-41) {
tmp = Math.atan((v / Math.sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = Math.atan(Math.sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v))))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -7.6e-75: tmp = math.atan(-math.sqrt((1.0 / (1.0 + (-19.6 * (H / math.pow(v, 2.0))))))) elif v <= 6.5e-41: tmp = math.atan((v / math.sqrt(((v * v) - (H * 19.6))))) else: tmp = math.atan(math.sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v)))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -7.6e-75) tmp = atan(Float64(-sqrt(Float64(1.0 / Float64(1.0 + Float64(-19.6 * Float64(H / (v ^ 2.0)))))))); elseif (v <= 6.5e-41) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(H * 19.6))))); else tmp = atan(sqrt(Float64(1.0 / Float64(1.0 - Float64(19.6 * Float64(Float64(H / v) / v)))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -7.6e-75) tmp = atan(-sqrt((1.0 / (1.0 + (-19.6 * (H / (v ^ 2.0))))))); elseif (v <= 6.5e-41) tmp = atan((v / sqrt(((v * v) - (H * 19.6))))); else tmp = atan(sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v)))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -7.6e-75], N[ArcTan[(-N[Sqrt[N[(1.0 / N[(1.0 + N[(-19.6 * N[(H / N[Power[v, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision], If[LessEqual[v, 6.5e-41], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(H * 19.6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sqrt[N[(1.0 / N[(1.0 - N[(19.6 * N[(N[(H / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -7.6 \cdot 10^{-75}:\\
\;\;\;\;\tan^{-1} \left(-\sqrt{\frac{1}{1 + -19.6 \cdot \frac{H}{{v}^{2}}}}\right)\\
\mathbf{elif}\;v \leq 6.5 \cdot 10^{-41}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - H \cdot 19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{1}{1 - 19.6 \cdot \frac{\frac{H}{v}}{v}}}\right)\\
\end{array}
\end{array}
if v < -7.59999999999999987e-75Initial program 53.1%
sqr-neg53.1%
sqr-neg53.1%
metadata-eval53.1%
Simplified53.1%
clear-num53.1%
associate-/r/53.2%
pow1/253.2%
pow-flip53.2%
sub-neg53.2%
+-commutative53.2%
*-commutative53.2%
distribute-rgt-neg-in53.2%
fma-define53.2%
metadata-eval53.2%
pow253.2%
metadata-eval53.2%
Applied egg-rr53.2%
Taylor expanded in v around inf 53.2%
Taylor expanded in v around -inf 99.9%
if -7.59999999999999987e-75 < v < 6.5000000000000004e-41Initial program 99.6%
sqr-neg99.6%
sqr-neg99.6%
metadata-eval99.6%
Simplified99.6%
if 6.5000000000000004e-41 < v Initial program 54.9%
sqr-neg54.9%
sqr-neg54.9%
metadata-eval54.9%
Simplified54.9%
clear-num54.9%
associate-/r/54.9%
pow1/254.9%
pow-flip54.9%
sub-neg54.9%
+-commutative54.9%
*-commutative54.9%
distribute-rgt-neg-in54.9%
fma-define54.9%
metadata-eval54.9%
pow254.9%
metadata-eval54.9%
Applied egg-rr54.9%
Taylor expanded in v around inf 55.0%
Taylor expanded in H around inf 100.0%
*-un-lft-identity100.0%
unpow2100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (v H)
:precision binary64
(if (<= v -1e+155)
(atan -1.0)
(if (<= v 4e-41)
(atan (/ v (sqrt (- (* v v) (* H 19.6)))))
(atan (sqrt (/ 1.0 (- 1.0 (* 19.6 (/ (/ H v) v)))))))))
double code(double v, double H) {
double tmp;
if (v <= -1e+155) {
tmp = atan(-1.0);
} else if (v <= 4e-41) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = atan(sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v))))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-1d+155)) then
tmp = atan((-1.0d0))
else if (v <= 4d-41) then
tmp = atan((v / sqrt(((v * v) - (h * 19.6d0)))))
else
tmp = atan(sqrt((1.0d0 / (1.0d0 - (19.6d0 * ((h / v) / v))))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1e+155) {
tmp = Math.atan(-1.0);
} else if (v <= 4e-41) {
tmp = Math.atan((v / Math.sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = Math.atan(Math.sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v))))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1e+155: tmp = math.atan(-1.0) elif v <= 4e-41: tmp = math.atan((v / math.sqrt(((v * v) - (H * 19.6))))) else: tmp = math.atan(math.sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v)))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -1e+155) tmp = atan(-1.0); elseif (v <= 4e-41) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(H * 19.6))))); else tmp = atan(sqrt(Float64(1.0 / Float64(1.0 - Float64(19.6 * Float64(Float64(H / v) / v)))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1e+155) tmp = atan(-1.0); elseif (v <= 4e-41) tmp = atan((v / sqrt(((v * v) - (H * 19.6))))); else tmp = atan(sqrt((1.0 / (1.0 - (19.6 * ((H / v) / v)))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1e+155], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 4e-41], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(H * 19.6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[Sqrt[N[(1.0 / N[(1.0 - N[(19.6 * N[(N[(H / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 4 \cdot 10^{-41}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - H \cdot 19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{1}{1 - 19.6 \cdot \frac{\frac{H}{v}}{v}}}\right)\\
\end{array}
\end{array}
if v < -1.00000000000000001e155Initial program 3.1%
sqr-neg3.1%
sqr-neg3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in v around -inf 100.0%
if -1.00000000000000001e155 < v < 4.00000000000000002e-41Initial program 99.7%
sqr-neg99.7%
sqr-neg99.7%
metadata-eval99.7%
Simplified99.7%
if 4.00000000000000002e-41 < v Initial program 54.9%
sqr-neg54.9%
sqr-neg54.9%
metadata-eval54.9%
Simplified54.9%
clear-num54.9%
associate-/r/54.9%
pow1/254.9%
pow-flip54.9%
sub-neg54.9%
+-commutative54.9%
*-commutative54.9%
distribute-rgt-neg-in54.9%
fma-define54.9%
metadata-eval54.9%
pow254.9%
metadata-eval54.9%
Applied egg-rr54.9%
Taylor expanded in v around inf 55.0%
Taylor expanded in H around inf 100.0%
*-un-lft-identity100.0%
unpow2100.0%
times-frac100.0%
Applied egg-rr100.0%
associate-*l/100.0%
*-lft-identity100.0%
Simplified100.0%
Final simplification99.9%
(FPCore (v H) :precision binary64 (if (<= v -1e+155) (atan -1.0) (if (<= v 1e+150) (atan (/ v (sqrt (- (* v v) (* H 19.6))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1e+155) {
tmp = atan(-1.0);
} else if (v <= 1e+150) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} 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+155)) then
tmp = atan((-1.0d0))
else if (v <= 1d+150) then
tmp = atan((v / sqrt(((v * v) - (h * 19.6d0)))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1e+155) {
tmp = Math.atan(-1.0);
} else if (v <= 1e+150) {
tmp = Math.atan((v / Math.sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1e+155: tmp = math.atan(-1.0) elif v <= 1e+150: tmp = math.atan((v / math.sqrt(((v * v) - (H * 19.6))))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1e+155) tmp = atan(-1.0); elseif (v <= 1e+150) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(H * 19.6))))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1e+155) tmp = atan(-1.0); elseif (v <= 1e+150) tmp = atan((v / sqrt(((v * v) - (H * 19.6))))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1e+155], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1e+150], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(H * 19.6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+155}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 10^{+150}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - H \cdot 19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.00000000000000001e155Initial program 3.1%
sqr-neg3.1%
sqr-neg3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in v around -inf 100.0%
if -1.00000000000000001e155 < v < 9.99999999999999981e149Initial program 99.8%
sqr-neg99.8%
sqr-neg99.8%
metadata-eval99.8%
Simplified99.8%
if 9.99999999999999981e149 < v Initial program 3.1%
sqr-neg3.1%
sqr-neg3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in v around inf 100.0%
Final simplification99.8%
(FPCore (v H)
:precision binary64
(if (<= v -3.5e-62)
(atan (+ -1.0 (/ (/ (* H -9.8) v) v)))
(if (<= v 1.52e-43)
(atan (/ v (sqrt (* -19.6 H))))
(atan (/ v (+ v (* (/ H v) -9.8)))))))
double code(double v, double H) {
double tmp;
if (v <= -3.5e-62) {
tmp = atan((-1.0 + (((H * -9.8) / v) / v)));
} else if (v <= 1.52e-43) {
tmp = atan((v / sqrt((-19.6 * H))));
} else {
tmp = atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-3.5d-62)) then
tmp = atan(((-1.0d0) + (((h * (-9.8d0)) / v) / v)))
else if (v <= 1.52d-43) then
tmp = atan((v / sqrt(((-19.6d0) * h))))
else
tmp = atan((v / (v + ((h / v) * (-9.8d0)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -3.5e-62) {
tmp = Math.atan((-1.0 + (((H * -9.8) / v) / v)));
} else if (v <= 1.52e-43) {
tmp = Math.atan((v / Math.sqrt((-19.6 * H))));
} else {
tmp = Math.atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -3.5e-62: tmp = math.atan((-1.0 + (((H * -9.8) / v) / v))) elif v <= 1.52e-43: tmp = math.atan((v / math.sqrt((-19.6 * H)))) else: tmp = math.atan((v / (v + ((H / v) * -9.8)))) return tmp
function code(v, H) tmp = 0.0 if (v <= -3.5e-62) tmp = atan(Float64(-1.0 + Float64(Float64(Float64(H * -9.8) / v) / v))); elseif (v <= 1.52e-43) tmp = atan(Float64(v / sqrt(Float64(-19.6 * H)))); else tmp = atan(Float64(v / Float64(v + Float64(Float64(H / v) * -9.8)))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -3.5e-62) tmp = atan((-1.0 + (((H * -9.8) / v) / v))); elseif (v <= 1.52e-43) tmp = atan((v / sqrt((-19.6 * H)))); else tmp = atan((v / (v + ((H / v) * -9.8)))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -3.5e-62], N[ArcTan[N[(-1.0 + N[(N[(N[(H * -9.8), $MachinePrecision] / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.52e-43], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(N[(H / v), $MachinePrecision] * -9.8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -3.5 \cdot 10^{-62}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{\frac{H \cdot -9.8}{v}}{v}\right)\\
\mathbf{elif}\;v \leq 1.52 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + \frac{H}{v} \cdot -9.8}\right)\\
\end{array}
\end{array}
if v < -3.5000000000000001e-62Initial program 52.1%
sqr-neg52.1%
sqr-neg52.1%
metadata-eval52.1%
Simplified52.1%
Taylor expanded in v around -inf 92.7%
associate-*r/92.7%
unpow292.7%
associate-/r*92.7%
*-commutative92.7%
Applied egg-rr92.7%
if -3.5000000000000001e-62 < v < 1.52e-43Initial program 99.6%
sqr-neg99.6%
sqr-neg99.6%
metadata-eval99.6%
Simplified99.6%
add-cube-cbrt98.8%
pow398.8%
Applied egg-rr98.8%
Taylor expanded in H around -inf 0.0%
mul-1-neg0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt88.6%
distribute-lft-neg-in88.6%
metadata-eval88.6%
rem-cube-cbrt90.1%
*-commutative90.1%
Simplified90.1%
*-un-lft-identity90.1%
*-un-lft-identity90.1%
*-commutative90.1%
Applied egg-rr90.1%
*-lft-identity90.1%
Simplified90.1%
if 1.52e-43 < v Initial program 54.9%
sqr-neg54.9%
sqr-neg54.9%
metadata-eval54.9%
Simplified54.9%
Taylor expanded in H around 0 91.6%
Final simplification91.5%
(FPCore (v H)
:precision binary64
(if (<= v -1.22e-62)
(atan (+ -1.0 (/ (/ (* H -9.8) v) v)))
(if (<= v 1.6e-43)
(atan (* v (sqrt (/ -0.05102040816326531 H))))
(atan (/ v (+ v (* (/ H v) -9.8)))))))
double code(double v, double H) {
double tmp;
if (v <= -1.22e-62) {
tmp = atan((-1.0 + (((H * -9.8) / v) / v)));
} else if (v <= 1.6e-43) {
tmp = atan((v * sqrt((-0.05102040816326531 / H))));
} else {
tmp = atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-1.22d-62)) then
tmp = atan(((-1.0d0) + (((h * (-9.8d0)) / v) / v)))
else if (v <= 1.6d-43) then
tmp = atan((v * sqrt(((-0.05102040816326531d0) / h))))
else
tmp = atan((v / (v + ((h / v) * (-9.8d0)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.22e-62) {
tmp = Math.atan((-1.0 + (((H * -9.8) / v) / v)));
} else if (v <= 1.6e-43) {
tmp = Math.atan((v * Math.sqrt((-0.05102040816326531 / H))));
} else {
tmp = Math.atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.22e-62: tmp = math.atan((-1.0 + (((H * -9.8) / v) / v))) elif v <= 1.6e-43: tmp = math.atan((v * math.sqrt((-0.05102040816326531 / H)))) else: tmp = math.atan((v / (v + ((H / v) * -9.8)))) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.22e-62) tmp = atan(Float64(-1.0 + Float64(Float64(Float64(H * -9.8) / v) / v))); elseif (v <= 1.6e-43) tmp = atan(Float64(v * sqrt(Float64(-0.05102040816326531 / H)))); else tmp = atan(Float64(v / Float64(v + Float64(Float64(H / v) * -9.8)))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.22e-62) tmp = atan((-1.0 + (((H * -9.8) / v) / v))); elseif (v <= 1.6e-43) tmp = atan((v * sqrt((-0.05102040816326531 / H)))); else tmp = atan((v / (v + ((H / v) * -9.8)))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.22e-62], N[ArcTan[N[(-1.0 + N[(N[(N[(H * -9.8), $MachinePrecision] / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.6e-43], N[ArcTan[N[(v * N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(N[(H / v), $MachinePrecision] * -9.8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.22 \cdot 10^{-62}:\\
\;\;\;\;\tan^{-1} \left(-1 + \frac{\frac{H \cdot -9.8}{v}}{v}\right)\\
\mathbf{elif}\;v \leq 1.6 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{-0.05102040816326531}{H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + \frac{H}{v} \cdot -9.8}\right)\\
\end{array}
\end{array}
if v < -1.2199999999999999e-62Initial program 52.1%
sqr-neg52.1%
sqr-neg52.1%
metadata-eval52.1%
Simplified52.1%
Taylor expanded in v around -inf 92.7%
associate-*r/92.7%
unpow292.7%
associate-/r*92.7%
*-commutative92.7%
Applied egg-rr92.7%
if -1.2199999999999999e-62 < v < 1.59999999999999992e-43Initial program 99.6%
sqr-neg99.6%
sqr-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 99.4%
Taylor expanded in v around 0 90.0%
if 1.59999999999999992e-43 < v Initial program 54.9%
sqr-neg54.9%
sqr-neg54.9%
metadata-eval54.9%
Simplified54.9%
Taylor expanded in H around 0 91.6%
Final simplification91.5%
(FPCore (v H) :precision binary64 (if (<= v -2.2e-137) (atan -1.0) (atan (/ v (+ v (* (/ H v) -9.8))))))
double code(double v, double H) {
double tmp;
if (v <= -2.2e-137) {
tmp = atan(-1.0);
} else {
tmp = atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-2.2d-137)) then
tmp = atan((-1.0d0))
else
tmp = atan((v / (v + ((h / v) * (-9.8d0)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -2.2e-137) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -2.2e-137: tmp = math.atan(-1.0) else: tmp = math.atan((v / (v + ((H / v) * -9.8)))) return tmp
function code(v, H) tmp = 0.0 if (v <= -2.2e-137) tmp = atan(-1.0); else tmp = atan(Float64(v / Float64(v + Float64(Float64(H / v) * -9.8)))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -2.2e-137) tmp = atan(-1.0); else tmp = atan((v / (v + ((H / v) * -9.8)))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -2.2e-137], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(N[(H / v), $MachinePrecision] * -9.8), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2.2 \cdot 10^{-137}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + \frac{H}{v} \cdot -9.8}\right)\\
\end{array}
\end{array}
if v < -2.2000000000000001e-137Initial program 59.2%
sqr-neg59.2%
sqr-neg59.2%
metadata-eval59.2%
Simplified59.2%
Taylor expanded in v around -inf 81.5%
if -2.2000000000000001e-137 < v Initial program 71.3%
sqr-neg71.3%
sqr-neg71.3%
metadata-eval71.3%
Simplified71.3%
Taylor expanded in H around 0 66.8%
Final simplification72.5%
(FPCore (v H) :precision binary64 (if (<= v 1.78e-274) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= 1.78e-274) {
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.78d-274) 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.78e-274) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= 1.78e-274: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= 1.78e-274) 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.78e-274) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, 1.78e-274], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 1.78 \cdot 10^{-274}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < 1.77999999999999991e-274Initial program 67.8%
sqr-neg67.8%
sqr-neg67.8%
metadata-eval67.8%
Simplified67.8%
Taylor expanded in v around -inf 65.0%
if 1.77999999999999991e-274 < v Initial program 65.3%
sqr-neg65.3%
sqr-neg65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in v around inf 74.7%
(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 66.5%
sqr-neg66.5%
sqr-neg66.5%
metadata-eval66.5%
Simplified66.5%
Taylor expanded in v around -inf 33.1%
herbie shell --seed 2024185
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))