
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y \cdot \left(z - t\right)}{a - t}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + \frac{y \cdot \left(z - t\right)}{a - t}
(FPCore (x y z t a) :precision binary64 (fma (/ z (- a t)) y (fma (/ t (- t a)) y x)))
double code(double x, double y, double z, double t, double a) {
return fma((z / (a - t)), y, fma((t / (t - a)), y, x));
}
function code(x, y, z, t, a) return fma(Float64(z / Float64(a - t)), y, fma(Float64(t / Float64(t - a)), y, x)) end
code[x_, y_, z_, t_, a_] := N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + N[(N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]), $MachinePrecision]
\mathsf{fma}\left(\frac{z}{a - t}, y, \mathsf{fma}\left(\frac{t}{t - a}, y, x\right)\right)
Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
distribute-rgt-inN/A
div-addN/A
associate-+l+N/A
associate-*l/N/A
lower-fma.f64N/A
lower-/.f64N/A
associate-*l/N/A
lower-fma.f64N/A
frac-2negN/A
remove-double-negN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6498.0
Applied rewrites98.0%
(FPCore (x y z t a) :precision binary64 (fma (/ (- t z) (- t a)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((t - z) / (t - a)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(t - z) / Float64(t - a)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\mathsf{fma}\left(\frac{t - z}{t - a}, y, x\right)
Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- t a)) (- t z) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (t - a)), (t - z), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(t - a)), Float64(t - z), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision] + x), $MachinePrecision]
\mathsf{fma}\left(\frac{y}{t - a}, t - z, x\right)
Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
frac-2negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift--.f64N/A
sub-negate-revN/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6495.8
Applied rewrites95.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ t (- t a)) y x))) (if (<= t -1.36e+57) t_1 (if (<= t 5.6e+69) (fma (/ z (- a t)) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((t / (t - a)), y, x);
double tmp;
if (t <= -1.36e+57) {
tmp = t_1;
} else if (t <= 5.6e+69) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(t / Float64(t - a)), y, x) tmp = 0.0 if (t <= -1.36e+57) tmp = t_1; elseif (t <= 5.6e+69) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(t / N[(t - a), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -1.36e+57], t$95$1, If[LessEqual[t, 5.6e+69], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t}{t - a}, y, x\right)\\
\mathbf{if}\;t \leq -1.36 \cdot 10^{+57}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 5.6 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -1.36e57 or 5.59999999999999964e69 < t Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
Taylor expanded in z around 0
Applied rewrites72.0%
if -1.36e57 < t < 5.59999999999999964e69Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6497.9
Applied rewrites97.9%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6476.5
Applied rewrites76.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t z) t) y x)))
(if (<= t -4e+59)
t_1
(if (<= t 28000000000000.0) (fma (/ z (- a t)) y x) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - z) / t), y, x);
double tmp;
if (t <= -4e+59) {
tmp = t_1;
} else if (t <= 28000000000000.0) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - z) / t), y, x) tmp = 0.0 if (t <= -4e+59) tmp = t_1; elseif (t <= 28000000000000.0) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -4e+59], t$95$1, If[LessEqual[t, 28000000000000.0], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -4 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 28000000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -3.99999999999999989e59 or 2.8e13 < t Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.1
Applied rewrites67.1%
if -3.99999999999999989e59 < t < 2.8e13Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6497.9
Applied rewrites97.9%
lift-/.f64N/A
lift-/.f64N/A
div-flip-revN/A
frac-2negN/A
lift--.f64N/A
sub-negate-revN/A
lower-/.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower--.f6498.0
Applied rewrites98.0%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6476.5
Applied rewrites76.5%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t z) t) y x)))
(if (<= t -390000000.0)
t_1
(if (<= t 26000000000000.0) (+ x (/ (* y z) a)) t_1))))double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - z) / t), y, x);
double tmp;
if (t <= -390000000.0) {
tmp = t_1;
} else if (t <= 26000000000000.0) {
tmp = x + ((y * z) / a);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - z) / t), y, x) tmp = 0.0 if (t <= -390000000.0) tmp = t_1; elseif (t <= 26000000000000.0) tmp = Float64(x + Float64(Float64(y * z) / a)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -390000000.0], t$95$1, If[LessEqual[t, 26000000000000.0], N[(x + N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -390000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 26000000000000:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -3.9e8 or 2.6e13 < t Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
Taylor expanded in a around 0
lower-/.f64N/A
lower--.f6467.1
Applied rewrites67.1%
if -3.9e8 < t < 2.6e13Initial program 85.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6460.6
Applied rewrites60.6%
(FPCore (x y z t a) :precision binary64 (if (<= t -4600.0) (+ x y) (if (<= t 1.12e+36) (+ x (/ (* y z) a)) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4600.0) {
tmp = x + y;
} else if (t <= 1.12e+36) {
tmp = x + ((y * z) / a);
} 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 (t <= (-4600.0d0)) then
tmp = x + y
else if (t <= 1.12d+36) then
tmp = x + ((y * z) / a)
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 (t <= -4600.0) {
tmp = x + y;
} else if (t <= 1.12e+36) {
tmp = x + ((y * z) / a);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -4600.0: tmp = x + y elif t <= 1.12e+36: tmp = x + ((y * z) / a) else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4600.0) tmp = Float64(x + y); elseif (t <= 1.12e+36) tmp = Float64(x + Float64(Float64(y * z) / a)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -4600.0) tmp = x + y; elseif (t <= 1.12e+36) tmp = x + ((y * z) / a); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4600.0], N[(x + y), $MachinePrecision], If[LessEqual[t, 1.12e+36], N[(x + N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -4600:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 1.12 \cdot 10^{+36}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
if t < -4600 or 1.11999999999999999e36 < t Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
if -4600 < t < 1.11999999999999999e36Initial program 85.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6460.6
Applied rewrites60.6%
(FPCore (x y z t a) :precision binary64 (if (<= t -4600.0) (+ x y) (if (<= t 1.12e+36) (+ x (* (/ y a) z)) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4600.0) {
tmp = x + y;
} else if (t <= 1.12e+36) {
tmp = x + ((y / a) * z);
} 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 (t <= (-4600.0d0)) then
tmp = x + y
else if (t <= 1.12d+36) then
tmp = x + ((y / a) * z)
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 (t <= -4600.0) {
tmp = x + y;
} else if (t <= 1.12e+36) {
tmp = x + ((y / a) * z);
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -4600.0: tmp = x + y elif t <= 1.12e+36: tmp = x + ((y / a) * z) else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4600.0) tmp = Float64(x + y); elseif (t <= 1.12e+36) tmp = Float64(x + Float64(Float64(y / a) * z)); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -4600.0) tmp = x + y; elseif (t <= 1.12e+36) tmp = x + ((y / a) * z); else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4600.0], N[(x + y), $MachinePrecision], If[LessEqual[t, 1.12e+36], N[(x + N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -4600:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 1.12 \cdot 10^{+36}:\\
\;\;\;\;x + \frac{y}{a} \cdot z\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
if t < -4600 or 1.11999999999999999e36 < t Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
if -4600 < t < 1.11999999999999999e36Initial program 85.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6460.6
Applied rewrites60.6%
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-/.f6462.1
Applied rewrites62.1%
(FPCore (x y z t a) :precision binary64 (if (<= t -4600.0) (+ x y) (if (<= t 1.12e+36) (fma (/ z a) y x) (+ x y))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4600.0) {
tmp = x + y;
} else if (t <= 1.12e+36) {
tmp = fma((z / a), y, x);
} else {
tmp = x + y;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4600.0) tmp = Float64(x + y); elseif (t <= 1.12e+36) tmp = fma(Float64(z / a), y, x); else tmp = Float64(x + y); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4600.0], N[(x + y), $MachinePrecision], If[LessEqual[t, 1.12e+36], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision], N[(x + y), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;t \leq -4600:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 1.12 \cdot 10^{+36}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
if t < -4600 or 1.11999999999999999e36 < t Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
if -4600 < t < 1.11999999999999999e36Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6497.9
Applied rewrites97.9%
Taylor expanded in t around 0
lower-/.f6462.1
Applied rewrites62.1%
(FPCore (x y z t a) :precision binary64 (if (<= (/ (* y (- z t)) (- a t)) -5e+141) (/ (* y z) a) (+ x y)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((y * (z - t)) / (a - t)) <= -5e+141) {
tmp = (y * z) / a;
} 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 (((y * (z - t)) / (a - t)) <= (-5d+141)) then
tmp = (y * z) / a
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 (((y * (z - t)) / (a - t)) <= -5e+141) {
tmp = (y * z) / a;
} else {
tmp = x + y;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if ((y * (z - t)) / (a - t)) <= -5e+141: tmp = (y * z) / a else: tmp = x + y return tmp
function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(y * Float64(z - t)) / Float64(a - t)) <= -5e+141) tmp = Float64(Float64(y * z) / a); else tmp = Float64(x + y); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (((y * (z - t)) / (a - t)) <= -5e+141) tmp = (y * z) / a; else tmp = x + y; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision], -5e+141], N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision], N[(x + y), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{y \cdot \left(z - t\right)}{a - t} \leq -5 \cdot 10^{+141}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\mathbf{else}:\\
\;\;\;\;x + y\\
\end{array}
if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -5.00000000000000025e141Initial program 85.5%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-flipN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
remove-double-negN/A
lower-fma.f64N/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.0
Applied rewrites98.0%
Taylor expanded in x around 0
lower-/.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower--.f6438.8
Applied rewrites38.8%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6418.5
Applied rewrites18.5%
if -5.00000000000000025e141 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
(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]
x + y
Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
(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
y
Initial program 85.5%
Taylor expanded in t around inf
lower-+.f6460.9
Applied rewrites60.9%
Taylor expanded in x around 0
Applied rewrites18.6%
herbie shell --seed 2025172
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
:precision binary64
(+ x (/ (* y (- z t)) (- a t))))