
(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 9 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+154) (atan (/ v (fabs (fma -9.8 (/ H v) v)))) (if (<= v 2e+145) (atan (/ v (sqrt (fma v v (* H -19.6))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1e+154) {
tmp = atan((v / fabs(fma(-9.8, (H / v), v))));
} else if (v <= 2e+145) {
tmp = atan((v / sqrt(fma(v, v, (H * -19.6)))));
} else {
tmp = atan(1.0);
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -1e+154) tmp = atan(Float64(v / abs(fma(-9.8, Float64(H / v), v)))); elseif (v <= 2e+145) tmp = atan(Float64(v / sqrt(fma(v, v, Float64(H * -19.6))))); else tmp = atan(1.0); end return tmp end
code[v_, H_] := If[LessEqual[v, -1e+154], N[ArcTan[N[(v / N[Abs[N[(-9.8 * N[(H / v), $MachinePrecision] + v), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 2e+145], N[ArcTan[N[(v / N[Sqrt[N[(v * v + 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^{+154}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\left|\mathsf{fma}\left(-9.8, \frac{H}{v}, v\right)\right|}\right)\\
\mathbf{elif}\;v \leq 2 \cdot 10^{+145}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(v, v, H \cdot -19.6\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.00000000000000004e154Initial program 3.0%
sqr-neg3.0%
sqr-neg3.0%
fmm-def3.0%
*-commutative3.0%
distribute-rgt-neg-in3.0%
metadata-eval3.0%
metadata-eval3.0%
Simplified3.0%
Taylor expanded in H around 0 1.6%
add-sqr-sqrt0.0%
sqrt-unprod3.1%
pow23.1%
+-commutative3.1%
fma-define3.1%
Applied egg-rr3.1%
unpow23.1%
rem-sqrt-square99.1%
Simplified99.1%
if -1.00000000000000004e154 < v < 2e145Initial program 99.7%
sqr-neg99.7%
sqr-neg99.7%
fmm-def99.7%
*-commutative99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
if 2e145 < v Initial program 14.1%
sqr-neg14.1%
sqr-neg14.1%
metadata-eval14.1%
Simplified14.1%
Taylor expanded in v around inf 100.0%
(FPCore (v H)
:precision binary64
(if (<= v -1.2e+154)
(atan (/ v (fabs (fma -9.8 (/ H v) v))))
(if (<= v 5e+141)
(atan (/ v (sqrt (- (* v v) (* H 19.6)))))
(atan (/ v (+ v (* -9.8 (/ H v))))))))
double code(double v, double H) {
double tmp;
if (v <= -1.2e+154) {
tmp = atan((v / fabs(fma(-9.8, (H / v), v))));
} else if (v <= 5e+141) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -1.2e+154) tmp = atan(Float64(v / abs(fma(-9.8, Float64(H / v), v)))); elseif (v <= 5e+141) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(H * 19.6))))); else tmp = atan(Float64(v / Float64(v + Float64(-9.8 * Float64(H / v))))); end return tmp end
code[v_, H_] := If[LessEqual[v, -1.2e+154], N[ArcTan[N[(v / N[Abs[N[(-9.8 * N[(H / v), $MachinePrecision] + v), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 5e+141], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(H * 19.6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.2 \cdot 10^{+154}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\left|\mathsf{fma}\left(-9.8, \frac{H}{v}, v\right)\right|}\right)\\
\mathbf{elif}\;v \leq 5 \cdot 10^{+141}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - H \cdot 19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + -9.8 \cdot \frac{H}{v}}\right)\\
\end{array}
\end{array}
if v < -1.20000000000000007e154Initial program 3.0%
sqr-neg3.0%
sqr-neg3.0%
fmm-def3.0%
*-commutative3.0%
distribute-rgt-neg-in3.0%
metadata-eval3.0%
metadata-eval3.0%
Simplified3.0%
Taylor expanded in H around 0 1.6%
add-sqr-sqrt0.0%
sqrt-unprod3.1%
pow23.1%
+-commutative3.1%
fma-define3.1%
Applied egg-rr3.1%
unpow23.1%
rem-sqrt-square99.1%
Simplified99.1%
if -1.20000000000000007e154 < v < 5.00000000000000025e141Initial program 99.7%
sqr-neg99.7%
sqr-neg99.7%
metadata-eval99.7%
Simplified99.7%
if 5.00000000000000025e141 < v Initial program 16.0%
sqr-neg16.0%
sqr-neg16.0%
fmm-def16.0%
*-commutative16.0%
distribute-rgt-neg-in16.0%
metadata-eval16.0%
metadata-eval16.0%
Simplified16.0%
Taylor expanded in H around 0 100.0%
Final simplification99.7%
(FPCore (v H)
:precision binary64
(if (<= v -1e+154)
(atan (+ (* -9.8 (/ (/ H v) v)) -1.0))
(if (<= v 8e+142)
(atan (/ v (sqrt (- (* v v) (* H 19.6)))))
(atan (/ v (+ v (* -9.8 (/ H v))))))))
double code(double v, double H) {
double tmp;
if (v <= -1e+154) {
tmp = atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 8e+142) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = atan((v / (v + (-9.8 * (H / 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+154)) then
tmp = atan((((-9.8d0) * ((h / v) / v)) + (-1.0d0)))
else if (v <= 8d+142) then
tmp = atan((v / sqrt(((v * v) - (h * 19.6d0)))))
else
tmp = atan((v / (v + ((-9.8d0) * (h / v)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1e+154) {
tmp = Math.atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 8e+142) {
tmp = Math.atan((v / Math.sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = Math.atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1e+154: tmp = math.atan(((-9.8 * ((H / v) / v)) + -1.0)) elif v <= 8e+142: tmp = math.atan((v / math.sqrt(((v * v) - (H * 19.6))))) else: tmp = math.atan((v / (v + (-9.8 * (H / v))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -1e+154) tmp = atan(Float64(Float64(-9.8 * Float64(Float64(H / v) / v)) + -1.0)); elseif (v <= 8e+142) tmp = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(H * 19.6))))); else tmp = atan(Float64(v / Float64(v + Float64(-9.8 * Float64(H / v))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1e+154) tmp = atan(((-9.8 * ((H / v) / v)) + -1.0)); elseif (v <= 8e+142) tmp = atan((v / sqrt(((v * v) - (H * 19.6))))); else tmp = atan((v / (v + (-9.8 * (H / v))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1e+154], N[ArcTan[N[(N[(-9.8 * N[(N[(H / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 8e+142], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(H * 19.6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\tan^{-1} \left(-9.8 \cdot \frac{\frac{H}{v}}{v} + -1\right)\\
\mathbf{elif}\;v \leq 8 \cdot 10^{+142}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - H \cdot 19.6}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + -9.8 \cdot \frac{H}{v}}\right)\\
\end{array}
\end{array}
if v < -1.00000000000000004e154Initial program 3.0%
sqr-neg3.0%
sqr-neg3.0%
metadata-eval3.0%
Simplified3.0%
Taylor expanded in v around -inf 98.4%
add-sqr-sqrt57.9%
unpow257.9%
times-frac58.5%
Applied egg-rr58.5%
associate-*l/58.5%
associate-*r/58.5%
rem-square-sqrt99.0%
Simplified99.0%
if -1.00000000000000004e154 < v < 8.00000000000000041e142Initial program 99.7%
sqr-neg99.7%
sqr-neg99.7%
metadata-eval99.7%
Simplified99.7%
if 8.00000000000000041e142 < v Initial program 16.0%
sqr-neg16.0%
sqr-neg16.0%
fmm-def16.0%
*-commutative16.0%
distribute-rgt-neg-in16.0%
metadata-eval16.0%
metadata-eval16.0%
Simplified16.0%
Taylor expanded in H around 0 100.0%
Final simplification99.7%
(FPCore (v H)
:precision binary64
(if (<= v -2.06e-16)
(atan (+ (* -9.8 (/ (/ H v) v)) -1.0))
(if (<= v 1.4e-70)
(atan (* v (sqrt (* (/ 1.0 H) -0.05102040816326531))))
(atan (/ v (+ v (* -9.8 (/ H v))))))))
double code(double v, double H) {
double tmp;
if (v <= -2.06e-16) {
tmp = atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 1.4e-70) {
tmp = atan((v * sqrt(((1.0 / H) * -0.05102040816326531))));
} else {
tmp = atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-2.06d-16)) then
tmp = atan((((-9.8d0) * ((h / v) / v)) + (-1.0d0)))
else if (v <= 1.4d-70) then
tmp = atan((v * sqrt(((1.0d0 / h) * (-0.05102040816326531d0)))))
else
tmp = atan((v / (v + ((-9.8d0) * (h / v)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -2.06e-16) {
tmp = Math.atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 1.4e-70) {
tmp = Math.atan((v * Math.sqrt(((1.0 / H) * -0.05102040816326531))));
} else {
tmp = Math.atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -2.06e-16: tmp = math.atan(((-9.8 * ((H / v) / v)) + -1.0)) elif v <= 1.4e-70: tmp = math.atan((v * math.sqrt(((1.0 / H) * -0.05102040816326531)))) else: tmp = math.atan((v / (v + (-9.8 * (H / v))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -2.06e-16) tmp = atan(Float64(Float64(-9.8 * Float64(Float64(H / v) / v)) + -1.0)); elseif (v <= 1.4e-70) tmp = atan(Float64(v * sqrt(Float64(Float64(1.0 / H) * -0.05102040816326531)))); else tmp = atan(Float64(v / Float64(v + Float64(-9.8 * Float64(H / v))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -2.06e-16) tmp = atan(((-9.8 * ((H / v) / v)) + -1.0)); elseif (v <= 1.4e-70) tmp = atan((v * sqrt(((1.0 / H) * -0.05102040816326531)))); else tmp = atan((v / (v + (-9.8 * (H / v))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -2.06e-16], N[ArcTan[N[(N[(-9.8 * N[(N[(H / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.4e-70], N[ArcTan[N[(v * N[Sqrt[N[(N[(1.0 / H), $MachinePrecision] * -0.05102040816326531), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2.06 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1} \left(-9.8 \cdot \frac{\frac{H}{v}}{v} + -1\right)\\
\mathbf{elif}\;v \leq 1.4 \cdot 10^{-70}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{1}{H} \cdot -0.05102040816326531}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + -9.8 \cdot \frac{H}{v}}\right)\\
\end{array}
\end{array}
if v < -2.0599999999999999e-16Initial program 53.9%
sqr-neg53.9%
sqr-neg53.9%
metadata-eval53.9%
Simplified53.9%
Taylor expanded in v around -inf 94.6%
add-sqr-sqrt53.1%
unpow253.1%
times-frac53.4%
Applied egg-rr53.4%
associate-*l/53.4%
associate-*r/53.4%
rem-square-sqrt94.9%
Simplified94.9%
if -2.0599999999999999e-16 < v < 1.4e-70Initial 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 88.2%
clear-num88.1%
associate-/r/88.2%
Applied egg-rr88.2%
if 1.4e-70 < v Initial program 62.9%
sqr-neg62.9%
sqr-neg62.9%
fmm-def62.9%
*-commutative62.9%
distribute-rgt-neg-in62.9%
metadata-eval62.9%
metadata-eval62.9%
Simplified62.9%
Taylor expanded in H around 0 90.0%
Final simplification90.9%
(FPCore (v H)
:precision binary64
(if (<= v -1.78e-16)
(atan (+ (* -9.8 (/ (/ H v) v)) -1.0))
(if (<= v 1.4e-70)
(atan (* v (sqrt (/ -0.05102040816326531 H))))
(atan (/ v (+ v (* -9.8 (/ H v))))))))
double code(double v, double H) {
double tmp;
if (v <= -1.78e-16) {
tmp = atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 1.4e-70) {
tmp = atan((v * sqrt((-0.05102040816326531 / H))));
} else {
tmp = atan((v / (v + (-9.8 * (H / v)))));
}
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-16)) then
tmp = atan((((-9.8d0) * ((h / v) / v)) + (-1.0d0)))
else if (v <= 1.4d-70) then
tmp = atan((v * sqrt(((-0.05102040816326531d0) / h))))
else
tmp = atan((v / (v + ((-9.8d0) * (h / v)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.78e-16) {
tmp = Math.atan(((-9.8 * ((H / v) / v)) + -1.0));
} else if (v <= 1.4e-70) {
tmp = Math.atan((v * Math.sqrt((-0.05102040816326531 / H))));
} else {
tmp = Math.atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.78e-16: tmp = math.atan(((-9.8 * ((H / v) / v)) + -1.0)) elif v <= 1.4e-70: tmp = math.atan((v * math.sqrt((-0.05102040816326531 / H)))) else: tmp = math.atan((v / (v + (-9.8 * (H / v))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.78e-16) tmp = atan(Float64(Float64(-9.8 * Float64(Float64(H / v) / v)) + -1.0)); elseif (v <= 1.4e-70) tmp = atan(Float64(v * sqrt(Float64(-0.05102040816326531 / H)))); else tmp = atan(Float64(v / Float64(v + Float64(-9.8 * Float64(H / v))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.78e-16) tmp = atan(((-9.8 * ((H / v) / v)) + -1.0)); elseif (v <= 1.4e-70) tmp = atan((v * sqrt((-0.05102040816326531 / H)))); else tmp = atan((v / (v + (-9.8 * (H / v))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.78e-16], N[ArcTan[N[(N[(-9.8 * N[(N[(H / v), $MachinePrecision] / v), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.4e-70], N[ArcTan[N[(v * N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.78 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1} \left(-9.8 \cdot \frac{\frac{H}{v}}{v} + -1\right)\\
\mathbf{elif}\;v \leq 1.4 \cdot 10^{-70}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{-0.05102040816326531}{H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + -9.8 \cdot \frac{H}{v}}\right)\\
\end{array}
\end{array}
if v < -1.78000000000000008e-16Initial program 53.9%
sqr-neg53.9%
sqr-neg53.9%
metadata-eval53.9%
Simplified53.9%
Taylor expanded in v around -inf 94.6%
add-sqr-sqrt53.1%
unpow253.1%
times-frac53.4%
Applied egg-rr53.4%
associate-*l/53.4%
associate-*r/53.4%
rem-square-sqrt94.9%
Simplified94.9%
if -1.78000000000000008e-16 < v < 1.4e-70Initial 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 88.2%
if 1.4e-70 < v Initial program 62.9%
sqr-neg62.9%
sqr-neg62.9%
fmm-def62.9%
*-commutative62.9%
distribute-rgt-neg-in62.9%
metadata-eval62.9%
metadata-eval62.9%
Simplified62.9%
Taylor expanded in H around 0 90.0%
Final simplification90.9%
(FPCore (v H) :precision binary64 (if (<= v -1.05e-185) (atan -1.0) (if (<= v 3.4e-139) (atan (/ v (* -9.8 (/ H v)))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1.05e-185) {
tmp = atan(-1.0);
} else if (v <= 3.4e-139) {
tmp = atan((v / (-9.8 * (H / v))));
} 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.05d-185)) then
tmp = atan((-1.0d0))
else if (v <= 3.4d-139) then
tmp = atan((v / ((-9.8d0) * (h / v))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.05e-185) {
tmp = Math.atan(-1.0);
} else if (v <= 3.4e-139) {
tmp = Math.atan((v / (-9.8 * (H / v))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.05e-185: tmp = math.atan(-1.0) elif v <= 3.4e-139: tmp = math.atan((v / (-9.8 * (H / v)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.05e-185) tmp = atan(-1.0); elseif (v <= 3.4e-139) tmp = atan(Float64(v / Float64(-9.8 * Float64(H / v)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.05e-185) tmp = atan(-1.0); elseif (v <= 3.4e-139) tmp = atan((v / (-9.8 * (H / v)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.05e-185], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 3.4e-139], N[ArcTan[N[(v / N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.05 \cdot 10^{-185}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 3.4 \cdot 10^{-139}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{-9.8 \cdot \frac{H}{v}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.05e-185Initial program 65.3%
sqr-neg65.3%
sqr-neg65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in v around -inf 76.8%
if -1.05e-185 < v < 3.39999999999999999e-139Initial program 99.6%
sqr-neg99.6%
sqr-neg99.6%
fmm-def99.6%
*-commutative99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in H around 0 36.0%
Taylor expanded in v around 0 36.0%
if 3.39999999999999999e-139 < v Initial program 67.3%
sqr-neg67.3%
sqr-neg67.3%
metadata-eval67.3%
Simplified67.3%
Taylor expanded in v around inf 83.2%
(FPCore (v H) :precision binary64 (if (<= v -1.05e-185) (atan -1.0) (atan (/ v (+ v (* -9.8 (/ H v)))))))
double code(double v, double H) {
double tmp;
if (v <= -1.05e-185) {
tmp = atan(-1.0);
} else {
tmp = atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= (-1.05d-185)) then
tmp = atan((-1.0d0))
else
tmp = atan((v / (v + ((-9.8d0) * (h / v)))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -1.05e-185) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan((v / (v + (-9.8 * (H / v)))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.05e-185: tmp = math.atan(-1.0) else: tmp = math.atan((v / (v + (-9.8 * (H / v))))) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.05e-185) tmp = atan(-1.0); else tmp = atan(Float64(v / Float64(v + Float64(-9.8 * Float64(H / v))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -1.05e-185) tmp = atan(-1.0); else tmp = atan((v / (v + (-9.8 * (H / v))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.05e-185], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[N[(v / N[(v + N[(-9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.05 \cdot 10^{-185}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + -9.8 \cdot \frac{H}{v}}\right)\\
\end{array}
\end{array}
if v < -1.05e-185Initial program 65.3%
sqr-neg65.3%
sqr-neg65.3%
metadata-eval65.3%
Simplified65.3%
Taylor expanded in v around -inf 76.8%
if -1.05e-185 < v Initial program 75.0%
sqr-neg75.0%
sqr-neg75.0%
fmm-def75.0%
*-commutative75.0%
distribute-rgt-neg-in75.0%
metadata-eval75.0%
metadata-eval75.0%
Simplified75.0%
Taylor expanded in H around 0 72.6%
(FPCore (v H) :precision binary64 (if (<= v 6e-307) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= 6e-307) {
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 <= 6d-307) 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 <= 6e-307) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= 6e-307: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= 6e-307) tmp = atan(-1.0); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= 6e-307) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, 6e-307], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 6 \cdot 10^{-307}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < 5.9999999999999999e-307Initial program 69.9%
sqr-neg69.9%
sqr-neg69.9%
metadata-eval69.9%
Simplified69.9%
Taylor expanded in v around -inf 67.0%
if 5.9999999999999999e-307 < v Initial program 72.1%
sqr-neg72.1%
sqr-neg72.1%
metadata-eval72.1%
Simplified72.1%
Taylor expanded in v around inf 71.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 71.0%
sqr-neg71.0%
sqr-neg71.0%
metadata-eval71.0%
Simplified71.0%
Taylor expanded in v around -inf 32.4%
herbie shell --seed 2024165
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))