
(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}
Sampling outcomes in binary64 precision:
Herbie found 15 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 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) INFINITY) (fma d1 (- d4 d1) (* (- d2 d3) d1)) (* (- (- d4 d1) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= ((double) INFINITY)) {
tmp = fma(d1, (d4 - d1), ((d2 - d3) * d1));
} else {
tmp = ((d4 - d1) - d3) * d1;
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) <= Inf) tmp = fma(d1, Float64(d4 - d1), Float64(Float64(d2 - d3) * d1)); else tmp = Float64(Float64(Float64(d4 - d1) - d3) * d1); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], Infinity], N[(d1 * N[(d4 - d1), $MachinePrecision] + N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(d1, d4 - d1, \left(d2 - d3\right) \cdot d1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < +inf.0Initial program 100.0%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f64100.0
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
if +inf.0 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 0.0%
Taylor expanded in d2 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
associate--l-N/A
+-commutativeN/A
associate--l-N/A
lower--.f64N/A
lower--.f6491.4
Applied rewrites91.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) INFINITY) (* d2 d1) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= ((double) INFINITY)) {
tmp = d2 * d1;
} else {
tmp = d1 * d1;
}
return tmp;
}
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= Double.POSITIVE_INFINITY) {
tmp = d2 * d1;
} else {
tmp = d1 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if ((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= math.inf: tmp = d2 * d1 else: tmp = d1 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) <= Inf) tmp = Float64(d2 * d1); else tmp = Float64(d1 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= Inf) tmp = d2 * d1; else tmp = d1 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], Infinity], N[(d2 * d1), $MachinePrecision], N[(d1 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq \infty:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d1\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < +inf.0Initial program 100.0%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f64100.0
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6426.8
Applied rewrites26.8%
if +inf.0 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 0.0%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6454.4
Applied rewrites54.4%
Applied rewrites42.9%
Final simplification29.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d3 -7.2e+29)
(* (- d2 d3) d1)
(if (<= d3 7.2e-259)
(* (- d4 d1) d1)
(if (<= d3 9.2e+22) (* (- d2 d1) d1) (* (- d4 d3) d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -7.2e+29) {
tmp = (d2 - d3) * d1;
} else if (d3 <= 7.2e-259) {
tmp = (d4 - d1) * d1;
} else if (d3 <= 9.2e+22) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * 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 (d3 <= (-7.2d+29)) then
tmp = (d2 - d3) * d1
else if (d3 <= 7.2d-259) then
tmp = (d4 - d1) * d1
else if (d3 <= 9.2d+22) then
tmp = (d2 - d1) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -7.2e+29) {
tmp = (d2 - d3) * d1;
} else if (d3 <= 7.2e-259) {
tmp = (d4 - d1) * d1;
} else if (d3 <= 9.2e+22) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -7.2e+29: tmp = (d2 - d3) * d1 elif d3 <= 7.2e-259: tmp = (d4 - d1) * d1 elif d3 <= 9.2e+22: tmp = (d2 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -7.2e+29) tmp = Float64(Float64(d2 - d3) * d1); elseif (d3 <= 7.2e-259) tmp = Float64(Float64(d4 - d1) * d1); elseif (d3 <= 9.2e+22) tmp = Float64(Float64(d2 - d1) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -7.2e+29) tmp = (d2 - d3) * d1; elseif (d3 <= 7.2e-259) tmp = (d4 - d1) * d1; elseif (d3 <= 9.2e+22) tmp = (d2 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -7.2e+29], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, 7.2e-259], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, 9.2e+22], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -7.2 \cdot 10^{+29}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d3 \leq 7.2 \cdot 10^{-259}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{elif}\;d3 \leq 9.2 \cdot 10^{+22}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -7.19999999999999952e29Initial program 82.8%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in d1 around 0
Applied rewrites74.7%
if -7.19999999999999952e29 < d3 < 7.1999999999999996e-259Initial program 85.7%
Taylor expanded in d2 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
associate--l-N/A
+-commutativeN/A
associate--l-N/A
lower--.f64N/A
lower--.f6471.7
Applied rewrites71.7%
Taylor expanded in d3 around 0
Applied rewrites71.3%
if 7.1999999999999996e-259 < d3 < 9.2000000000000008e22Initial program 93.6%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6473.7
Applied rewrites73.7%
Taylor expanded in d3 around 0
Applied rewrites72.3%
if 9.2000000000000008e22 < d3 Initial program 83.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6494.3
Applied rewrites94.3%
Taylor expanded in d2 around 0
Applied rewrites85.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d3 -2.7e+78)
(* (- d2 d3) d1)
(if (<= d3 -1100000000.0)
(* (+ d2 d4) d1)
(if (<= d3 9.2e+22) (* (- d2 d1) d1) (* (- d4 d3) d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -2.7e+78) {
tmp = (d2 - d3) * d1;
} else if (d3 <= -1100000000.0) {
tmp = (d2 + d4) * d1;
} else if (d3 <= 9.2e+22) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * 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 (d3 <= (-2.7d+78)) then
tmp = (d2 - d3) * d1
else if (d3 <= (-1100000000.0d0)) then
tmp = (d2 + d4) * d1
else if (d3 <= 9.2d+22) then
tmp = (d2 - d1) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d3 <= -2.7e+78) {
tmp = (d2 - d3) * d1;
} else if (d3 <= -1100000000.0) {
tmp = (d2 + d4) * d1;
} else if (d3 <= 9.2e+22) {
tmp = (d2 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d3 <= -2.7e+78: tmp = (d2 - d3) * d1 elif d3 <= -1100000000.0: tmp = (d2 + d4) * d1 elif d3 <= 9.2e+22: tmp = (d2 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d3 <= -2.7e+78) tmp = Float64(Float64(d2 - d3) * d1); elseif (d3 <= -1100000000.0) tmp = Float64(Float64(d2 + d4) * d1); elseif (d3 <= 9.2e+22) tmp = Float64(Float64(d2 - d1) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d3 <= -2.7e+78) tmp = (d2 - d3) * d1; elseif (d3 <= -1100000000.0) tmp = (d2 + d4) * d1; elseif (d3 <= 9.2e+22) tmp = (d2 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d3, -2.7e+78], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, -1100000000.0], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d3, 9.2e+22], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.7 \cdot 10^{+78}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d3 \leq -1100000000:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\mathbf{elif}\;d3 \leq 9.2 \cdot 10^{+22}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -2.70000000000000004e78Initial program 83.9%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6488.8
Applied rewrites88.8%
Taylor expanded in d1 around 0
Applied rewrites81.9%
if -2.70000000000000004e78 < d3 < -1.1e9Initial program 84.1%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6484.5
Applied rewrites84.5%
Taylor expanded in d3 around 0
Applied rewrites69.2%
if -1.1e9 < d3 < 9.2000000000000008e22Initial program 89.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6475.8
Applied rewrites75.8%
Taylor expanded in d3 around 0
Applied rewrites74.8%
if 9.2000000000000008e22 < d3 Initial program 83.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6494.3
Applied rewrites94.3%
Taylor expanded in d2 around 0
Applied rewrites85.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 4.4e-299)
(* d2 d1)
(if (<= d4 4.5e-224)
(* (- d3) d1)
(if (<= d4 7e+24) (* (- d1) d1) (* d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e-299) {
tmp = d2 * d1;
} else if (d4 <= 4.5e-224) {
tmp = -d3 * d1;
} else if (d4 <= 7e+24) {
tmp = -d1 * d1;
} else {
tmp = d4 * 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 (d4 <= 4.4d-299) then
tmp = d2 * d1
else if (d4 <= 4.5d-224) then
tmp = -d3 * d1
else if (d4 <= 7d+24) then
tmp = -d1 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e-299) {
tmp = d2 * d1;
} else if (d4 <= 4.5e-224) {
tmp = -d3 * d1;
} else if (d4 <= 7e+24) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.4e-299: tmp = d2 * d1 elif d4 <= 4.5e-224: tmp = -d3 * d1 elif d4 <= 7e+24: tmp = -d1 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.4e-299) tmp = Float64(d2 * d1); elseif (d4 <= 4.5e-224) tmp = Float64(Float64(-d3) * d1); elseif (d4 <= 7e+24) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.4e-299) tmp = d2 * d1; elseif (d4 <= 4.5e-224) tmp = -d3 * d1; elseif (d4 <= 7e+24) tmp = -d1 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.4e-299], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 4.5e-224], N[((-d3) * d1), $MachinePrecision], If[LessEqual[d4, 7e+24], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.4 \cdot 10^{-299}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 4.5 \cdot 10^{-224}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 7 \cdot 10^{+24}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 4.3999999999999999e-299Initial program 86.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f6493.4
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6494.9
Applied rewrites94.9%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
if 4.3999999999999999e-299 < d4 < 4.5000000000000004e-224Initial program 88.1%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6499.9
Applied rewrites99.9%
Taylor expanded in d1 around 0
Applied rewrites76.9%
Taylor expanded in d2 around 0
Applied rewrites49.8%
if 4.5000000000000004e-224 < d4 < 7.0000000000000004e24Initial program 88.2%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6445.3
Applied rewrites45.3%
if 7.0000000000000004e24 < d4 Initial program 84.3%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6466.6
Applied rewrites66.6%
Final simplification41.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -4.5e+157) (not (<= d1 1.3e+29))) (* (- (- d3) d1) d1) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.5e+157) || !(d1 <= 1.3e+29)) {
tmp = (-d3 - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * 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 ((d1 <= (-4.5d+157)) .or. (.not. (d1 <= 1.3d+29))) then
tmp = (-d3 - d1) * d1
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -4.5e+157) || !(d1 <= 1.3e+29)) {
tmp = (-d3 - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -4.5e+157) or not (d1 <= 1.3e+29): tmp = (-d3 - d1) * d1 else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -4.5e+157) || !(d1 <= 1.3e+29)) tmp = Float64(Float64(Float64(-d3) - d1) * d1); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -4.5e+157) || ~((d1 <= 1.3e+29))) tmp = (-d3 - d1) * d1; else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -4.5e+157], N[Not[LessEqual[d1, 1.3e+29]], $MachinePrecision]], N[(N[((-d3) - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4.5 \cdot 10^{+157} \lor \neg \left(d1 \leq 1.3 \cdot 10^{+29}\right):\\
\;\;\;\;\left(\left(-d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -4.49999999999999985e157 or 1.3e29 < d1 Initial program 61.8%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6492.0
Applied rewrites92.0%
Taylor expanded in d2 around 0
Applied rewrites87.2%
if -4.49999999999999985e157 < d1 < 1.3e29Initial program 99.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6493.7
Applied rewrites93.7%
Final simplification91.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.7e-233) (* (- d2 d3) d1) (if (<= d4 2.15e+24) (* (- (- d3) d1) d1) (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.7e-233) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 2.15e+24) {
tmp = (-d3 - d1) * d1;
} else {
tmp = (d4 - d3) * 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 (d4 <= 1.7d-233) then
tmp = (d2 - d3) * d1
else if (d4 <= 2.15d+24) then
tmp = (-d3 - d1) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.7e-233) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 2.15e+24) {
tmp = (-d3 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.7e-233: tmp = (d2 - d3) * d1 elif d4 <= 2.15e+24: tmp = (-d3 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.7e-233) tmp = Float64(Float64(d2 - d3) * d1); elseif (d4 <= 2.15e+24) tmp = Float64(Float64(Float64(-d3) - d1) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.7e-233) tmp = (d2 - d3) * d1; elseif (d4 <= 2.15e+24) tmp = (-d3 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.7e-233], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 2.15e+24], N[(N[((-d3) - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.7 \cdot 10^{-233}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 2.15 \cdot 10^{+24}:\\
\;\;\;\;\left(\left(-d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 1.7000000000000001e-233Initial program 86.3%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6481.8
Applied rewrites81.8%
Taylor expanded in d1 around 0
Applied rewrites62.3%
if 1.7000000000000001e-233 < d4 < 2.14999999999999994e24Initial program 88.2%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6494.1
Applied rewrites94.1%
Taylor expanded in d2 around 0
Applied rewrites72.1%
if 2.14999999999999994e24 < d4 Initial program 84.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.5
Applied rewrites88.5%
Taylor expanded in d2 around 0
Applied rewrites81.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1950000000.0) (not (<= d3 9.2e+22))) (* (- d4 d3) d1) (* (- d2 d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1950000000.0) || !(d3 <= 9.2e+22)) {
tmp = (d4 - d3) * d1;
} else {
tmp = (d2 - 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 ((d3 <= (-1950000000.0d0)) .or. (.not. (d3 <= 9.2d+22))) then
tmp = (d4 - d3) * d1
else
tmp = (d2 - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1950000000.0) || !(d3 <= 9.2e+22)) {
tmp = (d4 - d3) * d1;
} else {
tmp = (d2 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1950000000.0) or not (d3 <= 9.2e+22): tmp = (d4 - d3) * d1 else: tmp = (d2 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1950000000.0) || !(d3 <= 9.2e+22)) tmp = Float64(Float64(d4 - d3) * d1); else tmp = Float64(Float64(d2 - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1950000000.0) || ~((d3 <= 9.2e+22))) tmp = (d4 - d3) * d1; else tmp = (d2 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1950000000.0], N[Not[LessEqual[d3, 9.2e+22]], $MachinePrecision]], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1950000000 \lor \neg \left(d3 \leq 9.2 \cdot 10^{+22}\right):\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -1.95e9 or 9.2000000000000008e22 < d3 Initial program 83.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6493.1
Applied rewrites93.1%
Taylor expanded in d2 around 0
Applied rewrites82.0%
if -1.95e9 < d3 < 9.2000000000000008e22Initial program 89.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6475.8
Applied rewrites75.8%
Taylor expanded in d3 around 0
Applied rewrites74.8%
Final simplification78.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.8e+52) (not (<= d3 2.6e+79))) (* (- d4 d3) d1) (* (+ d2 d4) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+52) || !(d3 <= 2.6e+79)) {
tmp = (d4 - d3) * d1;
} else {
tmp = (d2 + d4) * 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 ((d3 <= (-1.8d+52)) .or. (.not. (d3 <= 2.6d+79))) then
tmp = (d4 - d3) * d1
else
tmp = (d2 + d4) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.8e+52) || !(d3 <= 2.6e+79)) {
tmp = (d4 - d3) * d1;
} else {
tmp = (d2 + d4) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.8e+52) or not (d3 <= 2.6e+79): tmp = (d4 - d3) * d1 else: tmp = (d2 + d4) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.8e+52) || !(d3 <= 2.6e+79)) tmp = Float64(Float64(d4 - d3) * d1); else tmp = Float64(Float64(d2 + d4) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.8e+52) || ~((d3 <= 2.6e+79))) tmp = (d4 - d3) * d1; else tmp = (d2 + d4) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.8e+52], N[Not[LessEqual[d3, 2.6e+79]], $MachinePrecision]], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.8 \cdot 10^{+52} \lor \neg \left(d3 \leq 2.6 \cdot 10^{+79}\right):\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -1.8e52 or 2.60000000000000015e79 < d3 Initial program 81.5%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6493.4
Applied rewrites93.4%
Taylor expanded in d2 around 0
Applied rewrites84.1%
if -1.8e52 < d3 < 2.60000000000000015e79Initial program 89.5%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6468.9
Applied rewrites68.9%
Taylor expanded in d3 around 0
Applied rewrites65.6%
Final simplification73.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -1.7e+97) (not (<= d3 9.8e+123))) (* (- d3) d1) (* (+ d2 d4) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.7e+97) || !(d3 <= 9.8e+123)) {
tmp = -d3 * d1;
} else {
tmp = (d2 + d4) * 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 ((d3 <= (-1.7d+97)) .or. (.not. (d3 <= 9.8d+123))) then
tmp = -d3 * d1
else
tmp = (d2 + d4) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -1.7e+97) || !(d3 <= 9.8e+123)) {
tmp = -d3 * d1;
} else {
tmp = (d2 + d4) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -1.7e+97) or not (d3 <= 9.8e+123): tmp = -d3 * d1 else: tmp = (d2 + d4) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -1.7e+97) || !(d3 <= 9.8e+123)) tmp = Float64(Float64(-d3) * d1); else tmp = Float64(Float64(d2 + d4) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -1.7e+97) || ~((d3 <= 9.8e+123))) tmp = -d3 * d1; else tmp = (d2 + d4) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -1.7e+97], N[Not[LessEqual[d3, 9.8e+123]], $MachinePrecision]], N[((-d3) * d1), $MachinePrecision], N[(N[(d2 + d4), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -1.7 \cdot 10^{+97} \lor \neg \left(d3 \leq 9.8 \cdot 10^{+123}\right):\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d2 + d4\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -1.70000000000000005e97 or 9.79999999999999952e123 < d3 Initial program 79.5%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6492.4
Applied rewrites92.4%
Taylor expanded in d1 around 0
Applied rewrites87.8%
Taylor expanded in d2 around 0
Applied rewrites80.7%
if -1.70000000000000005e97 < d3 < 9.79999999999999952e123Initial program 89.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6470.8
Applied rewrites70.8%
Taylor expanded in d3 around 0
Applied rewrites64.4%
Final simplification69.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.4e-299) (* d2 d1) (if (<= d4 2.6e+88) (* (- d3) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e-299) {
tmp = d2 * d1;
} else if (d4 <= 2.6e+88) {
tmp = -d3 * d1;
} else {
tmp = d4 * 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 (d4 <= 4.4d-299) then
tmp = d2 * d1
else if (d4 <= 2.6d+88) then
tmp = -d3 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.4e-299) {
tmp = d2 * d1;
} else if (d4 <= 2.6e+88) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.4e-299: tmp = d2 * d1 elif d4 <= 2.6e+88: tmp = -d3 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.4e-299) tmp = Float64(d2 * d1); elseif (d4 <= 2.6e+88) tmp = Float64(Float64(-d3) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 4.4e-299) tmp = d2 * d1; elseif (d4 <= 2.6e+88) tmp = -d3 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.4e-299], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 2.6e+88], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.4 \cdot 10^{-299}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 2.6 \cdot 10^{+88}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 4.3999999999999999e-299Initial program 86.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f6493.4
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6494.9
Applied rewrites94.9%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6428.8
Applied rewrites28.8%
if 4.3999999999999999e-299 < d4 < 2.6000000000000001e88Initial program 88.3%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6494.8
Applied rewrites94.8%
Taylor expanded in d1 around 0
Applied rewrites61.1%
Taylor expanded in d2 around 0
Applied rewrites36.0%
if 2.6000000000000001e88 < d4 Initial program 83.3%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6478.0
Applied rewrites78.0%
Final simplification39.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.8e-12) (* (- (- d2 d3) d1) d1) (* (- (- d4 d1) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e-12) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 - d1) - d3) * 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 <= (-1.8d-12)) then
tmp = ((d2 - d3) - d1) * d1
else
tmp = ((d4 - d1) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e-12) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 - d1) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.8e-12: tmp = ((d2 - d3) - d1) * d1 else: tmp = ((d4 - d1) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.8e-12) tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1); else tmp = Float64(Float64(Float64(d4 - d1) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.8e-12) tmp = ((d2 - d3) - d1) * d1; else tmp = ((d4 - d1) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e-12], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.8 \cdot 10^{-12}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -1.8e-12Initial program 87.3%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6489.2
Applied rewrites89.2%
if -1.8e-12 < d2 Initial program 85.9%
Taylor expanded in d2 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
associate--l-N/A
+-commutativeN/A
associate--l-N/A
lower--.f64N/A
lower--.f6488.8
Applied rewrites88.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 9.5e+21) (* (- (- d2 d3) d1) d1) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 9.5e+21) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * 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 (d4 <= 9.5d+21) then
tmp = ((d2 - d3) - d1) * d1
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 9.5e+21) {
tmp = ((d2 - d3) - d1) * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 9.5e+21: tmp = ((d2 - d3) - d1) * d1 else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 9.5e+21) tmp = Float64(Float64(Float64(d2 - d3) - d1) * d1); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 9.5e+21) tmp = ((d2 - d3) - d1) * d1; else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 9.5e+21], N[(N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 9.5 \cdot 10^{+21}:\\
\;\;\;\;\left(\left(d2 - d3\right) - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 9.500000000000001e21Initial program 87.2%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
unpow2N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6484.7
Applied rewrites84.7%
if 9.500000000000001e21 < d4 Initial program 83.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6487.1
Applied rewrites87.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.8e-12) (* d2 d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e-12) {
tmp = d2 * d1;
} else {
tmp = d4 * 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 <= (-1.8d-12)) then
tmp = d2 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.8e-12) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.8e-12: tmp = d2 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.8e-12) tmp = Float64(d2 * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.8e-12) tmp = d2 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.8e-12], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.8 \cdot 10^{-12}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -1.8e-12Initial program 87.3%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f6490.1
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6491.5
Applied rewrites91.5%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6451.1
Applied rewrites51.1%
if -1.8e-12 < d2 Initial program 85.9%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6433.5
Applied rewrites33.5%
Final simplification38.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
double code(double d1, double d2, double d3, double d4) {
return d2 * 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
end function
public static double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
def code(d1, d2, d3, d4): return d2 * d1
function code(d1, d2, d3, d4) return Float64(d2 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d2 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
\begin{array}{l}
\\
d2 \cdot d1
\end{array}
Initial program 86.3%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower--.f6493.3
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f6494.1
Applied rewrites94.1%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6426.5
Applied rewrites26.5%
Final simplification26.5%
(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 2025007
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform default (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))