
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (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 - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (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 - x) * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t z) (- t a)) (- y x) x)))
(if (<= y -1.35e+26)
t_1
(if (<= y 4000.0)
(-
(* x (+ (/ a (- a t)) (/ z (- t a))))
(* -1.0 (/ (* y (- t z)) (- t a))))
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - z) / (t - a)), (y - x), x);
double tmp;
if (y <= -1.35e+26) {
tmp = t_1;
} else if (y <= 4000.0) {
tmp = (x * ((a / (a - t)) + (z / (t - a)))) - (-1.0 * ((y * (t - z)) / (t - a)));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x) tmp = 0.0 if (y <= -1.35e+26) tmp = t_1; elseif (y <= 4000.0) tmp = Float64(Float64(x * Float64(Float64(a / Float64(a - t)) + Float64(z / Float64(t - a)))) - Float64(-1.0 * Float64(Float64(y * Float64(t - z)) / Float64(t - 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] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[y, -1.35e+26], t$95$1, If[LessEqual[y, 4000.0], N[(N[(x * N[(N[(a / N[(a - t), $MachinePrecision]), $MachinePrecision] + N[(z / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(y * N[(t - z), $MachinePrecision]), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4000:\\
\;\;\;\;x \cdot \left(\frac{a}{a - t} + \frac{z}{t - a}\right) - -1 \cdot \frac{y \cdot \left(t - z\right)}{t - a}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.35e26 or 4e3 < y Initial program 67.6%
Applied rewrites84.0%
if -1.35e26 < y < 4e3Initial program 67.6%
Applied rewrites84.0%
Applied rewrites76.8%
Taylor expanded in x around 0
Applied rewrites82.3%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- t z) (- t a)) (- y x) x))
(t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_2 -5e-253)
t_1
(if (<= t_2 0.0)
(+ y (* -1.0 (/ (- (* z (- y x)) (* a (- y x))) t)))
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((t - z) / (t - a)), (y - x), x);
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -5e-253) {
tmp = t_1;
} else if (t_2 <= 0.0) {
tmp = y + (-1.0 * (((z * (y - x)) - (a * (y - x))) / t));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x) t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_2 <= -5e-253) tmp = t_1; elseif (t_2 <= 0.0) tmp = Float64(y + Float64(-1.0 * Float64(Float64(Float64(z * Float64(y - x)) - Float64(a * Float64(y - x))) / t))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -5e-253], t$95$1, If[LessEqual[t$95$2, 0.0], N[(y + N[(-1.0 * N[(N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] - N[(a * N[(y - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{-253}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 0:\\
\;\;\;\;y + -1 \cdot \frac{z \cdot \left(y - x\right) - a \cdot \left(y - x\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -4.99999999999999971e-253 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 67.6%
Applied rewrites84.0%
if -4.99999999999999971e-253 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 67.6%
Taylor expanded in t around -inf
Applied rewrites46.1%
(FPCore (x y z t a) :precision binary64 (fma (/ (- t z) (- t a)) (- y x) x))
double code(double x, double y, double z, double t, double a) {
return fma(((t - z) / (t - a)), (y - x), x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(t - z) / Float64(t - a)), Float64(y - x), x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{t - z}{t - a}, y - x, x\right)
\end{array}
Initial program 67.6%
Applied rewrites84.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- t z) (- t a)) y)))
(if (<= t -3.35)
t_1
(if (<= t 2.9e+20)
(fma (/ z a) (- y x) x)
(if (<= t 3.9e+122) (fma (/ (- t z) t) (- y x) x) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((t - z) / (t - a)) * y;
double tmp;
if (t <= -3.35) {
tmp = t_1;
} else if (t <= 2.9e+20) {
tmp = fma((z / a), (y - x), x);
} else if (t <= 3.9e+122) {
tmp = fma(((t - z) / t), (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y) tmp = 0.0 if (t <= -3.35) tmp = t_1; elseif (t <= 2.9e+20) tmp = fma(Float64(z / a), Float64(y - x), x); elseif (t <= 3.9e+122) tmp = fma(Float64(Float64(t - z) / t), Float64(y - x), 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] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 2.9e+20], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 3.9e+122], N[(N[(N[(t - z), $MachinePrecision] / t), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{elif}\;t \leq 3.9 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t - z}{t}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.35000000000000009 or 3.8999999999999999e122 < t Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Applied rewrites52.3%
if -3.35000000000000009 < t < 2.9e20Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
if 2.9e20 < t < 3.8999999999999999e122Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in a around 0
Applied rewrites38.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* (/ (- t z) (- t a)) y)))
(if (<= t -4.2e+45)
t_1
(if (<= t 1.15e+107) (+ x (/ (* z (- y x)) (- a t))) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((t - z) / (t - a)) * y;
double tmp;
if (t <= -4.2e+45) {
tmp = t_1;
} else if (t <= 1.15e+107) {
tmp = x + ((z * (y - x)) / (a - t));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = ((t - z) / (t - a)) * y
if (t <= (-4.2d+45)) then
tmp = t_1
else if (t <= 1.15d+107) then
tmp = x + ((z * (y - x)) / (a - t))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double t_1 = ((t - z) / (t - a)) * y;
double tmp;
if (t <= -4.2e+45) {
tmp = t_1;
} else if (t <= 1.15e+107) {
tmp = x + ((z * (y - x)) / (a - t));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = ((t - z) / (t - a)) * y tmp = 0 if t <= -4.2e+45: tmp = t_1 elif t <= 1.15e+107: tmp = x + ((z * (y - x)) / (a - t)) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y) tmp = 0.0 if (t <= -4.2e+45) tmp = t_1; elseif (t <= 1.15e+107) tmp = Float64(x + Float64(Float64(z * Float64(y - x)) / Float64(a - t))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = ((t - z) / (t - a)) * y; tmp = 0.0; if (t <= -4.2e+45) tmp = t_1; elseif (t <= 1.15e+107) tmp = x + ((z * (y - x)) / (a - t)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -4.2e+45], t$95$1, If[LessEqual[t, 1.15e+107], N[(x + N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -4.2 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+107}:\\
\;\;\;\;x + \frac{z \cdot \left(y - x\right)}{a - t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -4.1999999999999999e45 or 1.15e107 < t Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Applied rewrites52.3%
if -4.1999999999999999e45 < t < 1.15e107Initial program 67.6%
Taylor expanded in z around inf
Applied rewrites54.6%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ (- t z) (- t a)) y))) (if (<= t -3.35) t_1 (if (<= t 1.58e-49) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = ((t - z) / (t - a)) * y;
double tmp;
if (t <= -3.35) {
tmp = t_1;
} else if (t <= 1.58e-49) {
tmp = fma((z / a), (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(Float64(t - z) / Float64(t - a)) * y) tmp = 0.0 if (t <= -3.35) tmp = t_1; elseif (t <= 1.58e-49) tmp = fma(Float64(z / a), Float64(y - x), 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] / N[(t - a), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 1.58e-49], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{t - z}{t - a} \cdot y\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.35000000000000009 or 1.58e-49 < t Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Applied rewrites52.3%
if -3.35000000000000009 < t < 1.58e-49Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (* (/ y (- t a)) (- t z)))) (if (<= t -3.35) t_1 (if (<= t 1.58e-49) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = (y / (t - a)) * (t - z);
double tmp;
if (t <= -3.35) {
tmp = t_1;
} else if (t <= 1.58e-49) {
tmp = fma((z / a), (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = Float64(Float64(y / Float64(t - a)) * Float64(t - z)) tmp = 0.0 if (t <= -3.35) tmp = t_1; elseif (t <= 1.58e-49) tmp = fma(Float64(z / a), Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3.35], t$95$1, If[LessEqual[t, 1.58e-49], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{y}{t - a} \cdot \left(t - z\right)\\
\mathbf{if}\;t \leq -3.35:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.58 \cdot 10^{-49}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.35000000000000009 or 1.58e-49 < t Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Applied rewrites46.6%
if -3.35000000000000009 < t < 1.58e-49Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (/ y (- t a)) t x))) (if (<= t -5.8e+46) t_1 (if (<= t 6.8e-58) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((y / (t - a)), t, x);
double tmp;
if (t <= -5.8e+46) {
tmp = t_1;
} else if (t <= 6.8e-58) {
tmp = fma((z / a), (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(y / Float64(t - a)), t, x) tmp = 0.0 if (t <= -5.8e+46) tmp = t_1; elseif (t <= 6.8e-58) tmp = fma(Float64(z / a), Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y / N[(t - a), $MachinePrecision]), $MachinePrecision] * t + x), $MachinePrecision]}, If[LessEqual[t, -5.8e+46], t$95$1, If[LessEqual[t, 6.8e-58], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{y}{t - a}, t, x\right)\\
\mathbf{if}\;t \leq -5.8 \cdot 10^{+46}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 6.8 \cdot 10^{-58}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -5.8000000000000004e46 or 6.79999999999999947e-58 < t Initial program 67.6%
Applied rewrites80.1%
Taylor expanded in z around 0
Applied rewrites46.3%
Taylor expanded in x around 0
Applied rewrites44.6%
if -5.8000000000000004e46 < t < 6.79999999999999947e-58Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.42e+119) (fma 1.0 (- y x) x) (if (<= t 2e+196) (fma (/ z a) (- y x) x) (fma (/ (- y x) t) t x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.42e+119) {
tmp = fma(1.0, (y - x), x);
} else if (t <= 2e+196) {
tmp = fma((z / a), (y - x), x);
} else {
tmp = fma(((y - x) / t), t, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.42e+119) tmp = fma(1.0, Float64(y - x), x); elseif (t <= 2e+196) tmp = fma(Float64(z / a), Float64(y - x), x); else tmp = fma(Float64(Float64(y - x) / t), t, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.42e+119], N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 2e+196], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] * t + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y - x}{t}, t, x\right)\\
\end{array}
\end{array}
if t < -1.4199999999999999e119Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around inf
Applied rewrites19.4%
if -1.4199999999999999e119 < t < 1.9999999999999999e196Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
if 1.9999999999999999e196 < t Initial program 67.6%
Applied rewrites80.1%
Taylor expanded in z around 0
Applied rewrites46.3%
Taylor expanded in t around inf
Applied rewrites21.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma 1.0 (- y x) x))) (if (<= t -1.42e+119) t_1 (if (<= t 2e+196) (fma (/ z a) (- y x) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(1.0, (y - x), x);
double tmp;
if (t <= -1.42e+119) {
tmp = t_1;
} else if (t <= 2e+196) {
tmp = fma((z / a), (y - x), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(1.0, Float64(y - x), x) tmp = 0.0 if (t <= -1.42e+119) tmp = t_1; elseif (t <= 2e+196) tmp = fma(Float64(z / a), Float64(y - x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.42e+119], t$95$1, If[LessEqual[t, 2e+196], N[(N[(z / a), $MachinePrecision] * N[(y - x), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -1.42 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2 \cdot 10^{+196}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y - x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.4199999999999999e119 or 1.9999999999999999e196 < t Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around inf
Applied rewrites19.4%
if -1.4199999999999999e119 < t < 1.9999999999999999e196Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around 0
Applied rewrites48.9%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma 1.0 (- y x) x))) (if (<= t -1.22e+39) t_1 (if (<= t 8e+49) (/ (* y z) (- a t)) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(1.0, (y - x), x);
double tmp;
if (t <= -1.22e+39) {
tmp = t_1;
} else if (t <= 8e+49) {
tmp = (y * z) / (a - t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(1.0, Float64(y - x), x) tmp = 0.0 if (t <= -1.22e+39) tmp = t_1; elseif (t <= 8e+49) tmp = Float64(Float64(y * z) / Float64(a - t)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -1.22e+39], t$95$1, If[LessEqual[t, 8e+49], N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -1.22 \cdot 10^{+39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 8 \cdot 10^{+49}:\\
\;\;\;\;\frac{y \cdot z}{a - t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.22e39 or 7.99999999999999957e49 < t Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around inf
Applied rewrites19.4%
if -1.22e39 < t < 7.99999999999999957e49Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Taylor expanded in z around inf
Applied rewrites21.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma 1.0 (- y x) x))) (if (<= t -470.0) t_1 (if (<= t 3e+43) (* (/ z a) y) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(1.0, (y - x), x);
double tmp;
if (t <= -470.0) {
tmp = t_1;
} else if (t <= 3e+43) {
tmp = (z / a) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(1.0, Float64(y - x), x) tmp = 0.0 if (t <= -470.0) tmp = t_1; elseif (t <= 3e+43) tmp = Float64(Float64(z / a) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(1.0 * N[(y - x), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t, -470.0], t$95$1, If[LessEqual[t, 3e+43], N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1, y - x, x\right)\\
\mathbf{if}\;t \leq -470:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 3 \cdot 10^{+43}:\\
\;\;\;\;\frac{z}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -470 or 3.00000000000000017e43 < t Initial program 67.6%
Applied rewrites84.0%
Taylor expanded in t around inf
Applied rewrites19.4%
if -470 < t < 3.00000000000000017e43Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Taylor expanded in t around 0
Applied rewrites16.9%
Applied rewrites19.4%
(FPCore (x y z t a) :precision binary64 (* (/ z a) y))
double code(double x, double y, double z, double t, double a) {
return (z / a) * 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 = (z / a) * y
end function
public static double code(double x, double y, double z, double t, double a) {
return (z / a) * y;
}
def code(x, y, z, t, a): return (z / a) * y
function code(x, y, z, t, a) return Float64(Float64(z / a) * y) end
function tmp = code(x, y, z, t, a) tmp = (z / a) * y; end
code[x_, y_, z_, t_, a_] := N[(N[(z / a), $MachinePrecision] * y), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{a} \cdot y
\end{array}
Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Taylor expanded in t around 0
Applied rewrites16.9%
Applied rewrites19.4%
(FPCore (x y z t a) :precision binary64 (* (/ y a) z))
double code(double x, double y, double z, double t, double a) {
return (y / 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 = (y / a) * z
end function
public static double code(double x, double y, double z, double t, double a) {
return (y / a) * z;
}
def code(x, y, z, t, a): return (y / a) * z
function code(x, y, z, t, a) return Float64(Float64(y / a) * z) end
function tmp = code(x, y, z, t, a) tmp = (y / a) * z; end
code[x_, y_, z_, t_, a_] := N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{a} \cdot z
\end{array}
Initial program 67.6%
Taylor expanded in x around 0
Applied rewrites39.9%
Taylor expanded in t around 0
Applied rewrites16.9%
Applied rewrites18.2%
herbie shell --seed 2025153
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
(+ x (/ (* (- y x) (- z t)) (- a t))))