
(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 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)))));
}
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
(let* ((t_0 (fma 19.6 H (* v v))))
(if (<= v -1e+154)
(atan -1.0)
(if (<= v 1e+133)
(atan
(/ v (sqrt (fma (* v v) (/ (* v v) t_0) (* -384.16 (* (/ H t_0) H))))))
(atan 1.0)))))
double code(double v, double H) {
double t_0 = fma(19.6, H, (v * v));
double tmp;
if (v <= -1e+154) {
tmp = atan(-1.0);
} else if (v <= 1e+133) {
tmp = atan((v / sqrt(fma((v * v), ((v * v) / t_0), (-384.16 * ((H / t_0) * H))))));
} else {
tmp = atan(1.0);
}
return tmp;
}
function code(v, H) t_0 = fma(19.6, H, Float64(v * v)) tmp = 0.0 if (v <= -1e+154) tmp = atan(-1.0); elseif (v <= 1e+133) tmp = atan(Float64(v / sqrt(fma(Float64(v * v), Float64(Float64(v * v) / t_0), Float64(-384.16 * Float64(Float64(H / t_0) * H)))))); else tmp = atan(1.0); end return tmp end
code[v_, H_] := Block[{t$95$0 = N[(19.6 * H + N[(v * v), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -1e+154], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1e+133], N[ArcTan[N[(v / N[Sqrt[N[(N[(v * v), $MachinePrecision] * N[(N[(v * v), $MachinePrecision] / t$95$0), $MachinePrecision] + N[(-384.16 * N[(N[(H / t$95$0), $MachinePrecision] * H), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(19.6, H, v \cdot v\right)\\
\mathbf{if}\;v \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 10^{+133}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(v \cdot v, \frac{v \cdot v}{t\_0}, -384.16 \cdot \left(\frac{H}{t\_0} \cdot H\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.00000000000000004e154Initial program 3.1%
Taylor expanded in v around -inf
Applied rewrites100.0%
if -1.00000000000000004e154 < v < 1e133Initial program 99.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
metadata-eval99.2
Applied rewrites99.2%
Applied rewrites99.2%
if 1e133 < v Initial program 13.0%
Taylor expanded in v around inf
Applied rewrites100.0%
(FPCore (v H) :precision binary64 (if (<= v -1e+154) (atan -1.0) (if (<= v 1e+133) (atan (/ v (sqrt (- (* v v) (* H 19.6))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1e+154) {
tmp = atan(-1.0);
} else if (v <= 1e+133) {
tmp = atan((v / sqrt(((v * v) - (H * 19.6)))));
} else {
tmp = atan(1.0);
}
return tmp;
}
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
real(8) :: tmp
if (v <= (-1d+154)) then
tmp = atan((-1.0d0))
else if (v <= 1d+133) 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+154) {
tmp = Math.atan(-1.0);
} else if (v <= 1e+133) {
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+154: tmp = math.atan(-1.0) elif v <= 1e+133: 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+154) tmp = atan(-1.0); elseif (v <= 1e+133) 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+154) tmp = atan(-1.0); elseif (v <= 1e+133) 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+154], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1e+133], 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^{+154}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 10^{+133}:\\
\;\;\;\;\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.00000000000000004e154Initial program 3.1%
Taylor expanded in v around -inf
Applied rewrites100.0%
if -1.00000000000000004e154 < v < 1e133Initial program 99.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
lift-*.f64N/A
metadata-eval99.2
Applied rewrites99.2%
if 1e133 < v Initial program 13.0%
Taylor expanded in v around inf
Applied rewrites100.0%
(FPCore (v H) :precision binary64 (if (<= v -1e+154) (atan -1.0) (if (<= v 1e+133) (atan (/ v (sqrt (fma v v (* -19.6 H))))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -1e+154) {
tmp = atan(-1.0);
} else if (v <= 1e+133) {
tmp = atan((v / sqrt(fma(v, v, (-19.6 * H)))));
} else {
tmp = atan(1.0);
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -1e+154) tmp = atan(-1.0); elseif (v <= 1e+133) tmp = atan(Float64(v / sqrt(fma(v, v, Float64(-19.6 * H))))); else tmp = atan(1.0); end return tmp end
code[v_, H_] := If[LessEqual[v, -1e+154], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 1e+133], N[ArcTan[N[(v / N[Sqrt[N[(v * v + N[(-19.6 * H), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -1 \cdot 10^{+154}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 10^{+133}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{\mathsf{fma}\left(v, v, -19.6 \cdot H\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.00000000000000004e154Initial program 3.1%
Taylor expanded in v around -inf
Applied rewrites100.0%
if -1.00000000000000004e154 < v < 1e133Initial program 99.2%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
metadata-evalN/A
metadata-eval99.2
Applied rewrites99.2%
if 1e133 < v Initial program 13.0%
Taylor expanded in v around inf
Applied rewrites100.0%
(FPCore (v H)
:precision binary64
(if (<= v -4.4e-72)
(atan (/ v (fma (/ H v) 9.8 (- v))))
(if (<= v 4e-124)
(atan (* (sqrt (/ -0.05102040816326531 H)) v))
(atan (/ v (fma (/ H v) -9.8 v))))))
double code(double v, double H) {
double tmp;
if (v <= -4.4e-72) {
tmp = atan((v / fma((H / v), 9.8, -v)));
} else if (v <= 4e-124) {
tmp = atan((sqrt((-0.05102040816326531 / H)) * v));
} else {
tmp = atan((v / fma((H / v), -9.8, v)));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -4.4e-72) tmp = atan(Float64(v / fma(Float64(H / v), 9.8, Float64(-v)))); elseif (v <= 4e-124) tmp = atan(Float64(sqrt(Float64(-0.05102040816326531 / H)) * v)); else tmp = atan(Float64(v / fma(Float64(H / v), -9.8, v))); end return tmp end
code[v_, H_] := If[LessEqual[v, -4.4e-72], N[ArcTan[N[(v / N[(N[(H / v), $MachinePrecision] * 9.8 + (-v)), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[v, 4e-124], N[ArcTan[N[(N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(N[(H / v), $MachinePrecision] * -9.8 + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -4.4 \cdot 10^{-72}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, 9.8, -v\right)}\right)\\
\mathbf{elif}\;v \leq 4 \cdot 10^{-124}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}\right)\\
\end{array}
\end{array}
if v < -4.40000000000000005e-72Initial program 54.4%
Taylor expanded in v around -inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
+-commutativeN/A
distribute-neg-inN/A
distribute-lft-neg-inN/A
metadata-evalN/A
associate-*r/N/A
unpow2N/A
times-fracN/A
metadata-evalN/A
associate-*r/N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6488.3
Applied rewrites88.3%
Taylor expanded in H around 0
Applied rewrites88.3%
if -4.40000000000000005e-72 < v < 3.99999999999999973e-124Initial program 99.6%
Applied rewrites96.6%
Taylor expanded in v around 0
lower-atan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.3%
Taylor expanded in v around 0
Applied rewrites96.6%
if 3.99999999999999973e-124 < v Initial program 55.5%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.1
Applied rewrites87.1%
(FPCore (v H)
:precision binary64
(if (<= v -4.4e-72)
(atan -1.0)
(if (<= v 4e-124)
(atan (* (sqrt (/ -0.05102040816326531 H)) v))
(atan (/ v (fma (/ H v) -9.8 v))))))
double code(double v, double H) {
double tmp;
if (v <= -4.4e-72) {
tmp = atan(-1.0);
} else if (v <= 4e-124) {
tmp = atan((sqrt((-0.05102040816326531 / H)) * v));
} else {
tmp = atan((v / fma((H / v), -9.8, v)));
}
return tmp;
}
function code(v, H) tmp = 0.0 if (v <= -4.4e-72) tmp = atan(-1.0); elseif (v <= 4e-124) tmp = atan(Float64(sqrt(Float64(-0.05102040816326531 / H)) * v)); else tmp = atan(Float64(v / fma(Float64(H / v), -9.8, v))); end return tmp end
code[v_, H_] := If[LessEqual[v, -4.4e-72], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 4e-124], N[ArcTan[N[(N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(v / N[(N[(H / v), $MachinePrecision] * -9.8 + v), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -4.4 \cdot 10^{-72}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 4 \cdot 10^{-124}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\mathsf{fma}\left(\frac{H}{v}, -9.8, v\right)}\right)\\
\end{array}
\end{array}
if v < -4.40000000000000005e-72Initial program 54.4%
Taylor expanded in v around -inf
Applied rewrites88.1%
if -4.40000000000000005e-72 < v < 3.99999999999999973e-124Initial program 99.6%
Applied rewrites96.6%
Taylor expanded in v around 0
lower-atan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites70.3%
Taylor expanded in v around 0
Applied rewrites96.6%
if 3.99999999999999973e-124 < v Initial program 55.5%
Taylor expanded in H around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.1
Applied rewrites87.1%
(FPCore (v H) :precision binary64 (if (<= v -4.4e-72) (atan -1.0) (if (<= v 7.6e-57) (atan (/ v (sqrt (* -19.6 H)))) (atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -4.4e-72) {
tmp = atan(-1.0);
} else if (v <= 7.6e-57) {
tmp = atan((v / sqrt((-19.6 * H))));
} else {
tmp = atan(1.0);
}
return tmp;
}
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
real(8) :: tmp
if (v <= (-4.4d-72)) then
tmp = atan((-1.0d0))
else if (v <= 7.6d-57) then
tmp = atan((v / sqrt(((-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 <= -4.4e-72) {
tmp = Math.atan(-1.0);
} else if (v <= 7.6e-57) {
tmp = Math.atan((v / Math.sqrt((-19.6 * H))));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -4.4e-72: tmp = math.atan(-1.0) elif v <= 7.6e-57: tmp = math.atan((v / math.sqrt((-19.6 * H)))) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -4.4e-72) tmp = atan(-1.0); elseif (v <= 7.6e-57) tmp = atan(Float64(v / sqrt(Float64(-19.6 * H)))); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -4.4e-72) tmp = atan(-1.0); elseif (v <= 7.6e-57) tmp = atan((v / sqrt((-19.6 * H)))); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -4.4e-72], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 7.6e-57], N[ArcTan[N[(v / N[Sqrt[N[(-19.6 * H), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -4.4 \cdot 10^{-72}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 7.6 \cdot 10^{-57}:\\
\;\;\;\;\tan^{-1} \left(\frac{v}{\sqrt{-19.6 \cdot H}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -4.40000000000000005e-72Initial program 54.4%
Taylor expanded in v around -inf
Applied rewrites88.1%
if -4.40000000000000005e-72 < v < 7.5999999999999995e-57Initial program 99.6%
Taylor expanded in v around 0
lower-*.f6491.0
Applied rewrites91.0%
if 7.5999999999999995e-57 < v Initial program 51.5%
Taylor expanded in v around inf
Applied rewrites90.5%
(FPCore (v H)
:precision binary64
(if (<= v -4.4e-72)
(atan -1.0)
(if (<= v 7.6e-57)
(atan (* (sqrt (/ -0.05102040816326531 H)) v))
(atan 1.0))))
double code(double v, double H) {
double tmp;
if (v <= -4.4e-72) {
tmp = atan(-1.0);
} else if (v <= 7.6e-57) {
tmp = atan((sqrt((-0.05102040816326531 / H)) * v));
} else {
tmp = atan(1.0);
}
return tmp;
}
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
real(8) :: tmp
if (v <= (-4.4d-72)) then
tmp = atan((-1.0d0))
else if (v <= 7.6d-57) then
tmp = atan((sqrt(((-0.05102040816326531d0) / 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 <= -4.4e-72) {
tmp = Math.atan(-1.0);
} else if (v <= 7.6e-57) {
tmp = Math.atan((Math.sqrt((-0.05102040816326531 / H)) * v));
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -4.4e-72: tmp = math.atan(-1.0) elif v <= 7.6e-57: tmp = math.atan((math.sqrt((-0.05102040816326531 / H)) * v)) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -4.4e-72) tmp = atan(-1.0); elseif (v <= 7.6e-57) tmp = atan(Float64(sqrt(Float64(-0.05102040816326531 / H)) * v)); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -4.4e-72) tmp = atan(-1.0); elseif (v <= 7.6e-57) tmp = atan((sqrt((-0.05102040816326531 / H)) * v)); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -4.4e-72], N[ArcTan[-1.0], $MachinePrecision], If[LessEqual[v, 7.6e-57], N[ArcTan[N[(N[Sqrt[N[(-0.05102040816326531 / H), $MachinePrecision]], $MachinePrecision] * v), $MachinePrecision]], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -4.4 \cdot 10^{-72}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{elif}\;v \leq 7.6 \cdot 10^{-57}:\\
\;\;\;\;\tan^{-1} \left(\sqrt{\frac{-0.05102040816326531}{H}} \cdot v\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -4.40000000000000005e-72Initial program 54.4%
Taylor expanded in v around -inf
Applied rewrites88.1%
if -4.40000000000000005e-72 < v < 7.5999999999999995e-57Initial program 99.6%
Applied rewrites91.3%
Taylor expanded in v around 0
lower-atan.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.7%
Taylor expanded in v around 0
Applied rewrites90.9%
if 7.5999999999999995e-57 < v Initial program 51.5%
Taylor expanded in v around inf
Applied rewrites90.5%
(FPCore (v H) :precision binary64 (if (<= v -2e-310) (atan -1.0) (atan 1.0)))
double code(double v, double H) {
double tmp;
if (v <= -2e-310) {
tmp = atan(-1.0);
} else {
tmp = atan(1.0);
}
return tmp;
}
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
real(8) :: tmp
if (v <= (-2d-310)) then
tmp = atan((-1.0d0))
else
tmp = atan(1.0d0)
end if
code = tmp
end function
public static double code(double v, double H) {
double tmp;
if (v <= -2e-310) {
tmp = Math.atan(-1.0);
} else {
tmp = Math.atan(1.0);
}
return tmp;
}
def code(v, H): tmp = 0 if v <= -2e-310: tmp = math.atan(-1.0) else: tmp = math.atan(1.0) return tmp
function code(v, H) tmp = 0.0 if (v <= -2e-310) tmp = atan(-1.0); else tmp = atan(1.0); end return tmp end
function tmp_2 = code(v, H) tmp = 0.0; if (v <= -2e-310) tmp = atan(-1.0); else tmp = atan(1.0); end tmp_2 = tmp; end
code[v_, H_] := If[LessEqual[v, -2e-310], N[ArcTan[-1.0], $MachinePrecision], N[ArcTan[1.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\tan^{-1} -1\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1} 1\\
\end{array}
\end{array}
if v < -1.999999999999994e-310Initial program 66.8%
Taylor expanded in v around -inf
Applied rewrites65.5%
if -1.999999999999994e-310 < v Initial program 63.7%
Taylor expanded in v around inf
Applied rewrites71.9%
(FPCore (v H) :precision binary64 (atan -1.0))
double code(double v, double H) {
return atan(-1.0);
}
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((-1.0d0))
end function
public static double code(double v, double H) {
return Math.atan(-1.0);
}
def code(v, H): return math.atan(-1.0)
function code(v, H) return atan(-1.0) end
function tmp = code(v, H) tmp = atan(-1.0); end
code[v_, H_] := N[ArcTan[-1.0], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1} -1
\end{array}
Initial program 65.4%
Taylor expanded in v around -inf
Applied rewrites36.1%
herbie shell --seed 2024364
(FPCore (v H)
:name "Optimal throwing angle"
:precision binary64
(atan (/ v (sqrt (- (* v v) (* (* 2.0 9.8) H))))))