
(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}
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) 0.5) h) l))))
(if (<= l -4.8e+53)
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) t_0)
(if (<= l -5e-310)
(*
(- 1.0 (/ (* (pow (* (/ D d) (/ M_m 2.0)) 2.0) (* 0.5 h)) l))
(* (- (pow (* l h) -0.5)) d))
(* (/ (* (/ 1.0 (sqrt l)) d) (sqrt h)) t_0)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 - (((pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (l <= -4.8e+53) {
tmp = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * t_0;
} else if (l <= -5e-310) {
tmp = (1.0 - ((pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-pow((l * h), -0.5) * d);
} else {
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * t_0;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - ((((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0) * h) / l)
if (l <= (-4.8d+53)) then
tmp = (((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * t_0
else if (l <= (-5d-310)) then
tmp = (1.0d0 - (((((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0) * (0.5d0 * h)) / l)) * (-((l * h) ** (-0.5d0)) * d)
else
tmp = (((1.0d0 / sqrt(l)) * d) / sqrt(h)) * t_0
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = 1.0 - (((Math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l);
double tmp;
if (l <= -4.8e+53) {
tmp = (Math.pow((d / h), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * t_0;
} else if (l <= -5e-310) {
tmp = (1.0 - ((Math.pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-Math.pow((l * h), -0.5) * d);
} else {
tmp = (((1.0 / Math.sqrt(l)) * d) / Math.sqrt(h)) * t_0;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = 1.0 - (((math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5) * h) / l) tmp = 0 if l <= -4.8e+53: tmp = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * t_0 elif l <= -5e-310: tmp = (1.0 - ((math.pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-math.pow((l * h), -0.5) * d) else: tmp = (((1.0 / math.sqrt(l)) * d) / math.sqrt(h)) * t_0 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) * h) / l)) tmp = 0.0 if (l <= -4.8e+53) tmp = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * t_0); elseif (l <= -5e-310) tmp = Float64(Float64(1.0 - Float64(Float64((Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0) * Float64(0.5 * h)) / l)) * Float64(Float64(-(Float64(l * h) ^ -0.5)) * d)); else tmp = Float64(Float64(Float64(Float64(1.0 / sqrt(l)) * d) / sqrt(h)) * t_0); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = 1.0 - ((((((M_m / 2.0) * (D / d)) ^ 2.0) * 0.5) * h) / l);
tmp = 0.0;
if (l <= -4.8e+53)
tmp = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * t_0;
elseif (l <= -5e-310)
tmp = (1.0 - (((((D / d) * (M_m / 2.0)) ^ 2.0) * (0.5 * h)) / l)) * (-((l * h) ^ -0.5) * d);
else
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * t_0;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -4.8e+53], 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] * t$95$0), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(1.0 - N[(N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[((-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]) * d), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+53}:\\
\;\;\;\;\left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot t\_0\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(1 - \frac{{\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right) \cdot \left(\left(-{\left(\ell \cdot h\right)}^{-0.5}\right) \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}} \cdot d}{\sqrt{h}} \cdot t\_0\\
\end{array}
\end{array}
if l < -4.8e53Initial program 56.4%
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.6%
if -4.8e53 < l < -4.999999999999985e-310Initial program 72.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f640.6
Applied rewrites0.6%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval78.1
Applied rewrites78.1%
Applied rewrites85.1%
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 rewrites67.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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6477.8
Applied rewrites77.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6482.2
Applied rewrites82.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
5e+140)
(* (sqrt (* (/ d l) (/ d h))) (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (* -1.0 d) (sqrt (pow (* l h) -1.0))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-1.0 * d) * sqrt(pow((l * h), -1.0));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 5d+140) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = ((-1.0d0) * d) * sqrt(((l * h) ** (-1.0d0)))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double tmp;
if (((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-1.0 * d) * Math.sqrt(Math.pow((l * h), -1.0));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) tmp = 0 if ((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = (-1.0 * d) * math.sqrt(math.pow((l * h), -1.0)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+140) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(-1.0 * d) * sqrt((Float64(l * h) ^ -1.0))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 5e+140)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
else
tmp = (-1.0 * d) * sqrt(((l * h) ^ -1.0));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+140], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * d), $MachinePrecision] * N[Sqrt[N[Power[N[(l * h), $MachinePrecision], -1.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+140}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot d\right) \cdot \sqrt{{\left(\ell \cdot h\right)}^{-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)))) < 5.00000000000000008e140Initial program 85.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 rewrites84.2%
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-/.f6475.6
Applied rewrites75.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6475.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6475.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6475.6
Applied rewrites75.6%
if 5.00000000000000008e140 < (*.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 33.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-*.f6429.8
Applied rewrites29.8%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0))))
(if (<=
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
5e+140)
(* (sqrt (* (/ d l) (/ d h))) (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (- d) (pow (* l h) -0.5)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double tmp;
if (((pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140) {
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = -d * pow((l * h), -0.5);
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
if (((((d / h) ** (1.0d0 / 2.0d0)) * ((d / l) ** (1.0d0 / 2.0d0))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))) <= 5d+140) then
tmp = sqrt(((d / l) * (d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = -d * ((l * h) ** (-0.5d0))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double tmp;
if (((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140) {
tmp = Math.sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = -d * Math.pow((l * h), -0.5);
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) tmp = 0 if ((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_m * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 5e+140: tmp = math.sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = -d * math.pow((l * h), -0.5) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) tmp = 0.0 if (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_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 5e+140) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
tmp = 0.0;
if (((((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)))) <= 5e+140)
tmp = sqrt(((d / l) * (d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
else
tmp = -d * ((l * h) ^ -0.5);
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[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$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+140], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
\mathbf{if}\;\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\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 5 \cdot 10^{+140}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\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)))) < 5.00000000000000008e140Initial program 85.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 rewrites84.2%
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-/.f6475.6
Applied rewrites75.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6475.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6475.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6475.6
Applied rewrites75.6%
if 5.00000000000000008e140 < (*.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 33.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-*.f6429.4
Applied rewrites29.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6429.4
Applied rewrites29.4%
Taylor expanded in h around -inf
inv-powN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f6430.0
Applied rewrites30.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) 0.5)))
(if (<= l -4.8e+53)
(* (sqrt (/ d h)) (* (sqrt (/ d l)) (- 1.0 (* (/ h l) t_0))))
(if (<= l -5e-310)
(*
(- 1.0 (/ (* (pow (* (/ D d) (/ M_m 2.0)) 2.0) (* 0.5 h)) l))
(* (- (pow (* l h) -0.5)) d))
(* (/ (* (/ 1.0 (sqrt l)) d) (sqrt h)) (- 1.0 (/ (* t_0 h) l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5;
double tmp;
if (l <= -4.8e+53) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
} else if (l <= -5e-310) {
tmp = (1.0 - ((pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-pow((l * h), -0.5) * d);
} else {
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * (1.0 - ((t_0 * h) / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0
if (l <= (-4.8d+53)) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - ((h / l) * t_0)))
else if (l <= (-5d-310)) then
tmp = (1.0d0 - (((((d_1 / d) * (m_m / 2.0d0)) ** 2.0d0) * (0.5d0 * h)) / l)) * (-((l * h) ** (-0.5d0)) * d)
else
tmp = (((1.0d0 / sqrt(l)) * d) / sqrt(h)) * (1.0d0 - ((t_0 * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5;
double tmp;
if (l <= -4.8e+53) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
} else if (l <= -5e-310) {
tmp = (1.0 - ((Math.pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-Math.pow((l * h), -0.5) * d);
} else {
tmp = (((1.0 / Math.sqrt(l)) * d) / Math.sqrt(h)) * (1.0 - ((t_0 * h) / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5 tmp = 0 if l <= -4.8e+53: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - ((h / l) * t_0))) elif l <= -5e-310: tmp = (1.0 - ((math.pow(((D / d) * (M_m / 2.0)), 2.0) * (0.5 * h)) / l)) * (-math.pow((l * h), -0.5) * d) else: tmp = (((1.0 / math.sqrt(l)) * d) / math.sqrt(h)) * (1.0 - ((t_0 * h) / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) tmp = 0.0 if (l <= -4.8e+53) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(h / l) * t_0)))); elseif (l <= -5e-310) tmp = Float64(Float64(1.0 - Float64(Float64((Float64(Float64(D / d) * Float64(M_m / 2.0)) ^ 2.0) * Float64(0.5 * h)) / l)) * Float64(Float64(-(Float64(l * h) ^ -0.5)) * d)); else tmp = Float64(Float64(Float64(Float64(1.0 / sqrt(l)) * d) / sqrt(h)) * Float64(1.0 - Float64(Float64(t_0 * h) / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((M_m / 2.0) * (D / d)) ^ 2.0) * 0.5;
tmp = 0.0;
if (l <= -4.8e+53)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
elseif (l <= -5e-310)
tmp = (1.0 - (((((D / d) * (M_m / 2.0)) ^ 2.0) * (0.5 * h)) / l)) * (-((l * h) ^ -0.5) * d);
else
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * (1.0 - ((t_0 * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[l, -4.8e+53], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[l, -5e-310], N[(N[(1.0 - N[(N[(N[Power[N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(0.5 * h), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision] * N[((-N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]) * d), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\\
\mathbf{if}\;\ell \leq -4.8 \cdot 10^{+53}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot t\_0\right)\right)\\
\mathbf{elif}\;\ell \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(1 - \frac{{\left(\frac{D}{d} \cdot \frac{M\_m}{2}\right)}^{2} \cdot \left(0.5 \cdot h\right)}{\ell}\right) \cdot \left(\left(-{\left(\ell \cdot h\right)}^{-0.5}\right) \cdot d\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}} \cdot d}{\sqrt{h}} \cdot \left(1 - \frac{t\_0 \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if l < -4.8e53Initial program 56.4%
Applied rewrites56.2%
if -4.8e53 < l < -4.999999999999985e-310Initial program 72.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f640.6
Applied rewrites0.6%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
lower-*.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval78.1
Applied rewrites78.1%
Applied rewrites85.1%
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 rewrites67.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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6477.8
Applied rewrites77.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6482.2
Applied rewrites82.2%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) 0.5)))
(if (<= d -5e-306)
(* (sqrt (/ d h)) (* (sqrt (/ d l)) (- 1.0 (* (/ h l) t_0))))
(* (/ (* (/ 1.0 (sqrt l)) d) (sqrt h)) (- 1.0 (/ (* t_0 h) l))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5;
double tmp;
if (d <= -5e-306) {
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
} else {
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * (1.0 - ((t_0 * h) / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0
if (d <= (-5d-306)) then
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0d0 - ((h / l) * t_0)))
else
tmp = (((1.0d0 / sqrt(l)) * d) / sqrt(h)) * (1.0d0 - ((t_0 * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = Math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5;
double tmp;
if (d <= -5e-306) {
tmp = Math.sqrt((d / h)) * (Math.sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
} else {
tmp = (((1.0 / Math.sqrt(l)) * d) / Math.sqrt(h)) * (1.0 - ((t_0 * h) / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5 tmp = 0 if d <= -5e-306: tmp = math.sqrt((d / h)) * (math.sqrt((d / l)) * (1.0 - ((h / l) * t_0))) else: tmp = (((1.0 / math.sqrt(l)) * d) / math.sqrt(h)) * (1.0 - ((t_0 * h) / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * 0.5) tmp = 0.0 if (d <= -5e-306) tmp = Float64(sqrt(Float64(d / h)) * Float64(sqrt(Float64(d / l)) * Float64(1.0 - Float64(Float64(h / l) * t_0)))); else tmp = Float64(Float64(Float64(Float64(1.0 / sqrt(l)) * d) / sqrt(h)) * Float64(1.0 - Float64(Float64(t_0 * h) / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (((M_m / 2.0) * (D / d)) ^ 2.0) * 0.5;
tmp = 0.0;
if (d <= -5e-306)
tmp = sqrt((d / h)) * (sqrt((d / l)) * (1.0 - ((h / l) * t_0)));
else
tmp = (((1.0 / sqrt(l)) * d) / sqrt(h)) * (1.0 - ((t_0 * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[d, -5e-306], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(h / l), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(1.0 / N[Sqrt[l], $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := {\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\\
\mathbf{if}\;d \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(\sqrt{\frac{d}{\ell}} \cdot \left(1 - \frac{h}{\ell} \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{\ell}} \cdot d}{\sqrt{h}} \cdot \left(1 - \frac{t\_0 \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -4.99999999999999998e-306Initial program 66.2%
Applied rewrites65.5%
if -4.99999999999999998e-306 < d Initial program 67.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 rewrites67.8%
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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6477.6
Applied rewrites77.6%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
lower-sqrt.f6482.0
Applied rewrites82.0%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0))) (t_1 (sqrt (/ d l))))
(if (<= d -5e-306)
(*
(sqrt (/ d h))
(* t_1 (- 1.0 (* (/ h l) (* (pow (* (/ M_m 2.0) (/ D d)) 2.0) 0.5)))))
(if (<= d 5.5e-152)
(*
(* (sqrt (/ 1.0 (* l h))) d)
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (+ d d)) 2.0)) (/ h l))))
(*
(/ (* (sqrt d) t_1) (sqrt h))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = sqrt((d / l));
double tmp;
if (d <= -5e-306) {
tmp = sqrt((d / h)) * (t_1 * (1.0 - ((h / l) * (pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5))));
} else if (d <= 5.5e-152) {
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
t_1 = sqrt((d / l))
if (d <= (-5d-306)) then
tmp = sqrt((d / h)) * (t_1 * (1.0d0 - ((h / l) * ((((m_m / 2.0d0) * (d_1 / d)) ** 2.0d0) * 0.5d0))))
else if (d <= 5.5d-152) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (d + d)) ** 2.0d0)) * (h / l)))
else
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = Math.sqrt((d / l));
double tmp;
if (d <= -5e-306) {
tmp = Math.sqrt((d / h)) * (t_1 * (1.0 - ((h / l) * (Math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5))));
} else if (d <= 5.5e-152) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((Math.sqrt(d) * t_1) / Math.sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) t_1 = math.sqrt((d / l)) tmp = 0 if d <= -5e-306: tmp = math.sqrt((d / h)) * (t_1 * (1.0 - ((h / l) * (math.pow(((M_m / 2.0) * (D / d)), 2.0) * 0.5)))) elif d <= 5.5e-152: tmp = (math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l))) else: tmp = ((math.sqrt(d) * t_1) / math.sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -5e-306) tmp = Float64(sqrt(Float64(d / h)) * Float64(t_1 * Float64(1.0 - Float64(Float64(h / l) * Float64((Float64(Float64(M_m / 2.0) * Float64(D / d)) ^ 2.0) * 0.5))))); elseif (d <= 5.5e-152) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(d + d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(d) * t_1) / sqrt(h)) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
t_1 = sqrt((d / l));
tmp = 0.0;
if (d <= -5e-306)
tmp = sqrt((d / h)) * (t_1 * (1.0 - ((h / l) * ((((M_m / 2.0) * (D / d)) ^ 2.0) * 0.5))));
elseif (d <= 5.5e-152)
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (d + d)) ^ 2.0)) * (h / l)));
else
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5e-306], N[(N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision] * N[(t$95$1 * N[(1.0 - N[(N[(h / l), $MachinePrecision] * N[(N[Power[N[(N[(M$95$m / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-152], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{d}{h}} \cdot \left(t\_1 \cdot \left(1 - \frac{h}{\ell} \cdot \left({\left(\frac{M\_m}{2} \cdot \frac{D}{d}\right)}^{2} \cdot 0.5\right)\right)\right)\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D}{d + d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot t\_1}{\sqrt{h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -4.99999999999999998e-306Initial program 66.2%
Applied rewrites65.5%
if -4.99999999999999998e-306 < d < 5.4999999999999998e-152Initial program 43.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6459.7
Applied rewrites59.7%
if 5.4999999999999998e-152 < d Initial program 74.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 rewrites76.2%
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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6485.1
Applied rewrites85.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
Applied rewrites85.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0)))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= d -8.2e+156)
(* (- d) (pow (* l h) -0.5))
(if (<= d -5e-306)
(* (sqrt (* (/ d l) (/ d h))) t_1)
(if (<= d 5.5e-152)
(*
(* (sqrt (/ 1.0 (* l h))) d)
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (+ d d)) 2.0)) (/ h l))))
(* (/ (* (sqrt d) (sqrt (/ d l))) (sqrt h)) t_1))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= -8.2e+156) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= -5e-306) {
tmp = sqrt(((d / l) * (d / h))) * t_1;
} else if (d <= 5.5e-152) {
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (d <= (-8.2d+156)) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (d <= (-5d-306)) then
tmp = sqrt(((d / l) * (d / h))) * t_1
else if (d <= 5.5d-152) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (d + d)) ** 2.0d0)) * (h / l)))
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= -8.2e+156) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (d <= -5e-306) {
tmp = Math.sqrt(((d / l) * (d / h))) * t_1;
} else if (d <= 5.5e-152) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((Math.sqrt(d) * Math.sqrt((d / l))) / Math.sqrt(h)) * t_1;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if d <= -8.2e+156: tmp = -d * math.pow((l * h), -0.5) elif d <= -5e-306: tmp = math.sqrt(((d / l) * (d / h))) * t_1 elif d <= 5.5e-152: tmp = (math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l))) else: tmp = ((math.sqrt(d) * math.sqrt((d / l))) / math.sqrt(h)) * t_1 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) tmp = 0.0 if (d <= -8.2e+156) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= -5e-306) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * t_1); elseif (d <= 5.5e-152) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(d + d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(Float64(d / l))) / sqrt(h)) * t_1); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (d <= -8.2e+156)
tmp = -d * ((l * h) ^ -0.5);
elseif (d <= -5e-306)
tmp = sqrt(((d / l) * (d / h))) * t_1;
elseif (d <= 5.5e-152)
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (d + d)) ^ 2.0)) * (h / l)));
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.2e+156], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-306], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[d, 5.5e-152], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;d \leq -8.2 \cdot 10^{+156}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot t\_1\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D}{d + d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{h}} \cdot t\_1\\
\end{array}
\end{array}
if d < -8.2000000000000003e156Initial program 68.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-*.f646.6
Applied rewrites6.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f646.6
Applied rewrites6.6%
Taylor expanded in h around -inf
inv-powN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f6470.6
Applied rewrites70.6%
if -8.2000000000000003e156 < d < -4.99999999999999998e-306Initial program 65.4%
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 rewrites65.8%
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-/.f6456.4
Applied rewrites56.4%
lift-pow.f64N/A
unpow2N/A
lower-*.f6456.4
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.4
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.4
Applied rewrites56.4%
if -4.99999999999999998e-306 < d < 5.4999999999999998e-152Initial program 43.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6459.7
Applied rewrites59.7%
if 5.4999999999999998e-152 < d Initial program 74.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 rewrites76.2%
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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6485.1
Applied rewrites85.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
Applied rewrites85.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0))) (t_1 (sqrt (/ d l))))
(if (<= d -5e-306)
(*
(* t_1 (sqrt (/ d h)))
(- 1.0 (* (* 0.5 (pow (/ (* M_m D) (* 2.0 d)) 2.0)) (/ h l))))
(if (<= d 5.5e-152)
(*
(* (sqrt (/ 1.0 (* l h))) d)
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M_m D) (+ d d)) 2.0)) (/ h l))))
(*
(/ (* (sqrt d) t_1) (sqrt h))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = sqrt((d / l));
double tmp;
if (d <= -5e-306) {
tmp = (t_1 * sqrt((d / h))) * (1.0 - ((0.5 * pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (d <= 5.5e-152) {
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
t_1 = sqrt((d / l))
if (d <= (-5d-306)) then
tmp = (t_1 * sqrt((d / h))) * (1.0d0 - ((0.5d0 * (((m_m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else if (d <= 5.5d-152) then
tmp = (sqrt((1.0d0 / (l * h))) * d) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m_m * d_1) / (d + d)) ** 2.0d0)) * (h / l)))
else
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = Math.sqrt((d / l));
double tmp;
if (d <= -5e-306) {
tmp = (t_1 * Math.sqrt((d / h))) * (1.0 - ((0.5 * Math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (d <= 5.5e-152) {
tmp = (Math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * Math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l)));
} else {
tmp = ((Math.sqrt(d) * t_1) / Math.sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) t_1 = math.sqrt((d / l)) tmp = 0 if d <= -5e-306: tmp = (t_1 * math.sqrt((d / h))) * (1.0 - ((0.5 * math.pow(((M_m * D) / (2.0 * d)), 2.0)) * (h / l))) elif d <= 5.5e-152: tmp = (math.sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * math.pow(((M_m * D) / (d + d)), 2.0)) * (h / l))) else: tmp = ((math.sqrt(d) * t_1) / math.sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (d <= -5e-306) tmp = Float64(Float64(t_1 * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M_m * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); elseif (d <= 5.5e-152) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M_m * D) / Float64(d + d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(Float64(sqrt(d) * t_1) / sqrt(h)) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
t_1 = sqrt((d / l));
tmp = 0.0;
if (d <= -5e-306)
tmp = (t_1 * sqrt((d / h))) * (1.0 - ((0.5 * (((M_m * D) / (2.0 * d)) ^ 2.0)) * (h / l)));
elseif (d <= 5.5e-152)
tmp = (sqrt((1.0 / (l * h))) * d) * (1.0 - (((1.0 / 2.0) * (((M_m * D) / (d + d)) ^ 2.0)) * (h / l)));
else
tmp = ((sqrt(d) * t_1) / sqrt(h)) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[d, -5e-306], N[(N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.5e-152], N[(N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M$95$m * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;d \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M\_m \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-152}:\\
\;\;\;\;\left(\sqrt{\frac{1}{\ell \cdot h}} \cdot d\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M\_m \cdot D}{d + d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot t\_1}{\sqrt{h}} \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\end{array}
\end{array}
if d < -4.99999999999999998e-306Initial program 66.2%
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
metadata-evalN/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6466.2
Applied rewrites66.2%
lift-/.f64N/A
metadata-eval66.2
Applied rewrites66.2%
if -4.99999999999999998e-306 < d < 5.4999999999999998e-152Initial program 43.8%
Taylor expanded in d around 0
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6459.7
Applied rewrites59.7%
lift-*.f64N/A
count-2-revN/A
lower-+.f6459.7
Applied rewrites59.7%
if 5.4999999999999998e-152 < d Initial program 74.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 rewrites76.2%
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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6485.1
Applied rewrites85.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6485.1
Applied rewrites85.1%
M_m = (fabs.f64 M)
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
(FPCore (d h l M_m D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M_m 2.0)))
(t_1 (- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l))))
(if (<= d -8.2e+156)
(* (- d) (pow (* l h) -0.5))
(if (<= d -5e-306)
(* (sqrt (* (/ d l) (/ d h))) t_1)
(* (/ (* (sqrt d) (sqrt (/ d l))) (sqrt h)) t_1)))))M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= -8.2e+156) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= -5e-306) {
tmp = sqrt(((d / l) * (d / h))) * t_1;
} else {
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) * (m_m / 2.0d0)
t_1 = 1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l)
if (d <= (-8.2d+156)) then
tmp = -d * ((l * h) ** (-0.5d0))
else if (d <= (-5d-306)) then
tmp = sqrt(((d / l) * (d / h))) * t_1
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double t_0 = (D / d) * (M_m / 2.0);
double t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
double tmp;
if (d <= -8.2e+156) {
tmp = -d * Math.pow((l * h), -0.5);
} else if (d <= -5e-306) {
tmp = Math.sqrt(((d / l) * (d / h))) * t_1;
} else {
tmp = ((Math.sqrt(d) * Math.sqrt((d / l))) / Math.sqrt(h)) * t_1;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): t_0 = (D / d) * (M_m / 2.0) t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l) tmp = 0 if d <= -8.2e+156: tmp = -d * math.pow((l * h), -0.5) elif d <= -5e-306: tmp = math.sqrt(((d / l) * (d / h))) * t_1 else: tmp = ((math.sqrt(d) * math.sqrt((d / l))) / math.sqrt(h)) * t_1 return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) t_0 = Float64(Float64(D / d) * Float64(M_m / 2.0)) t_1 = Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l)) tmp = 0.0 if (d <= -8.2e+156) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= -5e-306) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * t_1); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(Float64(d / l))) / sqrt(h)) * t_1); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
t_0 = (D / d) * (M_m / 2.0);
t_1 = 1.0 - ((((t_0 * t_0) * 0.5) * h) / l);
tmp = 0.0;
if (d <= -8.2e+156)
tmp = -d * ((l * h) ^ -0.5);
elseif (d <= -5e-306)
tmp = sqrt(((d / l) * (d / h))) * t_1;
else
tmp = ((sqrt(d) * sqrt((d / l))) / sqrt(h)) * t_1;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision]
NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function.
code[d_, h_, l_, M$95$m_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M$95$m / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -8.2e+156], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5e-306], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M\_m}{2}\\
t_1 := 1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;d \leq -8.2 \cdot 10^{+156}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq -5 \cdot 10^{-306}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{\ell}}}{\sqrt{h}} \cdot t\_1\\
\end{array}
\end{array}
if d < -8.2000000000000003e156Initial program 68.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-*.f646.6
Applied rewrites6.6%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f646.6
Applied rewrites6.6%
Taylor expanded in h around -inf
inv-powN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f6470.6
Applied rewrites70.6%
if -8.2000000000000003e156 < d < -4.99999999999999998e-306Initial program 65.4%
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 rewrites65.8%
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-/.f6456.4
Applied rewrites56.4%
lift-pow.f64N/A
unpow2N/A
lower-*.f6456.4
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.4
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6456.4
Applied rewrites56.4%
if -4.99999999999999998e-306 < d Initial program 67.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 rewrites67.8%
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
sqrt-divN/A
pow1/2N/A
associate-*l/N/A
lower-/.f64N/A
lower-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
lift-/.f64N/A
lift-sqrt.f6477.6
Applied rewrites77.6%
lift-pow.f64N/A
unpow2N/A
lower-*.f6477.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6477.6
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-/.f6477.6
Applied rewrites77.6%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l 1.7e-221) (* (- d) (pow (* l h) -0.5)) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 1.7e-221) {
tmp = -d * pow((l * h), -0.5);
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 1.7d-221) then
tmp = -d * ((l * h) ** (-0.5d0))
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 1.7e-221) {
tmp = -d * Math.pow((l * h), -0.5);
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 1.7e-221: tmp = -d * math.pow((l * h), -0.5) else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 1.7e-221) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 1.7e-221)
tmp = -d * ((l * h) ^ -0.5);
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 1.7e-221], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.7 \cdot 10^{-221}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if l < 1.7000000000000001e-221Initial program 66.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-*.f6411.3
Applied rewrites11.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6411.3
Applied rewrites11.3%
Taylor expanded in h around -inf
inv-powN/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
metadata-evalN/A
lift-pow.f64N/A
lift-*.f6441.5
Applied rewrites41.5%
if 1.7000000000000001e-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
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6445.4
Applied rewrites45.4%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6452.9
Applied rewrites52.9%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (if (<= l 8.8e-248) (* (sqrt (* (/ d l) (/ d h))) 1.0) (* (/ 1.0 (* (sqrt l) (sqrt h))) d)))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 8.8e-248) {
tmp = sqrt(((d / l) * (d / h))) * 1.0;
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
real(8) :: tmp
if (l <= 8.8d-248) then
tmp = sqrt(((d / l) * (d / h))) * 1.0d0
else
tmp = (1.0d0 / (sqrt(l) * sqrt(h))) * d
end if
code = tmp
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
double tmp;
if (l <= 8.8e-248) {
tmp = Math.sqrt(((d / l) * (d / h))) * 1.0;
} else {
tmp = (1.0 / (Math.sqrt(l) * Math.sqrt(h))) * d;
}
return tmp;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): tmp = 0 if l <= 8.8e-248: tmp = math.sqrt(((d / l) * (d / h))) * 1.0 else: tmp = (1.0 / (math.sqrt(l) * math.sqrt(h))) * d return tmp
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) tmp = 0.0 if (l <= 8.8e-248) tmp = Float64(sqrt(Float64(Float64(d / l) * Float64(d / h))) * 1.0); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp_2 = code(d, h, l, M_m, D)
tmp = 0.0;
if (l <= 8.8e-248)
tmp = sqrt(((d / l) * (d / h))) * 1.0;
else
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
end
tmp_2 = tmp;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := If[LessEqual[l, 8.8e-248], N[(N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 8.8 \cdot 10^{-248}:\\
\;\;\;\;\sqrt{\frac{d}{\ell} \cdot \frac{d}{h}} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if l < 8.79999999999999998e-248Initial program 66.6%
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.3%
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-/.f6459.7
Applied rewrites59.7%
Taylor expanded in d around inf
frac-times31.3
*-commutative31.3
associate-*r/31.3
metadata-eval31.3
Applied rewrites31.3%
if 8.79999999999999998e-248 < l 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-*.f6444.4
Applied rewrites44.4%
lift-sqrt.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
inv-powN/A
sqrt-divN/A
metadata-evalN/A
lower-/.f64N/A
*-commutativeN/A
lower-sqrt.f64N/A
lift-*.f6444.6
Applied rewrites44.6%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6452.1
Applied rewrites52.1%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (/ (/ 1.0 l) h)) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt(((1.0 / l) / h)) * d;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
code = sqrt(((1.0d0 / l) / h)) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt(((1.0 / l) / h)) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt(((1.0 / l) / h)) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt(((1.0 / l) / h)) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{\frac{1}{\ell}}{h}} \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-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6426.0
Applied rewrites26.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6426.1
Applied rewrites26.1%
M_m = (fabs.f64 M) NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. (FPCore (d h l M_m D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
M_m = fabs(M);
assert(d < h && h < l && l < M_m && M_m < D);
double code(double d, double h, double l, double M_m, double D) {
return sqrt((1.0 / (l * h))) * d;
}
M_m = private
NOTE: d, h, l, M_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_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_m
real(8), intent (in) :: d_1
code = sqrt((1.0d0 / (l * h))) * d
end function
M_m = Math.abs(M);
assert d < h && h < l && l < M_m && M_m < D;
public static double code(double d, double h, double l, double M_m, double D) {
return Math.sqrt((1.0 / (l * h))) * d;
}
M_m = math.fabs(M) [d, h, l, M_m, D] = sort([d, h, l, M_m, D]) def code(d, h, l, M_m, D): return math.sqrt((1.0 / (l * h))) * d
M_m = abs(M) d, h, l, M_m, D = sort([d, h, l, M_m, D]) function code(d, h, l, M_m, D) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
M_m = abs(M);
d, h, l, M_m, D = num2cell(sort([d, h, l, M_m, D])){:}
function tmp = code(d, h, l, M_m, D)
tmp = sqrt((1.0 / (l * h))) * d;
end
M_m = N[Abs[M], $MachinePrecision] NOTE: d, h, l, M_m, and D should be sorted in increasing order before calling this function. code[d_, h_, l_, M$95$m_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
M_m = \left|M\right|
\\
[d, h, l, M_m, D] = \mathsf{sort}([d, h, l, M_m, D])\\
\\
\sqrt{\frac{1}{\ell \cdot h}} \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-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6426.0
Applied rewrites26.0%
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)))))