
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- z a)))))
double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
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) / (z - a)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y * ((z - t) / (z - a)));
}
def code(x, y, z, t, a): return x + (y * ((z - t) / (z - a)))
function code(x, y, z, t, a) return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(z - a)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y * ((z - t) / (z - a))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \frac{z - t}{z - a}
\end{array}
Initial program 98.2%
(FPCore (x y z t a) :precision binary64 (- x (* (/ y (- a z)) (- z t))))
double code(double x, double y, double z, double t, double a) {
return x - ((y / (a - z)) * (z - 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 / (a - z)) * (z - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y / (a - z)) * (z - t));
}
def code(x, y, z, t, a): return x - ((y / (a - z)) * (z - t))
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y / Float64(a - z)) * Float64(z - t))) end
function tmp = code(x, y, z, t, a) tmp = x - ((y / (a - z)) * (z - t)); end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x - \frac{y}{a - z} \cdot \left(z - t\right)
\end{array}
Initial program 98.2%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
frac-2neg-revN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6495.9
Applied rewrites95.9%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- z a)) (- z t) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (z - a)), (z - t), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(z - a)), Float64(z - t), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{z - a}, z - t, x\right)
\end{array}
Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flip-revN/A
lower-/.f6495.9
Applied rewrites95.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* (/ y (- z a)) (- z t))))
(if (<= t_1 -5e+261)
t_2
(if (<= t_1 0.0005)
(+ x (* y (/ (- t z) a)))
(if (<= t_1 1e+35) (fma (/ (- z t) z) y x) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / (z - a)) * (z - t);
double tmp;
if (t_1 <= -5e+261) {
tmp = t_2;
} else if (t_1 <= 0.0005) {
tmp = x + (y * ((t - z) / a));
} else if (t_1 <= 1e+35) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) tmp = 0.0 if (t_1 <= -5e+261) tmp = t_2; elseif (t_1 <= 0.0005) tmp = Float64(x + Float64(y * Float64(Float64(t - z) / a))); elseif (t_1 <= 1e+35) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+261], t$95$2, If[LessEqual[t$95$1, 0.0005], N[(x + N[(y * N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+35], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a} \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+261}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.0005:\\
\;\;\;\;x + y \cdot \frac{t - z}{a}\\
\mathbf{elif}\;t\_1 \leq 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.0000000000000001e261 or 9.9999999999999997e34 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.2%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6439.5
Applied rewrites39.5%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift--.f6447.2
Applied rewrites47.2%
if -5.0000000000000001e261 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.0000000000000001e-4Initial program 98.2%
lift-/.f64N/A
frac-2negN/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
metadata-evalN/A
frac-2neg-revN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in a around inf
lower-/.f64N/A
lower--.f6461.0
Applied rewrites61.0%
if 5.0000000000000001e-4 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999997e34Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.5
Applied rewrites66.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* (/ y (- z a)) (- z t))))
(if (<= t_1 -5e+261)
t_2
(if (<= t_1 0.0005)
(- x (* (/ y a) (- z t)))
(if (<= t_1 1e+35) (fma (/ (- z t) z) y x) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / (z - a)) * (z - t);
double tmp;
if (t_1 <= -5e+261) {
tmp = t_2;
} else if (t_1 <= 0.0005) {
tmp = x - ((y / a) * (z - t));
} else if (t_1 <= 1e+35) {
tmp = fma(((z - t) / z), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) tmp = 0.0 if (t_1 <= -5e+261) tmp = t_2; elseif (t_1 <= 0.0005) tmp = Float64(x - Float64(Float64(y / a) * Float64(z - t))); elseif (t_1 <= 1e+35) tmp = fma(Float64(Float64(z - t) / z), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+261], t$95$2, If[LessEqual[t$95$1, 0.0005], N[(x - N[(N[(y / a), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+35], N[(N[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a} \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+261}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.0005:\\
\;\;\;\;x - \frac{y}{a} \cdot \left(z - t\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.0000000000000001e261 or 9.9999999999999997e34 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.2%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6439.5
Applied rewrites39.5%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift--.f6447.2
Applied rewrites47.2%
if -5.0000000000000001e261 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.0000000000000001e-4Initial program 98.2%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
frac-2neg-revN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in z around 0
Applied rewrites61.5%
if 5.0000000000000001e-4 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999997e34Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.5
Applied rewrites66.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (* (/ y (- z a)) (- z t))))
(if (<= t_1 -5e+261)
t_2
(if (<= t_1 1e-73)
(fma (/ t a) y x)
(if (<= t_1 1e+35) (fma (/ z (- z a)) y x) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (y / (z - a)) * (z - t);
double tmp;
if (t_1 <= -5e+261) {
tmp = t_2;
} else if (t_1 <= 1e-73) {
tmp = fma((t / a), y, x);
} else if (t_1 <= 1e+35) {
tmp = fma((z / (z - a)), y, x);
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(y / Float64(z - a)) * Float64(z - t)) tmp = 0.0 if (t_1 <= -5e+261) tmp = t_2; elseif (t_1 <= 1e-73) tmp = fma(Float64(t / a), y, x); elseif (t_1 <= 1e+35) tmp = fma(Float64(z / Float64(z - a)), y, x); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+261], t$95$2, If[LessEqual[t$95$1, 1e-73], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+35], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{y}{z - a} \cdot \left(z - t\right)\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+261}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-73}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+35}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.0000000000000001e261 or 9.9999999999999997e34 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.2%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6439.5
Applied rewrites39.5%
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
mult-flipN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f64N/A
lift--.f6447.2
Applied rewrites47.2%
if -5.0000000000000001e261 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.99999999999999997e-74Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
if 9.99999999999999997e-74 < (/.f64 (-.f64 z t) (-.f64 z a)) < 9.9999999999999997e34Initial program 98.2%
Taylor expanded in t around 0
lower-/.f64N/A
lower--.f6471.4
Applied rewrites71.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6471.4
Applied rewrites71.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z t) z) y x))) (if (<= z -2.1e-99) t_1 (if (<= z 6.8e-43) (fma (/ t a) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - t) / z), y, x);
double tmp;
if (z <= -2.1e-99) {
tmp = t_1;
} else if (z <= 6.8e-43) {
tmp = fma((t / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - t) / z), y, x) tmp = 0.0 if (z <= -2.1e-99) tmp = t_1; elseif (z <= 6.8e-43) tmp = fma(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[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[z, -2.1e-99], t$95$1, If[LessEqual[z, 6.8e-43], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{-99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.09999999999999984e-99 or 6.8000000000000001e-43 < z Initial program 98.2%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.5
Applied rewrites66.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6466.5
Applied rewrites66.5%
if -2.09999999999999984e-99 < z < 6.8000000000000001e-43Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
(FPCore (x y z t a) :precision binary64 (if (<= z -1.9e-99) (fma (/ z (- z a)) y x) (if (<= z 6.8e-43) (fma (/ t a) y x) (fma (/ y z) (- z t) x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -1.9e-99) {
tmp = fma((z / (z - a)), y, x);
} else if (z <= 6.8e-43) {
tmp = fma((t / a), y, x);
} else {
tmp = fma((y / z), (z - t), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -1.9e-99) tmp = fma(Float64(z / Float64(z - a)), y, x); elseif (z <= 6.8e-43) tmp = fma(Float64(t / a), y, x); else tmp = fma(Float64(y / z), Float64(z - t), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -1.9e-99], N[(N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[z, 6.8e-43], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.9 \cdot 10^{-99}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{z - a}, y, x\right)\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{z}, z - t, x\right)\\
\end{array}
\end{array}
if z < -1.8999999999999998e-99Initial program 98.2%
Taylor expanded in t around 0
lower-/.f64N/A
lower--.f6471.4
Applied rewrites71.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6471.4
Applied rewrites71.4%
if -1.8999999999999998e-99 < z < 6.8000000000000001e-43Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
if 6.8000000000000001e-43 < z Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flip-revN/A
lower-/.f6495.9
Applied rewrites95.9%
Taylor expanded in z around inf
lower-/.f6465.2
Applied rewrites65.2%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (/ (* t y) (- a z))))
(if (<= t_1 -5e+261)
t_2
(if (<= t_1 0.0005) (fma (/ t a) y x) (if (<= t_1 2e+42) (+ x y) t_2)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = (t * y) / (a - z);
double tmp;
if (t_1 <= -5e+261) {
tmp = t_2;
} else if (t_1 <= 0.0005) {
tmp = fma((t / a), y, x);
} else if (t_1 <= 2e+42) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = Float64(Float64(t * y) / Float64(a - z)) tmp = 0.0 if (t_1 <= -5e+261) tmp = t_2; elseif (t_1 <= 0.0005) tmp = fma(Float64(t / a), y, x); elseif (t_1 <= 2e+42) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t * y), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -5e+261], t$95$2, If[LessEqual[t$95$1, 0.0005], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 2e+42], N[(x + y), $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \frac{t \cdot y}{a - z}\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+261}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 0.0005:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+42}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -5.0000000000000001e261 or 2.00000000000000009e42 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.2%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
*-commutativeN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
frac-2neg-revN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6495.9
Applied rewrites95.9%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.5
Applied rewrites26.5%
if -5.0000000000000001e261 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.0000000000000001e-4Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
if 5.0000000000000001e-4 < (/.f64 (-.f64 z t) (-.f64 z a)) < 2.00000000000000009e42Initial program 98.2%
Taylor expanded in z around inf
lower-+.f6460.0
Applied rewrites60.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ y z) (- z t) x))) (if (<= z -2.1e-99) t_1 (if (<= z 6.8e-43) (fma (/ t a) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y / z), (z - t), x);
double tmp;
if (z <= -2.1e-99) {
tmp = t_1;
} else if (z <= 6.8e-43) {
tmp = fma((t / a), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y / z), Float64(z - t), x) tmp = 0.0 if (z <= -2.1e-99) tmp = t_1; elseif (z <= 6.8e-43) tmp = fma(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[(y / z), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -2.1e-99], t$95$1, If[LessEqual[z, 6.8e-43], N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{z}, z - t, x\right)\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{-99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{-43}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -2.09999999999999984e-99 or 6.8000000000000001e-43 < z Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flip-revN/A
lower-/.f6495.9
Applied rewrites95.9%
Taylor expanded in z around inf
lower-/.f6465.2
Applied rewrites65.2%
if -2.09999999999999984e-99 < z < 6.8000000000000001e-43Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ t a) y x))) (if (<= t_1 0.0005) t_2 (if (<= t_1 5e+30) (+ x y) t_2))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (z - t) / (z - a);
double t_2 = fma((t / a), y, x);
double tmp;
if (t_1 <= 0.0005) {
tmp = t_2;
} else if (t_1 <= 5e+30) {
tmp = x + y;
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(z - t) / Float64(z - a)) t_2 = fma(Float64(t / a), y, x) tmp = 0.0 if (t_1 <= 0.0005) tmp = t_2; elseif (t_1 <= 5e+30) tmp = Float64(x + y); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t / a), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0005], t$95$2, If[LessEqual[t$95$1, 5e+30], N[(x + y), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \mathsf{fma}\left(\frac{t}{a}, y, x\right)\\
\mathbf{if}\;t\_1 \leq 0.0005:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+30}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 5.0000000000000001e-4 or 4.9999999999999998e30 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.2%
Taylor expanded in z around 0
lower-/.f6462.2
Applied rewrites62.2%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6462.2
Applied rewrites62.2%
if 5.0000000000000001e-4 < (/.f64 (-.f64 z t) (-.f64 z a)) < 4.9999999999999998e30Initial program 98.2%
Taylor expanded in z around inf
lower-+.f6460.0
Applied rewrites60.0%
(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 98.2%
Taylor expanded in z around inf
lower-+.f6460.0
Applied rewrites60.0%
(FPCore (x y z t a) :precision binary64 y)
double code(double x, double y, double z, double t, double a) {
return 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 = y
end function
public static double code(double x, double y, double z, double t, double a) {
return y;
}
def code(x, y, z, t, a): return y
function code(x, y, z, t, a) return y end
function tmp = code(x, y, z, t, a) tmp = y; end
code[x_, y_, z_, t_, a_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 98.2%
Taylor expanded in z around inf
lower-+.f6460.0
Applied rewrites60.0%
Taylor expanded in x around 0
Applied rewrites18.6%
herbie shell --seed 2025149
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, A"
:precision binary64
(+ x (* y (/ (- z t) (- z a)))))