
(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}
Sampling outcomes in binary64 precision:
Herbie found 12 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}
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (pow (/ d h) 0.25))
(t_1 (- 1.0 (/ (* (* (pow (/ (* D M) (* 2.0 d)) 2.0) 0.5) h) l)))
(t_2 (sqrt (/ d l))))
(if (<= h -2.35e+188)
(* (* t_2 (* t_0 t_0)) t_1)
(if (<= h -5e-311)
(* (* (- d) (pow (* l h) -0.5)) t_1)
(* (* t_2 (/ (sqrt d) (sqrt h))) t_1)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = pow((d / h), 0.25);
double t_1 = 1.0 - (((pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_2 = sqrt((d / l));
double tmp;
if (h <= -2.35e+188) {
tmp = (t_2 * (t_0 * t_0)) * t_1;
} else if (h <= -5e-311) {
tmp = (-d * pow((l * h), -0.5)) * t_1;
} else {
tmp = (t_2 * (sqrt(d) / sqrt(h))) * t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (d / h) ** 0.25d0
t_1 = 1.0d0 - ((((((d_1 * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l)
t_2 = sqrt((d / l))
if (h <= (-2.35d+188)) then
tmp = (t_2 * (t_0 * t_0)) * t_1
else if (h <= (-5d-311)) then
tmp = (-d * ((l * h) ** (-0.5d0))) * t_1
else
tmp = (t_2 * (sqrt(d) / sqrt(h))) * t_1
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.pow((d / h), 0.25);
double t_1 = 1.0 - (((Math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_2 = Math.sqrt((d / l));
double tmp;
if (h <= -2.35e+188) {
tmp = (t_2 * (t_0 * t_0)) * t_1;
} else if (h <= -5e-311) {
tmp = (-d * Math.pow((l * h), -0.5)) * t_1;
} else {
tmp = (t_2 * (Math.sqrt(d) / Math.sqrt(h))) * t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.pow((d / h), 0.25) t_1 = 1.0 - (((math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l) t_2 = math.sqrt((d / l)) tmp = 0 if h <= -2.35e+188: tmp = (t_2 * (t_0 * t_0)) * t_1 elif h <= -5e-311: tmp = (-d * math.pow((l * h), -0.5)) * t_1 else: tmp = (t_2 * (math.sqrt(d) / math.sqrt(h))) * t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(d / h) ^ 0.25 t_1 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -2.35e+188) tmp = Float64(Float64(t_2 * Float64(t_0 * t_0)) * t_1); elseif (h <= -5e-311) tmp = Float64(Float64(Float64(-d) * (Float64(l * h) ^ -0.5)) * t_1); else tmp = Float64(Float64(t_2 * Float64(sqrt(d) / sqrt(h))) * t_1); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (d / h) ^ 0.25; t_1 = 1.0 - ((((((D * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l); t_2 = sqrt((d / l)); tmp = 0.0; if (h <= -2.35e+188) tmp = (t_2 * (t_0 * t_0)) * t_1; elseif (h <= -5e-311) tmp = (-d * ((l * h) ^ -0.5)) * t_1; else tmp = (t_2 * (sqrt(d) / sqrt(h))) * t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Power[N[(d / h), $MachinePrecision], 0.25], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -2.35e+188], N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[h, -5e-311], N[(N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(t$95$2 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\frac{d}{h}\right)}^{0.25}\\
t_1 := 1 - \frac{\left({\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -2.35 \cdot 10^{+188}:\\
\;\;\;\;\left(t\_2 \cdot \left(t\_0 \cdot t\_0\right)\right) \cdot t\_1\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_1\\
\end{array}
\end{array}
if h < -2.3499999999999999e188Initial program 55.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 rewrites64.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6464.0
Applied rewrites64.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6464.0
Applied rewrites64.0%
lift-/.f64N/A
lift-sqrt.f64N/A
pow1/2N/A
sqr-powN/A
lower-*.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f64N/A
metadata-evalN/A
lower-pow.f64N/A
lift-/.f6464.0
Applied rewrites64.0%
if -2.3499999999999999e188 < h < -5.00000000000023e-311Initial program 70.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 rewrites71.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6471.9
Applied rewrites71.9%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval81.0
Applied rewrites81.0%
if -5.00000000000023e-311 < h Initial program 73.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 rewrites78.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6478.5
Applied rewrites78.5%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.5
Applied rewrites78.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6490.1
Applied rewrites90.1%
(FPCore (d h l M D)
:precision binary64
(if (<=
(*
(* (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))))
-1e-27)
(* (* -0.125 (* (* D D) (/ (* M M) d))) (sqrt (/ h (* (* l l) l))))
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-27) {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((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)))) <= (-1d-27)) then
tmp = ((-0.125d0) * ((d_1 * d_1) * ((m * m) / d))) * sqrt((h / ((l * l) * l)))
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-27) {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * Math.sqrt((h / ((l * l) * l)));
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= -1e-27: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * math.sqrt((h / ((l * l) * l))) else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= -1e-27) tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (((((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)))) <= -1e-27) tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l))); else tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-27], N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq -1 \cdot 10^{-27}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 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)))) < -1e-27Initial program 87.5%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6440.0
Applied rewrites40.0%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6436.7
Applied rewrites36.7%
lift-pow.f64N/A
unpow3N/A
lower-*.f64N/A
lift-*.f6436.7
Applied rewrites36.7%
if -1e-27 < (*.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 60.2%
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 rewrites64.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6465.9
Applied rewrites65.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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6465.9
Applied rewrites65.9%
Taylor expanded in d around inf
Applied rewrites64.1%
(FPCore (d h l M D)
:precision binary64
(if (<=
(*
(* (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))))
0.0)
(* (sqrt (/ (/ 1.0 l) h)) d)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)))
double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = sqrt(((1.0 / l) / h)) * d;
} else {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: tmp
if (((((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)))) <= 0.0d0) then
tmp = sqrt(((1.0d0 / l) / h)) * d
else
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0d0
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0) {
tmp = Math.sqrt(((1.0 / l) / h)) * d;
} else {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * 1.0;
}
return tmp;
}
def code(d, h, l, M, D): 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 * D) / (2.0 * d)), 2.0)) * (h / l)))) <= 0.0: tmp = math.sqrt(((1.0 / l) / h)) * d else: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * 1.0 return tmp
function code(d, h, l, M, D) 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 * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) <= 0.0) tmp = Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d); else tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (((((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)))) <= 0.0) tmp = sqrt(((1.0 / l) / h)) * d; else tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := 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 * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\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 \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right) \leq 0:\\
\;\;\;\;\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 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)))) < 0.0Initial program 81.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-*.f6415.7
Applied rewrites15.7%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6415.7
Applied rewrites15.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6415.7
Applied rewrites15.7%
if 0.0 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) Initial program 62.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.5%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6469.0
Applied rewrites69.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6469.0
Applied rewrites69.0%
Taylor expanded in d around inf
Applied rewrites67.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (sqrt (/ d l)))
(t_1 (* (/ M 2.0) (/ D d)))
(t_2 (- 1.0 (/ (* (* (pow (/ (* D M) (* 2.0 d)) 2.0) 0.5) h) l))))
(if (<= h -2.35e+188)
(* (* t_0 (sqrt (/ d h))) (- 1.0 (/ (* (* (* t_1 t_1) 0.5) h) l)))
(if (<= h -5e-311)
(* (* (- d) (pow (* l h) -0.5)) t_2)
(* (* t_0 (/ (sqrt d) (sqrt h))) t_2)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = sqrt((d / l));
double t_1 = (M / 2.0) * (D / d);
double t_2 = 1.0 - (((pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double tmp;
if (h <= -2.35e+188) {
tmp = (t_0 * sqrt((d / h))) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
} else if (h <= -5e-311) {
tmp = (-d * pow((l * h), -0.5)) * t_2;
} else {
tmp = (t_0 * (sqrt(d) / sqrt(h))) * t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sqrt((d / l))
t_1 = (m / 2.0d0) * (d_1 / d)
t_2 = 1.0d0 - ((((((d_1 * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l)
if (h <= (-2.35d+188)) then
tmp = (t_0 * sqrt((d / h))) * (1.0d0 - ((((t_1 * t_1) * 0.5d0) * h) / l))
else if (h <= (-5d-311)) then
tmp = (-d * ((l * h) ** (-0.5d0))) * t_2
else
tmp = (t_0 * (sqrt(d) / sqrt(h))) * t_2
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = Math.sqrt((d / l));
double t_1 = (M / 2.0) * (D / d);
double t_2 = 1.0 - (((Math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double tmp;
if (h <= -2.35e+188) {
tmp = (t_0 * Math.sqrt((d / h))) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l));
} else if (h <= -5e-311) {
tmp = (-d * Math.pow((l * h), -0.5)) * t_2;
} else {
tmp = (t_0 * (Math.sqrt(d) / Math.sqrt(h))) * t_2;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = math.sqrt((d / l)) t_1 = (M / 2.0) * (D / d) t_2 = 1.0 - (((math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l) tmp = 0 if h <= -2.35e+188: tmp = (t_0 * math.sqrt((d / h))) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l)) elif h <= -5e-311: tmp = (-d * math.pow((l * h), -0.5)) * t_2 else: tmp = (t_0 * (math.sqrt(d) / math.sqrt(h))) * t_2 return tmp
function code(d, h, l, M, D) t_0 = sqrt(Float64(d / l)) t_1 = Float64(Float64(M / 2.0) * Float64(D / d)) t_2 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l)) tmp = 0.0 if (h <= -2.35e+188) tmp = Float64(Float64(t_0 * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_1 * t_1) * 0.5) * h) / l))); elseif (h <= -5e-311) tmp = Float64(Float64(Float64(-d) * (Float64(l * h) ^ -0.5)) * t_2); else tmp = Float64(Float64(t_0 * Float64(sqrt(d) / sqrt(h))) * t_2); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = sqrt((d / l)); t_1 = (M / 2.0) * (D / d); t_2 = 1.0 - ((((((D * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l); tmp = 0.0; if (h <= -2.35e+188) tmp = (t_0 * sqrt((d / h))) * (1.0 - ((((t_1 * t_1) * 0.5) * h) / l)); elseif (h <= -5e-311) tmp = (-d * ((l * h) ^ -0.5)) * t_2; else tmp = (t_0 * (sqrt(d) / sqrt(h))) * t_2; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -2.35e+188], N[(N[(t$95$0 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[h, -5e-311], N[(N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision], N[(N[(t$95$0 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\frac{d}{\ell}}\\
t_1 := \frac{M}{2} \cdot \frac{D}{d}\\
t_2 := 1 - \frac{\left({\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
\mathbf{if}\;h \leq -2.35 \cdot 10^{+188}:\\
\;\;\;\;\left(t\_0 \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_1 \cdot t\_1\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\right) \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_2\\
\end{array}
\end{array}
if h < -2.3499999999999999e188Initial program 55.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 rewrites64.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6464.0
Applied rewrites64.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6464.0
Applied rewrites64.0%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6464.0
Applied rewrites64.0%
if -2.3499999999999999e188 < h < -5.00000000000023e-311Initial program 70.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 rewrites71.0%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6471.9
Applied rewrites71.9%
Taylor expanded in h around -inf
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
mul-1-negN/A
lower-*.f64N/A
lift-neg.f64N/A
inv-powN/A
*-commutativeN/A
sqrt-pow1N/A
lower-pow.f64N/A
lift-*.f64N/A
metadata-eval81.0
Applied rewrites81.0%
if -5.00000000000023e-311 < h Initial program 73.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 rewrites78.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6478.5
Applied rewrites78.5%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.5
Applied rewrites78.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6490.1
Applied rewrites90.1%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (- 1.0 (/ (* (* (pow (/ (* D M) (* 2.0 d)) 2.0) 0.5) h) l)))
(t_1 (sqrt (/ d l))))
(if (<= h -4.2e+110)
(* (* t_1 (sqrt (/ d h))) t_0)
(if (<= h -5e-311)
(*
(* d (/ (- 1.0) (sqrt (* l h))))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l))))
(* (* t_1 (/ (sqrt d) (sqrt h))) t_0)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_1 = sqrt((d / l));
double tmp;
if (h <= -4.2e+110) {
tmp = (t_1 * sqrt((d / h))) * t_0;
} else if (h <= -5e-311) {
tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = (t_1 * (sqrt(d) / sqrt(h))) * t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - ((((((d_1 * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l)
t_1 = sqrt((d / l))
if (h <= (-4.2d+110)) then
tmp = (t_1 * sqrt((d / h))) * t_0
else if (h <= (-5d-311)) then
tmp = (d * (-1.0d0 / sqrt((l * h)))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else
tmp = (t_1 * (sqrt(d) / sqrt(h))) * t_0
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = 1.0 - (((Math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l);
double t_1 = Math.sqrt((d / l));
double tmp;
if (h <= -4.2e+110) {
tmp = (t_1 * Math.sqrt((d / h))) * t_0;
} else if (h <= -5e-311) {
tmp = (d * (-1.0 / Math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else {
tmp = (t_1 * (Math.sqrt(d) / Math.sqrt(h))) * t_0;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = 1.0 - (((math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l) t_1 = math.sqrt((d / l)) tmp = 0 if h <= -4.2e+110: tmp = (t_1 * math.sqrt((d / h))) * t_0 elif h <= -5e-311: tmp = (d * (-1.0 / math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) else: tmp = (t_1 * (math.sqrt(d) / math.sqrt(h))) * t_0 return tmp
function code(d, h, l, M, D) t_0 = Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l)) t_1 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -4.2e+110) tmp = Float64(Float64(t_1 * sqrt(Float64(d / h))) * t_0); elseif (h <= -5e-311) tmp = Float64(Float64(d * Float64(Float64(-1.0) / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); else tmp = Float64(Float64(t_1 * Float64(sqrt(d) / sqrt(h))) * t_0); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = 1.0 - ((((((D * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l); t_1 = sqrt((d / l)); tmp = 0.0; if (h <= -4.2e+110) tmp = (t_1 * sqrt((d / h))) * t_0; elseif (h <= -5e-311) tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); else tmp = (t_1 * (sqrt(d) / sqrt(h))) * t_0; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -4.2e+110], N[(N[(t$95$1 * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[h, -5e-311], N[(N[(d * N[((-1.0) / N[Sqrt[N[(l * h), $MachinePrecision]], $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], N[(N[(t$95$1 * N[(N[Sqrt[d], $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{\left({\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\\
t_1 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -4.2 \cdot 10^{+110}:\\
\;\;\;\;\left(t\_1 \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_0\\
\mathbf{elif}\;h \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\left(d \cdot \frac{-1}{\sqrt{\ell \cdot h}}\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)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_1 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_0\\
\end{array}
\end{array}
if h < -4.2000000000000003e110Initial program 64.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 rewrites71.3%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6471.3
Applied rewrites71.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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6471.3
Applied rewrites71.3%
if -4.2000000000000003e110 < h < -5.00000000000023e-311Initial program 68.7%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6477.7
Applied rewrites77.7%
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-*.f6477.7
Applied rewrites77.7%
if -5.00000000000023e-311 < h Initial program 73.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 rewrites78.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6478.5
Applied rewrites78.5%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6478.5
Applied rewrites78.5%
lift-/.f64N/A
lift-sqrt.f64N/A
sqrt-divN/A
lower-/.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6490.1
Applied rewrites90.1%
Final simplification82.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (pow (/ (* D M) (* 2.0 d)) 2.0) 0.5) h) l)))))
(if (<= h -4.2e+110)
t_0
(if (<= h -8e-298)
(*
(* d (/ (- 1.0) (sqrt (* l h))))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l))))
(if (<= h 1.35e+160)
t_0
(* (* -0.125 (* (* D D) (/ (* M M) d))) (/ (sqrt h) (pow l 1.5))))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - (((pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -4.2e+110) {
tmp = t_0;
} else if (h <= -8e-298) {
tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (h <= 1.35e+160) {
tmp = t_0;
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / pow(l, 1.5));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((((d_1 * m) / (2.0d0 * d)) ** 2.0d0) * 0.5d0) * h) / l))
if (h <= (-4.2d+110)) then
tmp = t_0
else if (h <= (-8d-298)) then
tmp = (d * (-1.0d0 / sqrt((l * h)))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else if (h <= 1.35d+160) then
tmp = t_0
else
tmp = ((-0.125d0) * ((d_1 * d_1) * ((m * m) / d))) * (sqrt(h) / (l ** 1.5d0))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - (((Math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l));
double tmp;
if (h <= -4.2e+110) {
tmp = t_0;
} else if (h <= -8e-298) {
tmp = (d * (-1.0 / Math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (h <= 1.35e+160) {
tmp = t_0;
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (Math.sqrt(h) / Math.pow(l, 1.5));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - (((math.pow(((D * M) / (2.0 * d)), 2.0) * 0.5) * h) / l)) tmp = 0 if h <= -4.2e+110: tmp = t_0 elif h <= -8e-298: tmp = (d * (-1.0 / math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) elif h <= 1.35e+160: tmp = t_0 else: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (math.sqrt(h) / math.pow(l, 1.5)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D * M) / Float64(2.0 * d)) ^ 2.0) * 0.5) * h) / l))) tmp = 0.0 if (h <= -4.2e+110) tmp = t_0; elseif (h <= -8e-298) tmp = Float64(Float64(d * Float64(Float64(-1.0) / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); elseif (h <= 1.35e+160) tmp = t_0; else tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * Float64(sqrt(h) / (l ^ 1.5))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((((D * M) / (2.0 * d)) ^ 2.0) * 0.5) * h) / l)); tmp = 0.0; if (h <= -4.2e+110) tmp = t_0; elseif (h <= -8e-298) tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); elseif (h <= 1.35e+160) tmp = t_0; else tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / (l ^ 1.5)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D * M), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * 0.5), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -4.2e+110], t$95$0, If[LessEqual[h, -8e-298], N[(N[(d * N[((-1.0) / N[Sqrt[N[(l * h), $MachinePrecision]], $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], If[LessEqual[h, 1.35e+160], t$95$0, N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{D \cdot M}{2 \cdot d}\right)}^{2} \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{if}\;h \leq -4.2 \cdot 10^{+110}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;h \leq -8 \cdot 10^{-298}:\\
\;\;\;\;\left(d \cdot \frac{-1}{\sqrt{\ell \cdot h}}\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)\\
\mathbf{elif}\;h \leq 1.35 \cdot 10^{+160}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\\
\end{array}
\end{array}
if h < -4.2000000000000003e110 or -7.9999999999999993e-298 < h < 1.35e160Initial program 75.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites82.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6482.4
Applied rewrites82.4%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6482.4
Applied rewrites82.4%
if -4.2000000000000003e110 < h < -7.9999999999999993e-298Initial program 69.6%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6480.0
Applied rewrites80.0%
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-*.f6480.0
Applied rewrites80.0%
if 1.35e160 < h Initial program 39.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6461.2
Applied rewrites61.2%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.2
Applied rewrites61.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-divN/A
lower-/.f64N/A
lift-sqrt.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
metadata-eval70.2
Applied rewrites70.2%
Final simplification80.4%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ M 2.0) (/ D d)))
(t_1
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))))
(if (<= h -4.2e+110)
t_1
(if (<= h -7.2e-298)
(*
(* d (/ (- 1.0) (sqrt (* l h))))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l))))
(if (<= h 1.35e+160)
t_1
(* (* -0.125 (* (* D D) (/ (* M M) d))) (/ (sqrt h) (pow l 1.5))))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
double tmp;
if (h <= -4.2e+110) {
tmp = t_1;
} else if (h <= -7.2e-298) {
tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (h <= 1.35e+160) {
tmp = t_1;
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / pow(l, 1.5));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (m / 2.0d0) * (d_1 / d)
t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
if (h <= (-4.2d+110)) then
tmp = t_1
else if (h <= (-7.2d-298)) then
tmp = (d * (-1.0d0 / sqrt((l * h)))) * (1.0d0 - (((1.0d0 / 2.0d0) * (((m * d_1) / (2.0d0 * d)) ** 2.0d0)) * (h / l)))
else if (h <= 1.35d+160) then
tmp = t_1
else
tmp = ((-0.125d0) * ((d_1 * d_1) * ((m * m) / d))) * (sqrt(h) / (l ** 1.5d0))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double t_1 = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
double tmp;
if (h <= -4.2e+110) {
tmp = t_1;
} else if (h <= -7.2e-298) {
tmp = (d * (-1.0 / Math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
} else if (h <= 1.35e+160) {
tmp = t_1;
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (Math.sqrt(h) / Math.pow(l, 1.5));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (M / 2.0) * (D / d) t_1 = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) tmp = 0 if h <= -4.2e+110: tmp = t_1 elif h <= -7.2e-298: tmp = (d * (-1.0 / math.sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) elif h <= 1.35e+160: tmp = t_1 else: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (math.sqrt(h) / math.pow(l, 1.5)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(M / 2.0) * Float64(D / d)) t_1 = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))) tmp = 0.0 if (h <= -4.2e+110) tmp = t_1; elseif (h <= -7.2e-298) tmp = Float64(Float64(d * Float64(Float64(-1.0) / sqrt(Float64(l * h)))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))); elseif (h <= 1.35e+160) tmp = t_1; else tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * Float64(sqrt(h) / (l ^ 1.5))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (M / 2.0) * (D / d); t_1 = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)); tmp = 0.0; if (h <= -4.2e+110) tmp = t_1; elseif (h <= -7.2e-298) tmp = (d * (-1.0 / sqrt((l * h)))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); elseif (h <= 1.35e+160) tmp = t_1; else tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / (l ^ 1.5)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[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]}, If[LessEqual[h, -4.2e+110], t$95$1, If[LessEqual[h, -7.2e-298], N[(N[(d * N[((-1.0) / N[Sqrt[N[(l * h), $MachinePrecision]], $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], If[LessEqual[h, 1.35e+160], t$95$1, N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{M}{2} \cdot \frac{D}{d}\\
t_1 := \left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{if}\;h \leq -4.2 \cdot 10^{+110}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;h \leq -7.2 \cdot 10^{-298}:\\
\;\;\;\;\left(d \cdot \frac{-1}{\sqrt{\ell \cdot h}}\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)\\
\mathbf{elif}\;h \leq 1.35 \cdot 10^{+160}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\\
\end{array}
\end{array}
if h < -4.2000000000000003e110 or -7.20000000000000005e-298 < h < 1.35e160Initial program 75.3%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
Applied rewrites82.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6482.4
Applied rewrites82.4%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6482.4
Applied rewrites82.4%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6482.2
Applied rewrites82.2%
if -4.2000000000000003e110 < h < -7.20000000000000005e-298Initial program 69.6%
Taylor expanded in h around -inf
lower-*.f64N/A
sqrt-pow2N/A
metadata-evalN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6480.0
Applied rewrites80.0%
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-*.f6480.0
Applied rewrites80.0%
if 1.35e160 < h Initial program 39.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6461.2
Applied rewrites61.2%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.2
Applied rewrites61.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-divN/A
lower-/.f64N/A
lift-sqrt.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
metadata-eval70.2
Applied rewrites70.2%
Final simplification80.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ M 2.0) (/ D d))))
(if (<= h 1.35e+160)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (* -0.125 (* (* D D) (/ (* M M) d))) (/ (sqrt h) (pow l 1.5))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double tmp;
if (h <= 1.35e+160) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / pow(l, 1.5));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (m / 2.0d0) * (d_1 / d)
if (h <= 1.35d+160) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = ((-0.125d0) * ((d_1 * d_1) * ((m * m) / d))) * (sqrt(h) / (l ** 1.5d0))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double tmp;
if (h <= 1.35e+160) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (Math.sqrt(h) / Math.pow(l, 1.5));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (M / 2.0) * (D / d) tmp = 0 if h <= 1.35e+160: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (math.sqrt(h) / math.pow(l, 1.5)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(M / 2.0) * Float64(D / d)) tmp = 0.0 if (h <= 1.35e+160) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * Float64(sqrt(h) / (l ^ 1.5))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (M / 2.0) * (D / d); tmp = 0.0; if (h <= 1.35e+160) tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)); else tmp = (-0.125 * ((D * D) * ((M * M) / d))) * (sqrt(h) / (l ^ 1.5)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, 1.35e+160], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[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[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Sqrt[h], $MachinePrecision] / N[Power[l, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{M}{2} \cdot \frac{D}{d}\\
\mathbf{if}\;h \leq 1.35 \cdot 10^{+160}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \frac{\sqrt{h}}{{\ell}^{1.5}}\\
\end{array}
\end{array}
if h < 1.35e160Initial program 73.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 rewrites76.9%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6477.4
Applied rewrites77.4%
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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6477.4
Applied rewrites77.4%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.9
Applied rewrites76.9%
if 1.35e160 < h Initial program 39.7%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6461.2
Applied rewrites61.2%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.2
Applied rewrites61.2%
lift-sqrt.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
sqrt-divN/A
lower-/.f64N/A
lift-sqrt.f64N/A
sqrt-pow1N/A
lower-pow.f64N/A
metadata-eval70.2
Applied rewrites70.2%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ M 2.0) (/ D d))))
(if (<= h 1.3e+251)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* (* (* t_0 t_0) 0.5) h) l)))
(* (* -0.125 (* (* D D) (/ (* M M) d))) (sqrt (/ h (* (* l l) l)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double tmp;
if (h <= 1.3e+251) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d, h, l, m, d_1)
use fmin_fmax_functions
real(8), intent (in) :: d
real(8), intent (in) :: h
real(8), intent (in) :: l
real(8), intent (in) :: m
real(8), intent (in) :: d_1
real(8) :: t_0
real(8) :: tmp
t_0 = (m / 2.0d0) * (d_1 / d)
if (h <= 1.3d+251) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((t_0 * t_0) * 0.5d0) * h) / l))
else
tmp = ((-0.125d0) * ((d_1 * d_1) * ((m * m) / d))) * sqrt((h / ((l * l) * l)))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (M / 2.0) * (D / d);
double tmp;
if (h <= 1.3e+251) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l));
} else {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * Math.sqrt((h / ((l * l) * l)));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (M / 2.0) * (D / d) tmp = 0 if h <= 1.3e+251: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)) else: tmp = (-0.125 * ((D * D) * ((M * M) / d))) * math.sqrt((h / ((l * l) * l))) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(M / 2.0) * Float64(D / d)) tmp = 0.0 if (h <= 1.3e+251) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(t_0 * t_0) * 0.5) * h) / l))); else tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * sqrt(Float64(h / Float64(Float64(l * l) * l)))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (M / 2.0) * (D / d); tmp = 0.0; if (h <= 1.3e+251) tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((t_0 * t_0) * 0.5) * h) / l)); else tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / ((l * l) * l))); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(M / 2.0), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, 1.3e+251], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[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[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{M}{2} \cdot \frac{D}{d}\\
\mathbf{if}\;h \leq 1.3 \cdot 10^{+251}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\left(t\_0 \cdot t\_0\right) \cdot 0.5\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \sqrt{\frac{h}{\left(\ell \cdot \ell\right) \cdot \ell}}\\
\end{array}
\end{array}
if h < 1.3000000000000001e251Initial program 72.2%
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
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6476.7
Applied rewrites76.7%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
lift-/.f64N/A
lift-/.f64N/A
metadata-evalN/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6476.7
Applied rewrites76.7%
lift-pow.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6476.2
Applied rewrites76.2%
if 1.3000000000000001e251 < h Initial program 31.3%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6461.9
Applied rewrites61.9%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6461.9
Applied rewrites61.9%
lift-pow.f64N/A
unpow3N/A
lower-*.f64N/A
lift-*.f6461.9
Applied rewrites61.9%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (* l l) l)))
(if (<= d -1.35e+86)
(* (- d) (pow (* l h) -0.5))
(if (<= d -5.5e-81)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) 1.0)
(if (<= d -2e-310)
(/
(fma
(- d)
(sqrt (/ t_0 h))
(* (* (sqrt (* l h)) (/ (* (* M D) (* M D)) d)) 0.125))
(* l l))
(if (<= d 8.5e-111)
(* (* -0.125 (* (* D D) (/ (* M M) d))) (sqrt (/ h t_0)))
(* (/ 1.0 (* (sqrt l) (sqrt h))) d)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (l * l) * l;
double tmp;
if (d <= -1.35e+86) {
tmp = -d * pow((l * h), -0.5);
} else if (d <= -5.5e-81) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * 1.0;
} else if (d <= -2e-310) {
tmp = fma(-d, sqrt((t_0 / h)), ((sqrt((l * h)) * (((M * D) * (M * D)) / d)) * 0.125)) / (l * l);
} else if (d <= 8.5e-111) {
tmp = (-0.125 * ((D * D) * ((M * M) / d))) * sqrt((h / t_0));
} else {
tmp = (1.0 / (sqrt(l) * sqrt(h))) * d;
}
return tmp;
}
function code(d, h, l, M, D) t_0 = Float64(Float64(l * l) * l) tmp = 0.0 if (d <= -1.35e+86) tmp = Float64(Float64(-d) * (Float64(l * h) ^ -0.5)); elseif (d <= -5.5e-81) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * 1.0); elseif (d <= -2e-310) tmp = Float64(fma(Float64(-d), sqrt(Float64(t_0 / h)), Float64(Float64(sqrt(Float64(l * h)) * Float64(Float64(Float64(M * D) * Float64(M * D)) / d)) * 0.125)) / Float64(l * l)); elseif (d <= 8.5e-111) tmp = Float64(Float64(-0.125 * Float64(Float64(D * D) * Float64(Float64(M * M) / d))) * sqrt(Float64(h / t_0))); else tmp = Float64(Float64(1.0 / Float64(sqrt(l) * sqrt(h))) * d); end return tmp end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(l * l), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[d, -1.35e+86], N[((-d) * N[Power[N[(l * h), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.5e-81], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[d, -2e-310], N[(N[((-d) * N[Sqrt[N[(t$95$0 / h), $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision]), $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 8.5e-111], N[(N[(-0.125 * N[(N[(D * D), $MachinePrecision] * N[(N[(M * M), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(h / t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\ell \cdot \ell\right) \cdot \ell\\
\mathbf{if}\;d \leq -1.35 \cdot 10^{+86}:\\
\;\;\;\;\left(-d\right) \cdot {\left(\ell \cdot h\right)}^{-0.5}\\
\mathbf{elif}\;d \leq -5.5 \cdot 10^{-81}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot 1\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, \sqrt{\frac{t\_0}{h}}, \left(\sqrt{\ell \cdot h} \cdot \frac{\left(M \cdot D\right) \cdot \left(M \cdot D\right)}{d}\right) \cdot 0.125\right)}{\ell \cdot \ell}\\
\mathbf{elif}\;d \leq 8.5 \cdot 10^{-111}:\\
\;\;\;\;\left(-0.125 \cdot \left(\left(D \cdot D\right) \cdot \frac{M \cdot M}{d}\right)\right) \cdot \sqrt{\frac{h}{t\_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sqrt{\ell} \cdot \sqrt{h}} \cdot d\\
\end{array}
\end{array}
if d < -1.35000000000000009e86Initial program 67.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 rewrites72.0%
Taylor expanded in l around -inf
metadata-evalN/A
metadata-evalN/A
Applied rewrites65.3%
if -1.35000000000000009e86 < d < -5.50000000000000026e-81Initial program 77.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 rewrites81.2%
lift-*.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f6481.2
Applied rewrites81.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
*-commutativeN/A
lower-*.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f64N/A
pow1/2N/A
lower-sqrt.f64N/A
lift-/.f6481.2
Applied rewrites81.2%
Taylor expanded in d around inf
Applied rewrites52.2%
if -5.50000000000000026e-81 < d < -1.999999999999994e-310Initial program 56.9%
Taylor expanded in l around -inf
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites56.1%
Taylor expanded in l around 0
lower-/.f64N/A
Applied rewrites43.3%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6443.3
Applied rewrites43.3%
lift-pow.f64N/A
unpow3N/A
lower-*.f64N/A
lift-*.f6443.3
Applied rewrites43.3%
if -1.999999999999994e-310 < d < 8.5000000000000003e-111Initial program 63.6%
Taylor expanded in d around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-/.f64N/A
pow-prod-downN/A
*-commutativeN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
lower-pow.f6470.2
Applied rewrites70.2%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
associate-/l*N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6466.2
Applied rewrites66.2%
lift-pow.f64N/A
unpow3N/A
lower-*.f64N/A
lift-*.f6466.2
Applied rewrites66.2%
if 8.5000000000000003e-111 < d Initial program 80.2%
Taylor expanded in d around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
inv-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f6462.4
Applied rewrites62.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-*.f6462.4
Applied rewrites62.4%
lift-*.f64N/A
lift-sqrt.f64N/A
sqrt-prodN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lift-sqrt.f6465.2
Applied rewrites65.2%
(FPCore (d h l M D) :precision binary64 (* (sqrt (/ (/ 1.0 l) h)) d))
double code(double d, double h, double l, double M, double D) {
return sqrt(((1.0 / l) / h)) * d;
}
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 = sqrt(((1.0d0 / l) / h)) * d
end function
public static double code(double d, double h, double l, double M, double D) {
return Math.sqrt(((1.0 / l) / h)) * d;
}
def code(d, h, l, M, D): return math.sqrt(((1.0 / l) / h)) * d
function code(d, h, l, M, D) return Float64(sqrt(Float64(Float64(1.0 / l) / h)) * d) end
function tmp = code(d, h, l, M, D) tmp = sqrt(((1.0 / l) / h)) * d; end
code[d_, h_, l_, M_, D_] := N[(N[Sqrt[N[(N[(1.0 / l), $MachinePrecision] / h), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{\frac{1}{\ell}}{h}} \cdot d
\end{array}
Initial program 70.1%
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-*.f6425.4
Applied rewrites25.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6425.4
Applied rewrites25.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6425.4
Applied rewrites25.4%
(FPCore (d h l M D) :precision binary64 (* (sqrt (/ 1.0 (* l h))) d))
double code(double d, double h, double l, double M, double D) {
return sqrt((1.0 / (l * h))) * d;
}
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 = sqrt((1.0d0 / (l * h))) * d
end function
public static double code(double d, double h, double l, double M, double D) {
return Math.sqrt((1.0 / (l * h))) * d;
}
def code(d, h, l, M, D): return math.sqrt((1.0 / (l * h))) * d
function code(d, h, l, M, D) return Float64(sqrt(Float64(1.0 / Float64(l * h))) * d) end
function tmp = code(d, h, l, M, D) tmp = sqrt((1.0 / (l * h))) * d; end
code[d_, h_, l_, M_, D_] := N[(N[Sqrt[N[(1.0 / N[(l * h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * d), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{\frac{1}{\ell \cdot h}} \cdot d
\end{array}
Initial program 70.1%
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-*.f6425.4
Applied rewrites25.4%
lift-*.f64N/A
lift-pow.f64N/A
unpow-1N/A
lower-/.f64N/A
lift-*.f6425.4
Applied rewrites25.4%
herbie shell --seed 2025050
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
:pre (TRUE)
(* (* (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)))))