(FPCore (x y z t) :precision binary64 (+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- x (/ y (* z 3.0)))))
(if (<= t -3.368747839604316e-141)
(+ t_1 (/ t (* 3.0 (* y z))))
(if (<= t 1e+32)
(+ t_1 (/ (/ t y) (* z 3.0)))
(+ (+ x (* (/ y 3.0) (/ -1.0 z))) (/ t (* y (* z 3.0))))))))double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (t <= -3.368747839604316e-141) {
tmp = t_1 + (t / (3.0 * (y * z)));
} else if (t <= 1e+32) {
tmp = t_1 + ((t / y) / (z * 3.0));
} else {
tmp = (x + ((y / 3.0) * (-1.0 / z))) + (t / (y * (z * 3.0)));
}
return tmp;
}
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 = (x - (y / (z * 3.0d0))) + (t / ((z * 3.0d0) * y))
end function
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
real(8) :: t_1
real(8) :: tmp
t_1 = x - (y / (z * 3.0d0))
if (t <= (-3.368747839604316d-141)) then
tmp = t_1 + (t / (3.0d0 * (y * z)))
else if (t <= 1d+32) then
tmp = t_1 + ((t / y) / (z * 3.0d0))
else
tmp = (x + ((y / 3.0d0) * ((-1.0d0) / z))) + (t / (y * (z * 3.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y));
}
public static double code(double x, double y, double z, double t) {
double t_1 = x - (y / (z * 3.0));
double tmp;
if (t <= -3.368747839604316e-141) {
tmp = t_1 + (t / (3.0 * (y * z)));
} else if (t <= 1e+32) {
tmp = t_1 + ((t / y) / (z * 3.0));
} else {
tmp = (x + ((y / 3.0) * (-1.0 / z))) + (t / (y * (z * 3.0)));
}
return tmp;
}
def code(x, y, z, t): return (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y))
def code(x, y, z, t): t_1 = x - (y / (z * 3.0)) tmp = 0 if t <= -3.368747839604316e-141: tmp = t_1 + (t / (3.0 * (y * z))) elif t <= 1e+32: tmp = t_1 + ((t / y) / (z * 3.0)) else: tmp = (x + ((y / 3.0) * (-1.0 / z))) + (t / (y * (z * 3.0))) return tmp
function code(x, y, z, t) return Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(t / Float64(Float64(z * 3.0) * y))) end
function code(x, y, z, t) t_1 = Float64(x - Float64(y / Float64(z * 3.0))) tmp = 0.0 if (t <= -3.368747839604316e-141) tmp = Float64(t_1 + Float64(t / Float64(3.0 * Float64(y * z)))); elseif (t <= 1e+32) tmp = Float64(t_1 + Float64(Float64(t / y) / Float64(z * 3.0))); else tmp = Float64(Float64(x + Float64(Float64(y / 3.0) * Float64(-1.0 / z))) + Float64(t / Float64(y * Float64(z * 3.0)))); end return tmp end
function tmp = code(x, y, z, t) tmp = (x - (y / (z * 3.0))) + (t / ((z * 3.0) * y)); end
function tmp_2 = code(x, y, z, t) t_1 = x - (y / (z * 3.0)); tmp = 0.0; if (t <= -3.368747839604316e-141) tmp = t_1 + (t / (3.0 * (y * z))); elseif (t <= 1e+32) tmp = t_1 + ((t / y) / (z * 3.0)); else tmp = (x + ((y / 3.0) * (-1.0 / z))) + (t / (y * (z * 3.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -3.368747839604316e-141], N[(t$95$1 + N[(t / N[(3.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1e+32], N[(t$95$1 + N[(N[(t / y), $MachinePrecision] / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(N[(y / 3.0), $MachinePrecision] * N[(-1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t / N[(y * N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
t_1 := x - \frac{y}{z \cdot 3}\\
\mathbf{if}\;t \leq -3.368747839604316 \cdot 10^{-141}:\\
\;\;\;\;t_1 + \frac{t}{3 \cdot \left(y \cdot z\right)}\\
\mathbf{elif}\;t \leq 10^{+32}:\\
\;\;\;\;t_1 + \frac{\frac{t}{y}}{z \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\left(x + \frac{y}{3} \cdot \frac{-1}{z}\right) + \frac{t}{y \cdot \left(z \cdot 3\right)}\\
\end{array}
Results
| Original | 3.6 |
|---|---|
| Target | 1.6 |
| Herbie | 0.7 |
if t < -3.36874783960431615e-141Initial program 1.3
Taylor expanded in z around 0 1.3
if -3.36874783960431615e-141 < t < 1.00000000000000005e32Initial program 6.3
Applied egg-rr1.1
Applied egg-rr1.1
Applied egg-rr0.2
if 1.00000000000000005e32 < t Initial program 0.7
Applied egg-rr0.8
Final simplification0.7
herbie shell --seed 2022211
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, H"
:precision binary64
:herbie-target
(+ (- x (/ y (* z 3.0))) (/ (/ t (* z 3.0)) y))
(+ (- x (/ y (* z 3.0))) (/ t (* (* z 3.0) y))))