
(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]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
Herbie found 10 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]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) (- a t)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (a - t)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(a - t)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)
\end{array}
Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
(FPCore (x y z t a) :precision binary64 (if (<= t -4000000.0) (fma (- 1.0 (/ z t)) y x) (if (<= t 0.061) (fma (/ z (- a t)) y x) (fma (/ (- t) (- a t)) y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4000000.0) {
tmp = fma((1.0 - (z / t)), y, x);
} else if (t <= 0.061) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = fma((-t / (a - t)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4000000.0) tmp = fma(Float64(1.0 - Float64(z / t)), y, x); elseif (t <= 0.061) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = fma(Float64(Float64(-t) / Float64(a - t)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4000000.0], N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 0.061], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[((-t) / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4000000:\\
\;\;\;\;\mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 0.061:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-t}{a - t}, y, x\right)\\
\end{array}
\end{array}
if t < -4e6Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in t around -inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f6460.0
Applied rewrites60.0%
Taylor expanded in a around 0
lower--.f64N/A
lower-/.f6466.0
Applied rewrites66.0%
if -4e6 < t < 0.060999999999999999Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f6476.0
Applied rewrites76.0%
if 0.060999999999999999 < t Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in z around 0
mul-1-negN/A
lift-neg.f6472.1
Applied rewrites72.1%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- 1.0 (/ z t)) y x)))
(if (<= t -4000000.0)
t_1
(if (<= t 6600000000.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((1.0 - (z / t)), y, x);
double tmp;
if (t <= -4000000.0) {
tmp = t_1;
} else if (t <= 6600000000.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(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -4000000.0) tmp = t_1; elseif (t <= 6600000000.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[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -4000000.0], t$95$1, If[LessEqual[t, 6600000000.0], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -4000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 6600000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4e6 or 6.6e9 < t Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in t around -inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f6460.0
Applied rewrites60.0%
Taylor expanded in a around 0
lower--.f64N/A
lower-/.f6466.0
Applied rewrites66.0%
if -4e6 < t < 6.6e9Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in z around inf
lower-/.f64N/A
lift--.f6476.0
Applied rewrites76.0%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z t)) y x))) (if (<= t -280000.0) t_1 (if (<= t 7.3e-53) (fma y (/ (- z t) a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -280000.0) {
tmp = t_1;
} else if (t <= 7.3e-53) {
tmp = fma(y, ((z - t) / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -280000.0) tmp = t_1; elseif (t <= 7.3e-53) tmp = fma(y, Float64(Float64(z - t) / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -280000.0], t$95$1, If[LessEqual[t, 7.3e-53], N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -280000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7.3 \cdot 10^{-53}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.8e5 or 7.30000000000000017e-53 < t Initial program 84.9%
lift-+.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
+-commutativeN/A
associate-/l*N/A
sub-divN/A
*-commutativeN/A
lower-fma.f64N/A
sub-divN/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.2
Applied rewrites98.2%
Taylor expanded in t around -inf
+-commutativeN/A
lower-+.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower--.f6460.0
Applied rewrites60.0%
Taylor expanded in a around 0
lower--.f64N/A
lower-/.f6466.0
Applied rewrites66.0%
if -2.8e5 < t < 7.30000000000000017e-53Initial program 84.9%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6460.8
Applied rewrites60.8%
(FPCore (x y z t a) :precision binary64 (if (<= t -310000.0) (+ y x) (if (<= t 5.2e+15) (fma y (/ (- z t) a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -310000.0) {
tmp = y + x;
} else if (t <= 5.2e+15) {
tmp = fma(y, ((z - t) / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -310000.0) tmp = Float64(y + x); elseif (t <= 5.2e+15) tmp = fma(y, Float64(Float64(z - t) / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -310000.0], N[(y + x), $MachinePrecision], If[LessEqual[t, 5.2e+15], N[(y * N[(N[(z - t), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -310000:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 5.2 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -3.1e5 or 5.2e15 < t Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
if -3.1e5 < t < 5.2e15Initial program 84.9%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6460.8
Applied rewrites60.8%
(FPCore (x y z t a) :precision binary64 (if (<= t -4000000.0) (+ y x) (if (<= t 3.9e-50) (fma y (/ z a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4000000.0) {
tmp = y + x;
} else if (t <= 3.9e-50) {
tmp = fma(y, (z / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4000000.0) tmp = Float64(y + x); elseif (t <= 3.9e-50) tmp = fma(y, Float64(z / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4000000.0], N[(y + x), $MachinePrecision], If[LessEqual[t, 3.9e-50], N[(y * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4000000:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 3.9 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -4e6 or 3.90000000000000021e-50 < t Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
if -4e6 < t < 3.90000000000000021e-50Initial program 84.9%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6461.4
Applied rewrites61.4%
(FPCore (x y z t a) :precision binary64 (if (<= y 4.3e+167) (+ y x) (* y (/ z a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 4.3e+167) {
tmp = y + x;
} else {
tmp = y * (z / a);
}
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 <= 4.3d+167) then
tmp = y + x
else
tmp = y * (z / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 4.3e+167) {
tmp = y + x;
} else {
tmp = y * (z / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 4.3e+167: tmp = y + x else: tmp = y * (z / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 4.3e+167) tmp = Float64(y + x); else tmp = Float64(y * Float64(z / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= 4.3e+167) tmp = y + x; else tmp = y * (z / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 4.3e+167], N[(y + x), $MachinePrecision], N[(y * N[(z / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+167}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z}{a}\\
\end{array}
\end{array}
if y < 4.3000000000000002e167Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
if 4.3000000000000002e167 < y Initial program 84.9%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lift--.f6460.8
Applied rewrites60.8%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f6420.0
Applied rewrites20.0%
(FPCore (x y z t a) :precision binary64 (if (<= y 4.3e+167) (+ y x) (/ (* y z) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 4.3e+167) {
tmp = y + x;
} else {
tmp = (y * z) / a;
}
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 <= 4.3d+167) then
tmp = y + x
else
tmp = (y * z) / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (y <= 4.3e+167) {
tmp = y + x;
} else {
tmp = (y * z) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if y <= 4.3e+167: tmp = y + x else: tmp = (y * z) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if (y <= 4.3e+167) tmp = Float64(y + x); else tmp = Float64(Float64(y * z) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (y <= 4.3e+167) tmp = y + x; else tmp = (y * z) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[y, 4.3e+167], N[(y + x), $MachinePrecision], N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.3 \cdot 10^{+167}:\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot z}{a}\\
\end{array}
\end{array}
if y < 4.3000000000000002e167Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
if 4.3000000000000002e167 < y Initial program 84.9%
Taylor expanded in z around inf
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6428.3
Applied rewrites28.3%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6418.4
Applied rewrites18.4%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + x;
}
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 + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
(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 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6460.1
Applied rewrites60.1%
Taylor expanded in x around 0
Applied rewrites18.9%
herbie shell --seed 2025131
(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))))