
(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 -4.9e+58)
(atan -1.0)
(if (<= v 8.2e+120)
(atan (* v (sqrt (/ -1.0 (- (* 19.6 H) (* v v))))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -4.9e+58) {
tmp = atan(-1.0);
} else if (v <= 8.2e+120) {
tmp = atan((v * sqrt((-1.0 / ((19.6 * H) - (v * 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 <= (-4.9d+58)) then
tmp = atan((-1.0d0))
else if (v <= 8.2d+120) then
tmp = atan((v * sqrt(((-1.0d0) / ((19.6d0 * h) - (v * v))))))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -4.9e+58) {
tmp = Math.atan(-1.0);
} else if (v <= 8.2e+120) {
tmp = Math.atan((v * Math.sqrt((-1.0 / ((19.6 * H) - (v * v))))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -4.9e+58: tmp = math.atan(-1.0) elif v <= 8.2e+120: tmp = math.atan((v * math.sqrt((-1.0 / ((19.6 * H) - (v * v)))))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -4.9e+58) tmp = atan(-1.0); elseif (v <= 8.2e+120) tmp = atan(Float64(v * sqrt(Float64(-1.0 / Float64(Float64(19.6 * H) - Float64(v * v)))))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -4.9e+58) tmp = atan(-1.0); elseif (v <= 8.2e+120) tmp = atan((v * sqrt((-1.0 / ((19.6 * H) - (v * v)))))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -4.9e+58], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 8.2e+120], N[ArcTan[N[(v * N[Sqrt[N[(-1.0 / N[(N[(19.6 * H), $MachinePrecision] - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -4.9 \cdot 10^{+58}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 8.2 \cdot 10^{+120}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \sqrt{\frac{-1}{19.6 \cdot H - v \cdot v}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -4.90000000000000018e58Initial program 39.5%
sqr-neg39.5%
sqr-neg39.5%
metadata-eval39.5%
Simplified39.5%
Taylor expanded in v around -inf 100.0%
if -4.90000000000000018e58 < v < 8.2e120Initial program 99.6%
sqr-neg99.6%
sqr-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in v around 0 99.7%
unpow299.7%
Applied egg-rr99.7%
if 8.2e120 < v Initial program 25.9%
sqr-neg25.9%
sqr-neg25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in v around inf 100.0%
Final simplification99.8%
(FPCore (v H) :precision binary64 (if (<= v -2e+159) (atan -1.0) (if (<= v 8.2e+120) (atan (/ v (sqrt (- (* v v) (* 19.6 H))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -2e+159) {
tmp = atan(-1.0);
} else if (v <= 8.2e+120) {
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 <= (-2d+159)) then
tmp = atan((-1.0d0))
else if (v <= 8.2d+120) 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 <= -2e+159) {
tmp = Math.atan(-1.0);
} else if (v <= 8.2e+120) {
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 <= -2e+159: tmp = math.atan(-1.0) elif v <= 8.2e+120: 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 <= -2e+159) tmp = atan(-1.0); elseif (v <= 8.2e+120) 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 <= -2e+159) tmp = atan(-1.0); elseif (v <= 8.2e+120) 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, -2e+159], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 8.2e+120], 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 -2 \cdot 10^{+159}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 8.2 \cdot 10^{+120}:\\
\;\;\;\;\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 < -1.9999999999999999e159Initial program 3.1%
sqr-neg3.1%
sqr-neg3.1%
metadata-eval3.1%
Simplified3.1%
Taylor expanded in v around -inf 100.0%
if -1.9999999999999999e159 < v < 8.2e120Initial program 99.7%
sqr-neg99.7%
sqr-neg99.7%
metadata-eval99.7%
Simplified99.7%
if 8.2e120 < v Initial program 25.9%
sqr-neg25.9%
sqr-neg25.9%
metadata-eval25.9%
Simplified25.9%
Taylor expanded in v around inf 100.0%
(FPCore (v H)
:precision binary64
(if (<= v -4.6e-13)
(atan (/ v (- (* 9.8 (/ H v)) v)))
(if (<= v 3.05e-71)
(atan (* v (sqrt (/ -0.05102040816326531 H))))
(atan (/ v (+ v (* (/ H v) -9.8)))))))
double code(double v, double H) {
double tmp;
if (v <= -4.6e-13) {
tmp = atan((v / ((9.8 * (H / v)) - v)));
} else if (v <= 3.05e-71) {
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 <= (-4.6d-13)) then
tmp = atan((v / ((9.8d0 * (h / v)) - v)))
else if (v <= 3.05d-71) 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 <= -4.6e-13) {
tmp = Math.atan((v / ((9.8 * (H / v)) - v)));
} else if (v <= 3.05e-71) {
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 <= -4.6e-13: tmp = math.atan((v / ((9.8 * (H / v)) - v))) elif v <= 3.05e-71: 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 <= -4.6e-13) tmp = atan(Float64(v / Float64(Float64(9.8 * Float64(H / v)) - v))); elseif (v <= 3.05e-71) 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 <= -4.6e-13) tmp = atan((v / ((9.8 * (H / v)) - v))); elseif (v <= 3.05e-71) 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, -4.6e-13], N[ArcTan[N[(v / N[(N[(9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision] - v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 3.05e-71], 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 -4.6 \cdot 10^{-13}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{9.8 \cdot \frac{H}{v} - v}\right)\\
\mathbf{elif}\;v \leq 3.05 \cdot 10^{-71}:\\
\;\;\;\;\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 < -4.59999999999999958e-13Initial program 47.5%
sqr-neg47.5%
sqr-neg47.5%
metadata-eval47.5%
Simplified47.5%
frac-2neg47.5%
div-inv47.5%
sub-neg47.5%
add-sqr-sqrt25.0%
hypot-define54.2%
*-commutative54.2%
distribute-rgt-neg-in54.2%
metadata-eval54.2%
Applied egg-rr54.2%
Taylor expanded in H around 0 0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt1.6%
Simplified1.6%
distribute-lft-neg-out1.6%
neg-sub01.6%
add-sqr-sqrt0.0%
sqrt-prod52.7%
sqr-neg52.7%
sqrt-unprod96.3%
add-sqr-sqrt96.7%
associate-*r/96.7%
frac-2neg96.7%
*-rgt-identity96.7%
add-sqr-sqrt96.2%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-prod0.0%
add-sqr-sqrt1.6%
add-sqr-sqrt1.6%
sqrt-unprod1.6%
sqr-neg1.6%
sqrt-prod0.0%
add-sqr-sqrt96.7%
remove-double-neg96.7%
+-commutative96.7%
fma-define96.7%
Applied egg-rr96.7%
neg-sub096.7%
distribute-neg-frac296.7%
fma-define96.7%
distribute-neg-in96.7%
*-rgt-identity96.7%
unsub-neg96.7%
*-rgt-identity96.7%
associate-*r*96.7%
metadata-eval96.7%
distribute-lft-neg-in96.7%
metadata-eval96.7%
Simplified96.7%
if -4.59999999999999958e-13 < v < 3.0499999999999999e-71Initial program 99.5%
sqr-neg99.5%
sqr-neg99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in v around 0 99.6%
Taylor expanded in v around 0 90.5%
if 3.0499999999999999e-71 < v Initial program 57.0%
sqr-neg57.0%
sqr-neg57.0%
metadata-eval57.0%
Simplified57.0%
Taylor expanded in H around 0 89.4%
Final simplification92.1%
(FPCore (v H) :precision binary64 (if (<= v 2e-296) (atan (/ v (- (* 9.8 (/ H v)) v))) (atan (* v (/ 1.0 (+ v (* 0.5 (* H (/ -19.6 v)))))))))
double code(double v, double H) {
double tmp;
if (v <= 2e-296) {
tmp = atan((v / ((9.8 * (H / v)) - v)));
} else {
tmp = atan((v * (1.0 / (v + (0.5 * (H * (-19.6 / v)))))));
}
return tmp;
}
real(8) function code(v, h)
real(8), intent (in) :: v
real(8), intent (in) :: h
real(8) :: tmp
if (v <= 2d-296) then
tmp = atan((v / ((9.8d0 * (h / v)) - v)))
else
tmp = atan((v * (1.0d0 / (v + (0.5d0 * (h * ((-19.6d0) / v)))))))
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= 2e-296) {
tmp = Math.atan((v / ((9.8 * (H / v)) - v)));
} else {
tmp = Math.atan((v * (1.0 / (v + (0.5 * (H * (-19.6 / v)))))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= 2e-296: tmp = math.atan((v / ((9.8 * (H / v)) - v))) else: tmp = math.atan((v * (1.0 / (v + (0.5 * (H * (-19.6 / v))))))) return tmp
function code(v, H) tmp = 0.0 if (v <= 2e-296) tmp = atan(Float64(v / Float64(Float64(9.8 * Float64(H / v)) - v))); else tmp = atan(Float64(v * Float64(1.0 / Float64(v + Float64(0.5 * Float64(H * Float64(-19.6 / v))))))); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= 2e-296) tmp = atan((v / ((9.8 * (H / v)) - v))); else tmp = atan((v * (1.0 / (v + (0.5 * (H * (-19.6 / v))))))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, 2e-296], N[ArcTan[N[(v / N[(N[(9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision] - v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v * N[(1.0 / N[(v + N[(0.5 * N[(H * N[(-19.6 / v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq 2 \cdot 10^{-296}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{9.8 \cdot \frac{H}{v} - v}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(v \cdot \frac{1}{v + 0.5 \cdot \left(H \cdot \frac{-19.6}{v}\right)}\right)\\
\end{array}
\end{array}
if v < 2e-296Initial program 65.8%
sqr-neg65.8%
sqr-neg65.8%
metadata-eval65.8%
Simplified65.8%
frac-2neg65.8%
div-inv65.8%
sub-neg65.8%
add-sqr-sqrt48.9%
hypot-define67.8%
*-commutative67.8%
distribute-rgt-neg-in67.8%
metadata-eval67.8%
Applied egg-rr67.8%
Taylor expanded in H around 0 0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt5.6%
Simplified5.6%
distribute-lft-neg-out5.6%
neg-sub05.6%
add-sqr-sqrt0.1%
sqrt-prod43.4%
sqr-neg43.4%
sqrt-unprod71.6%
add-sqr-sqrt72.0%
associate-*r/72.0%
frac-2neg72.0%
*-rgt-identity72.0%
add-sqr-sqrt71.5%
sqrt-unprod43.4%
sqr-neg43.4%
sqrt-prod0.1%
add-sqr-sqrt5.6%
add-sqr-sqrt5.5%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-prod0.1%
add-sqr-sqrt72.0%
remove-double-neg72.0%
+-commutative72.0%
fma-define72.0%
Applied egg-rr72.0%
neg-sub072.0%
distribute-neg-frac272.0%
fma-define72.0%
distribute-neg-in72.0%
*-rgt-identity72.0%
unsub-neg72.0%
*-rgt-identity72.0%
associate-*r*72.0%
metadata-eval72.0%
distribute-lft-neg-in72.0%
metadata-eval72.0%
Simplified72.0%
if 2e-296 < v Initial program 70.2%
sqr-neg70.2%
sqr-neg70.2%
metadata-eval70.2%
Simplified70.2%
frac-2neg70.2%
div-inv70.2%
sub-neg70.2%
add-sqr-sqrt52.6%
hypot-define68.5%
*-commutative68.5%
distribute-rgt-neg-in68.5%
metadata-eval68.5%
Applied egg-rr68.5%
Taylor expanded in H around 0 0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt68.9%
Simplified68.9%
Final simplification70.4%
(FPCore (v H)
:precision binary64
(if (<= v -6.4e-143)
(atan -1.0)
(if (<= v 9.8e-123)
(atan (* v (* -0.10204081632653061 (/ v H))))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -6.4e-143) {
tmp = atan(-1.0);
} else if (v <= 9.8e-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 <= (-6.4d-143)) then
tmp = atan((-1.0d0))
else if (v <= 9.8d-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 <= -6.4e-143) {
tmp = Math.atan(-1.0);
} else if (v <= 9.8e-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 <= -6.4e-143: tmp = math.atan(-1.0) elif v <= 9.8e-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 <= -6.4e-143) tmp = atan(-1.0); elseif (v <= 9.8e-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 <= -6.4e-143) tmp = atan(-1.0); elseif (v <= 9.8e-123) tmp = atan((v * (-0.10204081632653061 * (v / H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -6.4e-143], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 9.8e-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 -6.4 \cdot 10^{-143}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 9.8 \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 < -6.3999999999999997e-143Initial program 58.0%
sqr-neg58.0%
sqr-neg58.0%
metadata-eval58.0%
Simplified58.0%
Taylor expanded in v around -inf 83.2%
if -6.3999999999999997e-143 < v < 9.7999999999999996e-123Initial program 99.5%
sqr-neg99.5%
sqr-neg99.5%
metadata-eval99.5%
Simplified99.5%
frac-2neg99.5%
div-inv99.5%
sub-neg99.5%
add-sqr-sqrt99.5%
hypot-define99.5%
*-commutative99.5%
distribute-rgt-neg-in99.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in H around 0 0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt23.0%
Simplified23.0%
Taylor expanded in v around 0 23.0%
*-commutative23.0%
Simplified23.0%
distribute-lft-neg-out23.0%
Applied egg-rr23.0%
distribute-rgt-neg-in23.0%
*-commutative23.0%
distribute-lft-neg-in23.0%
metadata-eval23.0%
Simplified23.0%
if 9.7999999999999996e-123 < v Initial program 61.6%
sqr-neg61.6%
sqr-neg61.6%
metadata-eval61.6%
Simplified61.6%
Taylor expanded in v around inf 81.6%
(FPCore (v H) :precision binary64 (if (<= v 2e-296) (atan (/ v (- (* 9.8 (/ H v)) v))) (atan (/ v (+ v (* (/ H v) -9.8))))))
double code(double v, double H) {
double tmp;
if (v <= 2e-296) {
tmp = atan((v / ((9.8 * (H / v)) - v)));
} 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 <= 2d-296) then
tmp = atan((v / ((9.8d0 * (h / v)) - v)))
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 <= 2e-296) {
tmp = Math.atan((v / ((9.8 * (H / v)) - v)));
} else {
tmp = Math.atan((v / (v + ((H / v) * -9.8))));
}
return tmp;
}
def code(v, H): tmp = 0 if v <= 2e-296: tmp = math.atan((v / ((9.8 * (H / v)) - v))) else: tmp = math.atan((v / (v + ((H / v) * -9.8)))) return tmp
function code(v, H) tmp = 0.0 if (v <= 2e-296) tmp = atan(Float64(v / Float64(Float64(9.8 * Float64(H / v)) - v))); 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 <= 2e-296) tmp = atan((v / ((9.8 * (H / v)) - v))); else tmp = atan((v / (v + ((H / v) * -9.8)))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, 2e-296], N[ArcTan[N[(v / N[(N[(9.8 * N[(H / v), $MachinePrecision]), $MachinePrecision] - v), $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 2 \cdot 10^{-296}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{9.8 \cdot \frac{H}{v} - v}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + \frac{H}{v} \cdot -9.8}\right)\\
\end{array}
\end{array}
if v < 2e-296Initial program 65.8%
sqr-neg65.8%
sqr-neg65.8%
metadata-eval65.8%
Simplified65.8%
frac-2neg65.8%
div-inv65.8%
sub-neg65.8%
add-sqr-sqrt48.9%
hypot-define67.8%
*-commutative67.8%
distribute-rgt-neg-in67.8%
metadata-eval67.8%
Applied egg-rr67.8%
Taylor expanded in H around 0 0.0%
associate-/l*0.0%
unpow20.0%
rem-square-sqrt5.6%
Simplified5.6%
distribute-lft-neg-out5.6%
neg-sub05.6%
add-sqr-sqrt0.1%
sqrt-prod43.4%
sqr-neg43.4%
sqrt-unprod71.6%
add-sqr-sqrt72.0%
associate-*r/72.0%
frac-2neg72.0%
*-rgt-identity72.0%
add-sqr-sqrt71.5%
sqrt-unprod43.4%
sqr-neg43.4%
sqrt-prod0.1%
add-sqr-sqrt5.6%
add-sqr-sqrt5.5%
sqrt-unprod5.7%
sqr-neg5.7%
sqrt-prod0.1%
add-sqr-sqrt72.0%
remove-double-neg72.0%
+-commutative72.0%
fma-define72.0%
Applied egg-rr72.0%
neg-sub072.0%
distribute-neg-frac272.0%
fma-define72.0%
distribute-neg-in72.0%
*-rgt-identity72.0%
unsub-neg72.0%
*-rgt-identity72.0%
associate-*r*72.0%
metadata-eval72.0%
distribute-lft-neg-in72.0%
metadata-eval72.0%
Simplified72.0%
if 2e-296 < v Initial program 70.2%
sqr-neg70.2%
sqr-neg70.2%
metadata-eval70.2%
Simplified70.2%
Taylor expanded in H around 0 68.8%
Final simplification70.4%
(FPCore (v H) :precision binary64 (if (<= v -6.8e-143) (atan -1.0) (atan (/ v (+ v (* (/ H v) -9.8))))))
double code(double v, double H) {
double tmp;
if (v <= -6.8e-143) {
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 <= (-6.8d-143)) 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 <= -6.8e-143) {
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 <= -6.8e-143: 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 <= -6.8e-143) 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 <= -6.8e-143) tmp = atan(-1.0); else tmp = atan((v / (v + ((H / v) * -9.8)))); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -6.8e-143], 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 -6.8 \cdot 10^{-143}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{v + \frac{H}{v} \cdot -9.8}\right)\\
\end{array}
\end{array}
if v < -6.79999999999999966e-143Initial program 58.0%
sqr-neg58.0%
sqr-neg58.0%
metadata-eval58.0%
Simplified58.0%
Taylor expanded in v around -inf 83.2%
if -6.79999999999999966e-143 < v Initial program 74.9%
sqr-neg74.9%
sqr-neg74.9%
metadata-eval74.9%
Simplified74.9%
Taylor expanded in H around 0 61.4%
Final simplification70.3%
(FPCore (v H) :precision binary64 (if (<= v -1.35e-298) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= -1.35e-298) {
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.35d-298)) 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.35e-298) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -1.35e-298: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -1.35e-298) 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.35e-298) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -1.35e-298], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1.35 \cdot 10^{-298}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.3500000000000001e-298Initial program 64.7%
sqr-neg64.7%
sqr-neg64.7%
metadata-eval64.7%
Simplified64.7%
Taylor expanded in v around -inf 70.5%
if -1.3500000000000001e-298 < v Initial program 71.1%
sqr-neg71.1%
sqr-neg71.1%
metadata-eval71.1%
Simplified71.1%
Taylor expanded in v around inf 62.3%
(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 68.0%
sqr-neg68.0%
sqr-neg68.0%
metadata-eval68.0%
Simplified68.0%
Taylor expanded in v around -inf 35.1%
herbie shell --seed 2024150
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))