
(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 11 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 (* (- (+ (+ (- d1) d4) d2) d3) d1))
double code(double d1, double d2, double d3, double d4) {
return (((-d1 + d4) + d2) - d3) * 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 + d4) + d2) - d3) * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((-d1 + d4) + d2) - d3) * d1;
}
def code(d1, d2, d3, d4): return (((-d1 + d4) + d2) - d3) * d1
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(Float64(-d1) + d4) + d2) - d3) * d1) end
function tmp = code(d1, d2, d3, d4) tmp = (((-d1 + d4) + d2) - d3) * d1; end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[((-d1) + d4), $MachinePrecision] + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\left(\left(-d1\right) + d4\right) + d2\right) - d3\right) \cdot d1
\end{array}
Initial program 87.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.16e+14) (* (- (+ d4 d2) d3) d1) (* (- (- d4 d1) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.16e+14) {
tmp = ((d4 + d2) - d3) * 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.16d+14)) then
tmp = ((d4 + d2) - d3) * 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.16e+14) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = ((d4 - d1) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.16e+14: tmp = ((d4 + d2) - d3) * d1 else: tmp = ((d4 - d1) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.16e+14) tmp = Float64(Float64(Float64(d4 + d2) - d3) * 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.16e+14) tmp = ((d4 + d2) - d3) * d1; else tmp = ((d4 - d1) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.16e+14], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.16 \cdot 10^{+14}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -1.16e14Initial program 83.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.5
Applied rewrites88.5%
if -1.16e14 < d2 Initial program 88.9%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around 0
lower--.f6484.7
Applied rewrites84.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 4.1e+40) (* (- (- d2 d1) d3) d1) (* (- (- d4 d1) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 4.1e+40) {
tmp = ((d2 - d1) - d3) * 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 (d4 <= 4.1d+40) then
tmp = ((d2 - d1) - d3) * 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 (d4 <= 4.1e+40) {
tmp = ((d2 - d1) - d3) * d1;
} else {
tmp = ((d4 - d1) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 4.1e+40: tmp = ((d2 - d1) - d3) * d1 else: tmp = ((d4 - d1) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 4.1e+40) tmp = Float64(Float64(Float64(d2 - d1) - d3) * 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 (d4 <= 4.1e+40) tmp = ((d2 - d1) - d3) * d1; else tmp = ((d4 - d1) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 4.1e+40], N[(N[(N[(d2 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 4.1 \cdot 10^{+40}:\\
\;\;\;\;\left(\left(d2 - d1\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d1\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 4.1000000000000002e40Initial program 88.9%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around 0
lower--.f6483.8
Applied rewrites83.8%
if 4.1000000000000002e40 < d4 Initial program 83.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around 0
lower--.f6485.4
Applied rewrites85.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 8.5e+57) (* (- (- d2 d1) d3) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 8.5e+57) {
tmp = ((d2 - d1) - d3) * 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 <= 8.5d+57) then
tmp = ((d2 - d1) - d3) * 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 <= 8.5e+57) {
tmp = ((d2 - d1) - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 8.5e+57: tmp = ((d2 - d1) - d3) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 8.5e+57) tmp = Float64(Float64(Float64(d2 - d1) - d3) * 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 <= 8.5e+57) tmp = ((d2 - d1) - d3) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.5e+57], N[(N[(N[(d2 - d1), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 8.5 \cdot 10^{+57}:\\
\;\;\;\;\left(\left(d2 - d1\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 8.5000000000000001e57Initial program 88.7%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around 0
lower--.f6483.8
Applied rewrites83.8%
if 8.5000000000000001e57 < d4 Initial program 83.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around inf
Applied rewrites76.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.5e-301) (* (- d2 d3) d1) (if (<= d4 3.8e+57) (* (- (- d1) d3) d1) (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.5e-301) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 3.8e+57) {
tmp = (-d1 - d3) * 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 <= 3.5d-301) then
tmp = (d2 - d3) * d1
else if (d4 <= 3.8d+57) then
tmp = (-d1 - d3) * 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 <= 3.5e-301) {
tmp = (d2 - d3) * d1;
} else if (d4 <= 3.8e+57) {
tmp = (-d1 - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.5e-301: tmp = (d2 - d3) * d1 elif d4 <= 3.8e+57: tmp = (-d1 - d3) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.5e-301) tmp = Float64(Float64(d2 - d3) * d1); elseif (d4 <= 3.8e+57) tmp = Float64(Float64(Float64(-d1) - d3) * 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 <= 3.5e-301) tmp = (d2 - d3) * d1; elseif (d4 <= 3.8e+57) tmp = (-d1 - d3) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.5e-301], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d4, 3.8e+57], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.5 \cdot 10^{-301}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 3.8 \cdot 10^{+57}:\\
\;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 3.49999999999999992e-301Initial program 88.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around inf
Applied rewrites56.3%
if 3.49999999999999992e-301 < d4 < 3.7999999999999999e57Initial program 89.5%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d1 around inf
mul-1-negN/A
lift-neg.f6468.0
Applied rewrites68.0%
if 3.7999999999999999e57 < d4 Initial program 83.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around inf
Applied rewrites76.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.5e+72) (* (- d2 d3) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.5e+72) {
tmp = (d2 - d3) * 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 (d2 <= (-4.5d+72)) then
tmp = (d2 - d3) * 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 (d2 <= -4.5e+72) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.5e+72: tmp = (d2 - d3) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.5e+72) tmp = Float64(Float64(d2 - d3) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -4.5e+72) tmp = (d2 - d3) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4.5e+72], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.5 \cdot 10^{+72}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -4.4999999999999998e72Initial program 82.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around inf
Applied rewrites78.4%
if -4.4999999999999998e72 < d2 Initial program 88.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around inf
Applied rewrites61.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 9.2e+108) (* (- d2 d3) d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 9.2e+108) {
tmp = (d2 - 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 <= 9.2d+108) then
tmp = (d2 - 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 <= 9.2e+108) {
tmp = (d2 - d3) * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 9.2e+108: tmp = (d2 - d3) * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 9.2e+108) tmp = Float64(Float64(d2 - d3) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 9.2e+108) tmp = (d2 - d3) * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 9.2e+108], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 9.2 \cdot 10^{+108}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 9.1999999999999996e108Initial program 88.5%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around inf
Applied rewrites59.9%
if 9.1999999999999996e108 < d4 Initial program 83.0%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6471.2
Applied rewrites71.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 7.5e-301)
(* d2 d1)
(if (<= d4 5.2e-39)
(* (- d3) d1)
(if (<= d4 3.8e+57) (* (- d1) d1) (* d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 7.5e-301) {
tmp = d2 * d1;
} else if (d4 <= 5.2e-39) {
tmp = -d3 * d1;
} else if (d4 <= 3.8e+57) {
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 <= 7.5d-301) then
tmp = d2 * d1
else if (d4 <= 5.2d-39) then
tmp = -d3 * d1
else if (d4 <= 3.8d+57) 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 <= 7.5e-301) {
tmp = d2 * d1;
} else if (d4 <= 5.2e-39) {
tmp = -d3 * d1;
} else if (d4 <= 3.8e+57) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 7.5e-301: tmp = d2 * d1 elif d4 <= 5.2e-39: tmp = -d3 * d1 elif d4 <= 3.8e+57: tmp = -d1 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 7.5e-301) tmp = Float64(d2 * d1); elseif (d4 <= 5.2e-39) tmp = Float64(Float64(-d3) * d1); elseif (d4 <= 3.8e+57) 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 <= 7.5e-301) tmp = d2 * d1; elseif (d4 <= 5.2e-39) tmp = -d3 * d1; elseif (d4 <= 3.8e+57) tmp = -d1 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 7.5e-301], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 5.2e-39], N[((-d3) * d1), $MachinePrecision], If[LessEqual[d4, 3.8e+57], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 7.5 \cdot 10^{-301}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 5.2 \cdot 10^{-39}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 3.8 \cdot 10^{+57}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 7.5000000000000006e-301Initial program 88.3%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.6
Applied rewrites31.6%
if 7.5000000000000006e-301 < d4 < 5.2e-39Initial program 90.0%
Taylor expanded in d3 around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6440.3
Applied rewrites40.3%
if 5.2e-39 < d4 < 3.7999999999999999e57Initial program 88.0%
Taylor expanded in d1 around inf
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6435.4
Applied rewrites35.4%
if 3.7999999999999999e57 < d4 Initial program 83.2%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6464.3
Applied rewrites64.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.12e-293) (* d2 d1) (if (<= d4 3.8e+57) (* (- d1) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.12e-293) {
tmp = d2 * d1;
} else if (d4 <= 3.8e+57) {
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 <= 1.12d-293) then
tmp = d2 * d1
else if (d4 <= 3.8d+57) 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 <= 1.12e-293) {
tmp = d2 * d1;
} else if (d4 <= 3.8e+57) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.12e-293: tmp = d2 * d1 elif d4 <= 3.8e+57: tmp = -d1 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.12e-293) tmp = Float64(d2 * d1); elseif (d4 <= 3.8e+57) 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 <= 1.12e-293) tmp = d2 * d1; elseif (d4 <= 3.8e+57) tmp = -d1 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.12e-293], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 3.8e+57], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.12 \cdot 10^{-293}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 3.8 \cdot 10^{+57}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 1.11999999999999996e-293Initial program 88.3%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.7
Applied rewrites31.7%
if 1.11999999999999996e-293 < d4 < 3.7999999999999999e57Initial program 89.5%
Taylor expanded in d1 around inf
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6439.7
Applied rewrites39.7%
if 3.7999999999999999e57 < d4 Initial program 83.2%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6464.3
Applied rewrites64.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -4.5e+72) (* d2 d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -4.5e+72) {
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 <= (-4.5d+72)) 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 <= -4.5e+72) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -4.5e+72: tmp = d2 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -4.5e+72) 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 <= -4.5e+72) tmp = d2 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -4.5e+72], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -4.5 \cdot 10^{+72}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -4.4999999999999998e72Initial program 82.4%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6464.8
Applied rewrites64.8%
if -4.4999999999999998e72 < d2 Initial program 88.8%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6435.0
Applied rewrites35.0%
(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 87.6%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.0
Applied rewrites31.0%
(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 2025117
(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)))