
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (((y - z) * (t - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x + (((y - z) * (t - x)) / (a - z))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - z) * (t - x)) / (a - z));
}
def code(x, y, z, t, a): return x + (((y - z) * (t - x)) / (a - z))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))) end
function tmp = code(x, y, z, t, a) tmp = x + (((y - z) * (t - x)) / (a - z)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\end{array}
(FPCore (x y z t a) :precision binary64 (if (or (<= z -2.75e+45) (not (<= z 2.1e+69))) (fma (/ (- (- t x)) z) (- y a) t) (+ x (/ (* (- y z) (- t x)) (- a z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -2.75e+45) || !(z <= 2.1e+69)) {
tmp = fma((-(t - x) / z), (y - a), t);
} else {
tmp = x + (((y - z) * (t - x)) / (a - z));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -2.75e+45) || !(z <= 2.1e+69)) tmp = fma(Float64(Float64(-Float64(t - x)) / z), Float64(y - a), t); else tmp = Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -2.75e+45], N[Not[LessEqual[z, 2.1e+69]], $MachinePrecision]], N[(N[((-N[(t - x), $MachinePrecision]) / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+45} \lor \neg \left(z \leq 2.1 \cdot 10^{+69}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-\left(t - x\right)}{z}, y - a, t\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}\\
\end{array}
\end{array}
if z < -2.75e45 or 2.10000000000000015e69 < z Initial program 33.6%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites79.8%
if -2.75e45 < z < 2.10000000000000015e69Initial program 88.3%
Final simplification84.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (/ (- x t) a) z x)))
(if (<= a -2.3e+21)
t_1
(if (<= a 1.6e-196)
(* (/ (- x t) z) y)
(if (<= a 1.4e-69) t (if (<= a 6.4e+91) (* (/ (- t x) a) y) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(((x - t) / a), z, x);
double tmp;
if (a <= -2.3e+21) {
tmp = t_1;
} else if (a <= 1.6e-196) {
tmp = ((x - t) / z) * y;
} else if (a <= 1.4e-69) {
tmp = t;
} else if (a <= 6.4e+91) {
tmp = ((t - x) / a) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(Float64(x - t) / a), z, x) tmp = 0.0 if (a <= -2.3e+21) tmp = t_1; elseif (a <= 1.6e-196) tmp = Float64(Float64(Float64(x - t) / z) * y); elseif (a <= 1.4e-69) tmp = t; elseif (a <= 6.4e+91) tmp = Float64(Float64(Float64(t - x) / a) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(N[(x - t), $MachinePrecision] / a), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[a, -2.3e+21], t$95$1, If[LessEqual[a, 1.6e-196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[a, 1.4e-69], t, If[LessEqual[a, 6.4e+91], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{x - t}{a}, z, x\right)\\
\mathbf{if}\;a \leq -2.3 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-196}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{-69}:\\
\;\;\;\;t\\
\mathbf{elif}\;a \leq 6.4 \cdot 10^{+91}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -2.3e21 or 6.39999999999999979e91 < a Initial program 66.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6467.6
Applied rewrites67.6%
Taylor expanded in z around 0
Applied rewrites59.8%
if -2.3e21 < a < 1.6e-196Initial program 63.8%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites82.2%
Taylor expanded in y around inf
Applied rewrites53.2%
if 1.6e-196 < a < 1.3999999999999999e-69Initial program 48.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.2
Applied rewrites42.2%
Taylor expanded in t around 0
Applied rewrites9.2%
Taylor expanded in z around inf
Applied rewrites3.1%
Taylor expanded in z around inf
Applied rewrites58.1%
if 1.3999999999999999e-69 < a < 6.39999999999999979e91Initial program 73.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6459.2
Applied rewrites59.2%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6458.2
Applied rewrites58.2%
Taylor expanded in y around inf
Applied rewrites48.0%
Final simplification55.6%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ z (- a z)) x)))
(if (<= a -5.5e+22)
t_1
(if (<= a 1.6e-196)
(* (/ (- x t) z) y)
(if (<= a 1.4e-69) t (if (<= a 3.9e+154) (* (/ (- t x) a) y) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, (z / (a - z)), x);
double tmp;
if (a <= -5.5e+22) {
tmp = t_1;
} else if (a <= 1.6e-196) {
tmp = ((x - t) / z) * y;
} else if (a <= 1.4e-69) {
tmp = t;
} else if (a <= 3.9e+154) {
tmp = ((t - x) / a) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(z / Float64(a - z)), x) tmp = 0.0 if (a <= -5.5e+22) tmp = t_1; elseif (a <= 1.6e-196) tmp = Float64(Float64(Float64(x - t) / z) * y); elseif (a <= 1.4e-69) tmp = t; elseif (a <= 3.9e+154) tmp = Float64(Float64(Float64(t - x) / a) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(z / N[(a - z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -5.5e+22], t$95$1, If[LessEqual[a, 1.6e-196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[a, 1.4e-69], t, If[LessEqual[a, 3.9e+154], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{z}{a - z}, x\right)\\
\mathbf{if}\;a \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-196}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{-69}:\\
\;\;\;\;t\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.50000000000000021e22 or 3.9000000000000003e154 < a Initial program 66.7%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6470.1
Applied rewrites70.1%
Taylor expanded in t around 0
Applied rewrites53.5%
if -5.50000000000000021e22 < a < 1.6e-196Initial program 63.8%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites82.2%
Taylor expanded in y around inf
Applied rewrites53.2%
if 1.6e-196 < a < 1.3999999999999999e-69Initial program 48.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.2
Applied rewrites42.2%
Taylor expanded in t around 0
Applied rewrites9.2%
Taylor expanded in z around inf
Applied rewrites3.1%
Taylor expanded in z around inf
Applied rewrites58.1%
if 1.3999999999999999e-69 < a < 3.9000000000000003e154Initial program 69.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6457.3
Applied rewrites57.3%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6461.0
Applied rewrites61.0%
Taylor expanded in y around inf
Applied rewrites42.8%
Final simplification52.0%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ z a) x)))
(if (<= a -5.5e+22)
t_1
(if (<= a 1.6e-196)
(* (/ (- x t) z) y)
(if (<= a 1.4e-69) t (if (<= a 3.9e+154) (* (/ (- t x) a) y) t_1))))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, (z / a), x);
double tmp;
if (a <= -5.5e+22) {
tmp = t_1;
} else if (a <= 1.6e-196) {
tmp = ((x - t) / z) * y;
} else if (a <= 1.4e-69) {
tmp = t;
} else if (a <= 3.9e+154) {
tmp = ((t - x) / a) * y;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(z / a), x) tmp = 0.0 if (a <= -5.5e+22) tmp = t_1; elseif (a <= 1.6e-196) tmp = Float64(Float64(Float64(x - t) / z) * y); elseif (a <= 1.4e-69) tmp = t; elseif (a <= 3.9e+154) tmp = Float64(Float64(Float64(t - x) / a) * y); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(z / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -5.5e+22], t$95$1, If[LessEqual[a, 1.6e-196], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[a, 1.4e-69], t, If[LessEqual[a, 3.9e+154], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{z}{a}, x\right)\\
\mathbf{if}\;a \leq -5.5 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.6 \cdot 10^{-196}:\\
\;\;\;\;\frac{x - t}{z} \cdot y\\
\mathbf{elif}\;a \leq 1.4 \cdot 10^{-69}:\\
\;\;\;\;t\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{+154}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -5.50000000000000021e22 or 3.9000000000000003e154 < a Initial program 66.7%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6470.1
Applied rewrites70.1%
Taylor expanded in t around 0
Applied rewrites53.5%
Taylor expanded in z around 0
Applied rewrites52.8%
if -5.50000000000000021e22 < a < 1.6e-196Initial program 63.8%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites82.2%
Taylor expanded in y around inf
Applied rewrites53.2%
if 1.6e-196 < a < 1.3999999999999999e-69Initial program 48.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.2
Applied rewrites42.2%
Taylor expanded in t around 0
Applied rewrites9.2%
Taylor expanded in z around inf
Applied rewrites3.1%
Taylor expanded in z around inf
Applied rewrites58.1%
if 1.3999999999999999e-69 < a < 3.9000000000000003e154Initial program 69.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6457.3
Applied rewrites57.3%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6461.0
Applied rewrites61.0%
Taylor expanded in y around inf
Applied rewrites42.8%
Final simplification51.7%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -3700.0) (not (<= z 2.05e+65))) (fma (/ (- (- t x)) z) (- y a) t) (fma (- t x) (/ (- y z) a) x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -3700.0) || !(z <= 2.05e+65)) {
tmp = fma((-(t - x) / z), (y - a), t);
} else {
tmp = fma((t - x), ((y - z) / a), x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -3700.0) || !(z <= 2.05e+65)) tmp = fma(Float64(Float64(-Float64(t - x)) / z), Float64(y - a), t); else tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -3700.0], N[Not[LessEqual[z, 2.05e+65]], $MachinePrecision]], N[(N[((-N[(t - x), $MachinePrecision]) / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3700 \lor \neg \left(z \leq 2.05 \cdot 10^{+65}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{-\left(t - x\right)}{z}, y - a, t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\end{array}
\end{array}
if z < -3700 or 2.0500000000000001e65 < z Initial program 36.3%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites79.2%
if -3700 < z < 2.0500000000000001e65Initial program 88.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6482.0
Applied rewrites82.0%
Final simplification80.7%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma x (/ z a) x)))
(if (<= a -3.7e+45)
t_1
(if (<= a 1.62e-52)
(fma a (/ t z) t)
(if (<= a 3.9e+154) (* t (/ y (- a z))) t_1)))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma(x, (z / a), x);
double tmp;
if (a <= -3.7e+45) {
tmp = t_1;
} else if (a <= 1.62e-52) {
tmp = fma(a, (t / z), t);
} else if (a <= 3.9e+154) {
tmp = t * (y / (a - z));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(x, Float64(z / a), x) tmp = 0.0 if (a <= -3.7e+45) tmp = t_1; elseif (a <= 1.62e-52) tmp = fma(a, Float64(t / z), t); elseif (a <= 3.9e+154) tmp = Float64(t * Float64(y / Float64(a - z))); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x * N[(z / a), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[a, -3.7e+45], t$95$1, If[LessEqual[a, 1.62e-52], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[a, 3.9e+154], N[(t * N[(y / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(x, \frac{z}{a}, x\right)\\
\mathbf{if}\;a \leq -3.7 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;a \leq 1.62 \cdot 10^{-52}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\mathbf{elif}\;a \leq 3.9 \cdot 10^{+154}:\\
\;\;\;\;t \cdot \frac{y}{a - z}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if a < -3.69999999999999977e45 or 3.9000000000000003e154 < a Initial program 67.1%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6471.7
Applied rewrites71.7%
Taylor expanded in t around 0
Applied rewrites55.3%
Taylor expanded in z around 0
Applied rewrites54.5%
if -3.69999999999999977e45 < a < 1.61999999999999995e-52Initial program 62.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6430.6
Applied rewrites30.6%
Taylor expanded in x around 0
Applied rewrites36.7%
Taylor expanded in z around inf
Applied rewrites38.2%
if 1.61999999999999995e-52 < a < 3.9000000000000003e154Initial program 69.5%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6458.7
Applied rewrites58.7%
Taylor expanded in y around inf
Applied rewrites38.0%
(FPCore (x y z t a)
:precision binary64
(if (<= z -225.0)
(fma a (/ t z) t)
(if (<= z 1.1e-165)
(* (/ (- t x) a) y)
(if (<= z 82000.0) (fma x (/ z a) x) t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -225.0) {
tmp = fma(a, (t / z), t);
} else if (z <= 1.1e-165) {
tmp = ((t - x) / a) * y;
} else if (z <= 82000.0) {
tmp = fma(x, (z / a), x);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -225.0) tmp = fma(a, Float64(t / z), t); elseif (z <= 1.1e-165) tmp = Float64(Float64(Float64(t - x) / a) * y); elseif (z <= 82000.0) tmp = fma(x, Float64(z / a), x); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -225.0], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 1.1e-165], N[(N[(N[(t - x), $MachinePrecision] / a), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 82000.0], N[(x * N[(z / a), $MachinePrecision] + x), $MachinePrecision], t]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -225:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{-165}:\\
\;\;\;\;\frac{t - x}{a} \cdot y\\
\mathbf{elif}\;z \leq 82000:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -225Initial program 44.6%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in x around 0
Applied rewrites47.8%
Taylor expanded in z around inf
Applied rewrites43.6%
if -225 < z < 1.0999999999999999e-165Initial program 88.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6484.6
Applied rewrites84.6%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6484.9
Applied rewrites84.9%
Taylor expanded in y around inf
Applied rewrites52.6%
if 1.0999999999999999e-165 < z < 82000Initial program 88.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6456.7
Applied rewrites56.7%
Taylor expanded in t around 0
Applied rewrites48.4%
Taylor expanded in z around 0
Applied rewrites48.7%
if 82000 < z Initial program 39.2%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.5
Applied rewrites49.5%
Taylor expanded in t around 0
Applied rewrites12.5%
Taylor expanded in z around inf
Applied rewrites2.6%
Taylor expanded in z around inf
Applied rewrites36.5%
Final simplification45.8%
(FPCore (x y z t a) :precision binary64 (if (<= z -11500.0) (fma (/ x z) (- y a) t) (if (<= z 2.05e+65) (fma (- t x) (/ (- y z) a) x) (fma (/ (- x t) z) y t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -11500.0) {
tmp = fma((x / z), (y - a), t);
} else if (z <= 2.05e+65) {
tmp = fma((t - x), ((y - z) / a), x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -11500.0) tmp = fma(Float64(x / z), Float64(y - a), t); elseif (z <= 2.05e+65) tmp = fma(Float64(t - x), Float64(Float64(y - z) / a), x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -11500.0], N[(N[(x / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 2.05e+65], N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -11500:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y - a, t\right)\\
\mathbf{elif}\;z \leq 2.05 \cdot 10^{+65}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y - z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if z < -11500Initial program 44.6%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites82.0%
Taylor expanded in x around inf
Applied rewrites73.6%
if -11500 < z < 2.0500000000000001e65Initial program 88.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6482.0
Applied rewrites82.0%
if 2.0500000000000001e65 < z Initial program 23.6%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites74.8%
Taylor expanded in a around 0
Applied rewrites71.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -3.7e+45) (not (<= a 4.7e+61))) (fma (/ (- x t) a) z x) (fma (/ (- x t) z) y t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -3.7e+45) || !(a <= 4.7e+61)) {
tmp = fma(((x - t) / a), z, x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -3.7e+45) || !(a <= 4.7e+61)) tmp = fma(Float64(Float64(x - t) / a), z, x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -3.7e+45], N[Not[LessEqual[a, 4.7e+61]], $MachinePrecision]], N[(N[(N[(x - t), $MachinePrecision] / a), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.7 \cdot 10^{+45} \lor \neg \left(a \leq 4.7 \cdot 10^{+61}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{a}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if a < -3.69999999999999977e45 or 4.6999999999999998e61 < a Initial program 66.7%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6467.2
Applied rewrites67.2%
Taylor expanded in z around 0
Applied rewrites60.4%
if -3.69999999999999977e45 < a < 4.6999999999999998e61Initial program 63.5%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites74.9%
Taylor expanded in a around 0
Applied rewrites73.0%
Final simplification67.9%
(FPCore (x y z t a) :precision binary64 (if (<= z -7000.0) (fma (/ x z) (- y a) t) (if (<= z 2.8e+39) (fma (- t x) (/ y a) x) (fma (/ (- x t) z) y t))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -7000.0) {
tmp = fma((x / z), (y - a), t);
} else if (z <= 2.8e+39) {
tmp = fma((t - x), (y / a), x);
} else {
tmp = fma(((x - t) / z), y, t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -7000.0) tmp = fma(Float64(x / z), Float64(y - a), t); elseif (z <= 2.8e+39) tmp = fma(Float64(t - x), Float64(y / a), x); else tmp = fma(Float64(Float64(x - t) / z), y, t); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -7000.0], N[(N[(x / z), $MachinePrecision] * N[(y - a), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 2.8e+39], N[(N[(t - x), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(N[(x - t), $MachinePrecision] / z), $MachinePrecision] * y + t), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7000:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{z}, y - a, t\right)\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+39}:\\
\;\;\;\;\mathsf{fma}\left(t - x, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x - t}{z}, y, t\right)\\
\end{array}
\end{array}
if z < -7e3Initial program 44.6%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites82.0%
Taylor expanded in x around inf
Applied rewrites73.6%
if -7e3 < z < 2.80000000000000001e39Initial program 88.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6480.4
Applied rewrites80.4%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6482.8
Applied rewrites82.8%
Taylor expanded in y around inf
Applied rewrites79.0%
if 2.80000000000000001e39 < z Initial program 27.9%
Taylor expanded in z around inf
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
associate--l-N/A
fp-cancel-sign-subN/A
metadata-evalN/A
*-lft-identityN/A
div-subN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
Applied rewrites72.8%
Taylor expanded in a around 0
Applied rewrites69.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= a -3.7e+45) (not (<= a 1.3e+41))) (fma x (/ z a) x) (fma a (/ t z) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((a <= -3.7e+45) || !(a <= 1.3e+41)) {
tmp = fma(x, (z / a), x);
} else {
tmp = fma(a, (t / z), t);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((a <= -3.7e+45) || !(a <= 1.3e+41)) tmp = fma(x, Float64(z / a), x); else tmp = fma(a, Float64(t / z), t); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[a, -3.7e+45], N[Not[LessEqual[a, 1.3e+41]], $MachinePrecision]], N[(x * N[(z / a), $MachinePrecision] + x), $MachinePrecision], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.7 \cdot 10^{+45} \lor \neg \left(a \leq 1.3 \cdot 10^{+41}\right):\\
\;\;\;\;\mathsf{fma}\left(x, \frac{z}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\end{array}
\end{array}
if a < -3.69999999999999977e45 or 1.3e41 < a Initial program 67.3%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6466.0
Applied rewrites66.0%
Taylor expanded in t around 0
Applied rewrites49.3%
Taylor expanded in z around 0
Applied rewrites48.7%
if -3.69999999999999977e45 < a < 1.3e41Initial program 63.0%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6430.4
Applied rewrites30.4%
Taylor expanded in x around 0
Applied rewrites35.7%
Taylor expanded in z around inf
Applied rewrites36.4%
Final simplification41.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -36.0) (not (<= z 72000.0))) t (* t (/ y a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -36.0) || !(z <= 72000.0)) {
tmp = t;
} else {
tmp = t * (y / 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 ((z <= (-36.0d0)) .or. (.not. (z <= 72000.0d0))) then
tmp = t
else
tmp = t * (y / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -36.0) || !(z <= 72000.0)) {
tmp = t;
} else {
tmp = t * (y / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -36.0) or not (z <= 72000.0): tmp = t else: tmp = t * (y / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -36.0) || !(z <= 72000.0)) tmp = t; else tmp = Float64(t * Float64(y / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -36.0) || ~((z <= 72000.0))) tmp = t; else tmp = t * (y / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -36.0], N[Not[LessEqual[z, 72000.0]], $MachinePrecision]], t, N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -36 \lor \neg \left(z \leq 72000\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\end{array}
\end{array}
if z < -36 or 72000 < z Initial program 42.1%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6448.7
Applied rewrites48.7%
Taylor expanded in t around 0
Applied rewrites11.7%
Taylor expanded in z around inf
Applied rewrites3.0%
Taylor expanded in z around inf
Applied rewrites40.3%
if -36 < z < 72000Initial program 88.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6482.5
Applied rewrites82.5%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6484.4
Applied rewrites84.4%
Taylor expanded in x around 0
Applied rewrites32.7%
Taylor expanded in y around inf
Applied rewrites34.6%
Final simplification37.5%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -43.0) (not (<= z 1.7e-5))) t (/ (* t y) a)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -43.0) || !(z <= 1.7e-5)) {
tmp = t;
} else {
tmp = (t * y) / 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 ((z <= (-43.0d0)) .or. (.not. (z <= 1.7d-5))) then
tmp = t
else
tmp = (t * y) / a
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -43.0) || !(z <= 1.7e-5)) {
tmp = t;
} else {
tmp = (t * y) / a;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -43.0) or not (z <= 1.7e-5): tmp = t else: tmp = (t * y) / a return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -43.0) || !(z <= 1.7e-5)) tmp = t; else tmp = Float64(Float64(t * y) / a); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -43.0) || ~((z <= 1.7e-5))) tmp = t; else tmp = (t * y) / a; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -43.0], N[Not[LessEqual[z, 1.7e-5]], $MachinePrecision]], t, N[(N[(t * y), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -43 \lor \neg \left(z \leq 1.7 \cdot 10^{-5}\right):\\
\;\;\;\;t\\
\mathbf{else}:\\
\;\;\;\;\frac{t \cdot y}{a}\\
\end{array}
\end{array}
if z < -43 or 1.7e-5 < z Initial program 42.4%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6448.8
Applied rewrites48.8%
Taylor expanded in t around 0
Applied rewrites12.9%
Taylor expanded in z around inf
Applied rewrites3.0%
Taylor expanded in z around inf
Applied rewrites39.2%
if -43 < z < 1.7e-5Initial program 89.8%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6442.0
Applied rewrites42.0%
Taylor expanded in z around 0
Applied rewrites29.5%
Final simplification34.6%
(FPCore (x y z t a) :precision binary64 (if (<= z -0.74) (fma a (/ t z) t) (if (<= z 72000.0) (* t (/ y a)) t)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (z <= -0.74) {
tmp = fma(a, (t / z), t);
} else if (z <= 72000.0) {
tmp = t * (y / a);
} else {
tmp = t;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (z <= -0.74) tmp = fma(a, Float64(t / z), t); elseif (z <= 72000.0) tmp = Float64(t * Float64(y / a)); else tmp = t; end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[z, -0.74], N[(a * N[(t / z), $MachinePrecision] + t), $MachinePrecision], If[LessEqual[z, 72000.0], N[(t * N[(y / a), $MachinePrecision]), $MachinePrecision], t]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.74:\\
\;\;\;\;\mathsf{fma}\left(a, \frac{t}{z}, t\right)\\
\mathbf{elif}\;z \leq 72000:\\
\;\;\;\;t \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
\end{array}
if z < -0.73999999999999999Initial program 43.5%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6447.8
Applied rewrites47.8%
Taylor expanded in x around 0
Applied rewrites46.5%
Taylor expanded in z around inf
Applied rewrites42.5%
if -0.73999999999999999 < z < 72000Initial program 89.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6483.8
Applied rewrites83.8%
Taylor expanded in a around inf
+-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6484.1
Applied rewrites84.1%
Taylor expanded in x around 0
Applied rewrites33.2%
Taylor expanded in y around inf
Applied rewrites35.1%
if 72000 < z Initial program 39.2%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6449.5
Applied rewrites49.5%
Taylor expanded in t around 0
Applied rewrites12.5%
Taylor expanded in z around inf
Applied rewrites2.6%
Taylor expanded in z around inf
Applied rewrites36.5%
Final simplification37.5%
(FPCore (x y z t a) :precision binary64 t)
double code(double x, double y, double z, double t, double a) {
return 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 = t
end function
public static double code(double x, double y, double z, double t, double a) {
return t;
}
def code(x, y, z, t, a): return t
function code(x, y, z, t, a) return t end
function tmp = code(x, y, z, t, a) tmp = t; end
code[x_, y_, z_, t_, a_] := t
\begin{array}{l}
\\
t
\end{array}
Initial program 64.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6445.0
Applied rewrites45.0%
Taylor expanded in t around 0
Applied rewrites23.4%
Taylor expanded in z around inf
Applied rewrites2.9%
Taylor expanded in z around inf
Applied rewrites23.4%
Final simplification23.4%
(FPCore (x y z t a) :precision binary64 0.0)
double code(double x, double y, double z, double t, double a) {
return 0.0;
}
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 = 0.0d0
end function
public static double code(double x, double y, double z, double t, double a) {
return 0.0;
}
def code(x, y, z, t, a): return 0.0
function code(x, y, z, t, a) return 0.0 end
function tmp = code(x, y, z, t, a) tmp = 0.0; end
code[x_, y_, z_, t_, a_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 64.8%
Taylor expanded in y around 0
+-commutativeN/A
mul-1-negN/A
*-commutativeN/A
associate-/l*N/A
distribute-lft-neg-inN/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6445.0
Applied rewrites45.0%
Taylor expanded in t around 0
Applied rewrites23.4%
Taylor expanded in z around inf
Applied rewrites2.9%
Taylor expanded in x around 0
Applied rewrites2.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- t (* (/ y z) (- t x)))))
(if (< z -1.2536131056095036e+188)
t_1
(if (< z 4.446702369113811e+64)
(+ x (/ (- y z) (/ (- a z) (- t x))))
t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = t - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - x)));
} 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 - ((y / z) * (t - x))
if (z < (-1.2536131056095036d+188)) then
tmp = t_1
else if (z < 4.446702369113811d+64) then
tmp = x + ((y - z) / ((a - z) / (t - x)))
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 - ((y / z) * (t - x));
double tmp;
if (z < -1.2536131056095036e+188) {
tmp = t_1;
} else if (z < 4.446702369113811e+64) {
tmp = x + ((y - z) / ((a - z) / (t - x)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a): t_1 = t - ((y / z) * (t - x)) tmp = 0 if z < -1.2536131056095036e+188: tmp = t_1 elif z < 4.446702369113811e+64: tmp = x + ((y - z) / ((a - z) / (t - x))) else: tmp = t_1 return tmp
function code(x, y, z, t, a) t_1 = Float64(t - Float64(Float64(y / z) * Float64(t - x))) tmp = 0.0 if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = Float64(x + Float64(Float64(y - z) / Float64(Float64(a - z) / Float64(t - x)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t, a) t_1 = t - ((y / z) * (t - x)); tmp = 0.0; if (z < -1.2536131056095036e+188) tmp = t_1; elseif (z < 4.446702369113811e+64) tmp = x + ((y - z) / ((a - z) / (t - x))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t - N[(N[(y / z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[z, -1.2536131056095036e+188], t$95$1, If[Less[z, 4.446702369113811e+64], N[(x + N[(N[(y - z), $MachinePrecision] / N[(N[(a - z), $MachinePrecision] / N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t - \frac{y}{z} \cdot \left(t - x\right)\\
\mathbf{if}\;z < -1.2536131056095036 \cdot 10^{+188}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2025015
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -125361310560950360000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- t (* (/ y z) (- t x))) (if (< z 44467023691138110000000000000000000000000000000000000000000000000) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x))))))
(+ x (/ (* (- y z) (- t x)) (- a z))))