
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1 d2 d3 d4) :precision binary64 (- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))
double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1);
}
def code(d1, d2, d3, d4): return (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1)
function code(d1, d2, d3, d4) return Float64(Float64(Float64(Float64(d1 * d2) - Float64(d1 * d3)) + Float64(d4 * d1)) - Float64(d1 * d1)) end
function tmp = code(d1, d2, d3, d4) tmp = (((d1 * d2) - (d1 * d3)) + (d4 * d1)) - (d1 * d1); end
code[d1_, d2_, d3_, d4_] := N[(N[(N[(N[(d1 * d2), $MachinePrecision] - N[(d1 * d3), $MachinePrecision]), $MachinePrecision] + N[(d4 * d1), $MachinePrecision]), $MachinePrecision] - N[(d1 * d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(d1 \cdot d2 - d1 \cdot d3\right) + d4 \cdot d1\right) - d1 \cdot d1
\end{array}
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (+ (- d4 d1) (- d2 d3))))
double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - d3));
}
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 - d1) + (d2 - d3))
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * ((d4 - d1) + (d2 - d3));
}
def code(d1, d2, d3, d4): return d1 * ((d4 - d1) + (d2 - d3))
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(d4 - d1) + Float64(d2 - d3))) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * ((d4 - d1) + (d2 - d3)); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(d4 - d1), $MachinePrecision] + N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(d4 - d1\right) + \left(d2 - d3\right)\right)
\end{array}
Initial program 88.6%
Applied rewrites100.0%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.9e+74) (* d1 (- (+ d2 d4) d1)) (if (<= d1 1.35e+81) (fma d1 d4 (* d1 (- d2 d3))) (* d1 (- (- d4 d1) d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.9e+74) {
tmp = d1 * ((d2 + d4) - d1);
} else if (d1 <= 1.35e+81) {
tmp = fma(d1, d4, (d1 * (d2 - d3)));
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.9e+74) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); elseif (d1 <= 1.35e+81) tmp = fma(d1, d4, Float64(d1 * Float64(d2 - d3))); else tmp = Float64(d1 * Float64(Float64(d4 - d1) - d3)); end return tmp end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.9e+74], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.35e+81], N[(d1 * d4 + N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.9 \cdot 10^{+74}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(d1, d4, d1 \cdot \left(d2 - d3\right)\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -1.8999999999999999e74Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d3 around 0
Applied rewrites77.3%
if -1.8999999999999999e74 < d1 < 1.35e81Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d4 around 0
Applied rewrites80.8%
if 1.35e81 < d1 Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Applied rewrites76.3%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d1 -1.9e+74) (* d1 (- (+ d2 d4) d1)) (if (<= d1 1.35e+81) (* (- d2 (- d3 d4)) d1) (* d1 (- (- d4 d1) d3)))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.9e+74) {
tmp = d1 * ((d2 + d4) - d1);
} else if (d1 <= 1.35e+81) {
tmp = (d2 - (d3 - d4)) * d1;
} else {
tmp = d1 * ((d4 - d1) - 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 (d1 <= (-1.9d+74)) then
tmp = d1 * ((d2 + d4) - d1)
else if (d1 <= 1.35d+81) then
tmp = (d2 - (d3 - d4)) * d1
else
tmp = d1 * ((d4 - d1) - d3)
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d1 <= -1.9e+74) {
tmp = d1 * ((d2 + d4) - d1);
} else if (d1 <= 1.35e+81) {
tmp = (d2 - (d3 - d4)) * d1;
} else {
tmp = d1 * ((d4 - d1) - d3);
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d1 <= -1.9e+74: tmp = d1 * ((d2 + d4) - d1) elif d1 <= 1.35e+81: tmp = (d2 - (d3 - d4)) * d1 else: tmp = d1 * ((d4 - d1) - d3) return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d1 <= -1.9e+74) tmp = Float64(d1 * Float64(Float64(d2 + d4) - d1)); elseif (d1 <= 1.35e+81) tmp = Float64(Float64(d2 - Float64(d3 - d4)) * d1); else tmp = Float64(d1 * Float64(Float64(d4 - d1) - d3)); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d1 <= -1.9e+74) tmp = d1 * ((d2 + d4) - d1); elseif (d1 <= 1.35e+81) tmp = (d2 - (d3 - d4)) * d1; else tmp = d1 * ((d4 - d1) - d3); end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d1, -1.9e+74], N[(d1 * N[(N[(d2 + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.35e+81], N[(N[(d2 - N[(d3 - d4), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision], N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d1 \leq -1.9 \cdot 10^{+74}:\\
\;\;\;\;d1 \cdot \left(\left(d2 + d4\right) - d1\right)\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+81}:\\
\;\;\;\;\left(d2 - \left(d3 - d4\right)\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\end{array}
\end{array}
if d1 < -1.8999999999999999e74Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d3 around 0
Applied rewrites77.3%
if -1.8999999999999999e74 < d1 < 1.35e81Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Applied rewrites81.5%
if 1.35e81 < d1 Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Applied rewrites76.3%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- (- d4 d1) d3))))
(if (<= d1 -6.2e+75)
t_0
(if (<= d1 1.35e+81) (* (- d2 (- d3 d4)) d1) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * ((d4 - d1) - d3);
double tmp;
if (d1 <= -6.2e+75) {
tmp = t_0;
} else if (d1 <= 1.35e+81) {
tmp = (d2 - (d3 - 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 * ((d4 - d1) - d3)
if (d1 <= (-6.2d+75)) then
tmp = t_0
else if (d1 <= 1.35d+81) then
tmp = (d2 - (d3 - 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 * ((d4 - d1) - d3);
double tmp;
if (d1 <= -6.2e+75) {
tmp = t_0;
} else if (d1 <= 1.35e+81) {
tmp = (d2 - (d3 - d4)) * d1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * ((d4 - d1) - d3) tmp = 0 if d1 <= -6.2e+75: tmp = t_0 elif d1 <= 1.35e+81: tmp = (d2 - (d3 - d4)) * d1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(Float64(d4 - d1) - d3)) tmp = 0.0 if (d1 <= -6.2e+75) tmp = t_0; elseif (d1 <= 1.35e+81) tmp = Float64(Float64(d2 - Float64(d3 - d4)) * d1); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * ((d4 - d1) - d3); tmp = 0.0; if (d1 <= -6.2e+75) tmp = t_0; elseif (d1 <= 1.35e+81) tmp = (d2 - (d3 - d4)) * d1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(N[(d4 - d1), $MachinePrecision] - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -6.2e+75], t$95$0, If[LessEqual[d1, 1.35e+81], N[(N[(d2 - N[(d3 - d4), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(\left(d4 - d1\right) - d3\right)\\
\mathbf{if}\;d1 \leq -6.2 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+81}:\\
\;\;\;\;\left(d2 - \left(d3 - d4\right)\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -6.2000000000000002e75 or 1.35e81 < d1 Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Applied rewrites76.3%
if -6.2000000000000002e75 < d1 < 1.35e81Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Applied rewrites81.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d4 d1))))
(if (<= d1 -2.8e+76)
t_0
(if (<= d1 3.7e+154) (* (- d2 (- d3 d4)) d1) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d4 - d1);
double tmp;
if (d1 <= -2.8e+76) {
tmp = t_0;
} else if (d1 <= 3.7e+154) {
tmp = (d2 - (d3 - 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 * (d4 - d1)
if (d1 <= (-2.8d+76)) then
tmp = t_0
else if (d1 <= 3.7d+154) then
tmp = (d2 - (d3 - 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 * (d4 - d1);
double tmp;
if (d1 <= -2.8e+76) {
tmp = t_0;
} else if (d1 <= 3.7e+154) {
tmp = (d2 - (d3 - d4)) * d1;
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d4 - d1) tmp = 0 if d1 <= -2.8e+76: tmp = t_0 elif d1 <= 3.7e+154: tmp = (d2 - (d3 - d4)) * d1 else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d4 - d1)) tmp = 0.0 if (d1 <= -2.8e+76) tmp = t_0; elseif (d1 <= 3.7e+154) tmp = Float64(Float64(d2 - Float64(d3 - d4)) * d1); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d4 - d1); tmp = 0.0; if (d1 <= -2.8e+76) tmp = t_0; elseif (d1 <= 3.7e+154) tmp = (d2 - (d3 - d4)) * d1; else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -2.8e+76], t$95$0, If[LessEqual[d1, 3.7e+154], N[(N[(d2 - N[(d3 - d4), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d1 \leq -2.8 \cdot 10^{+76}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 3.7 \cdot 10^{+154}:\\
\;\;\;\;\left(d2 - \left(d3 - d4\right)\right) \cdot d1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d1 < -2.7999999999999999e76 or 3.69999999999999994e154 < d1 Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Taylor expanded in d3 around 0
Applied rewrites53.8%
if -2.7999999999999999e76 < d1 < 3.69999999999999994e154Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Applied rewrites81.5%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (+ d2 d4))) (t_1 (* d1 (- d4 d1))))
(if (<= d1 -6e+75)
t_1
(if (<= d1 -2.9e-29)
(* d1 (- d2 d3))
(if (<= d1 -2.8e-185)
t_0
(if (<= d1 1.52e-124)
(* d1 (- d4 d3))
(if (<= d1 1.35e+81) t_0 t_1)))))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * (d4 - d1);
double tmp;
if (d1 <= -6e+75) {
tmp = t_1;
} else if (d1 <= -2.9e-29) {
tmp = d1 * (d2 - d3);
} else if (d1 <= -2.8e-185) {
tmp = t_0;
} else if (d1 <= 1.52e-124) {
tmp = d1 * (d4 - d3);
} else if (d1 <= 1.35e+81) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = d1 * (d2 + d4)
t_1 = d1 * (d4 - d1)
if (d1 <= (-6d+75)) then
tmp = t_1
else if (d1 <= (-2.9d-29)) then
tmp = d1 * (d2 - d3)
else if (d1 <= (-2.8d-185)) then
tmp = t_0
else if (d1 <= 1.52d-124) then
tmp = d1 * (d4 - d3)
else if (d1 <= 1.35d+81) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 + d4);
double t_1 = d1 * (d4 - d1);
double tmp;
if (d1 <= -6e+75) {
tmp = t_1;
} else if (d1 <= -2.9e-29) {
tmp = d1 * (d2 - d3);
} else if (d1 <= -2.8e-185) {
tmp = t_0;
} else if (d1 <= 1.52e-124) {
tmp = d1 * (d4 - d3);
} else if (d1 <= 1.35e+81) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 + d4) t_1 = d1 * (d4 - d1) tmp = 0 if d1 <= -6e+75: tmp = t_1 elif d1 <= -2.9e-29: tmp = d1 * (d2 - d3) elif d1 <= -2.8e-185: tmp = t_0 elif d1 <= 1.52e-124: tmp = d1 * (d4 - d3) elif d1 <= 1.35e+81: tmp = t_0 else: tmp = t_1 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 + d4)) t_1 = Float64(d1 * Float64(d4 - d1)) tmp = 0.0 if (d1 <= -6e+75) tmp = t_1; elseif (d1 <= -2.9e-29) tmp = Float64(d1 * Float64(d2 - d3)); elseif (d1 <= -2.8e-185) tmp = t_0; elseif (d1 <= 1.52e-124) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d1 <= 1.35e+81) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 + d4); t_1 = d1 * (d4 - d1); tmp = 0.0; if (d1 <= -6e+75) tmp = t_1; elseif (d1 <= -2.9e-29) tmp = d1 * (d2 - d3); elseif (d1 <= -2.8e-185) tmp = t_0; elseif (d1 <= 1.52e-124) tmp = d1 * (d4 - d3); elseif (d1 <= 1.35e+81) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 + d4), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d1, -6e+75], t$95$1, If[LessEqual[d1, -2.9e-29], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, -2.8e-185], t$95$0, If[LessEqual[d1, 1.52e-124], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d1, 1.35e+81], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 + d4\right)\\
t_1 := d1 \cdot \left(d4 - d1\right)\\
\mathbf{if}\;d1 \leq -6 \cdot 10^{+75}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d1 \leq -2.9 \cdot 10^{-29}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{elif}\;d1 \leq -2.8 \cdot 10^{-185}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d1 \leq 1.52 \cdot 10^{-124}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d1 \leq 1.35 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d1 < -6e75 or 1.35e81 < d1 Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Taylor expanded in d3 around 0
Applied rewrites53.8%
if -6e75 < d1 < -2.90000000000000024e-29Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d4 around 0
Applied rewrites56.8%
if -2.90000000000000024e-29 < d1 < -2.79999999999999991e-185 or 1.52e-124 < d1 < 1.35e81Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
Taylor expanded in d3 around 0
Applied rewrites57.5%
if -2.79999999999999991e-185 < d1 < 1.52e-124Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
(FPCore (d1 d2 d3 d4)
:precision binary64
(let* ((t_0 (* d1 (- d2 d3))))
(if (<= d2 -1.4e+81)
t_0
(if (<= d2 -1.35e-291)
(* d1 (- d4 d3))
(if (<= d2 1.35e+169) (* d1 (- d4 d1)) t_0)))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d2 <= -1.4e+81) {
tmp = t_0;
} else if (d2 <= -1.35e-291) {
tmp = d1 * (d4 - d3);
} else if (d2 <= 1.35e+169) {
tmp = d1 * (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 - d3)
if (d2 <= (-1.4d+81)) then
tmp = t_0
else if (d2 <= (-1.35d-291)) then
tmp = d1 * (d4 - d3)
else if (d2 <= 1.35d+169) then
tmp = d1 * (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 - d3);
double tmp;
if (d2 <= -1.4e+81) {
tmp = t_0;
} else if (d2 <= -1.35e-291) {
tmp = d1 * (d4 - d3);
} else if (d2 <= 1.35e+169) {
tmp = d1 * (d4 - d1);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d2 <= -1.4e+81: tmp = t_0 elif d2 <= -1.35e-291: tmp = d1 * (d4 - d3) elif d2 <= 1.35e+169: tmp = d1 * (d4 - d1) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d2 <= -1.4e+81) tmp = t_0; elseif (d2 <= -1.35e-291) tmp = Float64(d1 * Float64(d4 - d3)); elseif (d2 <= 1.35e+169) tmp = Float64(d1 * Float64(d4 - d1)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d2 <= -1.4e+81) tmp = t_0; elseif (d2 <= -1.35e-291) tmp = d1 * (d4 - d3); elseif (d2 <= 1.35e+169) tmp = d1 * (d4 - d1); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d2, -1.4e+81], t$95$0, If[LessEqual[d2, -1.35e-291], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], If[LessEqual[d2, 1.35e+169], N[(d1 * N[(d4 - d1), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d2 \leq -1.35 \cdot 10^{-291}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{elif}\;d2 \leq 1.35 \cdot 10^{+169}:\\
\;\;\;\;d1 \cdot \left(d4 - d1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d2 < -1.39999999999999997e81 or 1.34999999999999995e169 < d2 Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d4 around 0
Applied rewrites56.8%
if -1.39999999999999997e81 < d2 < -1.34999999999999996e-291Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
if -1.34999999999999996e-291 < d2 < 1.34999999999999995e169Initial program 88.6%
Applied rewrites100.0%
Taylor expanded in d2 around 0
Applied rewrites76.3%
Taylor expanded in d3 around 0
Applied rewrites53.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (let* ((t_0 (* d1 (- d2 d3)))) (if (<= d2 -1.4e+81) t_0 (if (<= d2 5.2e+140) (* d1 (- d4 d3)) t_0))))
double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d2 <= -1.4e+81) {
tmp = t_0;
} else if (d2 <= 5.2e+140) {
tmp = d1 * (d4 - d3);
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: t_0
real(8) :: tmp
t_0 = d1 * (d2 - d3)
if (d2 <= (-1.4d+81)) then
tmp = t_0
else if (d2 <= 5.2d+140) then
tmp = d1 * (d4 - d3)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double t_0 = d1 * (d2 - d3);
double tmp;
if (d2 <= -1.4e+81) {
tmp = t_0;
} else if (d2 <= 5.2e+140) {
tmp = d1 * (d4 - d3);
} else {
tmp = t_0;
}
return tmp;
}
def code(d1, d2, d3, d4): t_0 = d1 * (d2 - d3) tmp = 0 if d2 <= -1.4e+81: tmp = t_0 elif d2 <= 5.2e+140: tmp = d1 * (d4 - d3) else: tmp = t_0 return tmp
function code(d1, d2, d3, d4) t_0 = Float64(d1 * Float64(d2 - d3)) tmp = 0.0 if (d2 <= -1.4e+81) tmp = t_0; elseif (d2 <= 5.2e+140) tmp = Float64(d1 * Float64(d4 - d3)); else tmp = t_0; end return tmp end
function tmp_2 = code(d1, d2, d3, d4) t_0 = d1 * (d2 - d3); tmp = 0.0; if (d2 <= -1.4e+81) tmp = t_0; elseif (d2 <= 5.2e+140) tmp = d1 * (d4 - d3); else tmp = t_0; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := Block[{t$95$0 = N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d2, -1.4e+81], t$95$0, If[LessEqual[d2, 5.2e+140], N[(d1 * N[(d4 - d3), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d2 - d3\right)\\
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+81}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d2 \leq 5.2 \cdot 10^{+140}:\\
\;\;\;\;d1 \cdot \left(d4 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if d2 < -1.39999999999999997e81 or 5.2000000000000002e140 < d2 Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d4 around 0
Applied rewrites56.8%
if -1.39999999999999997e81 < d2 < 5.2000000000000002e140Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d4 -1.4e+96) (* d1 d4) (if (<= d4 3.2e+150) (* d1 (- d2 d3)) (* d1 d4))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.4e+96) {
tmp = d1 * d4;
} else if (d4 <= 3.2e+150) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * 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 (d4 <= (-1.4d+96)) then
tmp = d1 * d4
else if (d4 <= 3.2d+150) then
tmp = d1 * (d2 - d3)
else
tmp = d1 * d4
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d4 <= -1.4e+96) {
tmp = d1 * d4;
} else if (d4 <= 3.2e+150) {
tmp = d1 * (d2 - d3);
} else {
tmp = d1 * d4;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d4 <= -1.4e+96: tmp = d1 * d4 elif d4 <= 3.2e+150: tmp = d1 * (d2 - d3) else: tmp = d1 * d4 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d4 <= -1.4e+96) tmp = Float64(d1 * d4); elseif (d4 <= 3.2e+150) tmp = Float64(d1 * Float64(d2 - d3)); else tmp = Float64(d1 * d4); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d4 <= -1.4e+96) tmp = d1 * d4; elseif (d4 <= 3.2e+150) tmp = d1 * (d2 - d3); else tmp = d1 * d4; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d4, -1.4e+96], N[(d1 * d4), $MachinePrecision], If[LessEqual[d4, 3.2e+150], N[(d1 * N[(d2 - d3), $MachinePrecision]), $MachinePrecision], N[(d1 * d4), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d4 \leq -1.4 \cdot 10^{+96}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{elif}\;d4 \leq 3.2 \cdot 10^{+150}:\\
\;\;\;\;d1 \cdot \left(d2 - d3\right)\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d4\\
\end{array}
\end{array}
if d4 < -1.4e96 or 3.20000000000000016e150 < d4 Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
Taylor expanded in d3 around 0
Applied rewrites31.2%
if -1.4e96 < d4 < 3.20000000000000016e150Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d4 around 0
Applied rewrites56.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (if (<= d2 -1.4e+81) (* d1 d2) (if (<= d2 5.2e+140) (* d1 d4) (* d1 d2))))
double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+81) {
tmp = d1 * d2;
} else if (d2 <= 5.2e+140) {
tmp = d1 * d4;
} else {
tmp = d1 * d2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
real(8) :: tmp
if (d2 <= (-1.4d+81)) then
tmp = d1 * d2
else if (d2 <= 5.2d+140) then
tmp = d1 * d4
else
tmp = d1 * d2
end if
code = tmp
end function
public static double code(double d1, double d2, double d3, double d4) {
double tmp;
if (d2 <= -1.4e+81) {
tmp = d1 * d2;
} else if (d2 <= 5.2e+140) {
tmp = d1 * d4;
} else {
tmp = d1 * d2;
}
return tmp;
}
def code(d1, d2, d3, d4): tmp = 0 if d2 <= -1.4e+81: tmp = d1 * d2 elif d2 <= 5.2e+140: tmp = d1 * d4 else: tmp = d1 * d2 return tmp
function code(d1, d2, d3, d4) tmp = 0.0 if (d2 <= -1.4e+81) tmp = Float64(d1 * d2); elseif (d2 <= 5.2e+140) tmp = Float64(d1 * d4); else tmp = Float64(d1 * d2); end return tmp end
function tmp_2 = code(d1, d2, d3, d4) tmp = 0.0; if (d2 <= -1.4e+81) tmp = d1 * d2; elseif (d2 <= 5.2e+140) tmp = d1 * d4; else tmp = d1 * d2; end tmp_2 = tmp; end
code[d1_, d2_, d3_, d4_] := If[LessEqual[d2, -1.4e+81], N[(d1 * d2), $MachinePrecision], If[LessEqual[d2, 5.2e+140], N[(d1 * d4), $MachinePrecision], N[(d1 * d2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d2 \leq -1.4 \cdot 10^{+81}:\\
\;\;\;\;d1 \cdot d2\\
\mathbf{elif}\;d2 \leq 5.2 \cdot 10^{+140}:\\
\;\;\;\;d1 \cdot d4\\
\mathbf{else}:\\
\;\;\;\;d1 \cdot d2\\
\end{array}
\end{array}
if d2 < -1.39999999999999997e81 or 5.2000000000000002e140 < d2 Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around inf
Applied rewrites31.8%
if -1.39999999999999997e81 < d2 < 5.2000000000000002e140Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around 0
Applied rewrites56.1%
Taylor expanded in d3 around 0
Applied rewrites31.2%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 d2))
double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * d2
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * d2;
}
def code(d1, d2, d3, d4): return d1 * d2
function code(d1, d2, d3, d4) return Float64(d1 * d2) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * d2; end
code[d1_, d2_, d3_, d4_] := N[(d1 * d2), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot d2
\end{array}
Initial program 88.6%
Taylor expanded in d1 around 0
Applied rewrites81.5%
Taylor expanded in d2 around inf
Applied rewrites31.8%
(FPCore (d1 d2 d3 d4) :precision binary64 (* d1 (- (+ (- d2 d3) d4) d1)))
double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(d1, d2, d3, d4)
use fmin_fmax_functions
real(8), intent (in) :: d1
real(8), intent (in) :: d2
real(8), intent (in) :: d3
real(8), intent (in) :: d4
code = d1 * (((d2 - d3) + d4) - d1)
end function
public static double code(double d1, double d2, double d3, double d4) {
return d1 * (((d2 - d3) + d4) - d1);
}
def code(d1, d2, d3, d4): return d1 * (((d2 - d3) + d4) - d1)
function code(d1, d2, d3, d4) return Float64(d1 * Float64(Float64(Float64(d2 - d3) + d4) - d1)) end
function tmp = code(d1, d2, d3, d4) tmp = d1 * (((d2 - d3) + d4) - d1); end
code[d1_, d2_, d3_, d4_] := N[(d1 * N[(N[(N[(d2 - d3), $MachinePrecision] + d4), $MachinePrecision] - d1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(\left(\left(d2 - d3\right) + d4\right) - d1\right)
\end{array}
herbie shell --seed 2025159
(FPCore (d1 d2 d3 d4)
:name "FastMath dist4"
:precision binary64
:alt
(! :herbie-platform c (* d1 (- (+ (- d2 d3) d4) d1)))
(- (+ (- (* d1 d2) (* d1 d3)) (* d4 d1)) (* d1 d1)))