
(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 15 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 (* (/ D d) (/ M 2.0))))
(if (<= h -5e-310)
(*
(* (sqrt (- d)) (/ (sqrt (/ d l)) (sqrt (- h))))
(- 1.0 (/ (* (* (pow (* (/ D 2.0) (/ M d)) 2.0) (/ 1.0 2.0)) h) l)))
(*
(/ (* (sqrt d) (sqrt d)) (* (sqrt l) (sqrt h)))
(- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double tmp;
if (h <= -5e-310) {
tmp = (sqrt(-d) * (sqrt((d / l)) / sqrt(-h))) * (1.0 - (((pow(((D / 2.0) * (M / d)), 2.0) * (1.0 / 2.0)) * h) / l));
} else {
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / 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 = (d_1 / d) * (m / 2.0d0)
if (h <= (-5d-310)) then
tmp = (sqrt(-d) * (sqrt((d / l)) / sqrt(-h))) * (1.0d0 - ((((((d_1 / 2.0d0) * (m / d)) ** 2.0d0) * (1.0d0 / 2.0d0)) * h) / l))
else
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double tmp;
if (h <= -5e-310) {
tmp = (Math.sqrt(-d) * (Math.sqrt((d / l)) / Math.sqrt(-h))) * (1.0 - (((Math.pow(((D / 2.0) * (M / d)), 2.0) * (1.0 / 2.0)) * h) / l));
} else {
tmp = ((Math.sqrt(d) * Math.sqrt(d)) / (Math.sqrt(l) * Math.sqrt(h))) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (D / d) * (M / 2.0) tmp = 0 if h <= -5e-310: tmp = (math.sqrt(-d) * (math.sqrt((d / l)) / math.sqrt(-h))) * (1.0 - (((math.pow(((D / 2.0) * (M / d)), 2.0) * (1.0 / 2.0)) * h) / l)) else: tmp = ((math.sqrt(d) * math.sqrt(d)) / (math.sqrt(l) * math.sqrt(h))) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(sqrt(Float64(-d)) * Float64(sqrt(Float64(d / l)) / sqrt(Float64(-h)))) * Float64(1.0 - Float64(Float64(Float64((Float64(Float64(D / 2.0) * Float64(M / d)) ^ 2.0) * Float64(1.0 / 2.0)) * h) / l))); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(d)) / Float64(sqrt(l) * sqrt(h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (D / d) * (M / 2.0); tmp = 0.0; if (h <= -5e-310) tmp = (sqrt(-d) * (sqrt((d / l)) / sqrt(-h))) * (1.0 - ((((((D / 2.0) * (M / d)) ^ 2.0) * (1.0 / 2.0)) * h) / l)); else tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(N[Sqrt[(-d)], $MachinePrecision] * N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[Power[N[(N[(D / 2.0), $MachinePrecision] * N[(M / d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * h), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(\sqrt{-d} \cdot \frac{\sqrt{\frac{d}{\ell}}}{\sqrt{-h}}\right) \cdot \left(1 - \frac{\left({\left(\frac{D}{2} \cdot \frac{M}{d}\right)}^{2} \cdot \frac{1}{2}\right) \cdot h}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\right)\\
\end{array}
\end{array}
if h < -4.999999999999985e-310Initial program 74.0%
Applied rewrites74.1%
Applied rewrites85.4%
if -4.999999999999985e-310 < h Initial program 67.2%
Applied rewrites71.1%
Applied rewrites74.1%
Applied rewrites74.1%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites92.8%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (* (/ D d) (/ M 2.0))))
(if (<= t_0 3e+160)
(*
(-
1.0
(/
(* (* (/ M d) D) (/ (* (* (/ h l) (/ 1.0 2.0)) (* (/ D 2.0) M)) d))
2.0))
(sqrt (* (/ d l) (/ d h))))
(if (<= t_0 5e+255)
(/ (* (sqrt d) (sqrt (/ d h))) (sqrt l))
(*
(sqrt (* (/ (/ d l) h) d))
(- 1.0 (/ (* t_1 (* t_1 (* (/ 1.0 2.0) h))) l)))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (D / d) * (M / 2.0);
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - ((((M / d) * D) * ((((h / l) * (1.0 / 2.0)) * ((D / 2.0) * M)) / d)) / 2.0)) * sqrt(((d / l) * (d / h)));
} else if (t_0 <= 5e+255) {
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l);
} else {
tmp = sqrt((((d / l) / h) * d)) * (1.0 - ((t_1 * (t_1 * ((1.0 / 2.0) * h))) / 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) :: t_1
real(8) :: tmp
t_0 = (((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)))
t_1 = (d_1 / d) * (m / 2.0d0)
if (t_0 <= 3d+160) then
tmp = (1.0d0 - ((((m / d) * d_1) * ((((h / l) * (1.0d0 / 2.0d0)) * ((d_1 / 2.0d0) * m)) / d)) / 2.0d0)) * sqrt(((d / l) * (d / h)))
else if (t_0 <= 5d+255) then
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l)
else
tmp = sqrt((((d / l) / h) * d)) * (1.0d0 - ((t_1 * (t_1 * ((1.0d0 / 2.0d0) * h))) / l))
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), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = (D / d) * (M / 2.0);
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - ((((M / d) * D) * ((((h / l) * (1.0 / 2.0)) * ((D / 2.0) * M)) / d)) / 2.0)) * Math.sqrt(((d / l) * (d / h)));
} else if (t_0 <= 5e+255) {
tmp = (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
} else {
tmp = Math.sqrt((((d / l) / h) * d)) * (1.0 - ((t_1 * (t_1 * ((1.0 / 2.0) * h))) / l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = (D / d) * (M / 2.0) tmp = 0 if t_0 <= 3e+160: tmp = (1.0 - ((((M / d) * D) * ((((h / l) * (1.0 / 2.0)) * ((D / 2.0) * M)) / d)) / 2.0)) * math.sqrt(((d / l) * (d / h))) elif t_0 <= 5e+255: tmp = (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l) else: tmp = math.sqrt((((d / l) / h) * d)) * (1.0 - ((t_1 * (t_1 * ((1.0 / 2.0) * h))) / l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = Float64(Float64(D / d) * Float64(M / 2.0)) tmp = 0.0 if (t_0 <= 3e+160) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(M / d) * D) * Float64(Float64(Float64(Float64(h / l) * Float64(1.0 / 2.0)) * Float64(Float64(D / 2.0) * M)) / d)) / 2.0)) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); elseif (t_0 <= 5e+255) tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)); else tmp = Float64(sqrt(Float64(Float64(Float64(d / l) / h) * d)) * Float64(1.0 - Float64(Float64(t_1 * Float64(t_1 * Float64(Float64(1.0 / 2.0) * h))) / l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = (D / d) * (M / 2.0); tmp = 0.0; if (t_0 <= 3e+160) tmp = (1.0 - ((((M / d) * D) * ((((h / l) * (1.0 / 2.0)) * ((D / 2.0) * M)) / d)) / 2.0)) * sqrt(((d / l) * (d / h))); elseif (t_0 <= 5e+255) tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); else tmp = sqrt((((d / l) / h) * d)) * (1.0 - ((t_1 * (t_1 * ((1.0 / 2.0) * h))) / l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 3e+160], N[(N[(1.0 - N[(N[(N[(N[(M / d), $MachinePrecision] * D), $MachinePrecision] * N[(N[(N[(N[(h / l), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(D / 2.0), $MachinePrecision] * M), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+255], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(t$95$1 * N[(t$95$1 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \frac{D}{d} \cdot \frac{M}{2}\\
\mathbf{if}\;t\_0 \leq 3 \cdot 10^{+160}:\\
\;\;\;\;\left(1 - \frac{\left(\frac{M}{d} \cdot D\right) \cdot \frac{\left(\frac{h}{\ell} \cdot \frac{1}{2}\right) \cdot \left(\frac{D}{2} \cdot M\right)}{d}}{2}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+255}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{\frac{d}{\ell}}{h} \cdot d} \cdot \left(1 - \frac{t\_1 \cdot \left(t\_1 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\right)\\
\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)))) < 2.9999999999999999e160Initial program 87.9%
Applied rewrites87.9%
Applied rewrites78.1%
Applied rewrites78.7%
Applied rewrites78.7%
if 2.9999999999999999e160 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e255Initial program 99.1%
Applied rewrites99.1%
Applied rewrites45.7%
Taylor expanded in d around inf
Applied rewrites45.7%
if 5.0000000000000002e255 < (*.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 28.2%
Applied rewrites35.1%
Applied rewrites37.7%
Applied rewrites42.7%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_0 3e+160)
(*
(-
1.0
(/
(* (* M D) (* (* (/ (/ D 2.0) d) M) (* (/ h l) (/ 1.0 2.0))))
(* 2.0 d)))
t_1)
(if (<= t_0 5e+255)
(/ (* (sqrt d) (sqrt (/ d h))) (sqrt l))
(*
(-
1.0
(/
(* (* (/ M d) D) (* (* (* (/ M 2.0) h) (/ 1.0 2.0)) (/ D d)))
(* 2.0 l)))
t_1)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1;
} else if (t_0 <= 5e+255) {
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l);
} else {
tmp = (1.0 - ((((M / d) * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / (2.0 * l))) * 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) :: tmp
t_0 = (((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)))
t_1 = sqrt(((d / l) * (d / h)))
if (t_0 <= 3d+160) then
tmp = (1.0d0 - (((m * d_1) * ((((d_1 / 2.0d0) / d) * m) * ((h / l) * (1.0d0 / 2.0d0)))) / (2.0d0 * d))) * t_1
else if (t_0 <= 5d+255) then
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l)
else
tmp = (1.0d0 - ((((m / d) * d_1) * ((((m / 2.0d0) * h) * (1.0d0 / 2.0d0)) * (d_1 / d))) / (2.0d0 * l))) * 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), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1;
} else if (t_0 <= 5e+255) {
tmp = (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
} else {
tmp = (1.0 - ((((M / d) * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / (2.0 * l))) * t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt(((d / l) * (d / h))) tmp = 0 if t_0 <= 3e+160: tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1 elif t_0 <= 5e+255: tmp = (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l) else: tmp = (1.0 - ((((M / d) * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / (2.0 * l))) * t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_0 <= 3e+160) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(D / 2.0) / d) * M) * Float64(Float64(h / l) * Float64(1.0 / 2.0)))) / Float64(2.0 * d))) * t_1); elseif (t_0 <= 5e+255) tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(M / d) * D) * Float64(Float64(Float64(Float64(M / 2.0) * h) * Float64(1.0 / 2.0)) * Float64(D / d))) / Float64(2.0 * l))) * t_1); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = sqrt(((d / l) * (d / h))); tmp = 0.0; if (t_0 <= 3e+160) tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1; elseif (t_0 <= 5e+255) tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); else tmp = (1.0 - ((((M / d) * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / (2.0 * l))) * t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 3e+160], N[(N[(1.0 - N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision] * M), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 5e+255], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(M / d), $MachinePrecision] * D), $MachinePrecision] * N[(N[(N[(N[(M / 2.0), $MachinePrecision] * h), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq 3 \cdot 10^{+160}:\\
\;\;\;\;\left(1 - \frac{\left(M \cdot D\right) \cdot \left(\left(\frac{\frac{D}{2}}{d} \cdot M\right) \cdot \left(\frac{h}{\ell} \cdot \frac{1}{2}\right)\right)}{2 \cdot d}\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+255}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{\left(\frac{M}{d} \cdot D\right) \cdot \left(\left(\left(\frac{M}{2} \cdot h\right) \cdot \frac{1}{2}\right) \cdot \frac{D}{d}\right)}{2 \cdot \ell}\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.9999999999999999e160Initial program 87.9%
Applied rewrites87.9%
Applied rewrites78.1%
Applied rewrites78.1%
if 2.9999999999999999e160 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e255Initial program 99.1%
Applied rewrites99.1%
Applied rewrites45.7%
Taylor expanded in d around inf
Applied rewrites45.7%
if 5.0000000000000002e255 < (*.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 28.2%
Applied rewrites35.1%
Applied rewrites28.3%
Applied rewrites37.6%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0
(*
(* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0)))
(- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))
(t_1 (sqrt (* (/ d l) (/ d h)))))
(if (<= t_0 3e+160)
(*
(-
1.0
(/
(* (* M D) (* (* (/ (/ D 2.0) d) M) (* (/ h l) (/ 1.0 2.0))))
(* 2.0 d)))
t_1)
(if (<= t_0 5e+255)
(/ (* (sqrt d) (sqrt (/ d h))) (sqrt l))
(*
(-
1.0
(*
(* (* (* (/ M 2.0) h) (/ 1.0 2.0)) (/ D d))
(/ (* M D) (* (* 2.0 d) l))))
t_1)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (pow((d / h), (1.0 / 2.0)) * pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1;
} else if (t_0 <= 5e+255) {
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l);
} else {
tmp = (1.0 - (((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d)) * ((M * D) / ((2.0 * d) * l)))) * 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) :: tmp
t_0 = (((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)))
t_1 = sqrt(((d / l) * (d / h)))
if (t_0 <= 3d+160) then
tmp = (1.0d0 - (((m * d_1) * ((((d_1 / 2.0d0) / d) * m) * ((h / l) * (1.0d0 / 2.0d0)))) / (2.0d0 * d))) * t_1
else if (t_0 <= 5d+255) then
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l)
else
tmp = (1.0d0 - (((((m / 2.0d0) * h) * (1.0d0 / 2.0d0)) * (d_1 / d)) * ((m * d_1) / ((2.0d0 * d) * l)))) * 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), (1.0 / 2.0)) * Math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * Math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l)));
double t_1 = Math.sqrt(((d / l) * (d / h)));
double tmp;
if (t_0 <= 3e+160) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1;
} else if (t_0 <= 5e+255) {
tmp = (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
} else {
tmp = (1.0 - (((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d)) * ((M * D) / ((2.0 * d) * l)))) * t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (math.pow((d / h), (1.0 / 2.0)) * math.pow((d / l), (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * math.pow(((M * D) / (2.0 * d)), 2.0)) * (h / l))) t_1 = math.sqrt(((d / l) * (d / h))) tmp = 0 if t_0 <= 3e+160: tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1 elif t_0 <= 5e+255: tmp = (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l) else: tmp = (1.0 - (((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d)) * ((M * D) / ((2.0 * d) * l)))) * t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64((Float64(d / h) ^ Float64(1.0 / 2.0)) * (Float64(d / l) ^ Float64(1.0 / 2.0))) * Float64(1.0 - Float64(Float64(Float64(1.0 / 2.0) * (Float64(Float64(M * D) / Float64(2.0 * d)) ^ 2.0)) * Float64(h / l)))) t_1 = sqrt(Float64(Float64(d / l) * Float64(d / h))) tmp = 0.0 if (t_0 <= 3e+160) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(D / 2.0) / d) * M) * Float64(Float64(h / l) * Float64(1.0 / 2.0)))) / Float64(2.0 * d))) * t_1); elseif (t_0 <= 5e+255) tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)); else tmp = Float64(Float64(1.0 - Float64(Float64(Float64(Float64(Float64(M / 2.0) * h) * Float64(1.0 / 2.0)) * Float64(D / d)) * Float64(Float64(M * D) / Float64(Float64(2.0 * d) * l)))) * t_1); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (((d / h) ^ (1.0 / 2.0)) * ((d / l) ^ (1.0 / 2.0))) * (1.0 - (((1.0 / 2.0) * (((M * D) / (2.0 * d)) ^ 2.0)) * (h / l))); t_1 = sqrt(((d / l) * (d / h))); tmp = 0.0; if (t_0 <= 3e+160) tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * t_1; elseif (t_0 <= 5e+255) tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); else tmp = (1.0 - (((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d)) * ((M * D) / ((2.0 * d) * l)))) * t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 3e+160], N[(N[(1.0 - N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision] * M), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 5e+255], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 - N[(N[(N[(N[(N[(M / 2.0), $MachinePrecision] * h), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision] * N[(N[(M * D), $MachinePrecision] / N[(N[(2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left({\left(\frac{d}{h}\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\frac{d}{\ell}\right)}^{\left(\frac{1}{2}\right)}\right) \cdot \left(1 - \left(\frac{1}{2} \cdot {\left(\frac{M \cdot D}{2 \cdot d}\right)}^{2}\right) \cdot \frac{h}{\ell}\right)\\
t_1 := \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{if}\;t\_0 \leq 3 \cdot 10^{+160}:\\
\;\;\;\;\left(1 - \frac{\left(M \cdot D\right) \cdot \left(\left(\frac{\frac{D}{2}}{d} \cdot M\right) \cdot \left(\frac{h}{\ell} \cdot \frac{1}{2}\right)\right)}{2 \cdot d}\right) \cdot t\_1\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+255}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 - \left(\left(\left(\frac{M}{2} \cdot h\right) \cdot \frac{1}{2}\right) \cdot \frac{D}{d}\right) \cdot \frac{M \cdot D}{\left(2 \cdot d\right) \cdot \ell}\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 2.9999999999999999e160Initial program 87.9%
Applied rewrites87.9%
Applied rewrites78.1%
Applied rewrites78.1%
if 2.9999999999999999e160 < (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e255Initial program 99.1%
Applied rewrites99.1%
Applied rewrites45.7%
Taylor expanded in d around inf
Applied rewrites45.7%
if 5.0000000000000002e255 < (*.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 28.2%
Applied rewrites35.1%
Applied rewrites28.3%
Applied rewrites36.4%
Applied rewrites37.6%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0)))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l))))
(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))))
5e+255)
(* (* (sqrt (/ d l)) (sqrt (/ d h))) t_1)
(* (/ (sqrt (* d d)) (sqrt (* l h))) t_1))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
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)))) <= 5e+255) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1;
} else {
tmp = (sqrt((d * d)) / sqrt((l * 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) :: tmp
t_0 = (d_1 / d) * (m / 2.0d0)
t_1 = 1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l)
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)))) <= 5d+255) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1
else
tmp = (sqrt((d * d)) / sqrt((l * 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
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)))) <= 5e+255) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * t_1;
} else {
tmp = (Math.sqrt((d * d)) / Math.sqrt((l * h))) * t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (D / d) * (M / 2.0) t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l) 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)))) <= 5e+255: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * t_1 else: tmp = (math.sqrt((d * d)) / math.sqrt((l * h))) * t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l)) 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)))) <= 5e+255) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * t_1); else tmp = Float64(Float64(sqrt(Float64(d * d)) / sqrt(Float64(l * h))) * t_1); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (D / d) * (M / 2.0); t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l); 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)))) <= 5e+255) tmp = (sqrt((d / l)) * sqrt((d / h))) * t_1; else tmp = (sqrt((d * d)) / sqrt((l * h))) * t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+255], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\\
\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 5 \cdot 10^{+255}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{\sqrt{\ell \cdot h}} \cdot t\_1\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e255Initial program 88.7%
Applied rewrites88.7%
Applied rewrites88.7%
Applied rewrites88.7%
if 5.0000000000000002e255 < (*.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 28.2%
Applied rewrites35.1%
Applied rewrites37.7%
Applied rewrites46.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0))) (t_1 (* (/ 1.0 2.0) h)))
(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))))
5e+255)
(*
(* (sqrt (/ d l)) (sqrt (/ d h)))
(- 1.0 (/ (* t_0 (* (/ (* M D) (+ d d)) t_1)) l)))
(* (/ (sqrt (* d d)) (sqrt (* l h))) (- 1.0 (/ (* t_0 (* t_0 t_1)) l))))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double t_1 = (1.0 / 2.0) * h;
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)))) <= 5e+255) {
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((t_0 * (((M * D) / (d + d)) * t_1)) / l));
} else {
tmp = (sqrt((d * d)) / sqrt((l * h))) * (1.0 - ((t_0 * (t_0 * t_1)) / 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) :: t_1
real(8) :: tmp
t_0 = (d_1 / d) * (m / 2.0d0)
t_1 = (1.0d0 / 2.0d0) * h
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)))) <= 5d+255) then
tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((t_0 * (((m * d_1) / (d + d)) * t_1)) / l))
else
tmp = (sqrt((d * d)) / sqrt((l * h))) * (1.0d0 - ((t_0 * (t_0 * t_1)) / l))
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double t_1 = (1.0 / 2.0) * h;
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)))) <= 5e+255) {
tmp = (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((t_0 * (((M * D) / (d + d)) * t_1)) / l));
} else {
tmp = (Math.sqrt((d * d)) / Math.sqrt((l * h))) * (1.0 - ((t_0 * (t_0 * t_1)) / l));
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (D / d) * (M / 2.0) t_1 = (1.0 / 2.0) * h 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)))) <= 5e+255: tmp = (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((t_0 * (((M * D) / (d + d)) * t_1)) / l)) else: tmp = (math.sqrt((d * d)) / math.sqrt((l * h))) * (1.0 - ((t_0 * (t_0 * t_1)) / l)) return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) t_1 = Float64(Float64(1.0 / 2.0) * h) 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)))) <= 5e+255) tmp = Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(Float64(Float64(M * D) / Float64(d + d)) * t_1)) / l))); else tmp = Float64(Float64(sqrt(Float64(d * d)) / sqrt(Float64(l * h))) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * t_1)) / l))); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (D / d) * (M / 2.0); t_1 = (1.0 / 2.0) * h; 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)))) <= 5e+255) tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((t_0 * (((M * D) / (d + d)) * t_1)) / l)); else tmp = (sqrt((d * d)) / sqrt((l * h))) * (1.0 - ((t_0 * (t_0 * t_1)) / l)); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]}, If[LessEqual[N[(N[(N[Power[N[(d / h), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Power[N[(d / l), $MachinePrecision], N[(1.0 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(1.0 / 2.0), $MachinePrecision] * N[Power[N[(N[(M * D), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(h / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+255], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(N[(N[(M * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(d * d), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(l * h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
t_1 := \frac{1}{2} \cdot h\\
\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 5 \cdot 10^{+255}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{t\_0 \cdot \left(\frac{M \cdot D}{d + d} \cdot t\_1\right)}{\ell}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d \cdot d}}{\sqrt{\ell \cdot h}} \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot t\_1\right)}{\ell}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (pow.f64 (/.f64 d h) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64))) (pow.f64 (/.f64 d l) (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)))) (-.f64 #s(literal 1 binary64) (*.f64 (*.f64 (/.f64 #s(literal 1 binary64) #s(literal 2 binary64)) (pow.f64 (/.f64 (*.f64 M D) (*.f64 #s(literal 2 binary64) d)) #s(literal 2 binary64))) (/.f64 h l)))) < 5.0000000000000002e255Initial program 88.7%
Applied rewrites88.7%
Applied rewrites88.7%
Applied rewrites88.7%
Taylor expanded in d around 0
Applied rewrites88.7%
if 5.0000000000000002e255 < (*.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 28.2%
Applied rewrites35.1%
Applied rewrites37.7%
Applied rewrites46.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0)))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l))))
(if (<= d -6.5e-279)
(* (* (sqrt (/ d l)) (/ (sqrt (- d)) (sqrt (- h)))) t_1)
(* (/ (* (sqrt d) (sqrt d)) (* (sqrt l) (sqrt h))) t_1))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double tmp;
if (d <= -6.5e-279) {
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * t_1;
} else {
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * 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) :: tmp
t_0 = (d_1 / d) * (m / 2.0d0)
t_1 = 1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l)
if (d <= (-6.5d-279)) then
tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * t_1
else
tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double tmp;
if (d <= -6.5e-279) {
tmp = (Math.sqrt((d / l)) * (Math.sqrt(-d) / Math.sqrt(-h))) * t_1;
} else {
tmp = ((Math.sqrt(d) * Math.sqrt(d)) / (Math.sqrt(l) * Math.sqrt(h))) * t_1;
}
return tmp;
}
def code(d, h, l, M, D): t_0 = (D / d) * (M / 2.0) t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l) tmp = 0 if d <= -6.5e-279: tmp = (math.sqrt((d / l)) * (math.sqrt(-d) / math.sqrt(-h))) * t_1 else: tmp = ((math.sqrt(d) * math.sqrt(d)) / (math.sqrt(l) * math.sqrt(h))) * t_1 return tmp
function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l)) tmp = 0.0 if (d <= -6.5e-279) tmp = Float64(Float64(sqrt(Float64(d / l)) * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * t_1); else tmp = Float64(Float64(Float64(sqrt(d) * sqrt(d)) / Float64(sqrt(l) * sqrt(h))) * t_1); end return tmp end
function tmp_2 = code(d, h, l, M, D) t_0 = (D / d) * (M / 2.0); t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l); tmp = 0.0; if (d <= -6.5e-279) tmp = (sqrt((d / l)) * (sqrt(-d) / sqrt(-h))) * t_1; else tmp = ((sqrt(d) * sqrt(d)) / (sqrt(l) * sqrt(h))) * t_1; end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.5e-279], N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[d], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[l], $MachinePrecision] * N[Sqrt[h], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\\
\mathbf{if}\;d \leq -6.5 \cdot 10^{-279}:\\
\;\;\;\;\left(\sqrt{\frac{d}{\ell}} \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{d}}{\sqrt{\ell} \cdot \sqrt{h}} \cdot t\_1\\
\end{array}
\end{array}
if d < -6.4999999999999997e-279Initial program 75.2%
Applied rewrites75.3%
Applied rewrites73.8%
Applied rewrites73.8%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lift-varN/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lift-var86.1
Applied rewrites86.1%
if -6.4999999999999997e-279 < d Initial program 66.2%
Applied rewrites70.1%
Applied rewrites73.0%
Applied rewrites73.0%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lift-*.f64N/A
lower-/.f64N/A
Applied rewrites91.4%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0)))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l)))
(t_2 (sqrt (/ d l))))
(if (<= l -4e-310)
(* (* t_2 (/ (sqrt (- d)) (sqrt (- h)))) 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double t_2 = sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_2 * (sqrt(-d) / sqrt(-h))) * 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_1 / d) * (m / 2.0d0)
t_1 = 1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l)
t_2 = sqrt((d / l))
if (l <= (-4d-310)) then
tmp = (t_2 * (sqrt(-d) / sqrt(-h))) * 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double t_2 = Math.sqrt((d / l));
double tmp;
if (l <= -4e-310) {
tmp = (t_2 * (Math.sqrt(-d) / Math.sqrt(-h))) * 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 = (D / d) * (M / 2.0) t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l) t_2 = math.sqrt((d / l)) tmp = 0 if l <= -4e-310: tmp = (t_2 * (math.sqrt(-d) / math.sqrt(-h))) * 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(Float64(D / d) * Float64(M / 2.0)) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (l <= -4e-310) tmp = Float64(Float64(t_2 * Float64(sqrt(Float64(-d)) / sqrt(Float64(-h)))) * 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 / d) * (M / 2.0); t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l); t_2 = sqrt((d / l)); tmp = 0.0; if (l <= -4e-310) tmp = (t_2 * (sqrt(-d) / sqrt(-h))) * 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[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[l, -4e-310], N[(N[(t$95$2 * N[(N[Sqrt[(-d)], $MachinePrecision] / N[Sqrt[(-h)], $MachinePrecision]), $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 := \frac{D}{d} \cdot \frac{M}{2}\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;\ell \leq -4 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_2 \cdot \frac{\sqrt{-d}}{\sqrt{-h}}\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 \cdot \frac{\sqrt{d}}{\sqrt{h}}\right) \cdot t\_1\\
\end{array}
\end{array}
if l < -3.999999999999988e-310Initial program 74.0%
Applied rewrites74.1%
Applied rewrites72.6%
Applied rewrites72.6%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lower-/.f64N/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lift-varN/A
lower-sqrt.f64N/A
lower-neg.f64N/A
lift-var84.7
Applied rewrites84.7%
if -3.999999999999988e-310 < l Initial program 67.2%
Applied rewrites71.1%
Applied rewrites74.1%
Applied rewrites74.1%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-varN/A
lower-sqrt.f64N/A
lift-var85.0
Applied rewrites85.0%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0)))
(t_1 (- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l)))
(t_2 (sqrt (/ d l))))
(if (<= h -5e-310)
(* (* t_2 (sqrt (/ d h))) 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double t_2 = sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (t_2 * sqrt((d / h))) * 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_1 / d) * (m / 2.0d0)
t_1 = 1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l)
t_2 = sqrt((d / l))
if (h <= (-5d-310)) then
tmp = (t_2 * sqrt((d / h))) * 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 = (D / d) * (M / 2.0);
double t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l);
double t_2 = Math.sqrt((d / l));
double tmp;
if (h <= -5e-310) {
tmp = (t_2 * Math.sqrt((d / h))) * 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 = (D / d) * (M / 2.0) t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l) t_2 = math.sqrt((d / l)) tmp = 0 if h <= -5e-310: tmp = (t_2 * math.sqrt((d / h))) * 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(Float64(D / d) * Float64(M / 2.0)) t_1 = Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l)) t_2 = sqrt(Float64(d / l)) tmp = 0.0 if (h <= -5e-310) tmp = Float64(Float64(t_2 * sqrt(Float64(d / h))) * 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 / d) * (M / 2.0); t_1 = 1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l); t_2 = sqrt((d / l)); tmp = 0.0; if (h <= -5e-310) tmp = (t_2 * sqrt((d / h))) * 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[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[h, -5e-310], N[(N[(t$95$2 * N[Sqrt[N[(d / h), $MachinePrecision]], $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 := \frac{D}{d} \cdot \frac{M}{2}\\
t_1 := 1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\\
t_2 := \sqrt{\frac{d}{\ell}}\\
\mathbf{if}\;h \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\left(t\_2 \cdot \sqrt{\frac{d}{h}}\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 < -4.999999999999985e-310Initial program 74.0%
Applied rewrites74.1%
Applied rewrites72.6%
Applied rewrites72.6%
if -4.999999999999985e-310 < h Initial program 67.2%
Applied rewrites71.1%
Applied rewrites74.1%
Applied rewrites74.1%
lift-varN/A
lift-varN/A
lift-/.f64N/A
lift-sqrt.f64N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-varN/A
lower-sqrt.f64N/A
lift-var85.0
Applied rewrites85.0%
(FPCore (d h l M D)
:precision binary64
(if (<= h 1.9e-272)
(*
(-
1.0
(/
(* (* M D) (* (* (/ (/ D 2.0) d) M) (* (/ h l) (/ 1.0 2.0))))
(* 2.0 d)))
(sqrt (* (/ d l) (/ d h))))
(/
(*
(-
1.0
(/
(* (* M D) (* (* (* (/ M 2.0) h) (/ 1.0 2.0)) (/ D d)))
(* (* 2.0 d) l)))
(sqrt (* (/ d l) d)))
(sqrt h))))
double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 1.9e-272) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * sqrt(((d / l) * (d / h)));
} else {
tmp = ((1.0 - (((M * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / ((2.0 * d) * l))) * sqrt(((d / l) * d))) / sqrt(h);
}
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 (h <= 1.9d-272) then
tmp = (1.0d0 - (((m * d_1) * ((((d_1 / 2.0d0) / d) * m) * ((h / l) * (1.0d0 / 2.0d0)))) / (2.0d0 * d))) * sqrt(((d / l) * (d / h)))
else
tmp = ((1.0d0 - (((m * d_1) * ((((m / 2.0d0) * h) * (1.0d0 / 2.0d0)) * (d_1 / d))) / ((2.0d0 * d) * l))) * sqrt(((d / l) * d))) / sqrt(h)
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (h <= 1.9e-272) {
tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * Math.sqrt(((d / l) * (d / h)));
} else {
tmp = ((1.0 - (((M * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / ((2.0 * d) * l))) * Math.sqrt(((d / l) * d))) / Math.sqrt(h);
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if h <= 1.9e-272: tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * math.sqrt(((d / l) * (d / h))) else: tmp = ((1.0 - (((M * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / ((2.0 * d) * l))) * math.sqrt(((d / l) * d))) / math.sqrt(h) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (h <= 1.9e-272) tmp = Float64(Float64(1.0 - Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(D / 2.0) / d) * M) * Float64(Float64(h / l) * Float64(1.0 / 2.0)))) / Float64(2.0 * d))) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(Float64(1.0 - Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(M / 2.0) * h) * Float64(1.0 / 2.0)) * Float64(D / d))) / Float64(Float64(2.0 * d) * l))) * sqrt(Float64(Float64(d / l) * d))) / sqrt(h)); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (h <= 1.9e-272) tmp = (1.0 - (((M * D) * ((((D / 2.0) / d) * M) * ((h / l) * (1.0 / 2.0)))) / (2.0 * d))) * sqrt(((d / l) * (d / h))); else tmp = ((1.0 - (((M * D) * ((((M / 2.0) * h) * (1.0 / 2.0)) * (D / d))) / ((2.0 * d) * l))) * sqrt(((d / l) * d))) / sqrt(h); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[h, 1.9e-272], N[(N[(1.0 - N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(D / 2.0), $MachinePrecision] / d), $MachinePrecision] * M), $MachinePrecision] * N[(N[(h / l), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(M / 2.0), $MachinePrecision] * h), $MachinePrecision] * N[(1.0 / 2.0), $MachinePrecision]), $MachinePrecision] * N[(D / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[h], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;h \leq 1.9 \cdot 10^{-272}:\\
\;\;\;\;\left(1 - \frac{\left(M \cdot D\right) \cdot \left(\left(\frac{\frac{D}{2}}{d} \cdot M\right) \cdot \left(\frac{h}{\ell} \cdot \frac{1}{2}\right)\right)}{2 \cdot d}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1 - \frac{\left(M \cdot D\right) \cdot \left(\left(\left(\frac{M}{2} \cdot h\right) \cdot \frac{1}{2}\right) \cdot \frac{D}{d}\right)}{\left(2 \cdot d\right) \cdot \ell}\right) \cdot \sqrt{\frac{d}{\ell} \cdot d}}{\sqrt{h}}\\
\end{array}
\end{array}
if h < 1.89999999999999985e-272Initial program 73.9%
Applied rewrites74.0%
Applied rewrites60.7%
Applied rewrites62.2%
if 1.89999999999999985e-272 < h Initial program 66.9%
Applied rewrites71.1%
Applied rewrites63.5%
Applied rewrites65.2%
(FPCore (d h l M D) :precision binary64 (* (* (sqrt (/ d l)) (sqrt (/ d h))) (- 1.0 (/ (* (* (/ D d) (/ M 2.0)) (* (/ (* M D) (+ d d)) (* (/ 1.0 2.0) h))) l))))
double code(double d, double h, double l, double M, double D) {
return (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((D / d) * (M / 2.0)) * (((M * D) / (d + d)) * ((1.0 / 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 = (sqrt((d / l)) * sqrt((d / h))) * (1.0d0 - ((((d_1 / d) * (m / 2.0d0)) * (((m * d_1) / (d + d)) * ((1.0d0 / 2.0d0) * h))) / l))
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.sqrt((d / l)) * Math.sqrt((d / h))) * (1.0 - ((((D / d) * (M / 2.0)) * (((M * D) / (d + d)) * ((1.0 / 2.0) * h))) / l));
}
def code(d, h, l, M, D): return (math.sqrt((d / l)) * math.sqrt((d / h))) * (1.0 - ((((D / d) * (M / 2.0)) * (((M * D) / (d + d)) * ((1.0 / 2.0) * h))) / l))
function code(d, h, l, M, D) return Float64(Float64(sqrt(Float64(d / l)) * sqrt(Float64(d / h))) * Float64(1.0 - Float64(Float64(Float64(Float64(D / d) * Float64(M / 2.0)) * Float64(Float64(Float64(M * D) / Float64(d + d)) * Float64(Float64(1.0 / 2.0) * h))) / l))) end
function tmp = code(d, h, l, M, D) tmp = (sqrt((d / l)) * sqrt((d / h))) * (1.0 - ((((D / d) * (M / 2.0)) * (((M * D) / (d + d)) * ((1.0 / 2.0) * h))) / l)); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Sqrt[N[(d / l), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(N[(N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(M * D), $MachinePrecision] / N[(d + d), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sqrt{\frac{d}{\ell}} \cdot \sqrt{\frac{d}{h}}\right) \cdot \left(1 - \frac{\left(\frac{D}{d} \cdot \frac{M}{2}\right) \cdot \left(\frac{M \cdot D}{d + d} \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\right)
\end{array}
Initial program 70.5%
Applied rewrites72.6%
Applied rewrites73.4%
Applied rewrites73.4%
Taylor expanded in d around 0
Applied rewrites73.3%
(FPCore (d h l M D)
:precision binary64
(let* ((t_0 (* (/ D d) (/ M 2.0))))
(*
(sqrt (* (/ (/ d l) h) d))
(- 1.0 (/ (* t_0 (* t_0 (* (/ 1.0 2.0) h))) l)))))
double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
return sqrt((((d / l) / h) * d)) * (1.0 - ((t_0 * (t_0 * ((1.0 / 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
real(8) :: t_0
t_0 = (d_1 / d) * (m / 2.0d0)
code = sqrt((((d / l) / h) * d)) * (1.0d0 - ((t_0 * (t_0 * ((1.0d0 / 2.0d0) * h))) / l))
end function
public static double code(double d, double h, double l, double M, double D) {
double t_0 = (D / d) * (M / 2.0);
return Math.sqrt((((d / l) / h) * d)) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l));
}
def code(d, h, l, M, D): t_0 = (D / d) * (M / 2.0) return math.sqrt((((d / l) / h) * d)) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l))
function code(d, h, l, M, D) t_0 = Float64(Float64(D / d) * Float64(M / 2.0)) return Float64(sqrt(Float64(Float64(Float64(d / l) / h) * d)) * Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(Float64(1.0 / 2.0) * h))) / l))) end
function tmp = code(d, h, l, M, D) t_0 = (D / d) * (M / 2.0); tmp = sqrt((((d / l) / h) * d)) * (1.0 - ((t_0 * (t_0 * ((1.0 / 2.0) * h))) / l)); end
code[d_, h_, l_, M_, D_] := Block[{t$95$0 = N[(N[(D / d), $MachinePrecision] * N[(M / 2.0), $MachinePrecision]), $MachinePrecision]}, N[(N[Sqrt[N[(N[(N[(d / l), $MachinePrecision] / h), $MachinePrecision] * d), $MachinePrecision]], $MachinePrecision] * N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[(1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{D}{d} \cdot \frac{M}{2}\\
\sqrt{\frac{\frac{d}{\ell}}{h} \cdot d} \cdot \left(1 - \frac{t\_0 \cdot \left(t\_0 \cdot \left(\frac{1}{2} \cdot h\right)\right)}{\ell}\right)
\end{array}
\end{array}
Initial program 70.5%
Applied rewrites72.6%
Applied rewrites73.4%
Applied rewrites63.4%
(FPCore (d h l M D)
:precision binary64
(if (<= l 0.00034)
(*
(+
1.0
(/
(* (* M D) (/ (* (* (/ M d) D) (* (/ -1.0 2.0) h)) 2.0))
(* (* 2.0 d) l)))
(sqrt (* (/ d l) (/ d h))))
(/ (* (sqrt d) (sqrt (/ d h))) (sqrt l))))
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 0.00034) {
tmp = (1.0 + (((M * D) * ((((M / d) * D) * ((-1.0 / 2.0) * h)) / 2.0)) / ((2.0 * d) * l))) * sqrt(((d / l) * (d / h)));
} else {
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(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) :: tmp
if (l <= 0.00034d0) then
tmp = (1.0d0 + (((m * d_1) * ((((m / d) * d_1) * (((-1.0d0) / 2.0d0) * h)) / 2.0d0)) / ((2.0d0 * d) * l))) * sqrt(((d / l) * (d / h)))
else
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l)
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 0.00034) {
tmp = (1.0 + (((M * D) * ((((M / d) * D) * ((-1.0 / 2.0) * h)) / 2.0)) / ((2.0 * d) * l))) * Math.sqrt(((d / l) * (d / h)));
} else {
tmp = (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if l <= 0.00034: tmp = (1.0 + (((M * D) * ((((M / d) * D) * ((-1.0 / 2.0) * h)) / 2.0)) / ((2.0 * d) * l))) * math.sqrt(((d / l) * (d / h))) else: tmp = (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (l <= 0.00034) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(M / d) * D) * Float64(Float64(-1.0 / 2.0) * h)) / 2.0)) / Float64(Float64(2.0 * d) * l))) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (l <= 0.00034) tmp = (1.0 + (((M * D) * ((((M / d) * D) * ((-1.0 / 2.0) * h)) / 2.0)) / ((2.0 * d) * l))) * sqrt(((d / l) * (d / h))); else tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 0.00034], N[(N[(1.0 + N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(M / d), $MachinePrecision] * D), $MachinePrecision] * N[(N[(-1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.00034:\\
\;\;\;\;\left(1 + \frac{\left(M \cdot D\right) \cdot \frac{\left(\frac{M}{d} \cdot D\right) \cdot \left(\frac{-1}{2} \cdot h\right)}{2}}{\left(2 \cdot d\right) \cdot \ell}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 3.4e-4Initial program 72.4%
Applied rewrites75.1%
Applied rewrites60.5%
Applied rewrites58.5%
Applied rewrites61.1%
if 3.4e-4 < l Initial program 64.5%
Applied rewrites64.7%
Applied rewrites67.8%
Taylor expanded in d around inf
Applied rewrites64.7%
Final simplification62.0%
(FPCore (d h l M D)
:precision binary64
(if (<= l 1.62e-131)
(*
(+
1.0
(/
(* (* M D) (/ (* (* (/ -1.0 2.0) h) (* M D)) (* 2.0 d)))
(* (* 2.0 d) l)))
(sqrt (* (/ d l) (/ d h))))
(/ (* (sqrt d) (sqrt (/ d h))) (sqrt l))))
double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 1.62e-131) {
tmp = (1.0 + (((M * D) * ((((-1.0 / 2.0) * h) * (M * D)) / (2.0 * d))) / ((2.0 * d) * l))) * sqrt(((d / l) * (d / h)));
} else {
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(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) :: tmp
if (l <= 1.62d-131) then
tmp = (1.0d0 + (((m * d_1) * (((((-1.0d0) / 2.0d0) * h) * (m * d_1)) / (2.0d0 * d))) / ((2.0d0 * d) * l))) * sqrt(((d / l) * (d / h)))
else
tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l)
end if
code = tmp
end function
public static double code(double d, double h, double l, double M, double D) {
double tmp;
if (l <= 1.62e-131) {
tmp = (1.0 + (((M * D) * ((((-1.0 / 2.0) * h) * (M * D)) / (2.0 * d))) / ((2.0 * d) * l))) * Math.sqrt(((d / l) * (d / h)));
} else {
tmp = (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
}
return tmp;
}
def code(d, h, l, M, D): tmp = 0 if l <= 1.62e-131: tmp = (1.0 + (((M * D) * ((((-1.0 / 2.0) * h) * (M * D)) / (2.0 * d))) / ((2.0 * d) * l))) * math.sqrt(((d / l) * (d / h))) else: tmp = (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l) return tmp
function code(d, h, l, M, D) tmp = 0.0 if (l <= 1.62e-131) tmp = Float64(Float64(1.0 + Float64(Float64(Float64(M * D) * Float64(Float64(Float64(Float64(-1.0 / 2.0) * h) * Float64(M * D)) / Float64(2.0 * d))) / Float64(Float64(2.0 * d) * l))) * sqrt(Float64(Float64(d / l) * Float64(d / h)))); else tmp = Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)); end return tmp end
function tmp_2 = code(d, h, l, M, D) tmp = 0.0; if (l <= 1.62e-131) tmp = (1.0 + (((M * D) * ((((-1.0 / 2.0) * h) * (M * D)) / (2.0 * d))) / ((2.0 * d) * l))) * sqrt(((d / l) * (d / h))); else tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); end tmp_2 = tmp; end
code[d_, h_, l_, M_, D_] := If[LessEqual[l, 1.62e-131], N[(N[(1.0 + N[(N[(N[(M * D), $MachinePrecision] * N[(N[(N[(N[(-1.0 / 2.0), $MachinePrecision] * h), $MachinePrecision] * N[(M * D), $MachinePrecision]), $MachinePrecision] / N[(2.0 * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(2.0 * d), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(d / l), $MachinePrecision] * N[(d / h), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.62 \cdot 10^{-131}:\\
\;\;\;\;\left(1 + \frac{\left(M \cdot D\right) \cdot \frac{\left(\frac{-1}{2} \cdot h\right) \cdot \left(M \cdot D\right)}{2 \cdot d}}{\left(2 \cdot d\right) \cdot \ell}\right) \cdot \sqrt{\frac{d}{\ell} \cdot \frac{d}{h}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}\\
\end{array}
\end{array}
if l < 1.61999999999999988e-131Initial program 74.3%
Applied rewrites76.8%
Applied rewrites63.1%
Applied rewrites60.6%
Applied rewrites62.5%
if 1.61999999999999988e-131 < l Initial program 63.8%
Applied rewrites65.1%
Applied rewrites68.0%
Taylor expanded in d around inf
Applied rewrites60.6%
Final simplification61.8%
(FPCore (d h l M D) :precision binary64 (/ (* (sqrt d) (sqrt (/ d h))) (sqrt l)))
double code(double d, double h, double l, double M, double D) {
return (sqrt(d) * sqrt((d / h))) / sqrt(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 = (sqrt(d) * sqrt((d / h))) / sqrt(l)
end function
public static double code(double d, double h, double l, double M, double D) {
return (Math.sqrt(d) * Math.sqrt((d / h))) / Math.sqrt(l);
}
def code(d, h, l, M, D): return (math.sqrt(d) * math.sqrt((d / h))) / math.sqrt(l)
function code(d, h, l, M, D) return Float64(Float64(sqrt(d) * sqrt(Float64(d / h))) / sqrt(l)) end
function tmp = code(d, h, l, M, D) tmp = (sqrt(d) * sqrt((d / h))) / sqrt(l); end
code[d_, h_, l_, M_, D_] := N[(N[(N[Sqrt[d], $MachinePrecision] * N[Sqrt[N[(d / h), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[l], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\sqrt{d} \cdot \sqrt{\frac{d}{h}}}{\sqrt{\ell}}
\end{array}
Initial program 70.5%
Applied rewrites72.6%
Applied rewrites36.6%
Taylor expanded in d around inf
Applied rewrites28.1%
herbie shell --seed 2025021
(FPCore (d h l M D)
:name "Henrywood and Agarwal, Equation (12)"
:precision binary64
(* (* (pow (/ d h) (/ 1.0 2.0)) (pow (/ d l) (/ 1.0 2.0))) (- 1.0 (* (* (/ 1.0 2.0) (pow (/ (* M D) (* 2.0 d)) 2.0)) (/ h l)))))