
(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 (fma (/ (- t z) (- a z)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((t - z) / (a - z)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(t - z) / Float64(a - z)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t - z}{a - z}, y, x\right)
\end{array}
Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ t (- a z)) y x)))
(if (<= t_1 -1000.0)
t_2
(if (<= t_1 1e-5)
(fma (/ (- t z) a) y x)
(if (<= t_1 2.0) (+ x (* y (/ z (- z a)))) 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 - z)), y, x);
double tmp;
if (t_1 <= -1000.0) {
tmp = t_2;
} else if (t_1 <= 1e-5) {
tmp = fma(((t - z) / a), y, x);
} else if (t_1 <= 2.0) {
tmp = x + (y * (z / (z - a)));
} 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 / Float64(a - z)), y, x) tmp = 0.0 if (t_1 <= -1000.0) tmp = t_2; elseif (t_1 <= 1e-5) tmp = fma(Float64(Float64(t - z) / a), y, x); elseif (t_1 <= 2.0) tmp = Float64(x + Float64(y * Float64(z / Float64(z - a)))); 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 / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, -1000.0], t$95$2, If[LessEqual[t$95$1, 1e-5], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 2.0], N[(x + N[(y * N[(z / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 - z}, y, x\right)\\
\mathbf{if}\;t\_1 \leq -1000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 2:\\
\;\;\;\;x + y \cdot \frac{z}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -1e3 or 2 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
if -1e3 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites61.6%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 2Initial program 98.3%
Taylor expanded in t around 0
lower-/.f64N/A
lower--.f6471.9
Applied rewrites71.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ t (- a z)) y x)))
(if (<= t_1 -1000.0)
t_2
(if (<= t_1 1e-5)
(fma (/ (- t z) a) y x)
(if (<= t_1 200000000.0) (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 = fma((t / (a - z)), y, x);
double tmp;
if (t_1 <= -1000.0) {
tmp = t_2;
} else if (t_1 <= 1e-5) {
tmp = fma(((t - z) / a), y, x);
} else if (t_1 <= 200000000.0) {
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 = fma(Float64(t / Float64(a - z)), y, x) tmp = 0.0 if (t_1 <= -1000.0) tmp = t_2; elseif (t_1 <= 1e-5) tmp = fma(Float64(Float64(t - z) / a), y, x); elseif (t_1 <= 200000000.0) 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[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, -1000.0], t$95$2, If[LessEqual[t$95$1, 1e-5], N[(N[(N[(t - z), $MachinePrecision] / a), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t$95$1, 200000000.0], 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 := \mathsf{fma}\left(\frac{t}{a - z}, y, x\right)\\
\mathbf{if}\;t\_1 \leq -1000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{a}, y, x\right)\\
\mathbf{elif}\;t\_1 \leq 200000000:\\
\;\;\;\;\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)) < -1e3 or 2e8 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
if -1e3 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites61.6%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 2e8Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.4
Applied rewrites66.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
(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.3%
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-/.f6496.1
Applied rewrites96.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ t (- a z)) y x)))
(if (<= t_1 1e-5)
t_2
(if (<= t_1 200000000.0) (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 = fma((t / (a - z)), y, x);
double tmp;
if (t_1 <= 1e-5) {
tmp = t_2;
} else if (t_1 <= 200000000.0) {
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 = fma(Float64(t / Float64(a - z)), y, x) tmp = 0.0 if (t_1 <= 1e-5) tmp = t_2; elseif (t_1 <= 200000000.0) 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[(t / N[(a - z), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-5], t$95$2, If[LessEqual[t$95$1, 200000000.0], 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 := \mathsf{fma}\left(\frac{t}{a - z}, y, x\right)\\
\mathbf{if}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 200000000:\\
\;\;\;\;\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)) < 1.00000000000000008e-5 or 2e8 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 2e8Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.4
Applied rewrites66.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ y (- a z)) t x))) (if (<= t_1 1e-5) t_2 (if (<= t_1 5e+45) (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 = fma((y / (a - z)), t, x);
double tmp;
if (t_1 <= 1e-5) {
tmp = t_2;
} else if (t_1 <= 5e+45) {
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 = fma(Float64(y / Float64(a - z)), t, x) tmp = 0.0 if (t_1 <= 1e-5) tmp = t_2; elseif (t_1 <= 5e+45) 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[(a - z), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-5], t$95$2, If[LessEqual[t$95$1, 5e+45], 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 := \mathsf{fma}\left(\frac{y}{a - z}, t, x\right)\\
\mathbf{if}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+45}:\\
\;\;\;\;\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)) < 1.00000000000000008e-5 or 5e45 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f6476.6
Applied rewrites76.6%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5e45Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.4
Applied rewrites66.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ (- z t) z) y x))) (if (<= t_1 -1000.0) t_2 (if (<= t_1 1e-5) (fma (/ y a) t 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 = fma(((z - t) / z), y, x);
double tmp;
if (t_1 <= -1000.0) {
tmp = t_2;
} else if (t_1 <= 1e-5) {
tmp = fma((y / a), t, 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 = fma(Float64(Float64(z - t) / z), y, x) tmp = 0.0 if (t_1 <= -1000.0) tmp = t_2; elseif (t_1 <= 1e-5) tmp = fma(Float64(y / a), t, 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[(N[(z - t), $MachinePrecision] / z), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t$95$1, -1000.0], t$95$2, If[LessEqual[t$95$1, 1e-5], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z - t}{z - a}\\
t_2 := \mathsf{fma}\left(\frac{z - t}{z}, y, x\right)\\
\mathbf{if}\;t\_1 \leq -1000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -1e3 or 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.4
Applied rewrites66.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6466.4
Applied rewrites66.4%
if -1e3 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
Taylor expanded in z around 0
Applied rewrites62.4%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flipN/A
lower-/.f6462.5
Applied rewrites62.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (/ (- z t) (- z a))) (t_2 (/ (* t y) (- a z))))
(if (<= t_1 -1000000000.0)
t_2
(if (<= t_1 1e-5) (fma (/ y a) t x) (if (<= t_1 1e+84) (+ 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 <= -1000000000.0) {
tmp = t_2;
} else if (t_1 <= 1e-5) {
tmp = fma((y / a), t, x);
} else if (t_1 <= 1e+84) {
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 <= -1000000000.0) tmp = t_2; elseif (t_1 <= 1e-5) tmp = fma(Float64(y / a), t, x); elseif (t_1 <= 1e+84) 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, -1000000000.0], t$95$2, If[LessEqual[t$95$1, 1e-5], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], If[LessEqual[t$95$1, 1e+84], 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 -1000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{elif}\;t\_1 \leq 10^{+84}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < -1e9 or 1.00000000000000006e84 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in t around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.2
Applied rewrites26.2%
if -1e9 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
Taylor expanded in z around 0
Applied rewrites62.4%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flipN/A
lower-/.f6462.5
Applied rewrites62.5%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000006e84Initial program 98.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (/ (- z t) (- z a))) (t_2 (fma (/ y a) t x))) (if (<= t_1 1e-5) t_2 (if (<= t_1 5e+99) (+ 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((y / a), t, x);
double tmp;
if (t_1 <= 1e-5) {
tmp = t_2;
} else if (t_1 <= 5e+99) {
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(y / a), t, x) tmp = 0.0 if (t_1 <= 1e-5) tmp = t_2; elseif (t_1 <= 5e+99) 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[(y / a), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-5], t$95$2, If[LessEqual[t$95$1, 5e+99], 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{y}{a}, t, x\right)\\
\mathbf{if}\;t\_1 \leq 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+99}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5 or 5.00000000000000008e99 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f6498.3
lift-/.f64N/A
frac-2negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.3
Applied rewrites98.3%
Taylor expanded in z around 0
Applied rewrites76.7%
Taylor expanded in z around 0
Applied rewrites62.4%
lift-fma.f64N/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
*-commutativeN/A
mult-flipN/A
lower-/.f6462.5
Applied rewrites62.5%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000008e99Initial program 98.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
(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 1e-5) t_2 (if (<= t_1 5e+99) (+ 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 <= 1e-5) {
tmp = t_2;
} else if (t_1 <= 5e+99) {
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 <= 1e-5) tmp = t_2; elseif (t_1 <= 5e+99) 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, 1e-5], t$95$2, If[LessEqual[t$95$1, 5e+99], 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 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+99}:\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 1.00000000000000008e-5 or 5.00000000000000008e99 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
Taylor expanded in z around 0
lower-/.f6462.4
Applied rewrites62.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6462.4
Applied rewrites62.4%
if 1.00000000000000008e-5 < (/.f64 (-.f64 z t) (-.f64 z a)) < 5.00000000000000008e99Initial program 98.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
(FPCore (x y z t a) :precision binary64 (if (<= (/ (- z t) (- z a)) 6.2e-12) (* x 1.0) (+ x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z - t) / (z - a)) <= 6.2e-12) {
tmp = x * 1.0;
} else {
tmp = x + y;
}
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) :: tmp
if (((z - t) / (z - a)) <= 6.2d-12) then
tmp = x * 1.0d0
else
tmp = x + y
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((z - t) / (z - a)) <= 6.2e-12) {
tmp = x * 1.0;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((z - t) / (z - a)) <= 6.2e-12: tmp = x * 1.0 else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(z - t) / Float64(z - a)) <= 6.2e-12) tmp = Float64(x * 1.0); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((z - t) / (z - a)) <= 6.2e-12) tmp = x * 1.0; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(z - t), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision], 6.2e-12], N[(x * 1.0), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z - t}{z - a} \leq 6.2 \cdot 10^{-12}:\\
\;\;\;\;x \cdot 1\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
\end{array}
if (/.f64 (-.f64 z t) (-.f64 z a)) < 6.2000000000000002e-12Initial program 98.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
Taylor expanded in x around inf
lower-*.f64N/A
lower-+.f64N/A
lower-/.f6457.3
Applied rewrites57.3%
Taylor expanded in x around inf
Applied rewrites50.8%
if 6.2000000000000002e-12 < (/.f64 (-.f64 z t) (-.f64 z a)) Initial program 98.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
(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.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
(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.3%
Taylor expanded in z around inf
lower-+.f6460.3
Applied rewrites60.3%
Taylor expanded in x around 0
Applied rewrites18.5%
herbie shell --seed 2025143
(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)))))