
(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 13 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 d3) 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 = fma(d1, (d4 - d1), ((d2 - d3) * d1));
} else {
tmp = ((d4 - d3) - 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 = fma(d1, Float64(d4 - d1), Float64(Float64(d2 - d3) * d1)); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * 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 - d3), $MachinePrecision] - d1), $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 - d3\right) - d1\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
lower--.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Final simplification99.6%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<= d4 -1.45e-110)
(* d1 d2)
(if (<= d4 1.65e-298)
(* (- d1) d1)
(if (<= d4 1e+56) (* (- d3) d1) (* d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.45e-110) {
tmp = d1 * d2;
} else if (d4 <= 1.65e-298) {
tmp = -d1 * d1;
} else if (d4 <= 1e+56) {
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 <= (-1.45d-110)) then
tmp = d1 * d2
else if (d4 <= 1.65d-298) then
tmp = -d1 * d1
else if (d4 <= 1d+56) 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 <= -1.45e-110) {
tmp = d1 * d2;
} else if (d4 <= 1.65e-298) {
tmp = -d1 * d1;
} else if (d4 <= 1e+56) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.45e-110: tmp = d1 * d2 elif d4 <= 1.65e-298: tmp = -d1 * d1 elif d4 <= 1e+56: tmp = -d3 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.45e-110) tmp = Float64(d1 * d2); elseif (d4 <= 1.65e-298) tmp = Float64(Float64(-d1) * d1); elseif (d4 <= 1e+56) 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 <= -1.45e-110) tmp = d1 * d2; elseif (d4 <= 1.65e-298) tmp = -d1 * d1; elseif (d4 <= 1e+56) tmp = -d3 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.45e-110], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1.65e-298], N[((-d1) * d1), $MachinePrecision], If[LessEqual[d4, 1e+56], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.45 \cdot 10^{-110}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 1.65 \cdot 10^{-298}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{elif}\;d4 \leq 10^{+56}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < -1.4500000000000001e-110Initial program 84.2%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6497.4
Applied rewrites97.4%
Taylor expanded in d2 around inf
lower-*.f6432.3
Applied rewrites32.3%
if -1.4500000000000001e-110 < d4 < 1.6500000000000001e-298Initial program 88.6%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6449.5
Applied rewrites49.5%
if 1.6500000000000001e-298 < d4 < 1.00000000000000009e56Initial program 90.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6481.0
Applied rewrites81.0%
Taylor expanded in d3 around inf
Applied rewrites45.6%
if 1.00000000000000009e56 < d4 Initial program 85.2%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6494.4
Applied rewrites94.4%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
distribute-lft-out--N/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Final simplification45.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -4e+112) (* (- (- d1) d3) d1) (if (<= d1 3e+98) (* (- (+ d4 d2) d3) d1) (* (- d4 d1) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -4e+112) {
tmp = (-d1 - d3) * d1;
} else if (d1 <= 3e+98) {
tmp = ((d4 + d2) - d3) * 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 (d1 <= (-4d+112)) then
tmp = (-d1 - d3) * d1
else if (d1 <= 3d+98) then
tmp = ((d4 + d2) - d3) * 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 (d1 <= -4e+112) {
tmp = (-d1 - d3) * d1;
} else if (d1 <= 3e+98) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -4e+112: tmp = (-d1 - d3) * d1 elif d1 <= 3e+98: tmp = ((d4 + d2) - d3) * d1 else: tmp = (d4 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -4e+112) tmp = Float64(Float64(Float64(-d1) - d3) * d1); elseif (d1 <= 3e+98) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = Float64(Float64(d4 - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -4e+112) tmp = (-d1 - d3) * d1; elseif (d1 <= 3e+98) tmp = ((d4 + d2) - d3) * d1; else tmp = (d4 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -4e+112], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d1, 3e+98], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -4 \cdot 10^{+112}:\\
\;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\
\mathbf{elif}\;d1 \leq 3 \cdot 10^{+98}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -3.9999999999999997e112Initial program 51.2%
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
lower--.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in d4 around 0
Applied rewrites92.9%
if -3.9999999999999997e112 < d1 < 3.0000000000000001e98Initial program 100.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6492.4
Applied rewrites92.4%
if 3.0000000000000001e98 < d1 Initial program 64.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
lower--.f64N/A
lower--.f6491.9
Applied rewrites91.9%
Taylor expanded in d3 around 0
Applied rewrites81.1%
Final simplification90.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.25e+63) (* (- d2 d3) d1) (if (<= d2 -7.8e-188) (* (- (- d1) d3) d1) (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.25e+63) {
tmp = (d2 - d3) * d1;
} else if (d2 <= -7.8e-188) {
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 (d2 <= (-1.25d+63)) then
tmp = (d2 - d3) * d1
else if (d2 <= (-7.8d-188)) 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 (d2 <= -1.25e+63) {
tmp = (d2 - d3) * d1;
} else if (d2 <= -7.8e-188) {
tmp = (-d1 - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.25e+63: tmp = (d2 - d3) * d1 elif d2 <= -7.8e-188: tmp = (-d1 - d3) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.25e+63) tmp = Float64(Float64(d2 - d3) * d1); elseif (d2 <= -7.8e-188) 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 (d2 <= -1.25e+63) tmp = (d2 - d3) * d1; elseif (d2 <= -7.8e-188) tmp = (-d1 - d3) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.25e+63], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -7.8e-188], N[(N[((-d1) - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.25 \cdot 10^{+63}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d2 \leq -7.8 \cdot 10^{-188}:\\
\;\;\;\;\left(\left(-d1\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -1.25000000000000003e63Initial program 81.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Taylor expanded in d4 around 0
Applied rewrites70.0%
if -1.25000000000000003e63 < d2 < -7.79999999999999954e-188Initial program 91.6%
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
lower--.f64N/A
lower--.f6495.8
Applied rewrites95.8%
Taylor expanded in d4 around 0
Applied rewrites80.0%
if -7.79999999999999954e-188 < d2 Initial program 87.4%
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
lower--.f64N/A
lower--.f6479.5
Applied rewrites79.5%
Taylor expanded in d1 around 0
Applied rewrites59.7%
Final simplification65.5%
(FPCore (d1 d2 d3 d4) :precision binary64 (fma d2 d1 (fma (- d1) d3 (* d1 (- d4 d1)))))
double code(double d1, double d2, double d3, double d4) {
return fma(d2, d1, fma(-d1, d3, (d1 * (d4 - d1))));
}
function code(d1, d2, d3, d4) return fma(d2, d1, fma(Float64(-d1), d3, Float64(d1 * Float64(d4 - d1)))) end
code[d1_, d2_, d3_, d4_] := N[(d2 * d1 + N[((-d1) * d3 + N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(d2, d1, \mathsf{fma}\left(-d1, d3, d1 \cdot \left(d4 - d1\right)\right)\right)
\end{array}
Initial program 87.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6497.6
Applied rewrites97.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -6.3e+69) (not (<= d1 1.65e+114))) (* (- d1) d1) (* (+ d4 d2) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114)) {
tmp = -d1 * d1;
} else {
tmp = (d4 + d2) * 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 <= (-6.3d+69)) .or. (.not. (d1 <= 1.65d+114))) then
tmp = -d1 * d1
else
tmp = (d4 + d2) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114)) {
tmp = -d1 * d1;
} else {
tmp = (d4 + d2) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -6.3e+69) or not (d1 <= 1.65e+114): tmp = -d1 * d1 else: tmp = (d4 + d2) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -6.3e+69) || !(d1 <= 1.65e+114)) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(Float64(d4 + d2) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -6.3e+69) || ~((d1 <= 1.65e+114))) tmp = -d1 * d1; else tmp = (d4 + d2) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -6.3e+69], N[Not[LessEqual[d1, 1.65e+114]], $MachinePrecision]], N[((-d1) * d1), $MachinePrecision], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -6.3 \cdot 10^{+69} \lor \neg \left(d1 \leq 1.65 \cdot 10^{+114}\right):\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 + d2\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -6.30000000000000007e69 or 1.65e114 < d1 Initial program 59.8%
Taylor expanded in d1 around inf
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6477.1
Applied rewrites77.1%
if -6.30000000000000007e69 < d1 < 1.65e114Initial program 100.0%
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 d3 around 0
Applied rewrites64.3%
Final simplification68.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -9.8e+27) (* (- d2 d3) d1) (if (<= d2 -3.8e-140) (* (- d4 d1) d1) (* (- d4 d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9.8e+27) {
tmp = (d2 - d3) * d1;
} else if (d2 <= -3.8e-140) {
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 <= (-9.8d+27)) then
tmp = (d2 - d3) * d1
else if (d2 <= (-3.8d-140)) 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 <= -9.8e+27) {
tmp = (d2 - d3) * d1;
} else if (d2 <= -3.8e-140) {
tmp = (d4 - d1) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -9.8e+27: tmp = (d2 - d3) * d1 elif d2 <= -3.8e-140: tmp = (d4 - d1) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -9.8e+27) tmp = Float64(Float64(d2 - d3) * d1); elseif (d2 <= -3.8e-140) 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 <= -9.8e+27) tmp = (d2 - d3) * d1; elseif (d2 <= -3.8e-140) tmp = (d4 - d1) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.8e+27], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], If[LessEqual[d2, -3.8e-140], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{elif}\;d2 \leq -3.8 \cdot 10^{-140}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -9.8000000000000003e27Initial program 82.1%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Taylor expanded in d4 around 0
Applied rewrites70.2%
if -9.8000000000000003e27 < d2 < -3.79999999999999998e-140Initial program 91.1%
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
lower--.f64N/A
lower--.f6496.7
Applied rewrites96.7%
Taylor expanded in d3 around 0
Applied rewrites65.7%
if -3.79999999999999998e-140 < d2 Initial program 87.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
lower--.f64N/A
lower--.f6480.4
Applied rewrites80.4%
Taylor expanded in d1 around 0
Applied rewrites60.2%
Final simplification63.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -1.05e-63) (* d1 d2) (if (<= d4 1e+56) (* (- d3) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.05e-63) {
tmp = d1 * d2;
} else if (d4 <= 1e+56) {
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 <= (-1.05d-63)) then
tmp = d1 * d2
else if (d4 <= 1d+56) 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 <= -1.05e-63) {
tmp = d1 * d2;
} else if (d4 <= 1e+56) {
tmp = -d3 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.05e-63: tmp = d1 * d2 elif d4 <= 1e+56: tmp = -d3 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.05e-63) tmp = Float64(d1 * d2); elseif (d4 <= 1e+56) 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 <= -1.05e-63) tmp = d1 * d2; elseif (d4 <= 1e+56) tmp = -d3 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.05e-63], N[(d1 * d2), $MachinePrecision], If[LessEqual[d4, 1e+56], N[((-d3) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.05 \cdot 10^{-63}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d4 \leq 10^{+56}:\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < -1.05e-63Initial program 82.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Taylor expanded in d2 around inf
lower-*.f6430.4
Applied rewrites30.4%
if -1.05e-63 < d4 < 1.00000000000000009e56Initial program 90.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6474.6
Applied rewrites74.6%
Taylor expanded in d3 around inf
Applied rewrites41.7%
if 1.00000000000000009e56 < d4 Initial program 85.2%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6494.4
Applied rewrites94.4%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
distribute-lft-out--N/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6494.4
Applied rewrites94.4%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
Final simplification42.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -5.8e+62) (* (- (+ d4 d2) d3) d1) (* (- (- d4 d3) d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.8e+62) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-5.8d+62)) then
tmp = ((d4 + d2) - d3) * d1
else
tmp = ((d4 - d3) - d1) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -5.8e+62) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = ((d4 - d3) - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -5.8e+62: tmp = ((d4 + d2) - d3) * d1 else: tmp = ((d4 - d3) - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -5.8e+62) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = Float64(Float64(Float64(d4 - d3) - d1) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -5.8e+62) tmp = ((d4 + d2) - d3) * d1; else tmp = ((d4 - d3) - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -5.8e+62], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d4 - d3), $MachinePrecision] - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -5.8 \cdot 10^{+62}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 - d3\right) - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -5.79999999999999968e62Initial program 81.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
if -5.79999999999999968e62 < d2 Initial program 88.4%
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
lower--.f64N/A
lower--.f6483.3
Applied rewrites83.3%
Final simplification83.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -9.8e+27) (* (- d2 d3) d1) (* (- d4 d1) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -9.8e+27) {
tmp = (d2 - d3) * 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 <= (-9.8d+27)) then
tmp = (d2 - d3) * 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 <= -9.8e+27) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 - d1) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -9.8e+27: tmp = (d2 - d3) * d1 else: tmp = (d4 - d1) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -9.8e+27) tmp = Float64(Float64(d2 - d3) * 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 <= -9.8e+27) tmp = (d2 - d3) * d1; else tmp = (d4 - d1) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -9.8e+27], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d1), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -9.8 \cdot 10^{+27}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d1\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -9.8000000000000003e27Initial program 82.1%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.7
Applied rewrites85.7%
Taylor expanded in d4 around 0
Applied rewrites70.2%
if -9.8000000000000003e27 < d2 Initial program 88.5%
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
lower--.f64N/A
lower--.f6483.2
Applied rewrites83.2%
Taylor expanded in d3 around 0
Applied rewrites56.8%
Final simplification59.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1e+56) (* (- d2 d3) d1) (* (+ d4 d2) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1e+56) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 + d2) * 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 <= 1d+56) then
tmp = (d2 - d3) * d1
else
tmp = (d4 + d2) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1e+56) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 + d2) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1e+56: tmp = (d2 - d3) * d1 else: tmp = (d4 + d2) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1e+56) tmp = Float64(Float64(d2 - d3) * d1); else tmp = Float64(Float64(d4 + d2) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1e+56) tmp = (d2 - d3) * d1; else tmp = (d4 + d2) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1e+56], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 10^{+56}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 + d2\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 1.00000000000000009e56Initial program 87.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6477.6
Applied rewrites77.6%
Taylor expanded in d4 around 0
Applied rewrites65.3%
if 1.00000000000000009e56 < d4 Initial program 85.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6489.6
Applied rewrites89.6%
Taylor expanded in d3 around 0
Applied rewrites83.8%
Final simplification69.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.35e+63) (* d1 d2) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.35e+63) {
tmp = d1 * d2;
} 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.35d+63)) then
tmp = d1 * d2
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.35e+63) {
tmp = d1 * d2;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.35e+63: tmp = d1 * d2 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.35e+63) tmp = Float64(d1 * d2); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.35e+63) tmp = d1 * d2; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.35e+63], N[(d1 * d2), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.35 \cdot 10^{+63}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -1.35000000000000009e63Initial program 81.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in d2 around inf
lower-*.f6465.3
Applied rewrites65.3%
if -1.35000000000000009e63 < d2 Initial program 88.4%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6497.1
Applied rewrites97.1%
lift-fma.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lift-neg.f64N/A
distribute-lft-out--N/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6496.1
Applied rewrites96.1%
Taylor expanded in d4 around inf
*-commutativeN/A
lower-*.f6431.1
Applied rewrites31.1%
Final simplification37.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 87.1%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
associate-+l+N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-fma.f64N/A
lower-neg.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f6497.6
Applied rewrites97.6%
Taylor expanded in d2 around inf
lower-*.f6435.5
Applied rewrites35.5%
Final simplification35.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 2025017
(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)))