
(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 10 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 (let* ((t_0 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))) (if (<= t_0 INFINITY) t_0 (* d1 (- (- d2 d3) d1)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = d1 * ((d2 - d3) - d1);
}
return tmp;
}
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = d1 * ((d2 - d3) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = d1 * ((d2 - d3) - d1) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); tmp = 0.0; if (t_0 <= Inf) tmp = t_0; else tmp = d1 * ((d2 - d3) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < +inf.0Initial program 88.0%
if +inf.0 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -5800000000.0) (* d1 (- (- d2 d3) d1)) (if (<= d1 1.2e+79) (* (- (+ d4 d2) d3) d1) (fma d2 d1 (* d1 (- d4 d1))))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -5800000000.0) {
tmp = d1 * ((d2 - d3) - d1);
} else if (d1 <= 1.2e+79) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = fma(d2, d1, (d1 * (d4 - d1)));
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -5800000000.0) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); elseif (d1 <= 1.2e+79) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = fma(d2, d1, Float64(d1 * Float64(d4 - d1))); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -5800000000.0], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.2e+79], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(d2 * d1 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -5800000000:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{elif}\;d1 \leq 1.2 \cdot 10^{+79}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(d2, d1, d1 \cdot \left(d4 - d1\right)\right)\\
\end{array}
\end{array}
if d1 < -5.8e9Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
if -5.8e9 < d1 < 1.19999999999999993e79Initial program 88.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6480.9
Applied rewrites80.9%
if 1.19999999999999993e79 < d1 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (- d2 d3) d1))))
(if (<= d1 -5800000000.0)
t_0
(if (<= d1 2e+85) (* (- (+ d4 d2) d3) d1) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * ((d2 - d3) - d1);
double tmp;
if (d1 <= -5800000000.0) {
tmp = t_0;
} else if (d1 <= 2e+85) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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) :: t_0
real(8) :: tmp
t_0 = d1 * ((d2 - d3) - d1)
if (d1 <= (-5800000000.0d0)) then
tmp = t_0
else if (d1 <= 2d+85) then
tmp = ((d4 + d2) - d3) * d1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * ((d2 - d3) - d1);
double tmp;
if (d1 <= -5800000000.0) {
tmp = t_0;
} else if (d1 <= 2e+85) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * ((d2 - d3) - d1) tmp = 0 if d1 <= -5800000000.0: tmp = t_0 elif d1 <= 2e+85: tmp = ((d4 + d2) - d3) * d1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(d2 - d3) - d1)) tmp = 0.0 if (d1 <= -5800000000.0) tmp = t_0; elseif (d1 <= 2e+85) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * ((d2 - d3) - d1); tmp = 0.0; if (d1 <= -5800000000.0) tmp = t_0; elseif (d1 <= 2e+85) tmp = ((d4 + d2) - d3) * d1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -5800000000.0], t$95$0, If[LessEqual[d1, 2e+85], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{if}\;d1 \leq -5800000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 2 \cdot 10^{+85}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -5.8e9 or 2e85 < d1 Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
if -5.8e9 < d1 < 2e85Initial program 88.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6480.9
Applied rewrites80.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 2e+147) (* d1 (- (- d2 d3) d1)) (fma d2 d1 (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 2e+147) {
tmp = d1 * ((d2 - d3) - d1);
} else {
tmp = fma(d2, d1, (d1 * d4));
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 2e+147) tmp = Float64(d1 * Float64(Float64(d2 - d3) - d1)); else tmp = fma(d2, d1, Float64(d1 * d4)); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 2e+147], N[(d1 * N[(N[(d2 - d3), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d2 * d1 + N[(d1 * d4), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 2 \cdot 10^{+147}:\\
\;\;\;\;d1 \cdot \left(\left(d2 - d3\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(d2, d1, d1 \cdot d4\right)\\
\end{array}
\end{array}
if d4 < 2e147Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
if 2e147 < d4 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d1 around 0
Applied rewrites55.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+29) (* d1 (- d2 d3)) (if (<= d2 -1.55e-119) (* (- d4 d1) d1) (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+29) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.55e-119) {
tmp = (d4 - 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 (d2 <= (-2.5d+29)) then
tmp = d1 * (d2 - d3)
else if (d2 <= (-1.55d-119)) then
tmp = (d4 - 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 (d2 <= -2.5e+29) {
tmp = d1 * (d2 - d3);
} else if (d2 <= -1.55e-119) {
tmp = (d4 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+29: tmp = d1 * (d2 - d3) elif d2 <= -1.55e-119: tmp = (d4 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+29) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d2 <= -1.55e-119) tmp = Float64(Float64(d4 - 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 (d2 <= -2.5e+29) tmp = d1 * (d2 - d3); elseif (d2 <= -1.55e-119) tmp = (d4 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+29], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, -1.55e-119], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+29}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d2 \leq -1.55 \cdot 10^{-119}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -2.5e29Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
Taylor expanded in d1 around 0
lift--.f6457.2
Applied rewrites57.2%
if -2.5e29 < d2 < -1.54999999999999989e-119Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
if -1.54999999999999989e-119 < d2 Initial program 88.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6480.9
Applied rewrites80.9%
Taylor expanded in d2 around 0
lower--.f6456.3
Applied rewrites56.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+29) (* d1 (- d2 d3)) (* (- d4 d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+29) {
tmp = d1 * (d2 - d3);
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.5d+29)) then
tmp = d1 * (d2 - d3)
else
tmp = (d4 - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+29) {
tmp = d1 * (d2 - d3);
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+29: tmp = d1 * (d2 - d3) else: tmp = (d4 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+29) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(Float64(d4 - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.5e+29) tmp = d1 * (d2 - d3); else tmp = (d4 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+29], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+29}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -2.5e29Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
Taylor expanded in d1 around 0
lift--.f6457.2
Applied rewrites57.2%
if -2.5e29 < d2 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -7.2e+77) (* d2 d1) (* (- d4 d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.2e+77) {
tmp = d2 * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-7.2d+77)) then
tmp = d2 * d1
else
tmp = (d4 - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -7.2e+77) {
tmp = d2 * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -7.2e+77: tmp = d2 * d1 else: tmp = (d4 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -7.2e+77) tmp = Float64(d2 * d1); else tmp = Float64(Float64(d4 - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -7.2e+77) tmp = d2 * d1; else tmp = (d4 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -7.2e+77], N[(d2 * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -7.2 \cdot 10^{+77}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -7.1999999999999996e77Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.6
Applied rewrites31.6%
if -7.1999999999999996e77 < d2 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 8.2e-229) (* d2 d1) (if (<= d4 2.1e+67) (* (- d1) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 8.2e-229) {
tmp = d2 * d1;
} else if (d4 <= 2.1e+67) {
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 <= 8.2d-229) then
tmp = d2 * d1
else if (d4 <= 2.1d+67) 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 <= 8.2e-229) {
tmp = d2 * d1;
} else if (d4 <= 2.1e+67) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 8.2e-229: tmp = d2 * d1 elif d4 <= 2.1e+67: tmp = -d1 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 8.2e-229) tmp = Float64(d2 * d1); elseif (d4 <= 2.1e+67) 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 <= 8.2e-229) tmp = d2 * d1; elseif (d4 <= 2.1e+67) tmp = -d1 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 8.2e-229], N[(d2 * d1), $MachinePrecision], If[LessEqual[d4, 2.1e+67], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 8.2 \cdot 10^{-229}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d4 \leq 2.1 \cdot 10^{+67}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 8.1999999999999999e-229Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.6
Applied rewrites31.6%
if 8.1999999999999999e-229 < d4 < 2.1000000000000001e67Initial program 88.0%
Taylor expanded in d1 around inf
mul-1-negN/A
pow2N/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6431.8
Applied rewrites31.8%
if 2.1000000000000001e67 < d4 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
Taylor expanded in d1 around 0
Applied rewrites30.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.5e+29) (* d2 d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.5e+29) {
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 <= (-2.5d+29)) 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 <= -2.5e+29) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.5e+29: tmp = d2 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.5e+29) 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 <= -2.5e+29) tmp = d2 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.5e+29], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.5 \cdot 10^{+29}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -2.5e29Initial program 88.0%
Taylor expanded in d4 around 0
associate--r+N/A
distribute-lft-out--N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6477.6
Applied rewrites77.6%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.6
Applied rewrites31.6%
if -2.5e29 < d2 Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
Taylor expanded in d1 around 0
Applied rewrites30.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d4 d1))
double code(double d1, double d2, double d3, double d4) {
return 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 = d4 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d4 * d1;
}
def code(d1, d2, d3, d4): return d4 * d1
function code(d1, d2, d3, d4) return Float64(d4 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d4 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d4 * d1), $MachinePrecision]
\begin{array}{l}
\\
d4 \cdot d1
\end{array}
Initial program 88.0%
Taylor expanded in d3 around 0
associate--l+N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
pow2N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6475.2
Applied rewrites75.2%
Taylor expanded in d2 around 0
*-commutativeN/A
lower-*.f64N/A
lift--.f6453.6
Applied rewrites53.6%
Taylor expanded in d1 around 0
Applied rewrites30.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2025142
(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)))