
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - 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 = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - 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 = 1.0d0 - (x / ((y - z) * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / ((y - z) * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\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 -4e-8) (- 1.0 (/ x (fma (fma -1.0 (+ t z) y) y (* t z)))) (- 1.0 (/ (/ x (- y t)) (- y z)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4e-8) {
tmp = 1.0 - (x / fma(fma(-1.0, (t + z), y), y, (t * z)));
} else {
tmp = 1.0 - ((x / (y - t)) / (y - z));
}
return tmp;
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) tmp = 0.0 if (z <= -4e-8) tmp = Float64(1.0 - Float64(x / fma(fma(-1.0, Float64(t + z), y), y, Float64(t * z)))); else tmp = Float64(1.0 - Float64(Float64(x / Float64(y - t)) / Float64(y - 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[z, -4e-8], N[(1.0 - N[(x / N[(N[(-1.0 * N[(t + z), $MachinePrecision] + y), $MachinePrecision] * y + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{-8}:\\
\;\;\;\;1 - \frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(-1, t + z, y\right), y, t \cdot z\right)}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{\frac{x}{y - t}}{y - z}\\
\end{array}
\end{array}
if z < -4.0000000000000001e-8Initial program 99.9%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f6499.9
Applied rewrites99.9%
if -4.0000000000000001e-8 < z Initial program 98.4%
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6499.9
Applied rewrites99.9%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ (/ x (- y z)) (- y t))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - z)) / (y - t));
}
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 = 1.0d0 - ((x / (y - z)) / (y - t))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - ((x / (y - z)) / (y - t));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0 - ((x / (y - z)) / (y - t))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(Float64(x / Float64(y - z)) / Float64(y - t))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - ((x / (y - z)) / (y - t));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{\frac{x}{y - z}}{y - t}
\end{array}
Initial program 99.1%
lift-/.f64N/A
lift--.f64N/A
lift--.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
lift--.f6498.4
Applied rewrites98.4%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* (- y z) (- y t)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
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 = 1.0d0 - (x / ((y - z) * (y - t)))
end function
assert x < y && y < z && z < t;
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / ((y - z) * (y - t)));
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): return 1.0 - (x / ((y - z) * (y - t)))
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(Float64(y - z) * Float64(y - t)))) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
tmp = 1.0 - (x / ((y - z) * (y - t)));
end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(y - z), $MachinePrecision] * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{x}{\left(y - z\right) \cdot \left(y - t\right)}
\end{array}
Initial program 99.1%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ x (fma (fma -1.0 (+ t z) y) y (* t z)))))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (x / fma(fma(-1.0, (t + z), y), y, (t * z)));
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(x / fma(fma(-1.0, Float64(t + z), y), y, Float64(t * z)))) end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(N[(-1.0 * N[(t + z), $MachinePrecision] + y), $MachinePrecision] * y + N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{x}{\mathsf{fma}\left(\mathsf{fma}\left(-1, t + z, y\right), y, t \cdot z\right)}
\end{array}
Initial program 99.1%
Taylor expanded in y around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
distribute-lft-outN/A
lower-fma.f64N/A
lower-+.f64N/A
lower-*.f6498.7
Applied rewrites98.7%
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (- 1.0 (/ (fma (* (/ x t) (/ y (- y z))) -1.0 (* (/ x (- y z)) -1.0)) t)))
assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
return 1.0 - (fma(((x / t) * (y / (y - z))), -1.0, ((x / (y - z)) * -1.0)) / t);
}
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) return Float64(1.0 - Float64(fma(Float64(Float64(x / t) * Float64(y / Float64(y - z))), -1.0, Float64(Float64(x / Float64(y - z)) * -1.0)) / t)) end
NOTE: x, y, z, and t should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(1.0 - N[(N[(N[(N[(x / t), $MachinePrecision] * N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
1 - \frac{\mathsf{fma}\left(\frac{x}{t} \cdot \frac{y}{y - z}, -1, \frac{x}{y - z} \cdot -1\right)}{t}
\end{array}
Initial program 99.1%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6462.9
Applied rewrites62.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 (* (/ x (- y z)) -1.0)) (t_2 (* (* (/ x t) (/ y (- y z))) -1.0)))
(-
1.0
(/
(/
(+ (pow t_2 3.0) (pow t_1 3.0))
(+ (* t_2 t_2) (- (* t_1 t_1) (* t_2 t_1))))
t))))assert(x < y && y < z && z < t);
double code(double x, double y, double z, double t) {
double t_1 = (x / (y - z)) * -1.0;
double t_2 = ((x / t) * (y / (y - z))) * -1.0;
return 1.0 - (((pow(t_2, 3.0) + pow(t_1, 3.0)) / ((t_2 * t_2) + ((t_1 * t_1) - (t_2 * t_1)))) / t);
}
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) :: t_2
t_1 = (x / (y - z)) * (-1.0d0)
t_2 = ((x / t) * (y / (y - z))) * (-1.0d0)
code = 1.0d0 - ((((t_2 ** 3.0d0) + (t_1 ** 3.0d0)) / ((t_2 * t_2) + ((t_1 * t_1) - (t_2 * t_1)))) / t)
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 / (y - z)) * -1.0;
double t_2 = ((x / t) * (y / (y - z))) * -1.0;
return 1.0 - (((Math.pow(t_2, 3.0) + Math.pow(t_1, 3.0)) / ((t_2 * t_2) + ((t_1 * t_1) - (t_2 * t_1)))) / t);
}
[x, y, z, t] = sort([x, y, z, t]) def code(x, y, z, t): t_1 = (x / (y - z)) * -1.0 t_2 = ((x / t) * (y / (y - z))) * -1.0 return 1.0 - (((math.pow(t_2, 3.0) + math.pow(t_1, 3.0)) / ((t_2 * t_2) + ((t_1 * t_1) - (t_2 * t_1)))) / t)
x, y, z, t = sort([x, y, z, t]) function code(x, y, z, t) t_1 = Float64(Float64(x / Float64(y - z)) * -1.0) t_2 = Float64(Float64(Float64(x / t) * Float64(y / Float64(y - z))) * -1.0) return Float64(1.0 - Float64(Float64(Float64((t_2 ^ 3.0) + (t_1 ^ 3.0)) / Float64(Float64(t_2 * t_2) + Float64(Float64(t_1 * t_1) - Float64(t_2 * t_1)))) / t)) end
x, y, z, t = num2cell(sort([x, y, z, t])){:}
function tmp = code(x, y, z, t)
t_1 = (x / (y - z)) * -1.0;
t_2 = ((x / t) * (y / (y - z))) * -1.0;
tmp = 1.0 - ((((t_2 ^ 3.0) + (t_1 ^ 3.0)) / ((t_2 * t_2) + ((t_1 * t_1) - (t_2 * t_1)))) / t);
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[(x / N[(y - z), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(x / t), $MachinePrecision] * N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]}, N[(1.0 - N[(N[(N[(N[Power[t$95$2, 3.0], $MachinePrecision] + N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[(t$95$2 * t$95$2), $MachinePrecision] + N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t] = \mathsf{sort}([x, y, z, t])\\
\\
\begin{array}{l}
t_1 := \frac{x}{y - z} \cdot -1\\
t_2 := \left(\frac{x}{t} \cdot \frac{y}{y - z}\right) \cdot -1\\
1 - \frac{\frac{{t\_2}^{3} + {t\_1}^{3}}{t\_2 \cdot t\_2 + \left(t\_1 \cdot t\_1 - t\_2 \cdot t\_1\right)}}{t}
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in t around inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lift--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f6462.9
Applied rewrites62.9%
lift-fma.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift--.f64N/A
lift-/.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites26.5%
herbie shell --seed 2025093
(FPCore (x y z t)
:name "Data.Random.Distribution.Triangular:triangularCDF from random-fu-0.2.6.2, A"
:precision binary64
(- 1.0 (/ x (* (- y z) (- y t)))))