
(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]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
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]
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
(FPCore (d1 d2 d3 d4) :precision binary64 (134-z0z1z2z3z4 1 (- d2 (- d1 d4)) d1 d3 d1))
\mathsf{134\_z0z1z2z3z4}\left(1, \left(d2 - \left(d1 - d4\right)\right), d1, d3, d1\right)
Initial program 87.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
add-flip-revN/A
sub-negate-revN/A
lower-unsound-*.f64N/A
Applied rewrites70.4%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
*-rgt-identityN/A
times-fracN/A
*-inversesN/A
Applied rewrites100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (- d4 (- d3 d2)) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - (d3 - d2)) - d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * ((d4 - (d3 - d2)) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - (d3 - d2)) - d1);
}
def code(d1, d2, d3, d4): return d1 * ((d4 - (d3 - d2)) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - Float64(d3 - d2)) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - (d3 - d2)) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - N[(d3 - d2), $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
d1 \cdot \left(\left(d4 - \left(d3 - d2\right)\right) - d1\right)
Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (+ d2 d4) d3))))
(if (<=
d3
-229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320)
t_0
(if (<=
d3
174999999999999995069302646809894275956724709459585730600186872097406976)
(* d1 (- (+ d2 d4) d1))
t_0))))double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * ((d2 + d4) - d3);
double tmp;
if (d3 <= -2.3e+137) {
tmp = t_0;
} else if (d3 <= 1.75e+71) {
tmp = d1 * ((d2 + d4) - 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 + d4) - d3)
if (d3 <= (-2.3d+137)) then
tmp = t_0
else if (d3 <= 1.75d+71) then
tmp = d1 * ((d2 + d4) - 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 + d4) - d3);
double tmp;
if (d3 <= -2.3e+137) {
tmp = t_0;
} else if (d3 <= 1.75e+71) {
tmp = d1 * ((d2 + d4) - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * ((d2 + d4) - d3) tmp = 0 if d3 <= -2.3e+137: tmp = t_0 elif d3 <= 1.75e+71: tmp = d1 * ((d2 + d4) - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(d2 + d4) - d3)) tmp = 0.0 if (d3 <= -2.3e+137) tmp = t_0; elseif (d3 <= 1.75e+71) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * ((d2 + d4) - d3); tmp = 0.0; if (d3 <= -2.3e+137) tmp = t_0; elseif (d3 <= 1.75e+71) tmp = d1 * ((d2 + d4) - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320], t$95$0, If[LessEqual[d3, 174999999999999995069302646809894275956724709459585730600186872097406976], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := d1 \cdot \left(\left(d2 + d4\right) - d3\right)\\
\mathbf{if}\;d3 \leq -229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 174999999999999995069302646809894275956724709459585730600186872097406976:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if d3 < -2.3e137 or 1.75e71 < d3 Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d1 around 0
lower--.f64N/A
lower-+.f6480.7%
Applied rewrites80.7%
if -2.3e137 < d3 < 1.75e71Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (fmax d2 d4) d3))))
(if (<=
d3
-229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320)
t_0
(if (<=
d3
1999999999999999876516601650563957080654054728944248956588832425077742983649199427273641055007816510603264)
(* d1 (- (+ (fmin d2 d4) (fmax d2 d4)) d1))
t_0))))double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (fmax(d2, d4) - d3);
double tmp;
if (d3 <= -2.3e+137) {
tmp = t_0;
} else if (d3 <= 2e+105) {
tmp = d1 * ((fmin(d2, d4) + fmax(d2, d4)) - 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 * (fmax(d2, d4) - d3)
if (d3 <= (-2.3d+137)) then
tmp = t_0
else if (d3 <= 2d+105) then
tmp = d1 * ((fmin(d2, d4) + fmax(d2, d4)) - 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 * (fmax(d2, d4) - d3);
double tmp;
if (d3 <= -2.3e+137) {
tmp = t_0;
} else if (d3 <= 2e+105) {
tmp = d1 * ((fmin(d2, d4) + fmax(d2, d4)) - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (fmax(d2, d4) - d3) tmp = 0 if d3 <= -2.3e+137: tmp = t_0 elif d3 <= 2e+105: tmp = d1 * ((fmin(d2, d4) + fmax(d2, d4)) - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(fmax(d2, d4) - d3)) tmp = 0.0 if (d3 <= -2.3e+137) tmp = t_0; elseif (d3 <= 2e+105) tmp = Float64(d1 * Float64(Float64(fmin(d2, d4) + fmax(d2, d4)) - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (max(d2, d4) - d3); tmp = 0.0; if (d3 <= -2.3e+137) tmp = t_0; elseif (d3 <= 2e+105) tmp = d1 * ((min(d2, d4) + max(d2, d4)) - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(N[Max[d2, d4], $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d3, -229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320], t$95$0, If[LessEqual[d3, 1999999999999999876516601650563957080654054728944248956588832425077742983649199427273641055007816510603264], N[(d1 * N[(N[(N[Min[d2, d4], $MachinePrecision] + N[Max[d2, d4], $MachinePrecision]), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := d1 \cdot \left(\mathsf{max}\left(d2, d4\right) - d3\right)\\
\mathbf{if}\;d3 \leq -229999999999999999290359762639025511268071539853072692112773550985996570528611298045047912140485482102443255603953099588199002533076664320:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d3 \leq 1999999999999999876516601650563957080654054728944248956588832425077742983649199427273641055007816510603264:\\
\;\;\;\;d1 \cdot \left(\left(\mathsf{min}\left(d2, d4\right) + \mathsf{max}\left(d2, d4\right)\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if d3 < -2.3e137 or 1.9999999999999999e105 < d3 Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d1 around 0
lower--.f64N/A
lower-+.f6480.7%
Applied rewrites80.7%
Taylor expanded in d2 around 0
Applied rewrites56.9%
if -2.3e137 < d3 < 1.9999999999999999e105Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= (fmax d2 d4) 9800000000000000587202560) (* d1 (- (fmin d2 d4) d1)) (* d1 (- (fmax d2 d4) d3))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 9.8e+24) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmax(d2, d4) - d3);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (fmax(d2, d4) <= 9.8d+24) then
tmp = d1 * (fmin(d2, d4) - d1)
else
tmp = d1 * (fmax(d2, d4) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 9.8e+24) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmax(d2, d4) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if fmax(d2, d4) <= 9.8e+24: tmp = d1 * (fmin(d2, d4) - d1) else: tmp = d1 * (fmax(d2, d4) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (fmax(d2, d4) <= 9.8e+24) tmp = Float64(d1 * Float64(fmin(d2, d4) - d1)); else tmp = Float64(d1 * Float64(fmax(d2, d4) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (max(d2, d4) <= 9.8e+24) tmp = d1 * (min(d2, d4) - d1); else tmp = d1 * (max(d2, d4) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[Max[d2, d4], $MachinePrecision], 9800000000000000587202560], N[(d1 * N[(N[Min[d2, d4], $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[Max[d2, d4], $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(d2, d4\right) \leq 9800000000000000587202560:\\
\;\;\;\;d1 \cdot \left(\mathsf{min}\left(d2, d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\mathsf{max}\left(d2, d4\right) - d3\right)\\
\end{array}
if d4 < 9.8000000000000006e24Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d4 around 0
lower-*.f64N/A
lower--.f6454.2%
Applied rewrites54.2%
if 9.8000000000000006e24 < d4 Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d1 around 0
lower--.f64N/A
lower-+.f6480.7%
Applied rewrites80.7%
Taylor expanded in d2 around 0
Applied rewrites56.9%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<=
(fmax d2 d4)
1107467480703865/748288838313422294120286634350736906063837462003712)
(* d1 (- (fmin d2 d4) d1))
(* d1 (- (fmax d2 d4) d1))))double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 1.48e-36) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmax(d2, d4) - d1);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (fmax(d2, d4) <= 1.48d-36) then
tmp = d1 * (fmin(d2, d4) - d1)
else
tmp = d1 * (fmax(d2, d4) - d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 1.48e-36) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmax(d2, d4) - d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if fmax(d2, d4) <= 1.48e-36: tmp = d1 * (fmin(d2, d4) - d1) else: tmp = d1 * (fmax(d2, d4) - d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (fmax(d2, d4) <= 1.48e-36) tmp = Float64(d1 * Float64(fmin(d2, d4) - d1)); else tmp = Float64(d1 * Float64(fmax(d2, d4) - d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (max(d2, d4) <= 1.48e-36) tmp = d1 * (min(d2, d4) - d1); else tmp = d1 * (max(d2, d4) - d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[Max[d2, d4], $MachinePrecision], 1107467480703865/748288838313422294120286634350736906063837462003712], N[(d1 * N[(N[Min[d2, d4], $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[Max[d2, d4], $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(d2, d4\right) \leq \frac{1107467480703865}{748288838313422294120286634350736906063837462003712}:\\
\;\;\;\;d1 \cdot \left(\mathsf{min}\left(d2, d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\mathsf{max}\left(d2, d4\right) - d1\right)\\
\end{array}
if d4 < 1.48e-36Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d4 around 0
lower-*.f64N/A
lower--.f6454.2%
Applied rewrites54.2%
if 1.48e-36 < d4 Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d2 around 0
Applied rewrites55.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(if (<=
(fmax d2 d4)
8302889752870899/1361129467683753853853498429727072845824)
(* d1 (- (fmin d2 d4) d1))
(* d1 (+ (fmin d2 d4) (fmax d2 d4)))))double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 6.1e-24) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmin(d2, d4) + fmax(d2, d4));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (fmax(d2, d4) <= 6.1d-24) then
tmp = d1 * (fmin(d2, d4) - d1)
else
tmp = d1 * (fmin(d2, d4) + fmax(d2, d4))
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 6.1e-24) {
tmp = d1 * (fmin(d2, d4) - d1);
} else {
tmp = d1 * (fmin(d2, d4) + fmax(d2, d4));
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if fmax(d2, d4) <= 6.1e-24: tmp = d1 * (fmin(d2, d4) - d1) else: tmp = d1 * (fmin(d2, d4) + fmax(d2, d4)) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (fmax(d2, d4) <= 6.1e-24) tmp = Float64(d1 * Float64(fmin(d2, d4) - d1)); else tmp = Float64(d1 * Float64(fmin(d2, d4) + fmax(d2, d4))); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (max(d2, d4) <= 6.1e-24) tmp = d1 * (min(d2, d4) - d1); else tmp = d1 * (min(d2, d4) + max(d2, d4)); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[Max[d2, d4], $MachinePrecision], 8302889752870899/1361129467683753853853498429727072845824], N[(d1 * N[(N[Min[d2, d4], $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[Min[d2, d4], $MachinePrecision] + N[Max[d2, d4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(d2, d4\right) \leq \frac{8302889752870899}{1361129467683753853853498429727072845824}:\\
\;\;\;\;d1 \cdot \left(\mathsf{min}\left(d2, d4\right) - d1\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\mathsf{min}\left(d2, d4\right) + \mathsf{max}\left(d2, d4\right)\right)\\
\end{array}
if d4 < 6.1000000000000004e-24Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d4 around 0
lower-*.f64N/A
lower--.f6454.2%
Applied rewrites54.2%
if 6.1000000000000004e-24 < d4 Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d4 around 0
lower-*.f64N/A
lower--.f6454.2%
Applied rewrites54.2%
Taylor expanded in d1 around 0
lower-*.f64N/A
lower-+.f6456.1%
Applied rewrites56.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ d2 d4)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + d4);
}
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 + d4)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (d2 + d4);
}
def code(d1, d2, d3, d4): return d1 * (d2 + d4)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(d2 + d4)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (d2 + d4); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]
d1 \cdot \left(d2 + d4\right)
Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d3 around 0
lower-*.f64N/A
lower--.f64N/A
lower-+.f6477.0%
Applied rewrites77.0%
Taylor expanded in d4 around 0
lower-*.f64N/A
lower--.f6454.2%
Applied rewrites54.2%
Taylor expanded in d1 around 0
lower-*.f64N/A
lower-+.f6456.1%
Applied rewrites56.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= (fmax d2 d4) 2589569785738035/1125899906842624) (* d1 (fmin d2 d4)) (* d1 (fmax d2 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 2.3) {
tmp = d1 * fmin(d2, d4);
} else {
tmp = d1 * fmax(d2, d4);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (fmax(d2, d4) <= 2.3d0) then
tmp = d1 * fmin(d2, d4)
else
tmp = d1 * fmax(d2, d4)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (fmax(d2, d4) <= 2.3) {
tmp = d1 * fmin(d2, d4);
} else {
tmp = d1 * fmax(d2, d4);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if fmax(d2, d4) <= 2.3: tmp = d1 * fmin(d2, d4) else: tmp = d1 * fmax(d2, d4) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (fmax(d2, d4) <= 2.3) tmp = Float64(d1 * fmin(d2, d4)); else tmp = Float64(d1 * fmax(d2, d4)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (max(d2, d4) <= 2.3) tmp = d1 * min(d2, d4); else tmp = d1 * max(d2, d4); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[Max[d2, d4], $MachinePrecision], 2589569785738035/1125899906842624], N[(d1 * N[Min[d2, d4], $MachinePrecision]), $MachinePrecision], N[(d1 * N[Max[d2, d4], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\mathsf{max}\left(d2, d4\right) \leq \frac{2589569785738035}{1125899906842624}:\\
\;\;\;\;d1 \cdot \mathsf{min}\left(d2, d4\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \mathsf{max}\left(d2, d4\right)\\
\end{array}
if d4 < 2.2999999999999998Initial program 87.6%
lift--.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
distribute-lft-out--N/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-outN/A
*-commutativeN/A
distribute-rgt-out--N/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
sub-negate-revN/A
sub-flip-reverseN/A
lower--.f64N/A
lower--.f64100.0%
Applied rewrites100.0%
Taylor expanded in d2 around inf
lower-*.f6430.5%
Applied rewrites30.5%
if 2.2999999999999998 < d4 Initial program 87.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
add-flip-revN/A
sub-negate-revN/A
lower-unsound-*.f64N/A
Applied rewrites70.4%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
*-rgt-identityN/A
times-fracN/A
*-inversesN/A
Applied rewrites100.0%
Taylor expanded in d4 around inf
lower-*.f6431.4%
Applied rewrites31.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (fmax d2 d4)))
double code(double d1, double d2, double d3, double d4) {
return d1 * fmax(d2, d4);
}
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 * fmax(d2, d4)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * fmax(d2, d4);
}
def code(d1, d2, d3, d4): return d1 * fmax(d2, d4)
function code(d1, d2, d3, d4) return Float64(d1 * fmax(d2, d4)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * max(d2, d4); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[Max[d2, d4], $MachinePrecision]), $MachinePrecision]
d1 \cdot \mathsf{max}\left(d2, d4\right)
Initial program 87.6%
lift--.f64N/A
lift-+.f64N/A
associate--l+N/A
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
associate-+l+N/A
sum-to-multN/A
add-flip-revN/A
sub-negate-revN/A
lower-unsound-*.f64N/A
Applied rewrites70.4%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
associate-*r/N/A
*-rgt-identityN/A
times-fracN/A
*-inversesN/A
Applied rewrites100.0%
Taylor expanded in d4 around inf
lower-*.f6431.4%
Applied rewrites31.4%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))