
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))) (if (<= t_0 5e+304) t_0 (* (- (/ (- (+ d4 d2) d3) d1) 1.0) (* d1 d1)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= 5e+304) {
tmp = t_0;
} else {
tmp = ((((d4 + d2) - d3) / d1) - 1.0) * (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) :: t_0
real(8) :: tmp
t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
if (t_0 <= 5d+304) then
tmp = t_0
else
tmp = ((((d4 + d2) - d3) / d1) - 1.0d0) * (d1 * d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= 5e+304) {
tmp = t_0;
} else {
tmp = ((((d4 + d2) - d3) / d1) - 1.0) * (d1 * d1);
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1) tmp = 0 if t_0 <= 5e+304: tmp = t_0 else: tmp = ((((d4 + d2) - d3) / d1) - 1.0) * (d1 * d1) return tmp
function code(d1, d2, d3, d4) t_0 = Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) tmp = 0.0 if (t_0 <= 5e+304) tmp = t_0; else tmp = Float64(Float64(Float64(Float64(Float64(d4 + d2) - d3) / d1) - 1.0) * Float64(d1 * d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); tmp = 0.0; if (t_0 <= 5e+304) tmp = t_0; else tmp = ((((d4 + d2) - d3) / d1) - 1.0) * (d1 * d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+304], t$95$0, N[(N[(N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] / d1), $MachinePrecision] - 1.0), $MachinePrecision] * N[(d1 * d1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\left(d4 + d2\right) - d3}{d1} - 1\right) \cdot \left(d1 \cdot d1\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < 4.9999999999999997e304Initial program 100.0%
if 4.9999999999999997e304 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 23.8%
Taylor expanded in d1 around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites100.0%
Final simplification100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))) (if (<= t_0 5e+304) t_0 (* (- (+ d4 d2) d3) d1))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= 5e+304) {
tmp = t_0;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
if (t_0 <= 5d+304) then
tmp = t_0
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
double tmp;
if (t_0 <= 5e+304) {
tmp = t_0;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1) tmp = 0 if t_0 <= 5e+304: tmp = t_0 else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) tmp = 0.0 if (t_0 <= 5e+304) tmp = t_0; else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); tmp = 0.0; if (t_0 <= 5e+304) tmp = t_0; else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e+304], t$95$0, N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1\\
\mathbf{if}\;t\_0 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < 4.9999999999999997e304Initial program 100.0%
if 4.9999999999999997e304 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 23.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6478.6
Applied rewrites78.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) 5e+304) (- (- (* d1 (+ d4 d2)) (* d3 d1)) (* d1 d1)) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 5e+304) {
tmp = ((d1 * (d4 + d2)) - (d3 * d1)) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 5d+304) then
tmp = ((d1 * (d4 + d2)) - (d3 * d1)) - (d1 * d1)
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 5e+304) {
tmp = ((d1 * (d4 + d2)) - (d3 * d1)) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if ((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 5e+304: tmp = ((d1 * (d4 + d2)) - (d3 * d1)) - (d1 * d1) else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) <= 5e+304) tmp = Float64(Float64(Float64(d1 * Float64(d4 + d2)) - Float64(d3 * d1)) - Float64(d1 * d1)); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= 5e+304) tmp = ((d1 * (d4 + d2)) - (d3 * d1)) - (d1 * d1); else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], 5e+304], N[(N[(N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision] - N[(d3 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq 5 \cdot 10^{+304}:\\
\;\;\;\;\left(d1 \cdot \left(d4 + d2\right) - d3 \cdot d1\right) - d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < 4.9999999999999997e304Initial program 100.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
if 4.9999999999999997e304 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 23.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6478.6
Applied rewrites78.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)) -2e+274) (- (* d4 d1) (* d1 d1)) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= -2e+274) {
tmp = (d4 * d1) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= (-2d+274)) then
tmp = (d4 * d1) - (d1 * d1)
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= -2e+274) {
tmp = (d4 * d1) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if ((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= -2e+274: tmp = (d4 * d1) - (d1 * d1) else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) <= -2e+274) tmp = Float64(Float64(d4 * d1) - Float64(d1 * d1)); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (((((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)) <= -2e+274) tmp = (d4 * d1) - (d1 * d1); else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], -2e+274], N[(N[(d4 * d1), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1 \leq -2 \cdot 10^{+274}:\\
\;\;\;\;d4 \cdot d1 - d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) < -1.99999999999999984e274Initial program 100.0%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6489.1
Applied rewrites89.1%
if -1.99999999999999984e274 < (-.f64 (+.f64 (-.f64 (*.f64 d1 d2) (*.f64 d1 d3)) (*.f64 d4 d1)) (*.f64 d1 d1)) Initial program 83.6%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6486.9
Applied rewrites86.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -6.8e-68) (not (<= d3 4.8e+69))) (* (- (+ d4 d2) d3) d1) (- (* d1 (+ d4 d2)) (* d1 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -6.8e-68) || !(d3 <= 4.8e+69)) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = (d1 * (d4 + d2)) - (d1 * d1);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d3 <= (-6.8d-68)) .or. (.not. (d3 <= 4.8d+69))) then
tmp = ((d4 + d2) - d3) * d1
else
tmp = (d1 * (d4 + d2)) - (d1 * d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -6.8e-68) || !(d3 <= 4.8e+69)) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = (d1 * (d4 + d2)) - (d1 * d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -6.8e-68) or not (d3 <= 4.8e+69): tmp = ((d4 + d2) - d3) * d1 else: tmp = (d1 * (d4 + d2)) - (d1 * d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -6.8e-68) || !(d3 <= 4.8e+69)) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = Float64(Float64(d1 * Float64(d4 + d2)) - Float64(d1 * d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d3 <= -6.8e-68) || ~((d3 <= 4.8e+69))) tmp = ((d4 + d2) - d3) * d1; else tmp = (d1 * (d4 + d2)) - (d1 * d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -6.8e-68], N[Not[LessEqual[d3, 4.8e+69]], $MachinePrecision]], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d1 * N[(d4 + d2), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -6.8 \cdot 10^{-68} \lor \neg \left(d3 \leq 4.8 \cdot 10^{+69}\right):\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(d4 + d2\right) - d1 \cdot d1\\
\end{array}
\end{array}
if d3 < -6.80000000000000037e-68 or 4.8000000000000003e69 < d3 Initial program 84.2%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6491.4
Applied rewrites91.4%
if -6.80000000000000037e-68 < d3 < 4.8000000000000003e69Initial program 90.7%
Taylor expanded in d3 around 0
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6491.4
Applied rewrites91.4%
Final simplification91.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.65e+36) (* (- (+ d4 d2) d3) d1) (- (- (* d1 d4) (* d3 d1)) (* d1 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.65e+36) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = ((d1 * d4) - (d3 * d1)) - (d1 * d1);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.65d+36)) then
tmp = ((d4 + d2) - d3) * d1
else
tmp = ((d1 * d4) - (d3 * d1)) - (d1 * d1)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.65e+36) {
tmp = ((d4 + d2) - d3) * d1;
} else {
tmp = ((d1 * d4) - (d3 * d1)) - (d1 * d1);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.65e+36: tmp = ((d4 + d2) - d3) * d1 else: tmp = ((d1 * d4) - (d3 * d1)) - (d1 * d1) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.65e+36) tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); else tmp = Float64(Float64(Float64(d1 * d4) - Float64(d3 * d1)) - Float64(d1 * d1)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.65e+36) tmp = ((d4 + d2) - d3) * d1; else tmp = ((d1 * d4) - (d3 * d1)) - (d1 * d1); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.65e+36], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(N[(d1 * d4), $MachinePrecision] - N[(d3 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.65 \cdot 10^{+36}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d1 \cdot d4 - d3 \cdot d1\right) - d1 \cdot d1\\
\end{array}
\end{array}
if d2 < -2.65e36Initial program 77.7%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6495.6
Applied rewrites95.6%
if -2.65e36 < d2 Initial program 90.1%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in d2 around 0
Applied rewrites80.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 6.5e+76) (- (- (* d1 d2) (* d3 d1)) (* d1 d1)) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.5e+76) {
tmp = ((d1 * d2) - (d3 * d1)) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 6.5d+76) then
tmp = ((d1 * d2) - (d3 * d1)) - (d1 * d1)
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 6.5e+76) {
tmp = ((d1 * d2) - (d3 * d1)) - (d1 * d1);
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 6.5e+76: tmp = ((d1 * d2) - (d3 * d1)) - (d1 * d1) else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 6.5e+76) tmp = Float64(Float64(Float64(d1 * d2) - Float64(d3 * d1)) - Float64(d1 * d1)); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 6.5e+76) tmp = ((d1 * d2) - (d3 * d1)) - (d1 * d1); else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 6.5e+76], N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d3 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 6.5 \cdot 10^{+76}:\\
\;\;\;\;\left(d1 \cdot d2 - d3 \cdot d1\right) - d1 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 6.5000000000000005e76Initial program 91.0%
lift-+.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-sign-invN/A
lower--.f64N/A
distribute-lft-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
*-commutativeN/A
lower-*.f6491.0
Applied rewrites91.0%
Taylor expanded in d2 around inf
Applied rewrites72.9%
if 6.5000000000000005e76 < d4 Initial program 74.9%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6489.6
Applied rewrites89.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d1 -3e+195) (not (<= d1 1.7e+169))) (* (- d1) d1) (* (- (+ d4 d2) d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -3e+195) || !(d1 <= 1.7e+169)) {
tmp = -d1 * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if ((d1 <= (-3d+195)) .or. (.not. (d1 <= 1.7d+169))) then
tmp = -d1 * d1
else
tmp = ((d4 + d2) - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d1 <= -3e+195) || !(d1 <= 1.7e+169)) {
tmp = -d1 * d1;
} else {
tmp = ((d4 + d2) - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d1 <= -3e+195) or not (d1 <= 1.7e+169): tmp = -d1 * d1 else: tmp = ((d4 + d2) - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d1 <= -3e+195) || !(d1 <= 1.7e+169)) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(Float64(Float64(d4 + d2) - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if ((d1 <= -3e+195) || ~((d1 <= 1.7e+169))) tmp = -d1 * d1; else tmp = ((d4 + d2) - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d1, -3e+195], N[Not[LessEqual[d1, 1.7e+169]], $MachinePrecision]], N[((-d1) * d1), $MachinePrecision], N[(N[(N[(d4 + d2), $MachinePrecision] - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -3 \cdot 10^{+195} \lor \neg \left(d1 \leq 1.7 \cdot 10^{+169}\right):\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(\left(d4 + d2\right) - d3\right) \cdot d1\\
\end{array}
\end{array}
if d1 < -3.0000000000000001e195 or 1.70000000000000014e169 < d1 Initial program 60.3%
Taylor expanded in d1 around inf
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6482.8
Applied rewrites82.8%
if -3.0000000000000001e195 < d1 < 1.70000000000000014e169Initial program 95.4%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6488.7
Applied rewrites88.7%
Final simplification87.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (or (<= d3 -2.5e+162) (not (<= d3 3.15e+152))) (* (- d3) d1) (* (+ d4 d2) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if ((d3 <= -2.5e+162) || !(d3 <= 3.15e+152)) {
tmp = -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 ((d3 <= (-2.5d+162)) .or. (.not. (d3 <= 3.15d+152))) then
tmp = -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 ((d3 <= -2.5e+162) || !(d3 <= 3.15e+152)) {
tmp = -d3 * d1;
} else {
tmp = (d4 + d2) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if (d3 <= -2.5e+162) or not (d3 <= 3.15e+152): tmp = -d3 * d1 else: tmp = (d4 + d2) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if ((d3 <= -2.5e+162) || !(d3 <= 3.15e+152)) tmp = Float64(Float64(-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 ((d3 <= -2.5e+162) || ~((d3 <= 3.15e+152))) tmp = -d3 * d1; else tmp = (d4 + d2) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[Or[LessEqual[d3, -2.5e+162], N[Not[LessEqual[d3, 3.15e+152]], $MachinePrecision]], N[((-d3) * d1), $MachinePrecision], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d3 \leq -2.5 \cdot 10^{+162} \lor \neg \left(d3 \leq 3.15 \cdot 10^{+152}\right):\\
\;\;\;\;\left(-d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 + d2\right) \cdot d1\\
\end{array}
\end{array}
if d3 < -2.4999999999999998e162 or 3.14999999999999979e152 < d3 Initial program 83.0%
Taylor expanded in d3 around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
if -2.4999999999999998e162 < d3 < 3.14999999999999979e152Initial program 88.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6476.1
Applied rewrites76.1%
Taylor expanded in d3 around 0
+-commutativeN/A
lift-+.f6468.9
Applied rewrites68.9%
Final simplification73.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -8e+36) (* d2 d1) (if (<= d2 -5.7e-188) (* (- d1) d1) (* d4 d1))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8e+36) {
tmp = d2 * d1;
} else if (d2 <= -5.7e-188) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-8d+36)) then
tmp = d2 * d1
else if (d2 <= (-5.7d-188)) then
tmp = -d1 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -8e+36) {
tmp = d2 * d1;
} else if (d2 <= -5.7e-188) {
tmp = -d1 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -8e+36: tmp = d2 * d1 elif d2 <= -5.7e-188: tmp = -d1 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -8e+36) tmp = Float64(d2 * d1); elseif (d2 <= -5.7e-188) tmp = Float64(Float64(-d1) * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -8e+36) tmp = d2 * d1; elseif (d2 <= -5.7e-188) tmp = -d1 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -8e+36], N[(d2 * d1), $MachinePrecision], If[LessEqual[d2, -5.7e-188], N[((-d1) * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -8 \cdot 10^{+36}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{elif}\;d2 \leq -5.7 \cdot 10^{-188}:\\
\;\;\;\;\left(-d1\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d2 < -8.00000000000000034e36Initial program 77.7%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
if -8.00000000000000034e36 < d2 < -5.70000000000000025e-188Initial program 95.5%
Taylor expanded in d1 around inf
mul-1-negN/A
pow2N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6447.6
Applied rewrites47.6%
if -5.70000000000000025e-188 < d2 Initial program 88.6%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6442.9
Applied rewrites42.9%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 3.8e+65) (* (- d2 d3) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e+65) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 3.8d+65) then
tmp = (d2 - d3) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 3.8e+65) {
tmp = (d2 - d3) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 3.8e+65: tmp = (d2 - d3) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 3.8e+65) tmp = Float64(Float64(d2 - d3) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 3.8e+65) tmp = (d2 - d3) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 3.8e+65], N[(N[(d2 - d3), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 3.8 \cdot 10^{+65}:\\
\;\;\;\;\left(d2 - d3\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d4 < 3.80000000000000011e65Initial program 90.8%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6479.6
Applied rewrites79.6%
Taylor expanded in d2 around inf
Applied rewrites58.9%
if 3.80000000000000011e65 < d4 Initial program 77.0%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6485.6
Applied rewrites85.6%
Taylor expanded in d2 around 0
lower--.f6479.4
Applied rewrites79.4%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -2.7e+66) (* (+ d4 d2) d1) (* (- d4 d3) d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e+66) {
tmp = (d4 + d2) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-2.7d+66)) then
tmp = (d4 + d2) * d1
else
tmp = (d4 - d3) * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -2.7e+66) {
tmp = (d4 + d2) * d1;
} else {
tmp = (d4 - d3) * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -2.7e+66: tmp = (d4 + d2) * d1 else: tmp = (d4 - d3) * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -2.7e+66) tmp = Float64(Float64(d4 + d2) * d1); else tmp = Float64(Float64(d4 - d3) * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -2.7e+66) tmp = (d4 + d2) * d1; else tmp = (d4 - d3) * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -2.7e+66], N[(N[(d4 + d2), $MachinePrecision] * d1), $MachinePrecision], N[(N[(d4 - d3), $MachinePrecision] * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -2.7 \cdot 10^{+66}:\\
\;\;\;\;\left(d4 + d2\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;\left(d4 - d3\right) \cdot d1\\
\end{array}
\end{array}
if d2 < -2.7e66Initial program 75.5%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6495.2
Applied rewrites95.2%
Taylor expanded in d3 around 0
+-commutativeN/A
lift-+.f6478.0
Applied rewrites78.0%
if -2.7e66 < d2 Initial program 90.3%
Taylor expanded in d1 around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-+.f6477.7
Applied rewrites77.7%
Taylor expanded in d2 around 0
lower--.f6464.7
Applied rewrites64.7%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 1.5e+61) (* d2 d1) (* d4 d1)))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.5e+61) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d4 <= 1.5d+61) then
tmp = d2 * d1
else
tmp = d4 * d1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= 1.5e+61) {
tmp = d2 * d1;
} else {
tmp = d4 * d1;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= 1.5e+61: tmp = d2 * d1 else: tmp = d4 * d1 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= 1.5e+61) tmp = Float64(d2 * d1); else tmp = Float64(d4 * d1); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= 1.5e+61) tmp = d2 * d1; else tmp = d4 * d1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, 1.5e+61], N[(d2 * d1), $MachinePrecision], N[(d4 * d1), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq 1.5 \cdot 10^{+61}:\\
\;\;\;\;d2 \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d4 \cdot d1\\
\end{array}
\end{array}
if d4 < 1.5e61Initial program 90.7%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6431.5
Applied rewrites31.5%
if 1.5e61 < d4 Initial program 77.4%
Taylor expanded in d4 around inf
*-commutativeN/A
lift-*.f6467.6
Applied rewrites67.6%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d2 d1))
double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d2 * d1
end function
public static double code(double d1, double d2, double d3, double d4) {
return d2 * d1;
}
def code(d1, d2, d3, d4): return d2 * d1
function code(d1, d2, d3, d4) return Float64(d2 * d1) end
function tmp = code(d1, d2, d3, d4) tmp = d2 * d1; end
code[d1_, d2_, d3_, d4_] := N[(d2 * d1), $MachinePrecision]
\begin{array}{l}
\\
d2 \cdot d1
\end{array}
Initial program 87.5%
Taylor expanded in d2 around inf
*-commutativeN/A
lower-*.f6426.3
Applied rewrites26.3%
herbie shell --seed 2025058
(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)))