
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* (- (- d2 d1) (- d3 d4)) d1))
double code(double d1, double d2, double d3, double d4) {
return ((d2 - d1) - (d3 - d4)) * d1;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = ((d2 - d1) - (d3 - d4)) * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return ((d2 - d1) - (d3 - d4)) * d1;
}
def code(d1, d2, d3, d4): return ((d2 - d1) - (d3 - d4)) * d1
function code(d1, d2, d3, d4) return Float64(Float64(Float64(d2 - d1) - Float64(d3 - d4)) * d1) end
function tmp = code(d1, d2, d3, d4) tmp = ((d2 - d1) - (d3 - d4)) * d1; end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(d2 - d1), $MachinePrecision] - N[(d3 - d4), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d2 - d1\right) - \left(d3 - d4\right)\right) \cdot d1
\end{array}
Initial program 87.9%
Applied rewrites100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.6e+20) (* d1 (- d2 (+ d1 d3))) (if (<= d2 -3.8e-78) (fma d1 d2 (* d1 (- d4 d1))) (* (- (- d4 d3) d1) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+20) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d2 <= -3.8e-78) {
tmp = fma(d1, d2, (d1 * (d4 - d1)));
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.6e+20) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); elseif (d2 <= -3.8e-78) tmp = fma(d1, d2, Float64(d1 * Float64(d4 - d1))); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.6e+20], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -3.8e-78], N[(d1 * d2 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.6 \cdot 10^{+20}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-78}:\\
\;\;\;\;\mathsf{fma}\left(d1, d2, d1 \cdot \left(d4 - d1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -2.6e20Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d4 around 0
Applied rewrites77.3%
if -2.6e20 < d2 < -3.7999999999999999e-78Initial program 87.9%
Applied rewrites96.9%
Taylor expanded in d3 around 0
Applied rewrites75.2%
if -3.7999999999999999e-78 < d2 Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.6e+20) (* d1 (- d2 (+ d1 d3))) (if (<= d2 -3.8e-78) (* (- (+ d2 d4) d1) d1) (* (- (- d4 d3) d1) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+20) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d2 <= -3.8e-78) {
tmp = ((d2 + d4) - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.6d+20)) then
tmp = d1 * (d2 - (d1 + d3))
else if (d2 <= (-3.8d-78)) then
tmp = ((d2 + d4) - d1) * d1
else
tmp = ((d4 - d3) - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.6e+20) {
tmp = d1 * (d2 - (d1 + d3));
} else if (d2 <= -3.8e-78) {
tmp = ((d2 + d4) - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.6e+20: tmp = d1 * (d2 - (d1 + d3)) elif d2 <= -3.8e-78: tmp = ((d2 + d4) - d1) * d1 else: tmp = ((d4 - d3) - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.6e+20) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); elseif (d2 <= -3.8e-78) tmp = Float64(Float64(Float64(d2 + d4) - d1) * d1); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.6e+20) tmp = d1 * (d2 - (d1 + d3)); elseif (d2 <= -3.8e-78) tmp = ((d2 + d4) - d1) * d1; else tmp = ((d4 - d3) - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.6e+20], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -3.8e-78], N[(N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.6 \cdot 10^{+20}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-78}:\\
\;\;\;\;\left(\left(d2 + d4\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -2.6e20Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d4 around 0
Applied rewrites77.3%
if -2.6e20 < d2 < -3.7999999999999999e-78Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d1 around inf
Applied rewrites32.3%
Taylor expanded in d3 around 0
Applied rewrites76.7%
if -3.7999999999999999e-78 < d2 Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.8e-78) (* d1 (- d2 (+ d1 d3))) (* (- (- d4 d3) d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.8e-78) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = ((d4 - d3) - d1) * d1;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.8d-78)) then
tmp = d1 * (d2 - (d1 + d3))
else
tmp = ((d4 - d3) - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.8e-78) {
tmp = d1 * (d2 - (d1 + d3));
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.8e-78: tmp = d1 * (d2 - (d1 + d3)) else: tmp = ((d4 - d3) - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.8e-78) tmp = Float64(d1 * Float64(d2 - Float64(d1 + d3))); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.8e-78) tmp = d1 * (d2 - (d1 + d3)); else tmp = ((d4 - d3) - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.8e-78], N[(d1 * N[(d2 - N[(d1 + d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.8 \cdot 10^{-78}:\\
\;\;\;\;d1 \cdot \left(d2 - \left(d1 + d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -3.7999999999999999e-78Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d4 around 0
Applied rewrites77.3%
if -3.7999999999999999e-78 < d2 Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.8e+99) (* (- d2 d1) d1) (* (- (- d4 d3) d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.8e+99) {
tmp = (d2 - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5.8d+99)) then
tmp = (d2 - d1) * d1
else
tmp = ((d4 - d3) - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.8e+99) {
tmp = (d2 - d1) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.8e+99: tmp = (d2 - d1) * d1 else: tmp = ((d4 - d3) - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.8e+99) tmp = Float64(Float64(d2 - d1) * d1); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5.8e+99) tmp = (d2 - d1) * d1; else tmp = ((d4 - d3) - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.8e+99], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.8 \cdot 10^{+99}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -5.8000000000000004e99Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d1 around inf
Applied rewrites32.3%
Taylor expanded in d3 around 0
Applied rewrites76.7%
Taylor expanded in d4 around 0
Applied rewrites54.3%
if -5.8000000000000004e99 < d2 Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Applied rewrites77.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d2 -8.2e+106)
(* (- d2 d1) d1)
(if (<= d2 -1450000000000.0)
(* d1 (- d2 d3))
(if (<= d2 -6.4e-282) (* (- d4 d1) d1) (* d1 (- d4 d3))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.2e+106) {
tmp = (d2 - d1) * d1;
} else if (d2 <= -1450000000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -6.4e-282) {
tmp = (d4 - d1) * d1;
} else {
tmp = d1 * (d4 - d3);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-8.2d+106)) then
tmp = (d2 - d1) * d1
else if (d2 <= (-1450000000000.0d0)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-6.4d-282)) then
tmp = (d4 - d1) * d1
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8.2e+106) {
tmp = (d2 - d1) * d1;
} else if (d2 <= -1450000000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -6.4e-282) {
tmp = (d4 - d1) * d1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8.2e+106: tmp = (d2 - d1) * d1 elif d2 <= -1450000000000.0: tmp = d1 * (d2 - d3) elif d2 <= -6.4e-282: tmp = (d4 - d1) * d1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8.2e+106) tmp = Float64(Float64(d2 - d1) * d1); elseif (d2 <= -1450000000000.0) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -6.4e-282) tmp = Float64(Float64(d4 - d1) * d1); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -8.2e+106) tmp = (d2 - d1) * d1; elseif (d2 <= -1450000000000.0) tmp = d1 * (d2 - d3); elseif (d2 <= -6.4e-282) tmp = (d4 - d1) * d1; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8.2e+106], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -1450000000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -6.4e-282], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8.2 \cdot 10^{+106}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{elif}\;d2 \leq -1450000000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -6.4 \cdot 10^{-282}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -8.2000000000000005e106Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d1 around inf
Applied rewrites32.3%
Taylor expanded in d3 around 0
Applied rewrites76.7%
Taylor expanded in d4 around 0
Applied rewrites54.3%
if -8.2000000000000005e106 < d2 < -1.45e12Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d4 around 0
Applied rewrites56.6%
if -1.45e12 < d2 < -6.39999999999999966e-282Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Taylor expanded in d3 around 0
Applied rewrites54.5%
if -6.39999999999999966e-282 < d2 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1450000000000.0) (* d1 (- d2 d3)) (if (<= d2 -6.4e-282) (* (- d4 d1) d1) (* d1 (- d4 d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1450000000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -6.4e-282) {
tmp = (d4 - d1) * d1;
} else {
tmp = d1 * (d4 - d3);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1450000000000.0d0)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-6.4d-282)) then
tmp = (d4 - d1) * d1
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1450000000000.0) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -6.4e-282) {
tmp = (d4 - d1) * d1;
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1450000000000.0: tmp = d1 * (d2 - d3) elif d2 <= -6.4e-282: tmp = (d4 - d1) * d1 else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1450000000000.0) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -6.4e-282) tmp = Float64(Float64(d4 - d1) * d1); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1450000000000.0) tmp = d1 * (d2 - d3); elseif (d2 <= -6.4e-282) tmp = (d4 - d1) * d1; else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1450000000000.0], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -6.4e-282], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1450000000000:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -6.4 \cdot 10^{-282}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -1.45e12Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d4 around 0
Applied rewrites56.6%
if -1.45e12 < d2 < -6.39999999999999966e-282Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites77.6%
Taylor expanded in d3 around 0
Applied rewrites54.5%
if -6.39999999999999966e-282 < d2 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -3.8e-78) (* d1 (- d2 d3)) (* d1 (- d4 d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.8e-78) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-3.8d-78)) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * (d4 - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -3.8e-78) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * (d4 - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -3.8e-78: tmp = d1 * (d2 - d3) else: tmp = d1 * (d4 - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -3.8e-78) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * Float64(d4 - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -3.8e-78) tmp = d1 * (d2 - d3); else tmp = d1 * (d4 - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -3.8e-78], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -3.8 \cdot 10^{-78}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\end{array}
\end{array}
if d2 < -3.7999999999999999e-78Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d4 around 0
Applied rewrites56.6%
if -3.7999999999999999e-78 < d2 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2.6e+51) (* d1 (- d2 d3)) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.6e+51) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * d4;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 2.6d+51) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2.6e+51) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 2.6e+51: tmp = d1 * (d2 - d3) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2.6e+51) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 2.6e+51) tmp = d1 * (d2 - d3); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2.6e+51], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2.6 \cdot 10^{+51}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < 2.6000000000000001e51Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d4 around 0
Applied rewrites56.6%
if 2.6000000000000001e51 < d4 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
Taylor expanded in d3 around 0
Applied rewrites31.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.8e+25) (* d1 d2) (if (<= d2 -6.2e-245) (* (- d1) d1) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e+25) {
tmp = d1 * d2;
} else if (d2 <= -6.2e-245) {
tmp = -d1 * d1;
} else {
tmp = d1 * d4;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.8d+25)) then
tmp = d1 * d2
else if (d2 <= (-6.2d-245)) then
tmp = -d1 * d1
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e+25) {
tmp = d1 * d2;
} else if (d2 <= -6.2e-245) {
tmp = -d1 * d1;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.8e+25: tmp = d1 * d2 elif d2 <= -6.2e-245: tmp = -d1 * d1 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.8e+25) tmp = Float64(d1 * d2); elseif (d2 <= -6.2e-245) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.8e+25) tmp = d1 * d2; elseif (d2 <= -6.2e-245) tmp = -d1 * d1; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e+25], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, -6.2e-245], N[((-d1) * d1), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.8 \cdot 10^{+25}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq -6.2 \cdot 10^{-245}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.80000000000000008e25Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around inf
Applied rewrites30.6%
if -1.80000000000000008e25 < d2 < -6.20000000000000006e-245Initial program 87.9%
Applied rewrites100.0%
Taylor expanded in d1 around inf
Applied rewrites32.3%
Applied rewrites32.3%
if -6.20000000000000006e-245 < d2 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
Taylor expanded in d3 around 0
Applied rewrites31.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.7e-85) (* d1 d2) (* d1 d4)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e-85) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.7d-85)) then
tmp = d1 * d2
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.7e-85) {
tmp = d1 * d2;
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.7e-85: tmp = d1 * d2 else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.7e-85) tmp = Float64(d1 * d2); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.7e-85) tmp = d1 * d2; else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.7e-85], N[(d1 * d2), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.7 \cdot 10^{-85}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d2 < -1.7e-85Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around inf
Applied rewrites30.6%
if -1.7e-85 < d2 Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around 0
Applied rewrites57.2%
Taylor expanded in d3 around 0
Applied rewrites31.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 87.9%
Taylor expanded in d1 around 0
Applied rewrites81.2%
Taylor expanded in d2 around inf
Applied rewrites30.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
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(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2025153
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform c (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))