
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
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(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x + y) - (((z - t) * y) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\end{array}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (- (+ x y) (/ (* (- z t) y) (- a t))))
double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
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(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (x + y) - (((z - t) * y) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return (x + y) - (((z - t) * y) / (a - t));
}
def code(x, y, z, t, a): return (x + y) - (((z - t) * y) / (a - t))
function code(x, y, z, t, a) return Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = (x + y) - (((z - t) * y) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (<= (- (+ x y) (/ (* (- z t) y) (- a t))) 2e+32) (fma (/ (- z a) (- t a)) y x) (fma (/ y (- t a)) (- z a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x + y) - (((z - t) * y) / (a - t))) <= 2e+32) {
tmp = fma(((z - a) / (t - a)), y, x);
} else {
tmp = fma((y / (t - a)), (z - a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) <= 2e+32) tmp = fma(Float64(Float64(z - a) / Float64(t - a)), y, x); else tmp = fma(Float64(y / Float64(t - a)), Float64(z - a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+32], N[(N[(N[(z - a), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(z - a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} \leq 2 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - a}{t - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t - a}, z - a, x\right)\\
\end{array}
\end{array}
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 2.00000000000000011e32Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
if 2.00000000000000011e32 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-outN/A
sub-negate-revN/A
lift--.f64N/A
mul-1-negN/A
distribute-lft-neg-inN/A
Applied rewrites95.9%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- t a)) (- z a) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (t - a)), (z - a), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(t - a)), Float64(z - a), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(z - a), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{t - a}, z - a, x\right)
\end{array}
Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-rgt-neg-outN/A
sub-negate-revN/A
lift--.f64N/A
mul-1-negN/A
distribute-lft-neg-inN/A
Applied rewrites95.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ z (- t a)) y x))
(t_2 (- (+ x y) (/ (* (- z t) y) (- a t)))))
(if (<= t_2 -2e+306)
t_1
(if (<= t_2 -5e-227)
(+ x y)
(if (<= t_2 0.0) (fma (/ (- z a) t) y x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((z / (t - a)), y, x);
double t_2 = (x + y) - (((z - t) * y) / (a - t));
double tmp;
if (t_2 <= -2e+306) {
tmp = t_1;
} else if (t_2 <= -5e-227) {
tmp = x + y;
} else if (t_2 <= 0.0) {
tmp = fma(((z - a) / t), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(z / Float64(t - a)), y, x) t_2 = Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) tmp = 0.0 if (t_2 <= -2e+306) tmp = t_1; elseif (t_2 <= -5e-227) tmp = Float64(x + y); elseif (t_2 <= 0.0) tmp = fma(Float64(Float64(z - a) / t), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+306], t$95$1, If[LessEqual[t$95$2, -5e-227], N[(x + y), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(N[(N[(z - a), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z}{t - a}, y, x\right)\\
t_2 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-227}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - a}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -2.00000000000000003e306 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6476.2
Applied rewrites76.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.2
Applied rewrites76.2%
if -2.00000000000000003e306 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -4.99999999999999961e-227Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
if -4.99999999999999961e-227 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0Initial program 76.5%
Taylor expanded in t around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
mul-1-negN/A
lift-/.f64N/A
lift--.f64N/A
div-subN/A
sub-negateN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lift-*.f64N/A
associate-/l*N/A
distribute-rgt-out--N/A
lower-fma.f64N/A
lower-/.f64N/A
lower--.f6461.1
Applied rewrites61.1%
lift-fma.f64N/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites60.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (- (+ x y) (* z (/ y a))))) (if (<= a -3.8e+66) t_1 (if (<= a 9.5e-8) (fma (/ z (- t a)) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) - (z * (y / a));
double tmp;
if (a <= -3.8e+66) {
tmp = t_1;
} else if (a <= 9.5e-8) {
tmp = fma((z / (t - a)), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(x + y) - Float64(z * Float64(y / a))) tmp = 0.0 if (a <= -3.8e+66) tmp = t_1; elseif (a <= 9.5e-8) tmp = fma(Float64(z / Float64(t - a)), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] - N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[a, -3.8e+66], t$95$1, If[LessEqual[a, 9.5e-8], N[(N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + y\right) - z \cdot \frac{y}{a}\\
\mathbf{if}\;a \leq -3.8 \cdot 10^{+66}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 9.5 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -3.8000000000000002e66 or 9.50000000000000036e-8 < a Initial program 76.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6464.8
Applied rewrites64.8%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6466.4
Applied rewrites66.4%
if -3.8000000000000002e66 < a < 9.50000000000000036e-8Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6476.2
Applied rewrites76.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.2
Applied rewrites76.2%
(FPCore (x y z t a) :precision binary64 (if (<= a -2.6e+70) (+ x y) (if (<= a 1.65e-7) (fma (/ z (- t a)) y x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2.6e+70) {
tmp = x + y;
} else if (a <= 1.65e-7) {
tmp = fma((z / (t - a)), y, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2.6e+70) tmp = Float64(x + y); elseif (a <= 1.65e-7) tmp = fma(Float64(z / Float64(t - a)), y, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2.6e+70], N[(x + y), $MachinePrecision], If[LessEqual[a, 1.65e-7], N[(N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2.6 \cdot 10^{+70}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 1.65 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if a < -2.6e70 or 1.6500000000000001e-7 < a Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
if -2.6e70 < a < 1.6500000000000001e-7Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6476.2
Applied rewrites76.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6476.2
Applied rewrites76.2%
(FPCore (x y z t a) :precision binary64 (if (<= a -2100.0) (+ x y) (if (<= a 2.4e-8) (fma (/ z t) y x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a <= -2100.0) {
tmp = x + y;
} else if (a <= 2.4e-8) {
tmp = fma((z / t), y, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (a <= -2100.0) tmp = Float64(x + y); elseif (a <= 2.4e-8) tmp = fma(Float64(z / t), y, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[a, -2100.0], N[(x + y), $MachinePrecision], If[LessEqual[a, 2.4e-8], N[(N[(z / t), $MachinePrecision] * y + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -2100:\\
\;\;\;\;x + y\\
\mathbf{elif}\;a \leq 2.4 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if a < -2100 or 2.39999999999999998e-8 < a Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
if -2100 < a < 2.39999999999999998e-8Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
Taylor expanded in a around 0
lower-/.f6461.7
Applied rewrites61.7%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6461.7
Applied rewrites61.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (+ x y) (/ (* (- z t) y) (- a t)))))
(if (<= t_1 -2e+306)
(* (/ z t) y)
(if (<= t_1 2e+305) (+ x y) (* (/ y t) z)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) - (((z - t) * y) / (a - t));
double tmp;
if (t_1 <= -2e+306) {
tmp = (z / t) * y;
} else if (t_1 <= 2e+305) {
tmp = x + y;
} else {
tmp = (y / t) * z;
}
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(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (x + y) - (((z - t) * y) / (a - t))
if (t_1 <= (-2d+306)) then
tmp = (z / t) * y
else if (t_1 <= 2d+305) then
tmp = x + y
else
tmp = (y / t) * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x + y) - (((z - t) * y) / (a - t));
double tmp;
if (t_1 <= -2e+306) {
tmp = (z / t) * y;
} else if (t_1 <= 2e+305) {
tmp = x + y;
} else {
tmp = (y / t) * z;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (x + y) - (((z - t) * y) / (a - t)) tmp = 0 if t_1 <= -2e+306: tmp = (z / t) * y elif t_1 <= 2e+305: tmp = x + y else: tmp = (y / t) * z return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) tmp = 0.0 if (t_1 <= -2e+306) tmp = Float64(Float64(z / t) * y); elseif (t_1 <= 2e+305) tmp = Float64(x + y); else tmp = Float64(Float64(y / t) * z); end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (x + y) - (((z - t) * y) / (a - t)); tmp = 0.0; if (t_1 <= -2e+306) tmp = (z / t) * y; elseif (t_1 <= 2e+305) tmp = x + y; else tmp = (y / t) * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+306], N[(N[(z / t), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[t$95$1, 2e+305], N[(x + y), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+306}:\\
\;\;\;\;\frac{z}{t} \cdot y\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{t} \cdot z\\
\end{array}
\end{array}
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -2.00000000000000003e306Initial program 76.5%
Taylor expanded in t around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6418.6
Applied rewrites18.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6420.2
Applied rewrites20.2%
if -2.00000000000000003e306 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 1.9999999999999999e305Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
if 1.9999999999999999e305 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 76.5%
Taylor expanded in t around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6418.6
Applied rewrites18.6%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6419.9
Applied rewrites19.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ y t) z)) (t_2 (- (+ x y) (/ (* (- z t) y) (- a t))))) (if (<= t_2 -2e+306) t_1 (if (<= t_2 2e+305) (+ x y) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / t) * z;
double t_2 = (x + y) - (((z - t) * y) / (a - t));
double tmp;
if (t_2 <= -2e+306) {
tmp = t_1;
} else if (t_2 <= 2e+305) {
tmp = x + y;
} 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(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y / t) * z
t_2 = (x + y) - (((z - t) * y) / (a - t))
if (t_2 <= (-2d+306)) then
tmp = t_1
else if (t_2 <= 2d+305) then
tmp = x + y
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (y / t) * z;
double t_2 = (x + y) - (((z - t) * y) / (a - t));
double tmp;
if (t_2 <= -2e+306) {
tmp = t_1;
} else if (t_2 <= 2e+305) {
tmp = x + y;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = (y / t) * z t_2 = (x + y) - (((z - t) * y) / (a - t)) tmp = 0 if t_2 <= -2e+306: tmp = t_1 elif t_2 <= 2e+305: tmp = x + y else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(y / t) * z) t_2 = Float64(Float64(x + y) - Float64(Float64(Float64(z - t) * y) / Float64(a - t))) tmp = 0.0 if (t_2 <= -2e+306) tmp = t_1; elseif (t_2 <= 2e+305) tmp = Float64(x + y); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = (y / t) * z; t_2 = (x + y) - (((z - t) * y) / (a - t)); tmp = 0.0; if (t_2 <= -2e+306) tmp = t_1; elseif (t_2 <= 2e+305) tmp = x + y; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / t), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x + y), $MachinePrecision] - N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e+306], t$95$1, If[LessEqual[t$95$2, 2e+305], N[(x + y), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{t} \cdot z\\
t_2 := \left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{+306}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -2.00000000000000003e306 or 1.9999999999999999e305 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) Initial program 76.5%
Taylor expanded in t around -inf
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f6457.7
Applied rewrites57.7%
Taylor expanded in z around inf
lower-/.f64N/A
lower-*.f6418.6
Applied rewrites18.6%
lift-/.f64N/A
lift-*.f64N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6419.9
Applied rewrites19.9%
if -2.00000000000000003e306 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 1.9999999999999999e305Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
(FPCore (x y z t a) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a) {
return x + y;
}
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(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + y
end function
public static double code(double x, double y, double z, double t, double a) {
return x + y;
}
def code(x, y, z, t, a): return x + y
function code(x, y, z, t, a) return Float64(x + y) end
function tmp = code(x, y, z, t, a) tmp = x + y; end
code[x_, y_, z_, t_, a_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 76.5%
Taylor expanded in y around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-+.f64N/A
lower-/.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6493.4
Applied rewrites93.4%
lift--.f64N/A
lift-+.f64N/A
lift-/.f64N/A
add-to-fractionN/A
mult-flipN/A
lift-/.f64N/A
mult-flipN/A
distribute-rgt-out--N/A
*-lft-identityN/A
sum-to-mult-revN/A
lift-/.f64N/A
lift-+.f64N/A
lower-*.f64N/A
frac-2negN/A
metadata-evalN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
Applied rewrites93.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6493.3
Applied rewrites98.3%
Taylor expanded in a around inf
lower-+.f6460.2
Applied rewrites60.2%
herbie shell --seed 2025149
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, B"
:precision binary64
(- (+ x y) (/ (* (- z t) y) (- a t))))