
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
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) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
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) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * t) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * t) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * t) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot t}{a - z}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (* (/ (- z y) (- z a)) t)))
double code(double x, double y, double z, double t, double a) {
return x + (((z - y) / (z - 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 + (((z - y) / (z - a)) * t)
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((z - y) / (z - a)) * t);
}
def code(x, y, z, t, a): return x + (((z - y) / (z - a)) * t)
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(z - y) / Float64(z - a)) * t)) end
function tmp = code(x, y, z, t, a) tmp = x + (((z - y) / (z - a)) * t); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(z - y), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{z - y}{z - a} \cdot t
\end{array}
Initial program 85.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
(FPCore (x y z t a) :precision binary64 (fma (/ (- z y) (- z a)) t x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - y) / (z - a)), t, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - y) / Float64(z - a)), t, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - y), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - y}{z - a}, t, x\right)
\end{array}
Initial program 85.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
(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(t / Float64(z - a)), Float64(z - y), x) end
code[x_, y_, z_, t_, a_] := N[(N[(t / N[(z - a), $MachinePrecision]), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t}{z - a}, z - y, x\right)
\end{array}
Initial program 85.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6495.6
Applied rewrites95.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z y) z) t x))) (if (<= z -4e-37) t_1 (if (<= z 2.5e+30) (- x (/ (* t y) (- z a))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / z), t, x);
double tmp;
if (z <= -4e-37) {
tmp = t_1;
} else if (z <= 2.5e+30) {
tmp = x - ((t * y) / (z - a));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / z), t, x) tmp = 0.0 if (z <= -4e-37) tmp = t_1; elseif (z <= 2.5e+30) tmp = Float64(x - Float64(Float64(t * y) / Float64(z - a))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[z, -4e-37], t$95$1, If[LessEqual[z, 2.5e+30], N[(x - N[(N[(t * y), $MachinePrecision] / N[(z - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{z}, t, x\right)\\
\mathbf{if}\;z \leq -4 \cdot 10^{-37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{+30}:\\
\;\;\;\;x - \frac{t \cdot y}{z - a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.00000000000000027e-37 or 2.4999999999999999e30 < z Initial program 85.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.2
Applied rewrites66.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6466.2
Applied rewrites66.2%
if -4.00000000000000027e-37 < z < 2.4999999999999999e30Initial program 85.9%
Taylor expanded in y around inf
lower-*.f6473.2
Applied rewrites73.2%
lift-+.f64N/A
add-flipN/A
lower--.f64N/A
lift-/.f64N/A
distribute-neg-frac2N/A
lift--.f64N/A
sub-negate-revN/A
lift--.f64N/A
lower-/.f6473.2
Applied rewrites73.2%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ (- z y) z) t x))) (if (<= z -9.6e-32) t_1 (if (<= z 1.52e-31) (+ x (* (/ t a) y)) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((z - y) / z), t, x);
double tmp;
if (z <= -9.6e-32) {
tmp = t_1;
} else if (z <= 1.52e-31) {
tmp = x + ((t / a) * y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(z - y) / z), t, x) tmp = 0.0 if (z <= -9.6e-32) tmp = t_1; elseif (z <= 1.52e-31) tmp = Float64(x + Float64(Float64(t / a) * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[z, -9.6e-32], t$95$1, If[LessEqual[z, 1.52e-31], N[(x + N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z - y}{z}, t, x\right)\\
\mathbf{if}\;z \leq -9.6 \cdot 10^{-32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.52 \cdot 10^{-31}:\\
\;\;\;\;x + \frac{t}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.6000000000000005e-32 or 1.52000000000000003e-31 < z Initial program 85.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6466.2
Applied rewrites66.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6466.2
Applied rewrites66.2%
if -9.6000000000000005e-32 < z < 1.52000000000000003e-31Initial program 85.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6461.5
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ t z) (- z y) x))) (if (<= z -9.6e-32) t_1 (if (<= z 1.5e-31) (+ x (* (/ t a) y)) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((t / z), (z - y), x);
double tmp;
if (z <= -9.6e-32) {
tmp = t_1;
} else if (z <= 1.5e-31) {
tmp = x + ((t / a) * y);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(t / z), Float64(z - y), x) tmp = 0.0 if (z <= -9.6e-32) tmp = t_1; elseif (z <= 1.5e-31) tmp = Float64(x + Float64(Float64(t / a) * y)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / z), $MachinePrecision] * N[(z - y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[z, -9.6e-32], t$95$1, If[LessEqual[z, 1.5e-31], N[(x + N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t}{z}, z - y, x\right)\\
\mathbf{if}\;z \leq -9.6 \cdot 10^{-32}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-31}:\\
\;\;\;\;x + \frac{t}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -9.6000000000000005e-32 or 1.49999999999999991e-31 < z Initial program 85.9%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
distribute-neg-frac2N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6495.6
Applied rewrites95.6%
Taylor expanded in z around inf
lower-/.f6464.4
Applied rewrites64.4%
if -9.6000000000000005e-32 < z < 1.49999999999999991e-31Initial program 85.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6461.5
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -4e-28) (+ x t) (if (<= z 1.12e+30) (+ x (* (/ t a) y)) (+ x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4e-28) {
tmp = x + t;
} else if (z <= 1.12e+30) {
tmp = x + ((t / a) * y);
} else {
tmp = x + t;
}
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 <= (-4d-28)) then
tmp = x + t
else if (z <= 1.12d+30) then
tmp = x + ((t / a) * y)
else
tmp = x + t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4e-28) {
tmp = x + t;
} else if (z <= 1.12e+30) {
tmp = x + ((t / a) * y);
} else {
tmp = x + t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4e-28: tmp = x + t elif z <= 1.12e+30: tmp = x + ((t / a) * y) else: tmp = x + t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4e-28) tmp = Float64(x + t); elseif (z <= 1.12e+30) tmp = Float64(x + Float64(Float64(t / a) * y)); else tmp = Float64(x + t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4e-28) tmp = x + t; elseif (z <= 1.12e+30) tmp = x + ((t / a) * y); else tmp = x + t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4e-28], N[(x + t), $MachinePrecision], If[LessEqual[z, 1.12e+30], N[(x + N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(x + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{-28}:\\
\;\;\;\;x + t\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+30}:\\
\;\;\;\;x + \frac{t}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
\end{array}
if z < -3.99999999999999988e-28 or 1.12e30 < z Initial program 85.9%
Taylor expanded in z around inf
Applied rewrites59.8%
if -3.99999999999999988e-28 < z < 1.12e30Initial program 85.9%
Taylor expanded in z around 0
lower-/.f64N/A
lower-*.f6459.9
Applied rewrites59.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6461.5
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -4e-28) (+ x t) (if (<= z 1.12e+30) (fma (/ y a) t x) (+ x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4e-28) {
tmp = x + t;
} else if (z <= 1.12e+30) {
tmp = fma((y / a), t, x);
} else {
tmp = x + t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4e-28) tmp = Float64(x + t); elseif (z <= 1.12e+30) tmp = fma(Float64(y / a), t, x); else tmp = Float64(x + t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4e-28], N[(x + t), $MachinePrecision], If[LessEqual[z, 1.12e+30], N[(N[(y / a), $MachinePrecision] * t + x), $MachinePrecision], N[(x + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{-28}:\\
\;\;\;\;x + t\\
\mathbf{elif}\;z \leq 1.12 \cdot 10^{+30}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{a}, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
\end{array}
if z < -3.99999999999999988e-28 or 1.12e30 < z Initial program 85.9%
Taylor expanded in z around inf
Applied rewrites59.8%
if -3.99999999999999988e-28 < z < 1.12e30Initial program 85.9%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lower--.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.1
Applied rewrites98.1%
Taylor expanded in z around 0
lower-/.f6461.5
Applied rewrites61.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-*.f64N/A
remove-double-negN/A
lower-fma.f6461.5
Applied rewrites61.5%
(FPCore (x y z t a) :precision binary64 (if (<= z -4.3e-178) (+ x t) (if (<= z 4.2e-168) (* (/ t a) y) (+ x t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.3e-178) {
tmp = x + t;
} else if (z <= 4.2e-168) {
tmp = (t / a) * y;
} else {
tmp = x + t;
}
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 <= (-4.3d-178)) then
tmp = x + t
else if (z <= 4.2d-168) then
tmp = (t / a) * y
else
tmp = x + t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -4.3e-178) {
tmp = x + t;
} else if (z <= 4.2e-168) {
tmp = (t / a) * y;
} else {
tmp = x + t;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if z <= -4.3e-178: tmp = x + t elif z <= 4.2e-168: tmp = (t / a) * y else: tmp = x + t return tmp
function code(x, y, z, t, a) tmp = 0.0 if (z <= -4.3e-178) tmp = Float64(x + t); elseif (z <= 4.2e-168) tmp = Float64(Float64(t / a) * y); else tmp = Float64(x + t); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (z <= -4.3e-178) tmp = x + t; elseif (z <= 4.2e-168) tmp = (t / a) * y; else tmp = x + t; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -4.3e-178], N[(x + t), $MachinePrecision], If[LessEqual[z, 4.2e-168], N[(N[(t / a), $MachinePrecision] * y), $MachinePrecision], N[(x + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.3 \cdot 10^{-178}:\\
\;\;\;\;x + t\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-168}:\\
\;\;\;\;\frac{t}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;x + t\\
\end{array}
\end{array}
if z < -4.3e-178 or 4.19999999999999988e-168 < z Initial program 85.9%
Taylor expanded in z around inf
Applied rewrites59.8%
if -4.3e-178 < z < 4.19999999999999988e-168Initial program 85.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower-*.f64N/A
lower--.f6426.3
Applied rewrites26.3%
Taylor expanded in z around 0
Applied rewrites18.4%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6420.0
Applied rewrites20.0%
(FPCore (x y z t a) :precision binary64 (+ x t))
double code(double x, double y, double z, double t, double a) {
return x + 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 + t
end function
public static double code(double x, double y, double z, double t, double a) {
return x + t;
}
def code(x, y, z, t, a): return x + t
function code(x, y, z, t, a) return Float64(x + t) end
function tmp = code(x, y, z, t, a) tmp = x + t; end
code[x_, y_, z_, t_, a_] := N[(x + t), $MachinePrecision]
\begin{array}{l}
\\
x + t
\end{array}
Initial program 85.9%
Taylor expanded in z around inf
Applied rewrites59.8%
herbie shell --seed 2025149
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTick from plot-0.2.3.4, A"
:precision binary64
(+ x (/ (* (- y z) t) (- a z))))