
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d h l M D) :precision binary64 (* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
double code(double d, double h, double l, double M, double D) {
return (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
}
def code(d, h, l, M, D): return (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)))
function code(d, h, l, M, D) return Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) end
function tmp = code(d, h, l, M, D) tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)
\end{array}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (* l h) -0.5)))
(if (<= l -9.8e+66)
(/
(fma
(sqrt (/ h l))
d
(* (/ (* (pow (/ h l) 1.5) (pow (* D M) 2.0)) d) -0.125))
h)
(if (<= l -5e-310)
(*
(- 1.0 (* (/ (* h (pow (* (/ D d) (/ M 2.0)) 2.0)) l) 0.5))
(* (- d) t_0))
(*
(* t_0 d)
(- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D d)) 2.0) 0.5) h) l)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((l * h), -0.5);
double tmp;
if (l <= -9.8e+66) {
tmp = fma(sqrt((h / l)), d, (((pow((h / l), 1.5) * pow((D * M), 2.0)) / d) * -0.125)) / h;
} else if (l <= -5e-310) {
tmp = (1.0 - (((h * pow(((D / d) * (M / 2.0)), 2.0)) / l) * 0.5)) * (-d * t_0);
} else {
tmp = (t_0 * d) * (1.0 - (((pow(((M / 2.0) * (D / d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(l * h) ^ -0.5 tmp = 0.0 if (l <= -9.8e+66) tmp = Float64(fma(sqrt(Float64(h / l)), d, Float64(Float64(Float64((Float64(h / l) ^ 1.5) * (Float64(D * M) ^ 2.0)) / d) * -0.125)) / h); elseif (l <= -5e-310) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(h * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)) / l) * 0.5)) * Float64(Float64(-d) * t_0)); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) * h) / l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, -9.8e+66], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d + N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(1.0 - N[(N[(N[(h * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[((-d) * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+66}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{h}{\ell}}, d, \frac{{\left(\frac{h}{\ell}\right)}^{1.5} \cdot {\left(D \cdot M\right)}^{2}}{d} \cdot -0.125\right)}{h}\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(1 - \frac{h \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}}{\ell} \cdot 0.5\right) \cdot \left(\left(-d\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if l < -9.7999999999999995e66Initial program 55.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites55.1%
Taylor expanded in h around 0
Applied rewrites47.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-*r/N/A
cube-divN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites54.0%
if -9.7999999999999995e66 < l < -4.999999999999985e-310Initial program 72.7%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Applied rewrites77.7%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f6484.9
Applied rewrites84.9%
if -4.999999999999985e-310 < l Initial program 67.1%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.1%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval74.0
Applied rewrites74.0%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (* l h) -0.5)))
(if (<= l -9.8e+66)
(/
(fma
(sqrt (/ h l))
d
(* (/ (* (pow (/ h l) 1.5) (pow (* D M) 2.0)) d) -0.125))
h)
(if (<= l -5e-310)
(*
(- 1.0 (* (* (/ h l) (pow (* (/ D d) (/ M 2.0)) 2.0)) 0.5))
(* (- d) t_0))
(*
(* t_0 d)
(- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D d)) 2.0) 0.5) h) l)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((l * h), -0.5);
double tmp;
if (l <= -9.8e+66) {
tmp = fma(sqrt((h / l)), d, (((pow((h / l), 1.5) * pow((D * M), 2.0)) / d) * -0.125)) / h;
} else if (l <= -5e-310) {
tmp = (1.0 - (((h / l) * pow(((D / d) * (M / 2.0)), 2.0)) * 0.5)) * (-d * t_0);
} else {
tmp = (t_0 * d) * (1.0 - (((pow(((M / 2.0) * (D / d)), 2.0) * 0.5) * h) / l));
}
return tmp;
}
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(l * h) ^ -0.5 tmp = 0.0 if (l <= -9.8e+66) tmp = Float64(fma(sqrt(Float64(h / l)), d, Float64(Float64(Float64((Float64(h / l) ^ 1.5) * (Float64(D * M) ^ 2.0)) / d) * -0.125)) / h); elseif (l <= -5e-310) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(h / l) * (Float64(Float64(D / d) * Float64(M / 2.0)) ^ 2.0)) * 0.5)) * Float64(Float64(-d) * t_0)); else tmp = Float64(Float64(t_0 * d) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) * h) / l))); end return tmp end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, -9.8e+66], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d + N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(1.0 - N[(N[(N[(h / l), $MachinePrecision] * N[Power[N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[((-d) * t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+66}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\sqrt{\frac{h}{\ell}}, d, \frac{{\left(\frac{h}{\ell}\right)}^{1.5} \cdot {\left(D \cdot M\right)}^{2}}{d} \cdot -0.125\right)}{h}\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(1 - \left(\frac{h}{\ell} \cdot {\left(\frac{D}{d} \cdot \frac{M}{2}\right)}^{2}\right) \cdot 0.5\right) \cdot \left(\left(-d\right) \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot d\right) \cdot \left(1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if l < -9.7999999999999995e66Initial program 55.8%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites55.1%
Taylor expanded in h around 0
Applied rewrites47.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-*r/N/A
cube-divN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites54.0%
if -9.7999999999999995e66 < l < -4.999999999999985e-310Initial program 72.7%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6477.6
Applied rewrites77.6%
Applied rewrites77.7%
if -4.999999999999985e-310 < l Initial program 67.1%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.1%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval74.0
Applied rewrites74.0%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (/ (* (* (pow (/ h l) 1.5) (/ (pow (* D M) 2.0) d)) -0.125) h)))
(if (<= t_0 -1e-221)
t_1
(if (<= t_0 4e-200)
(* (sqrt (/ (pow h -1.0) l)) d)
(if (<= t_0 2e+214)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= t_0 INFINITY) (/ (* (sqrt (/ h l)) d) h) t_1))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = ((pow((h / l), 1.5) * (pow((D * M), 2.0) / d)) * -0.125) / h;
double tmp;
if (t_0 <= -1e-221) {
tmp = t_1;
} else if (t_0 <= 4e-200) {
tmp = sqrt((pow(h, -1.0) / l)) * d;
} else if (t_0 <= 2e+214) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (t_0 <= ((double) INFINITY)) {
tmp = (sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = ((Math.pow((h / l), 1.5) * (Math.pow((D * M), 2.0) / d)) * -0.125) / h;
double tmp;
if (t_0 <= -1e-221) {
tmp = t_1;
} else if (t_0 <= 4e-200) {
tmp = Math.sqrt((Math.pow(h, -1.0) / l)) * d;
} else if (t_0 <= 2e+214) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (Math.sqrt((h / l)) * d) / h;
} else {
tmp = t_1;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = ((math.pow((h / l), 1.5) * (math.pow((D * M), 2.0) / d)) * -0.125) / h tmp = 0 if t_0 <= -1e-221: tmp = t_1 elif t_0 <= 4e-200: tmp = math.sqrt((math.pow(h, -1.0) / l)) * d elif t_0 <= 2e+214: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif t_0 <= math.inf: tmp = (math.sqrt((h / l)) * d) / h else: tmp = t_1 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(Float64((Float64(h / l) ^ 1.5) * Float64((Float64(D * M) ^ 2.0) / d)) * -0.125) / h) tmp = 0.0 if (t_0 <= -1e-221) tmp = t_1; elseif (t_0 <= 4e-200) tmp = Float64(sqrt(Float64((h ^ -1.0) / l)) * d); elseif (t_0 <= 2e+214) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (t_0 <= Inf) tmp = Float64(Float64(sqrt(Float64(h / l)) * d) / h); else tmp = t_1; end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = ((((h / l) ^ 1.5) * (((D * M) ^ 2.0) / d)) * -0.125) / h;
tmp = 0.0;
if (t_0 <= -1e-221)
tmp = t_1;
elseif (t_0 <= 4e-200)
tmp = sqrt(((h ^ -1.0) / l)) * d;
elseif (t_0 <= 2e+214)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (t_0 <= Inf)
tmp = (sqrt((h / l)) * d) / h;
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / h), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-221], t$95$1, If[LessEqual[t$95$0, 4e-200], N[(N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], If[LessEqual[t$95$0, 2e+214], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] / h), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot -0.125}{h}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-221}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-200}:\\
\;\;\;\;\sqrt{\frac{{h}^{-1}}{\ell}} \cdot d\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+214}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\sqrt{\frac{h}{\ell}} \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.00000000000000002e-221 or +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 57.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites60.0%
Taylor expanded in h around 0
Applied rewrites42.4%
Taylor expanded in d around 0
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
cube-divN/A
lower-sqrt.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f6455.8
Applied rewrites64.8%
if -1.00000000000000002e-221 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 3.9999999999999999e-200Initial program 46.3%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6448.7
Applied rewrites48.7%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6449.2
Applied rewrites49.2%
if 3.9999999999999999e-200 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1.9999999999999999e214Initial program 98.9%
Taylor expanded in d around inf
Applied rewrites98.1%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6498.1
Applied rewrites98.1%
if 1.9999999999999999e214 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 56.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites56.3%
Taylor expanded in h around 0
Applied rewrites55.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f6473.5
Applied rewrites73.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M 2.0) (/ D d)) 2.0) 0.5) h) l))))
(if (<= d -1.15e+157)
(* (* -1.0 d) (sqrt (/ (pow h -1.0) l)))
(if (<= d -2.55e-105)
(* (sqrt (* (/ d l) (/ d h))) t_0)
(if (<= d 5.8e-241)
(/ (* (* (pow (/ h l) 1.5) (/ (pow (* D M) 2.0) d)) -0.125) h)
(* (* (pow (* l h) -0.5) d) t_0))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((pow(((M / 2.0) * (D / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (d <= -1.15e+157) {
tmp = (-1.0 * d) * sqrt((pow(h, -1.0) / l));
} else if (d <= -2.55e-105) {
tmp = sqrt(((d / l) * (d / h))) * t_0;
} else if (d <= 5.8e-241) {
tmp = ((pow((h / l), 1.5) * (pow((D * M), 2.0) / d)) * -0.125) / h;
} else {
tmp = (pow((l * h), -0.5) * d) * t_0;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((((((m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0) * h) / l)
if (d <= (-1.15d+157)) then
tmp = ((-1.0d0) * d) * sqrt(((h ** (-1.0d0)) / l))
else if (d <= (-2.55d-105)) then
tmp = sqrt(((d / l) * (d / h))) * t_0
else if (d <= 5.8d-241) then
tmp = ((((h / l) ** 1.5d0) * (((d_1 * m) ** 2.0d0) / d)) * (-0.125d0)) / h
else
tmp = (((l * h) ** (-0.5d0)) * d) * t_0
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((Math.pow(((M / 2.0) * (D / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (d <= -1.15e+157) {
tmp = (-1.0 * d) * Math.sqrt((Math.pow(h, -1.0) / l));
} else if (d <= -2.55e-105) {
tmp = Math.sqrt(((d / l) * (d / h))) * t_0;
} else if (d <= 5.8e-241) {
tmp = ((Math.pow((h / l), 1.5) * (Math.pow((D * M), 2.0) / d)) * -0.125) / h;
} else {
tmp = (Math.pow((l * h), -0.5) * d) * t_0;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = 1.0 - (((math.pow(((M / 2.0) * (D / d)), 2.0) * 0.5) * h) / l) tmp = 0 if d <= -1.15e+157: tmp = (-1.0 * d) * math.sqrt((math.pow(h, -1.0) / l)) elif d <= -2.55e-105: tmp = math.sqrt(((d / l) * (d / h))) * t_0 elif d <= 5.8e-241: tmp = ((math.pow((h / l), 1.5) * (math.pow((D * M), 2.0) / d)) * -0.125) / h else: tmp = (math.pow((l * h), -0.5) * d) * t_0 return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) * h) / l)) tmp = 0.0 if (d <= -1.15e+157) tmp = Float64(Float64(-1.0 * d) * sqrt(Float64((h ^ -1.0) / l))); elseif (d <= -2.55e-105) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * t_0); elseif (d <= 5.8e-241) tmp = Float64(Float64(Float64((Float64(h / l) ^ 1.5) * Float64((Float64(D * M) ^ 2.0) / d)) * -0.125) / h); else tmp = Float64(Float64((Float64(l * h) ^ -0.5) * d) * t_0); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = 1.0 - ((((((M / 2.0) * (D / d)) ^ 2.0) * 0.5) * h) / l);
tmp = 0.0;
if (d <= -1.15e+157)
tmp = (-1.0 * d) * sqrt(((h ^ -1.0) / l));
elseif (d <= -2.55e-105)
tmp = sqrt(((d / l) * (d / h))) * t_0;
elseif (d <= 5.8e-241)
tmp = ((((h / l) ^ 1.5) * (((D * M) ^ 2.0) / d)) * -0.125) / h;
else
tmp = (((l * h) ^ -0.5) * d) * t_0;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.15e+157], N[(N[(-1.0 * d), $MachinePrecision] * N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.55e-105], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[d, 5.8e-241], N[(N[(N[(N[Power[N[(h / l), $MachinePrecision], 1.5], $MachinePrecision] * N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * -0.125), $MachinePrecision] / h), $MachinePrecision], N[(N[(N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision] * d), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;d \leq -1.15 \cdot 10^{+157}:\\
\;\;\;\;\left(-1 \cdot d\right) \cdot \sqrt{\frac{{h}^{-1}}{\ell}}\\
\mathbf{elif}\;d \leq -2.55 \cdot 10^{-105}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot t\_0\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-241}:\\
\;\;\;\;\frac{\left({\left(\frac{h}{\ell}\right)}^{1.5} \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot -0.125}{h}\\
\mathbf{else}:\\
\;\;\;\;\left({\left(\ell \cdot h\right)}^{-0.5} \cdot d\right) \cdot t\_0\\
\end{array}
\end{array}
if d < -1.15000000000000002e157Initial program 68.7%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6470.5
Applied rewrites70.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6471.0
Applied rewrites71.0%
if -1.15000000000000002e157 < d < -2.55000000000000004e-105Initial program 78.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites80.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6470.0
Applied rewrites70.0%
if -2.55000000000000004e-105 < d < 5.7999999999999998e-241Initial program 44.1%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites43.4%
Taylor expanded in h around 0
Applied rewrites45.9%
Taylor expanded in d around 0
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
cube-divN/A
lower-sqrt.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f6447.6
Applied rewrites56.4%
if 5.7999999999999998e-241 < d Initial program 70.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites71.8%
Taylor expanded in d around 0
metadata-evalN/A
metadata-evalN/A
pow1/2N/A
pow1/2N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval76.3
Applied rewrites76.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (/ (pow (* D M) 2.0) d))
(t_1 (sqrt (/ h (pow l 3.0))))
(t_2 (sqrt (/ (pow h -1.0) l))))
(if (<= d -5.8e+152)
(* (* -1.0 d) t_2)
(if (<= d -1.9e-47)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= d -2.6e-302)
(* (* 0.125 t_0) t_1)
(if (<= d 4.1e-85) (* (* -0.125 t_0) t_1) (* t_2 d)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((D * M), 2.0) / d;
double t_1 = sqrt((h / pow(l, 3.0)));
double t_2 = sqrt((pow(h, -1.0) / l));
double tmp;
if (d <= -5.8e+152) {
tmp = (-1.0 * d) * t_2;
} else if (d <= -1.9e-47) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (d <= -2.6e-302) {
tmp = (0.125 * t_0) * t_1;
} else if (d <= 4.1e-85) {
tmp = (-0.125 * t_0) * t_1;
} else {
tmp = t_2 * d;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((d_1 * m) ** 2.0d0) / d
t_1 = sqrt((h / (l ** 3.0d0)))
t_2 = sqrt(((h ** (-1.0d0)) / l))
if (d <= (-5.8d+152)) then
tmp = ((-1.0d0) * d) * t_2
else if (d <= (-1.9d-47)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
else if (d <= (-2.6d-302)) then
tmp = (0.125d0 * t_0) * t_1
else if (d <= 4.1d-85) then
tmp = ((-0.125d0) * t_0) * t_1
else
tmp = t_2 * d
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow((D * M), 2.0) / d;
double t_1 = Math.sqrt((h / Math.pow(l, 3.0)));
double t_2 = Math.sqrt((Math.pow(h, -1.0) / l));
double tmp;
if (d <= -5.8e+152) {
tmp = (-1.0 * d) * t_2;
} else if (d <= -1.9e-47) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (d <= -2.6e-302) {
tmp = (0.125 * t_0) * t_1;
} else if (d <= 4.1e-85) {
tmp = (-0.125 * t_0) * t_1;
} else {
tmp = t_2 * d;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = math.pow((D * M), 2.0) / d t_1 = math.sqrt((h / math.pow(l, 3.0))) t_2 = math.sqrt((math.pow(h, -1.0) / l)) tmp = 0 if d <= -5.8e+152: tmp = (-1.0 * d) * t_2 elif d <= -1.9e-47: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif d <= -2.6e-302: tmp = (0.125 * t_0) * t_1 elif d <= 4.1e-85: tmp = (-0.125 * t_0) * t_1 else: tmp = t_2 * d return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64((Float64(D * M) ^ 2.0) / d) t_1 = sqrt(Float64(h / (l ^ 3.0))) t_2 = sqrt(Float64((h ^ -1.0) / l)) tmp = 0.0 if (d <= -5.8e+152) tmp = Float64(Float64(-1.0 * d) * t_2); elseif (d <= -1.9e-47) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (d <= -2.6e-302) tmp = Float64(Float64(0.125 * t_0) * t_1); elseif (d <= 4.1e-85) tmp = Float64(Float64(-0.125 * t_0) * t_1); else tmp = Float64(t_2 * d); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = ((D * M) ^ 2.0) / d;
t_1 = sqrt((h / (l ^ 3.0)));
t_2 = sqrt(((h ^ -1.0) / l));
tmp = 0.0;
if (d <= -5.8e+152)
tmp = (-1.0 * d) * t_2;
elseif (d <= -1.9e-47)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (d <= -2.6e-302)
tmp = (0.125 * t_0) * t_1;
elseif (d <= 4.1e-85)
tmp = (-0.125 * t_0) * t_1;
else
tmp = t_2 * d;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5.8e+152], N[(N[(-1.0 * d), $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[d, -1.9e-47], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[d, -2.6e-302], N[(N[(0.125 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 4.1e-85], N[(N[(-0.125 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision], N[(t$95$2 * d), $MachinePrecision]]]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \frac{{\left(D \cdot M\right)}^{2}}{d}\\
t_1 := \sqrt{\frac{h}{{\ell}^{3}}}\\
t_2 := \sqrt{\frac{{h}^{-1}}{\ell}}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+152}:\\
\;\;\;\;\left(-1 \cdot d\right) \cdot t\_2\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-47}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;d \leq -2.6 \cdot 10^{-302}:\\
\;\;\;\;\left(0.125 \cdot t\_0\right) \cdot t\_1\\
\mathbf{elif}\;d \leq 4.1 \cdot 10^{-85}:\\
\;\;\;\;\left(-0.125 \cdot t\_0\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot d\\
\end{array}
\end{array}
if d < -5.7999999999999997e152Initial program 68.2%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6471.0
Applied rewrites71.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6471.5
Applied rewrites71.5%
if -5.7999999999999997e152 < d < -1.90000000000000007e-47Initial program 81.2%
Taylor expanded in d around inf
Applied rewrites46.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6446.9
Applied rewrites46.9%
if -1.90000000000000007e-47 < d < -2.60000000000000011e-302Initial program 53.3%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites44.0%
Taylor expanded in d around 0
lower-*.f64N/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f6444.0
Applied rewrites44.0%
if -2.60000000000000011e-302 < d < 4.09999999999999994e-85Initial program 49.3%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6449.0
Applied rewrites49.0%
if 4.09999999999999994e-85 < d Initial program 76.5%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6452.0
Applied rewrites52.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6452.3
Applied rewrites52.3%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (/ h l))))
(if (<= t_0 -1e+36)
(* (* 0.125 (/ (pow (* D M) 2.0) d)) (sqrt (/ h (pow l 3.0))))
(if (<= t_0 4e-200)
(* (pow (* l h) -0.5) d)
(if (<= t_0 2e+214)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= t_0 INFINITY) (/ (* t_1 d) h) (/ (* (- d) t_1) h)))))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt((h / l));
double tmp;
if (t_0 <= -1e+36) {
tmp = (0.125 * (pow((D * M), 2.0) / d)) * sqrt((h / pow(l, 3.0)));
} else if (t_0 <= 4e-200) {
tmp = pow((l * h), -0.5) * d;
} else if (t_0 <= 2e+214) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (t_0 <= ((double) INFINITY)) {
tmp = (t_1 * d) / h;
} else {
tmp = (-d * t_1) / h;
}
return tmp;
}
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt((h / l));
double tmp;
if (t_0 <= -1e+36) {
tmp = (0.125 * (Math.pow((D * M), 2.0) / d)) * Math.sqrt((h / Math.pow(l, 3.0)));
} else if (t_0 <= 4e-200) {
tmp = Math.pow((l * h), -0.5) * d;
} else if (t_0 <= 2e+214) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = (t_1 * d) / h;
} else {
tmp = (-d * t_1) / h;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt((h / l)) tmp = 0 if t_0 <= -1e+36: tmp = (0.125 * (math.pow((D * M), 2.0) / d)) * math.sqrt((h / math.pow(l, 3.0))) elif t_0 <= 4e-200: tmp = math.pow((l * h), -0.5) * d elif t_0 <= 2e+214: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif t_0 <= math.inf: tmp = (t_1 * d) / h else: tmp = (-d * t_1) / h return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(h / l)) tmp = 0.0 if (t_0 <= -1e+36) tmp = Float64(Float64(0.125 * Float64((Float64(D * M) ^ 2.0) / d)) * sqrt(Float64(h / (l ^ 3.0)))); elseif (t_0 <= 4e-200) tmp = Float64((Float64(l * h) ^ -0.5) * d); elseif (t_0 <= 2e+214) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (t_0 <= Inf) tmp = Float64(Float64(t_1 * d) / h); else tmp = Float64(Float64(Float64(-d) * t_1) / h); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
t_1 = sqrt((h / l));
tmp = 0.0;
if (t_0 <= -1e+36)
tmp = (0.125 * (((D * M) ^ 2.0) / d)) * sqrt((h / (l ^ 3.0)));
elseif (t_0 <= 4e-200)
tmp = ((l * h) ^ -0.5) * d;
elseif (t_0 <= 2e+214)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (t_0 <= Inf)
tmp = (t_1 * d) / h;
else
tmp = (-d * t_1) / h;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -1e+36], N[(N[(0.125 * N[(N[Power[N[(D * M), $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[Power[l, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e-200], N[(N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision] * d), $MachinePrecision], If[LessEqual[t$95$0, 2e+214], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[(t$95$1 * d), $MachinePrecision] / h), $MachinePrecision], N[(N[((-d) * t$95$1), $MachinePrecision] / h), $MachinePrecision]]]]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{h}{\ell}}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{+36}:\\
\;\;\;\;\left(0.125 \cdot \frac{{\left(D \cdot M\right)}^{2}}{d}\right) \cdot \sqrt{\frac{h}{{\ell}^{3}}}\\
\mathbf{elif}\;t\_0 \leq 4 \cdot 10^{-200}:\\
\;\;\;\;{\left(\ell \cdot h\right)}^{-0.5} \cdot d\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+214}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{t\_1 \cdot d}{h}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-d\right) \cdot t\_1}{h}\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < -1.00000000000000004e36Initial program 85.5%
Taylor expanded in h around -inf
associate-*r*N/A
lower-*.f64N/A
Applied rewrites36.2%
Taylor expanded in d around 0
lower-*.f64N/A
lower-/.f64N/A
unpow-prod-downN/A
lift-pow.f64N/A
lift-*.f6436.2
Applied rewrites36.2%
if -1.00000000000000004e36 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 3.9999999999999999e-200Initial program 59.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6437.5
Applied rewrites37.5%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval37.5
Applied rewrites37.5%
if 3.9999999999999999e-200 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 1.9999999999999999e214Initial program 98.9%
Taylor expanded in d around inf
Applied rewrites98.1%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6498.1
Applied rewrites98.1%
if 1.9999999999999999e214 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < +inf.0Initial program 56.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites56.3%
Taylor expanded in h around 0
Applied rewrites55.1%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f6473.5
Applied rewrites73.5%
if +inf.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 0.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites11.8%
Taylor expanded in h around 0
Applied rewrites20.7%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6416.8
Applied rewrites16.8%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h -6.5e+140)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= h -1.75e-286)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= h 1.65e+190)
(* (sqrt (/ (pow h -1.0) l)) d)
(/ (* (- d) (sqrt (/ h l))) h)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -6.5e+140) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (h <= -1.75e-286) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (h <= 1.65e+190) {
tmp = sqrt((pow(h, -1.0) / l)) * d;
} else {
tmp = (-d * sqrt((h / l))) / h;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= (-6.5d+140)) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
else if (h <= (-1.75d-286)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (h <= 1.65d+190) then
tmp = sqrt(((h ** (-1.0d0)) / l)) * d
else
tmp = (-d * sqrt((h / l))) / h
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -6.5e+140) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
} else if (h <= -1.75e-286) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (h <= 1.65e+190) {
tmp = Math.sqrt((Math.pow(h, -1.0) / l)) * d;
} else {
tmp = (-d * Math.sqrt((h / l))) / h;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if h <= -6.5e+140: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 elif h <= -1.75e-286: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif h <= 1.65e+190: tmp = math.sqrt((math.pow(h, -1.0) / l)) * d else: tmp = (-d * math.sqrt((h / l))) / h return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= -6.5e+140) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (h <= -1.75e-286) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (h <= 1.65e+190) tmp = Float64(sqrt(Float64((h ^ -1.0) / l)) * d); else tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= -6.5e+140)
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
elseif (h <= -1.75e-286)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (h <= 1.65e+190)
tmp = sqrt(((h ^ -1.0) / l)) * d;
else
tmp = (-d * sqrt((h / l))) / h;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, -6.5e+140], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[h, -1.75e-286], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.65e+190], N[(N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -6.5 \cdot 10^{+140}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;h \leq -1.75 \cdot 10^{-286}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;h \leq 1.65 \cdot 10^{+190}:\\
\;\;\;\;\sqrt{\frac{{h}^{-1}}{\ell}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\end{array}
\end{array}
if h < -6.4999999999999999e140Initial program 53.0%
Taylor expanded in d around inf
Applied rewrites31.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
pow1/2N/A
*-commutativeN/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6431.0
Applied rewrites31.0%
if -6.4999999999999999e140 < h < -1.74999999999999994e-286Initial program 71.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites72.6%
Taylor expanded in l around -inf
Applied rewrites50.7%
lift-*.f64N/A
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sqrt.f6450.5
Applied rewrites50.5%
if -1.74999999999999994e-286 < h < 1.65e190Initial program 70.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.2
Applied rewrites45.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6445.5
Applied rewrites45.5%
if 1.65e190 < h Initial program 50.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites53.5%
Taylor expanded in h around 0
Applied rewrites32.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6431.0
Applied rewrites31.0%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ (pow h -1.0) l))))
(if (<= h -1.75e-286)
(* (* -1.0 d) t_0)
(if (<= h 1.65e+190) (* t_0 d) (/ (* (- d) (sqrt (/ h l))) h)))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((pow(h, -1.0) / l));
double tmp;
if (h <= -1.75e-286) {
tmp = (-1.0 * d) * t_0;
} else if (h <= 1.65e+190) {
tmp = t_0 * d;
} else {
tmp = (-d * sqrt((h / l))) / h;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((h ** (-1.0d0)) / l))
if (h <= (-1.75d-286)) then
tmp = ((-1.0d0) * d) * t_0
else if (h <= 1.65d+190) then
tmp = t_0 * d
else
tmp = (-d * sqrt((h / l))) / h
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((Math.pow(h, -1.0) / l));
double tmp;
if (h <= -1.75e-286) {
tmp = (-1.0 * d) * t_0;
} else if (h <= 1.65e+190) {
tmp = t_0 * d;
} else {
tmp = (-d * Math.sqrt((h / l))) / h;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = math.sqrt((math.pow(h, -1.0) / l)) tmp = 0 if h <= -1.75e-286: tmp = (-1.0 * d) * t_0 elif h <= 1.65e+190: tmp = t_0 * d else: tmp = (-d * math.sqrt((h / l))) / h return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = sqrt(Float64((h ^ -1.0) / l)) tmp = 0.0 if (h <= -1.75e-286) tmp = Float64(Float64(-1.0 * d) * t_0); elseif (h <= 1.65e+190) tmp = Float64(t_0 * d); else tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = sqrt(((h ^ -1.0) / l));
tmp = 0.0;
if (h <= -1.75e-286)
tmp = (-1.0 * d) * t_0;
elseif (h <= 1.65e+190)
tmp = t_0 * d;
else
tmp = (-d * sqrt((h / l))) / h;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -1.75e-286], N[(N[(-1.0 * d), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, 1.65e+190], N[(t$95$0 * d), $MachinePrecision], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := \sqrt{\frac{{h}^{-1}}{\ell}}\\
\mathbf{if}\;h \leq -1.75 \cdot 10^{-286}:\\
\;\;\;\;\left(-1 \cdot d\right) \cdot t\_0\\
\mathbf{elif}\;h \leq 1.65 \cdot 10^{+190}:\\
\;\;\;\;t\_0 \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\end{array}
\end{array}
if h < -1.74999999999999994e-286Initial program 66.3%
Taylor expanded in l around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6443.2
Applied rewrites43.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6443.4
Applied rewrites43.4%
if -1.74999999999999994e-286 < h < 1.65e190Initial program 70.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.2
Applied rewrites45.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6445.5
Applied rewrites45.5%
if 1.65e190 < h Initial program 50.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites53.5%
Taylor expanded in h around 0
Applied rewrites32.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6431.0
Applied rewrites31.0%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M D)
:precision binary64
(if (<= h -1.75e-286)
(* (- d) (sqrt (pow (* l h) -1.0)))
(if (<= h 1.65e+190)
(* (sqrt (/ (pow h -1.0) l)) d)
(/ (* (- d) (sqrt (/ h l))) h))))assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -1.75e-286) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else if (h <= 1.65e+190) {
tmp = sqrt((pow(h, -1.0) / l)) * d;
} else {
tmp = (-d * sqrt((h / l))) / h;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (h <= (-1.75d-286)) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else if (h <= 1.65d+190) then
tmp = sqrt(((h ** (-1.0d0)) / l)) * d
else
tmp = (-d * sqrt((h / l))) / h
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= -1.75e-286) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else if (h <= 1.65e+190) {
tmp = Math.sqrt((Math.pow(h, -1.0) / l)) * d;
} else {
tmp = (-d * Math.sqrt((h / l))) / h;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if h <= -1.75e-286: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) elif h <= 1.65e+190: tmp = math.sqrt((math.pow(h, -1.0) / l)) * d else: tmp = (-d * math.sqrt((h / l))) / h return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (h <= -1.75e-286) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); elseif (h <= 1.65e+190) tmp = Float64(sqrt(Float64((h ^ -1.0) / l)) * d); else tmp = Float64(Float64(Float64(-d) * sqrt(Float64(h / l))) / h); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (h <= -1.75e-286)
tmp = -d * sqrt(((l * h) ^ -1.0));
elseif (h <= 1.65e+190)
tmp = sqrt(((h ^ -1.0) / l)) * d;
else
tmp = (-d * sqrt((h / l))) / h;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[h, -1.75e-286], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[h, 1.65e+190], N[(N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[((-d) * N[Sqrt[N[(h / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / h), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;h \leq -1.75 \cdot 10^{-286}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{elif}\;h \leq 1.65 \cdot 10^{+190}:\\
\;\;\;\;\sqrt{\frac{{h}^{-1}}{\ell}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-d\right) \cdot \sqrt{\frac{h}{\ell}}}{h}\\
\end{array}
\end{array}
if h < -1.74999999999999994e-286Initial program 66.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites67.8%
Taylor expanded in l around -inf
Applied rewrites43.3%
lift-*.f64N/A
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sqrt.f6443.2
Applied rewrites43.2%
if -1.74999999999999994e-286 < h < 1.65e190Initial program 70.7%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.2
Applied rewrites45.2%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6445.5
Applied rewrites45.5%
if 1.65e190 < h Initial program 50.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites53.5%
Taylor expanded in h around 0
Applied rewrites32.8%
Taylor expanded in l around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
lift-sqrt.f64N/A
lift-/.f6431.0
Applied rewrites31.0%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= l 2e-221) (* (- d) (sqrt (pow (* l h) -1.0))) (* (sqrt (/ (pow h -1.0) l)) d)))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-221) {
tmp = -d * sqrt(pow((l * h), -1.0));
} else {
tmp = sqrt((pow(h, -1.0) / l)) * d;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 2d-221) then
tmp = -d * sqrt(((l * h) ** (-1.0d0)))
else
tmp = sqrt(((h ** (-1.0d0)) / l)) * d
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-221) {
tmp = -d * Math.sqrt(Math.pow((l * h), -1.0));
} else {
tmp = Math.sqrt((Math.pow(h, -1.0) / l)) * d;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if l <= 2e-221: tmp = -d * math.sqrt(math.pow((l * h), -1.0)) else: tmp = math.sqrt((math.pow(h, -1.0) / l)) * d return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 2e-221) tmp = Float64(Float64(-d) * sqrt((Float64(l * h) ^ -1.0))); else tmp = Float64(sqrt(Float64((h ^ -1.0) / l)) * d); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (l <= 2e-221)
tmp = -d * sqrt(((l * h) ^ -1.0));
else
tmp = sqrt(((h ^ -1.0) / l)) * d;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 2e-221], N[((-d) * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2 \cdot 10^{-221}:\\
\;\;\;\;\left(-d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-1}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{h}^{-1}}{\ell}} \cdot d\\
\end{array}
\end{array}
if l < 2.00000000000000003e-221Initial program 66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.7%
Taylor expanded in l around -inf
Applied rewrites41.5%
lift-*.f64N/A
lift-pow.f64N/A
metadata-evalN/A
sqrt-pow1N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-sqrt.f6441.5
Applied rewrites41.5%
if 2.00000000000000003e-221 < l Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.3
Applied rewrites45.3%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6445.6
Applied rewrites45.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (if (<= l 2e-221) (* (- d) (pow (* l h) -0.5)) (* (sqrt (/ (pow h -1.0) l)) d)))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-221) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = sqrt((pow(h, -1.0) / l)) * d;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 2d-221) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = sqrt(((h ** (-1.0d0)) / l)) * d
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 2e-221) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = Math.sqrt((Math.pow(h, -1.0) / l)) * d;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): tmp = 0 if l <= 2e-221: tmp = -d * math.pow((l * h), -0.5) else: tmp = math.sqrt((math.pow(h, -1.0) / l)) * d return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) tmp = 0.0 if (l <= 2e-221) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(sqrt(Float64((h ^ -1.0) / l)) * d); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
tmp = 0.0;
if (l <= 2e-221)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = sqrt(((h ^ -1.0) / l)) * d;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := If[LessEqual[l, 2e-221], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[Power[h, -1.0], $MachinePrecision] / l), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 2 \cdot 10^{-221}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{{h}^{-1}}{\ell}} \cdot d\\
\end{array}
\end{array}
if l < 2.00000000000000003e-221Initial program 66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.7%
Taylor expanded in l around -inf
Applied rewrites41.5%
if 2.00000000000000003e-221 < l Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.3
Applied rewrites45.3%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
associate-/r*N/A
lower-/.f64N/A
inv-powN/A
lower-pow.f6445.6
Applied rewrites45.6%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (let* ((t_0 (pow (* l h) -0.5))) (if (<= l 2e-221) (* (- d) t_0) (* t_0 d))))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((l * h), -0.5);
double tmp;
if (l <= 2e-221) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (l * h) ** (-0.5d0)
if (l <= 2d-221) then
tmp = -d * t_0
else
tmp = t_0 * d
end if
code = tmp
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow((l * h), -0.5);
double tmp;
if (l <= 2e-221) {
tmp = -d * t_0;
} else {
tmp = t_0 * d;
}
return tmp;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): t_0 = math.pow((l * h), -0.5) tmp = 0 if l <= 2e-221: tmp = -d * t_0 else: tmp = t_0 * d return tmp
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) t_0 = Float64(l * h) ^ -0.5 tmp = 0.0 if (l <= 2e-221) tmp = Float64(Float64(-d) * t_0); else tmp = Float64(t_0 * d); end return tmp end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp_2 = code(d, h, l, M, D)
t_0 = (l * h) ^ -0.5;
tmp = 0.0;
if (l <= 2e-221)
tmp = -d * t_0;
else
tmp = t_0 * d;
end
tmp_2 = tmp;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]}, If[LessEqual[l, 2e-221], N[((-d) * t$95$0), $MachinePrecision], N[(t$95$0 * d), $MachinePrecision]]]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
\begin{array}{l}
t_0 := {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{if}\;\ell \leq 2 \cdot 10^{-221}:\\
\;\;\;\;\left(-d\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot d\\
\end{array}
\end{array}
if l < 2.00000000000000003e-221Initial program 66.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites68.7%
Taylor expanded in l around -inf
Applied rewrites41.5%
if 2.00000000000000003e-221 < l Initial program 66.4%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6445.3
Applied rewrites45.3%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval45.5
Applied rewrites45.5%
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. (FPCore (d h l M D) :precision binary64 (* (pow (* l h) -0.5) d))
assert(d < h && h < l && l < M && M < D);
double code(double d, double h, double l, double M, double D) {
return pow((l * h), -0.5) * d;
}
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function.
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(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
code = ((l * h) ** (-0.5d0)) * d
end function
assert d < h && h < l && l < M && M < D;
public static double code(double d, double h, double l, double M, double D) {
return Math.pow((l * h), -0.5) * d;
}
[d, h, l, M, D] = sort([d, h, l, M, D]) def code(d, h, l, M, D): return math.pow((l * h), -0.5) * d
d, h, l, M, D = sort([d, h, l, M, D]) function code(d, h, l, M, D) return Float64((Float64(l * h) ^ -0.5) * d) end
d, h, l, M, D = num2cell(sort([d, h, l, M, D])){:}
function tmp = code(d, h, l, M, D)
tmp = ((l * h) ^ -0.5) * d;
end
NOTE: d, h, l, M, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M_, D_] := N[(N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
[d, h, l, M, D] = \mathsf{sort}([d, h, l, M, D])\\
\\
{\left(\ell \cdot h\right)}^{-0.5} \cdot d
\end{array}
Initial program 66.6%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6426.0
Applied rewrites26.0%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval25.9
Applied rewrites25.9%
herbie shell --seed 2025101
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))