
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ x (- y (* z t))))
double code(double x, double y, double z, double t) {
return x / (y - (z * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / (y - (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x / (y - (z * t));
}
def code(x, y, z, t): return x / (y - (z * t))
function code(x, y, z, t) return Float64(x / Float64(y - Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x / (y - (z * t)); end
code[x_, y_, z_, t_] := N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - z \cdot t}
\end{array}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+230) (/ (* (/ x t) -1.0) z) (* -1.0 (/ x (* -1.0 (fma (* -1.0 t) z y))))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+230) {
tmp = ((x / t) * -1.0) / z;
} else {
tmp = -1.0 * (x / (-1.0 * fma((-1.0 * t), z, y)));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+230) tmp = Float64(Float64(Float64(x / t) * -1.0) / z); else tmp = Float64(-1.0 * Float64(x / Float64(-1.0 * fma(Float64(-1.0 * t), z, y)))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+230], N[(N[(N[(x / t), $MachinePrecision] * -1.0), $MachinePrecision] / z), $MachinePrecision], N[(-1.0 * N[(x / N[(-1.0 * N[(N[(-1.0 * t), $MachinePrecision] * z + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+230}:\\
\;\;\;\;\frac{\frac{x}{t} \cdot -1}{z}\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \frac{x}{-1 \cdot \mathsf{fma}\left(-1 \cdot t, z, y\right)}\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000003e230Initial program 77.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
frac-2negN/A
mul-1-negN/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f6477.5
Applied rewrites77.5%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
frac-timesN/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
if -5.0000000000000003e230 < (*.f64 z t) Initial program 98.3%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
frac-2negN/A
mul-1-negN/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f6498.3
Applied rewrites98.3%
Final simplification98.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (if (<= (* z t) -5e+230) (/ (* (/ x t) -1.0) z) (/ x (- y (* z t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+230) {
tmp = ((x / t) * -1.0) / z;
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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)
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) :: tmp
if ((z * t) <= (-5d+230)) then
tmp = ((x / t) * (-1.0d0)) / z
else
tmp = x / (y - (z * t))
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -5e+230) {
tmp = ((x / t) * -1.0) / z;
} else {
tmp = x / (y - (z * t));
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): tmp = 0 if (z * t) <= -5e+230: tmp = ((x / t) * -1.0) / z else: tmp = x / (y - (z * t)) return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -5e+230) tmp = Float64(Float64(Float64(x / t) * -1.0) / z); else tmp = Float64(x / Float64(y - Float64(z * t))); end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if ((z * t) <= -5e+230)
tmp = ((x / t) * -1.0) / z;
else
tmp = x / (y - (z * t));
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -5e+230], N[(N[(N[(x / t), $MachinePrecision] * -1.0), $MachinePrecision] / z), $MachinePrecision], N[(x / N[(y - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+230}:\\
\;\;\;\;\frac{\frac{x}{t} \cdot -1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - z \cdot t}\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000003e230Initial program 77.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
frac-2negN/A
mul-1-negN/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f6477.5
Applied rewrites77.5%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
frac-timesN/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f6499.8
Applied rewrites99.8%
if -5.0000000000000003e230 < (*.f64 z t) Initial program 98.3%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* (/ x t) -1.0) z)))
(if (<= (* z t) -2e-136)
t_1
(if (<= (* z t) 5e-46)
(- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y)))
t_1))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = ((x / t) * -1.0) / z;
double tmp;
if ((z * t) <= -2e-136) {
tmp = t_1;
} else if ((z * t) <= 5e-46) {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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)
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) :: t_1
real(8) :: tmp
t_1 = ((x / t) * (-1.0d0)) / z
if ((z * t) <= (-2d-136)) then
tmp = t_1
else if ((z * t) <= 5d-46) then
tmp = ((((z * x) * t) / y) / y) - ((-1.0d0) * (x / y))
else
tmp = t_1
end if
code = tmp
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
double t_1 = ((x / t) * -1.0) / z;
double tmp;
if ((z * t) <= -2e-136) {
tmp = t_1;
} else if ((z * t) <= 5e-46) {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
} else {
tmp = t_1;
}
return tmp;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = ((x / t) * -1.0) / z tmp = 0 if (z * t) <= -2e-136: tmp = t_1 elif (z * t) <= 5e-46: tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y)) else: tmp = t_1 return tmp
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(Float64(x / t) * -1.0) / z) tmp = 0.0 if (Float64(z * t) <= -2e-136) tmp = t_1; elseif (Float64(z * t) <= 5e-46) tmp = Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))); else tmp = t_1; end return tmp end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp_2 = code(x, y, z, t)
t_1 = ((x / t) * -1.0) / z;
tmp = 0.0;
if ((z * t) <= -2e-136)
tmp = t_1;
elseif ((z * t) <= 5e-46)
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x / t), $MachinePrecision] * -1.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -2e-136], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e-46], N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{\frac{x}{t} \cdot -1}{z}\\
\mathbf{if}\;z \cdot t \leq -2 \cdot 10^{-136}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{-46}:\\
\;\;\;\;\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -2e-136 or 4.99999999999999992e-46 < (*.f64 z t) Initial program 94.6%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
frac-2negN/A
mul-1-negN/A
lower-/.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
fp-cancel-sub-sign-invN/A
mul-1-negN/A
associate-*r*N/A
+-commutativeN/A
associate-*r*N/A
mul-1-negN/A
lower-fma.f64N/A
mul-1-negN/A
lower-*.f6494.6
Applied rewrites94.6%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
frac-timesN/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lift-/.f64N/A
lift-*.f6472.1
Applied rewrites72.1%
if -2e-136 < (*.f64 z t) < 4.99999999999999992e-46Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6488.5
Applied rewrites88.5%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6488.5
Applied rewrites88.5%
Final simplification78.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (/ -1.0 z) (/ x t) (/ (* y (* -1.0 x)) (pow (* t z) 2.0)))))
(if (<= (* z t) -5e-34)
t_1
(if (<= (* z t) 5e+18)
(- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y)))
t_1))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = fma((-1.0 / z), (x / t), ((y * (-1.0 * x)) / pow((t * z), 2.0)));
double tmp;
if ((z * t) <= -5e-34) {
tmp = t_1;
} else if ((z * t) <= 5e+18) {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
} else {
tmp = t_1;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = fma(Float64(-1.0 / z), Float64(x / t), Float64(Float64(y * Float64(-1.0 * x)) / (Float64(t * z) ^ 2.0))) tmp = 0.0 if (Float64(z * t) <= -5e-34) tmp = t_1; elseif (Float64(z * t) <= 5e+18) tmp = Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))); else tmp = t_1; end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(-1.0 / z), $MachinePrecision] * N[(x / t), $MachinePrecision] + N[(N[(y * N[(-1.0 * x), $MachinePrecision]), $MachinePrecision] / N[Power[N[(t * z), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -5e-34], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], 5e+18], N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{-1}{z}, \frac{x}{t}, \frac{y \cdot \left(-1 \cdot x\right)}{{\left(t \cdot z\right)}^{2}}\right)\\
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (*.f64 z t) < -5.0000000000000003e-34 or 5e18 < (*.f64 z t) Initial program 92.7%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6475.1
Applied rewrites75.1%
if -5.0000000000000003e-34 < (*.f64 z t) < 5e18Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6474.8
Applied rewrites74.8%
Final simplification74.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (pow (* (* z t) -1.0) 2.0)) (t_2 (* (/ x t) -1.0)))
(if (<= (* z t) -1e+118)
(/
(-
(fma
(* (* -1.0 (/ x (* (* z z) z))) (* -1.0 (pow (* (/ y t) -1.0) 2.0)))
-1.0
(* (/ x z) -1.0))
(* (* -1.0 (/ x (* z z))) (* -1.0 (/ y t))))
t)
(if (<= (* z t) -5e-34)
(/ (fma (* (* y x) -1.0) z (* t_1 t_2)) (* t_1 z))
(if (<= (* z t) 5e+18)
(- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y)))
(/
(-
(fma
(*
(* -1.0 (pow (* (/ y z) -1.0) 2.0))
(* -1.0 (/ x (* (* t t) t))))
-1.0
t_2)
(* (* -1.0 (/ y (* t t))) (* -1.0 (/ x z))))
z))))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = pow(((z * t) * -1.0), 2.0);
double t_2 = (x / t) * -1.0;
double tmp;
if ((z * t) <= -1e+118) {
tmp = (fma(((-1.0 * (x / ((z * z) * z))) * (-1.0 * pow(((y / t) * -1.0), 2.0))), -1.0, ((x / z) * -1.0)) - ((-1.0 * (x / (z * z))) * (-1.0 * (y / t)))) / t;
} else if ((z * t) <= -5e-34) {
tmp = fma(((y * x) * -1.0), z, (t_1 * t_2)) / (t_1 * z);
} else if ((z * t) <= 5e+18) {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
} else {
tmp = (fma(((-1.0 * pow(((y / z) * -1.0), 2.0)) * (-1.0 * (x / ((t * t) * t)))), -1.0, t_2) - ((-1.0 * (y / (t * t))) * (-1.0 * (x / z)))) / z;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(z * t) * -1.0) ^ 2.0 t_2 = Float64(Float64(x / t) * -1.0) tmp = 0.0 if (Float64(z * t) <= -1e+118) tmp = Float64(Float64(fma(Float64(Float64(-1.0 * Float64(x / Float64(Float64(z * z) * z))) * Float64(-1.0 * (Float64(Float64(y / t) * -1.0) ^ 2.0))), -1.0, Float64(Float64(x / z) * -1.0)) - Float64(Float64(-1.0 * Float64(x / Float64(z * z))) * Float64(-1.0 * Float64(y / t)))) / t); elseif (Float64(z * t) <= -5e-34) tmp = Float64(fma(Float64(Float64(y * x) * -1.0), z, Float64(t_1 * t_2)) / Float64(t_1 * z)); elseif (Float64(z * t) <= 5e+18) tmp = Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))); else tmp = Float64(Float64(fma(Float64(Float64(-1.0 * (Float64(Float64(y / z) * -1.0) ^ 2.0)) * Float64(-1.0 * Float64(x / Float64(Float64(t * t) * t)))), -1.0, t_2) - Float64(Float64(-1.0 * Float64(y / Float64(t * t))) * Float64(-1.0 * Float64(x / z)))) / z); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Power[N[(N[(z * t), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(x / t), $MachinePrecision] * -1.0), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+118], N[(N[(N[(N[(N[(-1.0 * N[(x / N[(N[(z * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Power[N[(N[(y / t), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / z), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], -5e-34], N[(N[(N[(N[(y * x), $MachinePrecision] * -1.0), $MachinePrecision] * z + N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+18], N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-1.0 * N[Power[N[(N[(y / z), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(x / N[(N[(t * t), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + t$95$2), $MachinePrecision] - N[(N[(-1.0 * N[(y / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := {\left(\left(z \cdot t\right) \cdot -1\right)}^{2}\\
t_2 := \frac{x}{t} \cdot -1\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+118}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-1 \cdot \frac{x}{\left(z \cdot z\right) \cdot z}\right) \cdot \left(-1 \cdot {\left(\frac{y}{t} \cdot -1\right)}^{2}\right), -1, \frac{x}{z} \cdot -1\right) - \left(-1 \cdot \frac{x}{z \cdot z}\right) \cdot \left(-1 \cdot \frac{y}{t}\right)}{t}\\
\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{-34}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(y \cdot x\right) \cdot -1, z, t\_1 \cdot t\_2\right)}{t\_1 \cdot z}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-1 \cdot {\left(\frac{y}{z} \cdot -1\right)}^{2}\right) \cdot \left(-1 \cdot \frac{x}{\left(t \cdot t\right) \cdot t}\right), -1, t\_2\right) - \left(-1 \cdot \frac{y}{t \cdot t}\right) \cdot \left(-1 \cdot \frac{x}{z}\right)}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -9.99999999999999967e117Initial program 86.0%
Taylor expanded in t around inf
Applied rewrites85.2%
if -9.99999999999999967e117 < (*.f64 z t) < -5.0000000000000003e-34Initial program 99.7%
Taylor expanded in y around 0
associate-*r/N/A
*-commutativeN/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow-prod-downN/A
lower-pow.f64N/A
lower-*.f6462.7
Applied rewrites62.7%
lift-/.f64N/A
lift-/.f64N/A
lift-fma.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
mul-1-negN/A
associate-*l/N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites59.4%
if -5.0000000000000003e-34 < (*.f64 z t) < 5e18Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6474.8
Applied rewrites74.8%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6474.8
Applied rewrites74.8%
if 5e18 < (*.f64 z t) Initial program 93.1%
Taylor expanded in z around inf
Applied rewrites69.4%
Final simplification73.2%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (<= (* z t) -1e+68)
(/
(-
(fma
(* (* -1.0 (/ x (* (* z z) z))) (* -1.0 (pow (* (/ y t) -1.0) 2.0)))
-1.0
(* (/ x z) -1.0))
(* (* -1.0 (/ x (* z z))) (* -1.0 (/ y t))))
t)
(if (<= (* z t) 5e+18)
(- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y)))
(/
(-
(fma
(* (* -1.0 (pow (* (/ y z) -1.0) 2.0)) (* -1.0 (/ x (* (* t t) t))))
-1.0
(* (/ x t) -1.0))
(* (* -1.0 (/ y (* t t))) (* -1.0 (/ x z))))
z))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if ((z * t) <= -1e+68) {
tmp = (fma(((-1.0 * (x / ((z * z) * z))) * (-1.0 * pow(((y / t) * -1.0), 2.0))), -1.0, ((x / z) * -1.0)) - ((-1.0 * (x / (z * z))) * (-1.0 * (y / t)))) / t;
} else if ((z * t) <= 5e+18) {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
} else {
tmp = (fma(((-1.0 * pow(((y / z) * -1.0), 2.0)) * (-1.0 * (x / ((t * t) * t)))), -1.0, ((x / t) * -1.0)) - ((-1.0 * (y / (t * t))) * (-1.0 * (x / z)))) / z;
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (Float64(z * t) <= -1e+68) tmp = Float64(Float64(fma(Float64(Float64(-1.0 * Float64(x / Float64(Float64(z * z) * z))) * Float64(-1.0 * (Float64(Float64(y / t) * -1.0) ^ 2.0))), -1.0, Float64(Float64(x / z) * -1.0)) - Float64(Float64(-1.0 * Float64(x / Float64(z * z))) * Float64(-1.0 * Float64(y / t)))) / t); elseif (Float64(z * t) <= 5e+18) tmp = Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))); else tmp = Float64(Float64(fma(Float64(Float64(-1.0 * (Float64(Float64(y / z) * -1.0) ^ 2.0)) * Float64(-1.0 * Float64(x / Float64(Float64(t * t) * t)))), -1.0, Float64(Float64(x / t) * -1.0)) - Float64(Float64(-1.0 * Float64(y / Float64(t * t))) * Float64(-1.0 * Float64(x / z)))) / z); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[LessEqual[N[(z * t), $MachinePrecision], -1e+68], N[(N[(N[(N[(N[(-1.0 * N[(x / N[(N[(z * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Power[N[(N[(y / t), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / z), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], If[LessEqual[N[(z * t), $MachinePrecision], 5e+18], N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-1.0 * N[Power[N[(N[(y / z), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(x / N[(N[(t * t), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / t), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(y / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+68}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-1 \cdot \frac{x}{\left(z \cdot z\right) \cdot z}\right) \cdot \left(-1 \cdot {\left(\frac{y}{t} \cdot -1\right)}^{2}\right), -1, \frac{x}{z} \cdot -1\right) - \left(-1 \cdot \frac{x}{z \cdot z}\right) \cdot \left(-1 \cdot \frac{y}{t}\right)}{t}\\
\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+18}:\\
\;\;\;\;\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-1 \cdot {\left(\frac{y}{z} \cdot -1\right)}^{2}\right) \cdot \left(-1 \cdot \frac{x}{\left(t \cdot t\right) \cdot t}\right), -1, \frac{x}{t} \cdot -1\right) - \left(-1 \cdot \frac{y}{t \cdot t}\right) \cdot \left(-1 \cdot \frac{x}{z}\right)}{z}\\
\end{array}
\end{array}
if (*.f64 z t) < -9.99999999999999953e67Initial program 89.4%
Taylor expanded in t around inf
Applied rewrites75.6%
if -9.99999999999999953e67 < (*.f64 z t) < 5e18Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
Applied rewrites70.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6470.0
Applied rewrites70.0%
if 5e18 < (*.f64 z t) Initial program 93.1%
Taylor expanded in z around inf
Applied rewrites69.4%
Final simplification70.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= (* z t) -1e+68) (not (<= (* z t) 5e+18)))
(/
(-
(fma
(* (* -1.0 (/ x (* (* z z) z))) (* -1.0 (pow (* (/ y t) -1.0) 2.0)))
-1.0
(* (/ x z) -1.0))
(* (* -1.0 (/ x (* z z))) (* -1.0 (/ y t))))
t)
(- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y)))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (((z * t) <= -1e+68) || !((z * t) <= 5e+18)) {
tmp = (fma(((-1.0 * (x / ((z * z) * z))) * (-1.0 * pow(((y / t) * -1.0), 2.0))), -1.0, ((x / z) * -1.0)) - ((-1.0 * (x / (z * z))) * (-1.0 * (y / t)))) / t;
} else {
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if ((Float64(z * t) <= -1e+68) || !(Float64(z * t) <= 5e+18)) tmp = Float64(Float64(fma(Float64(Float64(-1.0 * Float64(x / Float64(Float64(z * z) * z))) * Float64(-1.0 * (Float64(Float64(y / t) * -1.0) ^ 2.0))), -1.0, Float64(Float64(x / z) * -1.0)) - Float64(Float64(-1.0 * Float64(x / Float64(z * z))) * Float64(-1.0 * Float64(y / t)))) / t); else tmp = Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))); end return tmp end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -1e+68], N[Not[LessEqual[N[(z * t), $MachinePrecision], 5e+18]], $MachinePrecision]], N[(N[(N[(N[(N[(-1.0 * N[(x / N[(N[(z * z), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[Power[N[(N[(y / t), $MachinePrecision] * -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / z), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(-1.0 * N[(x / N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 * N[(y / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+68} \lor \neg \left(z \cdot t \leq 5 \cdot 10^{+18}\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(\left(-1 \cdot \frac{x}{\left(z \cdot z\right) \cdot z}\right) \cdot \left(-1 \cdot {\left(\frac{y}{t} \cdot -1\right)}^{2}\right), -1, \frac{x}{z} \cdot -1\right) - \left(-1 \cdot \frac{x}{z \cdot z}\right) \cdot \left(-1 \cdot \frac{y}{t}\right)}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if (*.f64 z t) < -9.99999999999999953e67 or 5e18 < (*.f64 z t) Initial program 91.4%
Taylor expanded in t around inf
Applied rewrites74.6%
if -9.99999999999999953e67 < (*.f64 z t) < 5e18Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.0
Applied rewrites70.0%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6470.0
Applied rewrites70.0%
Final simplification71.8%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (/ (+ (/ (* (* z x) t) y) x) y))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return ((((z * x) * t) / y) + x) / y;
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((((z * x) * t) / y) + x) / y
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return ((((z * x) * t) / y) + x) / y;
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return ((((z * x) * t) / y) + x) / y
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) + x) / y) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = ((((z * x) * t) / y) + x) / y;
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\frac{\frac{\left(z \cdot x\right) \cdot t}{y} + x}{y}
\end{array}
Initial program 96.6%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.3
Applied rewrites46.3%
Final simplification46.3%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- (/ (/ (* (* z x) t) y) y) (* -1.0 (/ x y))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
}
NOTE: x, y, z, and t should be sorted in increasing order before calling this function.
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((((z * x) * t) / y) / y) - ((-1.0d0) * (x / y))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return ((((z * x) * t) / y) / y) - (-1.0 * (x / y))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(Float64(Float64(Float64(Float64(z * x) * t) / y) / y) - Float64(-1.0 * Float64(x / y))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = ((((z * x) * t) / y) / y) - (-1.0 * (x / y));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(N[(N[(N[(N[(z * x), $MachinePrecision] * t), $MachinePrecision] / y), $MachinePrecision] / y), $MachinePrecision] - N[(-1.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\frac{\frac{\left(z \cdot x\right) \cdot t}{y}}{y} - -1 \cdot \frac{x}{y}
\end{array}
Initial program 96.6%
Taylor expanded in y around inf
lower-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6446.3
Applied rewrites46.3%
lift-/.f64N/A
lift-+.f64N/A
div-addN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lower-/.f6446.3
Applied rewrites46.3%
Final simplification46.3%
herbie shell --seed 2025065
(FPCore (x y z t)
:name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, B"
:precision binary64
:alt
(! :herbie-platform default (if (< x -161819597360704900000000000000000000000000000000000) (/ 1 (- (/ y x) (* (/ z x) t))) (if (< x 213783064348764440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (- y (* z t))) (/ 1 (- (/ y x) (* (/ z x) t))))))
(/ x (- y (* z t))))