
(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)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, h)
use fmin_fmax_functions
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 5 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)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, h)
use fmin_fmax_functions
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 -5e+142)
(atan (/ v (* -1.0 (* (fma -9.8 (/ H (* v v)) 1.0) v))))
(if (<= v 3e+119)
(atan
(* (pow (pow (fma (pow v 1.0) (pow v 1.0) (* -19.6 H)) -1.0) 0.5) v))
(atan
(/
v
(fma (fma (/ H (* (* v v) v)) -48.02 (* -9.8 (pow v -1.0))) H v))))))
double code(double v, double H) {
double tmp;
if (v <= -5e+142) {
tmp = atan((v / (-1.0 * (fma(-9.8, (H / (v * v)), 1.0) * v))));
} else if (v <= 3e+119) {
tmp = atan((pow(pow(fma(pow(v, 1.0), pow(v, 1.0), (-19.6 * H)), -1.0), 0.5) * v));
} else {
tmp = atan((v / fma(fma((H / ((v * v) * v)), -48.02, (-9.8 * pow(v, -1.0))), H, v)));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -5e+142) tmp = atan(Float64(v / Float64(-1.0 * Float64(fma(-9.8, Float64(H / Float64(v * v)), 1.0) * v)))); elseif (v <= 3e+119) tmp = atan(Float64(((fma((v ^ 1.0), (v ^ 1.0), Float64(-19.6 * H)) ^ -1.0) ^ 0.5) * v)); else tmp = atan(Float64(v / fma(fma(Float64(H / Float64(Float64(v * v) * v)), -48.02, Float64(-9.8 * (v ^ -1.0))), H, v))); end return tmp end
code[v_, H_] := If[LessEqual[v, -5e+142], N[ArcTan[N[(v / N[(-1.0 * N[(N[(-9.8 * N[(H / N[(v * v), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 3e+119], N[ArcTan[N[(N[Power[N[Power[N[(N[Power[v, 1.0], $MachinePrecision] * N[Power[v, 1.0], $MachinePrecision] + N[(-19.6 * H), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(N[(N[(H / N[(N[(v * v), $MachinePrecision] * v), $MachinePrecision]), $MachinePrecision] * -48.02 + N[(-9.8 * N[Power[v, -1.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * H + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -5 \cdot 10^{+142}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{-1 \cdot \left(\mathsf{fma}\left(-9.8, \frac{H}{v \cdot v}, 1\right) \cdot v\right)}\right)\\
\mathbf{elif}\;v \leq 3 \cdot 10^{+119}:\\
\;\;\;\;\tan^{-1} \left({\left({\left(\mathsf{fma}\left({v}^{1}, {v}^{1}, -19.6 \cdot H\right)\right)}^{-1}\right)}^{0.5} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\mathsf{fma}\left(\frac{H}{\left(v \cdot v\right) \cdot v}, -48.02, -9.8 \cdot {v}^{-1}\right), H, v\right)}\right)\\
\end{array}
\end{array}
if v < -5.0000000000000001e142Initial program 7.7%
Taylor expanded in v around -inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6497.7
Applied rewrites97.7%
if -5.0000000000000001e142 < v < 3.00000000000000001e119Initial program 99.7%
Taylor expanded in v around 0
Applied rewrites99.8%
if 3.00000000000000001e119 < v Initial program 21.3%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
metadata-evalN/A
lower-*.f64N/A
inv-powN/A
lower-pow.f64100.0
Applied rewrites100.0%
(FPCore (v H)
:precision binary64
(if (<= v -5e+142)
(atan (/ v (* -1.0 (* (fma -9.8 (/ H (* v v)) 1.0) v))))
(if (<= v 1.4e+154)
(atan
(* (pow (pow (fma (pow v 1.0) (pow v 1.0) (* -19.6 H)) -1.0) 0.5) v))
(atan
(*
(pow
(/ (- (* (/ (* v v) H) -0.002603082049146189) 0.05102040816326531) H)
0.5)
v)))))
double code(double v, double H) {
double tmp;
if (v <= -5e+142) {
tmp = atan((v / (-1.0 * (fma(-9.8, (H / (v * v)), 1.0) * v))));
} else if (v <= 1.4e+154) {
tmp = atan((pow(pow(fma(pow(v, 1.0), pow(v, 1.0), (-19.6 * H)), -1.0), 0.5) * v));
} else {
tmp = atan((pow((((((v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H), 0.5) * v));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -5e+142) tmp = atan(Float64(v / Float64(-1.0 * Float64(fma(-9.8, Float64(H / Float64(v * v)), 1.0) * v)))); elseif (v <= 1.4e+154) tmp = atan(Float64(((fma((v ^ 1.0), (v ^ 1.0), Float64(-19.6 * H)) ^ -1.0) ^ 0.5) * v)); else tmp = atan(Float64((Float64(Float64(Float64(Float64(Float64(v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H) ^ 0.5) * v)); end return tmp end
code[v_, H_] := If[LessEqual[v, -5e+142], N[ArcTan[N[(v / N[(-1.0 * N[(N[(-9.8 * N[(H / N[(v * v), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 1.4e+154], N[ArcTan[N[(N[Power[N[Power[N[(N[Power[v, 1.0], $MachinePrecision] * N[Power[v, 1.0], $MachinePrecision] + N[(-19.6 * H), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Power[N[(N[(N[(N[(N[(v * v), $MachinePrecision] / H), $MachinePrecision] * -0.002603082049146189), $MachinePrecision] - 0.05102040816326531), $MachinePrecision] / H), $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -5 \cdot 10^{+142}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{-1 \cdot \left(\mathsf{fma}\left(-9.8, \frac{H}{v \cdot v}, 1\right) \cdot v\right)}\right)\\
\mathbf{elif}\;v \leq 1.4 \cdot 10^{+154}:\\
\;\;\;\;\tan^{-1} \left({\left({\left(\mathsf{fma}\left({v}^{1}, {v}^{1}, -19.6 \cdot H\right)\right)}^{-1}\right)}^{0.5} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left({\left(\frac{\frac{v \cdot v}{H} \cdot -0.002603082049146189 - 0.05102040816326531}{H}\right)}^{0.5} \cdot v\right)\\
\end{array}
\end{array}
if v < -5.0000000000000001e142Initial program 7.7%
Taylor expanded in v around -inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6497.7
Applied rewrites97.7%
if -5.0000000000000001e142 < v < 1.4e154Initial program 99.7%
Taylor expanded in v around 0
Applied rewrites99.8%
if 1.4e154 < v Initial program 3.1%
Taylor expanded in v around 0
Applied rewrites3.1%
Taylor expanded in H around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6418.8
Applied rewrites18.8%
(FPCore (v H)
:precision binary64
(let* ((t_0
(atan
(*
(pow (pow (fma (pow v 1.0) (pow v 1.0) (* -19.6 H)) -1.0) 0.5)
v)))
(t_1 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H)))))))
(if (<= t_1 -4e-115)
t_0
(if (<= t_1 5e-250)
(atan
(*
(pow
(/ (- (* (/ (* v v) H) -0.002603082049146189) 0.05102040816326531) H)
0.5)
v))
t_0))))
double code(double v, double H) {
double t_0 = atan((pow(pow(fma(pow(v, 1.0), pow(v, 1.0), (-19.6 * H)), -1.0), 0.5) * v));
double t_1 = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
double tmp;
if (t_1 <= -4e-115) {
tmp = t_0;
} else if (t_1 <= 5e-250) {
tmp = atan((pow((((((v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H), 0.5) * v));
} else {
tmp = t_0;
}
return tmp;
}
function code(v, H) t_0 = atan(Float64(((fma((v ^ 1.0), (v ^ 1.0), Float64(-19.6 * H)) ^ -1.0) ^ 0.5) * v)) t_1 = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H))))) tmp = 0.0 if (t_1 <= -4e-115) tmp = t_0; elseif (t_1 <= 5e-250) tmp = atan(Float64((Float64(Float64(Float64(Float64(Float64(v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H) ^ 0.5) * v)); else tmp = t_0; end return tmp end
code[v_, H_] := Block[{t$95$0 = N[ArcTan[N[(N[Power[N[Power[N[(N[Power[v, 1.0], $MachinePrecision] * N[Power[v, 1.0], $MachinePrecision] + N[(-19.6 * H), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -4e-115], t$95$0, If[LessEqual[t$95$1, 5e-250], N[ArcTan[N[(N[Power[N[(N[(N[(N[(N[(v * v), $MachinePrecision] / H), $MachinePrecision] * -0.002603082049146189), $MachinePrecision] - 0.05102040816326531), $MachinePrecision] / H), $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1} \left({\left({\left(\mathsf{fma}\left({v}^{1}, {v}^{1}, -19.6 \cdot H\right)\right)}^{-1}\right)}^{0.5} \cdot v\right)\\
t_1 := \tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{-115}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-250}:\\
\;\;\;\;\tan^{-1} \left({\left(\frac{\frac{v \cdot v}{H} \cdot -0.002603082049146189 - 0.05102040816326531}{H}\right)}^{0.5} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < -4.0000000000000002e-115 or 5.00000000000000027e-250 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) Initial program 99.8%
Taylor expanded in v around 0
Applied rewrites99.8%
if -4.0000000000000002e-115 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < 5.00000000000000027e-250Initial program 36.6%
Taylor expanded in v around 0
Applied rewrites36.7%
Taylor expanded in H around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6447.5
Applied rewrites47.5%
(FPCore (v H)
:precision binary64
(let* ((t_0 (pow (pow (fma -19.6 H (* v v)) -1.0) 0.25))
(t_1 (atan (* (* t_0 t_0) v)))
(t_2 (atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H)))))))
(if (<= t_2 -1e-41)
t_1
(if (<= t_2 5e-26)
(atan
(*
(pow
(/ (- (* (/ (* v v) H) -0.002603082049146189) 0.05102040816326531) H)
0.5)
v))
t_1))))
double code(double v, double H) {
double t_0 = pow(pow(fma(-19.6, H, (v * v)), -1.0), 0.25);
double t_1 = atan(((t_0 * t_0) * v));
double t_2 = atan((v / sqrt(((v * v) - ((2.0 * 9.8) * H)))));
double tmp;
if (t_2 <= -1e-41) {
tmp = t_1;
} else if (t_2 <= 5e-26) {
tmp = atan((pow((((((v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H), 0.5) * v));
} else {
tmp = t_1;
}
return tmp;
}
function code(v, H) t_0 = (fma(-19.6, H, Float64(v * v)) ^ -1.0) ^ 0.25 t_1 = atan(Float64(Float64(t_0 * t_0) * v)) t_2 = atan(Float64(v / sqrt(Float64(Float64(v * v) - Float64(Float64(2.0 * 9.8) * H))))) tmp = 0.0 if (t_2 <= -1e-41) tmp = t_1; elseif (t_2 <= 5e-26) tmp = atan(Float64((Float64(Float64(Float64(Float64(Float64(v * v) / H) * -0.002603082049146189) - 0.05102040816326531) / H) ^ 0.5) * v)); else tmp = t_1; end return tmp end
code[v_, H_] := Block[{t$95$0 = N[Power[N[Power[N[(-19.6 * H + N[(v * v), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[(t$95$0 * t$95$0), $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] - N[(N[(2.0 * 9.8), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -1e-41], t$95$1, If[LessEqual[t$95$2, 5e-26], N[ArcTan[N[(N[Power[N[(N[(N[(N[(N[(v * v), $MachinePrecision] / H), $MachinePrecision] * -0.002603082049146189), $MachinePrecision] - 0.05102040816326531), $MachinePrecision] / H), $MachinePrecision], 0.5], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left({\left(\mathsf{fma}\left(-19.6, H, v \cdot v\right)\right)}^{-1}\right)}^{0.25}\\
t_1 := \tan^{-1} \left(\left(t\_0 \cdot t\_0\right) \cdot v\right)\\
t_2 := \tan^{-1} \left(\frac{v}{\sqrt{v \cdot v - \left(2 \cdot 9.8\right) \cdot H}}\right)\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-41}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-26}:\\
\;\;\;\;\tan^{-1} \left({\left(\frac{\frac{v \cdot v}{H} \cdot -0.002603082049146189 - 0.05102040816326531}{H}\right)}^{0.5} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < -1.00000000000000001e-41 or 5.00000000000000019e-26 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) Initial program 99.9%
Taylor expanded in v around 0
Applied rewrites99.9%
lift-pow.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites99.7%
if -1.00000000000000001e-41 < (atan.f64 (/.f64 v (sqrt.f64 (-.f64 (*.f64 v v) (*.f64 (*.f64 #s(literal 2 binary64) #s(literal 49/5 binary64)) H))))) < 5.00000000000000019e-26Initial program 53.9%
Taylor expanded in v around 0
Applied rewrites54.0%
Taylor expanded in H around inf
lower-/.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
(FPCore (v H) :precision binary64 (let* ((t_0 (pow (pow (fma -19.6 H (* v v)) -1.0) 0.25))) (atan (* (* t_0 t_0) v))))
double code(double v, double H) {
double t_0 = pow(pow(fma(-19.6, H, (v * v)), -1.0), 0.25);
return atan(((t_0 * t_0) * v));
}
function code(v, H) t_0 = (fma(-19.6, H, Float64(v * v)) ^ -1.0) ^ 0.25 return atan(Float64(Float64(t_0 * t_0) * v)) end
code[v_, H_] := Block[{t$95$0 = N[Power[N[Power[N[(-19.6 * H + N[(v * v), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], 0.25], $MachinePrecision]}, N[ArcTan[N[(N[(t$95$0 * t$95$0), $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left({\left(\mathsf{fma}\left(-19.6, H, v \cdot v\right)\right)}^{-1}\right)}^{0.25}\\
\tan^{-1} \left(\left(t\_0 \cdot t\_0\right) \cdot v\right)
\end{array}
\end{array}
Initial program 69.9%
Taylor expanded in v around 0
Applied rewrites70.0%
lift-pow.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
sqr-powN/A
lower-*.f64N/A
Applied rewrites69.8%
herbie shell --seed 2025065
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))