
(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 3 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}
d_m = (fabs.f64 d)
M_m = (fabs.f64 M)
D_m = (fabs.f64 D)
(FPCore (d_m h l M_m D_m)
:precision binary64
(let* ((t_0 (* d_m (sqrt (/ 1.0 (* h l))))))
(if (<= (* M_m D_m) 1e-169)
(* t_0 1.0)
(*
t_0
(- 1.0 (* (* 0.5 (pow (/ (* M_m D_m) (* 2.0 d_m)) 2.0)) (/ h l)))))))d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m * sqrt((1.0 / (h * l)));
double tmp;
if ((M_m * D_m) <= 1e-169) {
tmp = t_0 * 1.0;
} else {
tmp = t_0 * (1.0 - ((0.5 * pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
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_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: t_0
real(8) :: tmp
t_0 = d_m * sqrt((1.0d0 / (h * l)))
if ((m_m * d_m_1) <= 1d-169) then
tmp = t_0 * 1.0d0
else
tmp = t_0 * (1.0d0 - ((0.5d0 * (((m_m * d_m_1) / (2.0d0 * d_m)) ** 2.0d0)) * (h / l)))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double t_0 = d_m * Math.sqrt((1.0 / (h * l)));
double tmp;
if ((M_m * D_m) <= 1e-169) {
tmp = t_0 * 1.0;
} else {
tmp = t_0 * (1.0 - ((0.5 * Math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l)));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) def code(d_m, h, l, M_m, D_m): t_0 = d_m * math.sqrt((1.0 / (h * l))) tmp = 0 if (M_m * D_m) <= 1e-169: tmp = t_0 * 1.0 else: tmp = t_0 * (1.0 - ((0.5 * math.pow(((M_m * D_m) / (2.0 * d_m)), 2.0)) * (h / l))) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) function code(d_m, h, l, M_m, D_m) t_0 = Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) tmp = 0.0 if (Float64(M_m * D_m) <= 1e-169) tmp = Float64(t_0 * 1.0); else tmp = Float64(t_0 * Float64(1.0 - Float64(Float64(0.5 * (Float64(Float64(M_m * D_m) / Float64(2.0 * d_m)) ^ 2.0)) * Float64(h / l)))); end return tmp end
d_m = abs(d); M_m = abs(M); D_m = abs(D); function tmp_2 = code(d_m, h, l, M_m, D_m) t_0 = d_m * sqrt((1.0 / (h * l))); tmp = 0.0; if ((M_m * D_m) <= 1e-169) tmp = t_0 * 1.0; else tmp = t_0 * (1.0 - ((0.5 * (((M_m * D_m) / (2.0 * d_m)) ^ 2.0)) * (h / l))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision]
M_m = N[Abs[M], $MachinePrecision]
D_m = N[Abs[D], $MachinePrecision]
code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := Block[{t$95$0 = N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1e-169], N[(t$95$0 * 1.0), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[(N[(0.5 * N[Power[N[(N[(M$95$m * D$95$m), $MachinePrecision] / N[(2.0 * d$95$m), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
\begin{array}{l}
t_0 := d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\\
\mathbf{if}\;M\_m \cdot D\_m \leq 10^{-169}:\\
\;\;\;\;t\_0 \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - \left(0.5 \cdot {\left(\frac{M\_m \cdot D\_m}{2 \cdot d\_m}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 1.00000000000000002e-169Initial program 35.3%
Taylor expanded in d around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6469.3
Applied rewrites69.3%
Taylor expanded in d around inf
Applied rewrites42.9%
if 1.00000000000000002e-169 < (*.f64 M D) Initial program 35.3%
Taylor expanded in d around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6469.3
Applied rewrites69.3%
lift-/.f64N/A
metadata-eval69.3
Applied rewrites69.3%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) (FPCore (d_m h l M_m D_m) :precision binary64 (if (<= (* M_m D_m) 1.6e+235) (* (* d_m (sqrt (/ 1.0 (* h l)))) 1.0) (* h (* d_m (sqrt (/ 1.0 (* (pow h 3.0) l)))))))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 1.6e+235) {
tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0;
} else {
tmp = h * (d_m * sqrt((1.0 / (pow(h, 3.0) * l))));
}
return tmp;
}
d_m = private
M_m = private
D_m = private
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_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
real(8) :: tmp
if ((m_m * d_m_1) <= 1.6d+235) then
tmp = (d_m * sqrt((1.0d0 / (h * l)))) * 1.0d0
else
tmp = h * (d_m * sqrt((1.0d0 / ((h ** 3.0d0) * l))))
end if
code = tmp
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
public static double code(double d_m, double h, double l, double M_m, double D_m) {
double tmp;
if ((M_m * D_m) <= 1.6e+235) {
tmp = (d_m * Math.sqrt((1.0 / (h * l)))) * 1.0;
} else {
tmp = h * (d_m * Math.sqrt((1.0 / (Math.pow(h, 3.0) * l))));
}
return tmp;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) def code(d_m, h, l, M_m, D_m): tmp = 0 if (M_m * D_m) <= 1.6e+235: tmp = (d_m * math.sqrt((1.0 / (h * l)))) * 1.0 else: tmp = h * (d_m * math.sqrt((1.0 / (math.pow(h, 3.0) * l)))) return tmp
d_m = abs(d) M_m = abs(M) D_m = abs(D) function code(d_m, h, l, M_m, D_m) tmp = 0.0 if (Float64(M_m * D_m) <= 1.6e+235) tmp = Float64(Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) * 1.0); else tmp = Float64(h * Float64(d_m * sqrt(Float64(1.0 / Float64((h ^ 3.0) * l))))); end return tmp end
d_m = abs(d); M_m = abs(M); D_m = abs(D); function tmp_2 = code(d_m, h, l, M_m, D_m) tmp = 0.0; if ((M_m * D_m) <= 1.6e+235) tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0; else tmp = h * (d_m * sqrt((1.0 / ((h ^ 3.0) * l)))); end tmp_2 = tmp; end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := If[LessEqual[N[(M$95$m * D$95$m), $MachinePrecision], 1.6e+235], N[(N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(h * N[(d$95$m * N[Sqrt[N[(1.0 / N[(N[Power[h, 3.0], $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
\begin{array}{l}
\mathbf{if}\;M\_m \cdot D\_m \leq 1.6 \cdot 10^{+235}:\\
\;\;\;\;\left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;h \cdot \left(d\_m \cdot \sqrt{\frac{1}{{h}^{3} \cdot \ell}}\right)\\
\end{array}
\end{array}
if (*.f64 M D) < 1.60000000000000003e235Initial program 35.3%
Taylor expanded in d around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6469.3
Applied rewrites69.3%
Taylor expanded in d around inf
Applied rewrites42.9%
if 1.60000000000000003e235 < (*.f64 M D) Initial program 35.3%
Taylor expanded in h around inf
lower-*.f64N/A
lower-fma.f64N/A
Applied rewrites13.7%
Taylor expanded in d around 0
lower-*.f64N/A
lift-pow.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f6415.3
Applied rewrites15.3%
Taylor expanded in d around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lift-pow.f6418.4
Applied rewrites18.4%
d_m = (fabs.f64 d) M_m = (fabs.f64 M) D_m = (fabs.f64 D) (FPCore (d_m h l M_m D_m) :precision binary64 (* (* d_m (sqrt (/ 1.0 (* h l)))) 1.0))
d_m = fabs(d);
M_m = fabs(M);
D_m = fabs(D);
double code(double d_m, double h, double l, double M_m, double D_m) {
return (d_m * sqrt((1.0 / (h * l)))) * 1.0;
}
d_m = private
M_m = private
D_m = private
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_m, h, l, m_m, d_m_1)
use fmin_fmax_functions
real(8), intent (in) :: d_m
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m_m
real(8), intent (in) :: d_m_1
code = (d_m * sqrt((1.0d0 / (h * l)))) * 1.0d0
end function
d_m = Math.abs(d);
M_m = Math.abs(M);
D_m = Math.abs(D);
public static double code(double d_m, double h, double l, double M_m, double D_m) {
return (d_m * Math.sqrt((1.0 / (h * l)))) * 1.0;
}
d_m = math.fabs(d) M_m = math.fabs(M) D_m = math.fabs(D) def code(d_m, h, l, M_m, D_m): return (d_m * math.sqrt((1.0 / (h * l)))) * 1.0
d_m = abs(d) M_m = abs(M) D_m = abs(D) function code(d_m, h, l, M_m, D_m) return Float64(Float64(d_m * sqrt(Float64(1.0 / Float64(h * l)))) * 1.0) end
d_m = abs(d); M_m = abs(M); D_m = abs(D); function tmp = code(d_m, h, l, M_m, D_m) tmp = (d_m * sqrt((1.0 / (h * l)))) * 1.0; end
d_m = N[Abs[d], $MachinePrecision] M_m = N[Abs[M], $MachinePrecision] D_m = N[Abs[D], $MachinePrecision] code[d$95$m_, h_, l_, M$95$m_, D$95$m_] := N[(N[(d$95$m * N[Sqrt[N[(1.0 / N[(h * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]
\begin{array}{l}
d_m = \left|d\right|
\\
M_m = \left|M\right|
\\
D_m = \left|D\right|
\\
\left(d\_m \cdot \sqrt{\frac{1}{h \cdot \ell}}\right) \cdot 1
\end{array}
Initial program 35.3%
Taylor expanded in d around 0
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-*.f6469.3
Applied rewrites69.3%
Taylor expanded in d around inf
Applied rewrites42.9%
herbie shell --seed 2025132
(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)))))