
(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)));
}
real(8) function code(x, y, z, t)
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}
Sampling outcomes in binary64 precision:
Herbie found 5 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)));
}
real(8) function code(x, y, z, t)
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}
(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)));
}
real(8) function code(x, y, z, t)
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}
Initial program 98.1%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (+ 1.0 (/ (/ x (- z y)) (- y t))))
double code(double x, double y, double z, double t) {
return 1.0 + ((x / (z - y)) / (y - t));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 + ((x / (z - y)) / (y - t))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 + ((x / (z - y)) / (y - t));
}
def code(x, y, z, t): return 1.0 + ((x / (z - y)) / (y - t))
function code(x, y, z, t) return Float64(1.0 + Float64(Float64(x / Float64(z - y)) / Float64(y - t))) end
function tmp = code(x, y, z, t) tmp = 1.0 + ((x / (z - y)) / (y - t)); end
code[x_, y_, z_, t_] := N[(1.0 + N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{\frac{x}{z - y}}{y - t}
\end{array}
Initial program 98.1%
sub-neg98.1%
neg-mul-198.1%
*-commutative98.1%
*-commutative98.1%
associate-/r*98.1%
associate-*r/98.1%
metadata-eval98.1%
times-frac98.1%
*-lft-identity98.1%
neg-mul-198.1%
sub-neg98.1%
+-commutative98.1%
distribute-neg-out98.1%
remove-double-neg98.1%
sub-neg98.1%
Simplified98.1%
Final simplification98.1%
(FPCore (x y z t) :precision binary64 (- 1.0 (/ x (* y (- y t)))))
double code(double x, double y, double z, double t) {
return 1.0 - (x / (y * (y - t)));
}
real(8) function code(x, y, z, t)
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 * (y - t)))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - (x / (y * (y - t)));
}
def code(x, y, z, t): return 1.0 - (x / (y * (y - t)))
function code(x, y, z, t) return Float64(1.0 - Float64(x / Float64(y * Float64(y - t)))) end
function tmp = code(x, y, z, t) tmp = 1.0 - (x / (y * (y - t))); end
code[x_, y_, z_, t_] := N[(1.0 - N[(x / N[(y * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{x}{y \cdot \left(y - t\right)}
\end{array}
Initial program 98.1%
Taylor expanded in z around 0 78.3%
Final simplification78.3%
(FPCore (x y z t) :precision binary64 (- 1.0 (/ (/ x t) (- z y))))
double code(double x, double y, double z, double t) {
return 1.0 - ((x / t) / (z - y));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0 - ((x / t) / (z - y))
end function
public static double code(double x, double y, double z, double t) {
return 1.0 - ((x / t) / (z - y));
}
def code(x, y, z, t): return 1.0 - ((x / t) / (z - y))
function code(x, y, z, t) return Float64(1.0 - Float64(Float64(x / t) / Float64(z - y))) end
function tmp = code(x, y, z, t) tmp = 1.0 - ((x / t) / (z - y)); end
code[x_, y_, z_, t_] := N[(1.0 - N[(N[(x / t), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \frac{\frac{x}{t}}{z - y}
\end{array}
Initial program 98.1%
sub-neg98.1%
neg-mul-198.1%
*-commutative98.1%
*-commutative98.1%
associate-/r*98.1%
associate-*r/98.1%
metadata-eval98.1%
times-frac98.1%
*-lft-identity98.1%
neg-mul-198.1%
sub-neg98.1%
+-commutative98.1%
distribute-neg-out98.1%
remove-double-neg98.1%
sub-neg98.1%
Simplified98.1%
Taylor expanded in t around inf 75.7%
associate-*r/75.7%
neg-mul-175.7%
associate-/r*76.7%
Simplified76.7%
Final simplification76.7%
(FPCore (x y z t) :precision binary64 1.0)
double code(double x, double y, double z, double t) {
return 1.0;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = 1.0d0
end function
public static double code(double x, double y, double z, double t) {
return 1.0;
}
def code(x, y, z, t): return 1.0
function code(x, y, z, t) return 1.0 end
function tmp = code(x, y, z, t) tmp = 1.0; end
code[x_, y_, z_, t_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 98.1%
Taylor expanded in y around 0 57.2%
Taylor expanded in x around 0 79.7%
Final simplification79.7%
herbie shell --seed 2024033
(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)))))