(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 (<= (* z 3.0) -2e-96)
(+ (/ t (* (* z 3.0) y)) t_1)
(if (<= (* z 3.0) 4e+29)
(+ (- x (/ y (* z 3.0))) (* (/ 1.0 z) (/ t (* 3.0 y))))
(+ t_1 (* 0.3333333333333333 (/ t (* z y))))))))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 ((z * 3.0) <= -2e-96) {
tmp = (t / ((z * 3.0) * y)) + t_1;
} else if ((z * 3.0) <= 4e+29) {
tmp = (x - (y / (z * 3.0))) + ((1.0 / z) * (t / (3.0 * y)));
} else {
tmp = t_1 + (0.3333333333333333 * (t / (z * y)));
}
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 ((z * 3.0d0) <= (-2d-96)) then
tmp = (t / ((z * 3.0d0) * y)) + t_1
else if ((z * 3.0d0) <= 4d+29) then
tmp = (x - (y / (z * 3.0d0))) + ((1.0d0 / z) * (t / (3.0d0 * y)))
else
tmp = t_1 + (0.3333333333333333d0 * (t / (z * y)))
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 ((z * 3.0) <= -2e-96) {
tmp = (t / ((z * 3.0) * y)) + t_1;
} else if ((z * 3.0) <= 4e+29) {
tmp = (x - (y / (z * 3.0))) + ((1.0 / z) * (t / (3.0 * y)));
} else {
tmp = t_1 + (0.3333333333333333 * (t / (z * y)));
}
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 (z * 3.0) <= -2e-96: tmp = (t / ((z * 3.0) * y)) + t_1 elif (z * 3.0) <= 4e+29: tmp = (x - (y / (z * 3.0))) + ((1.0 / z) * (t / (3.0 * y))) else: tmp = t_1 + (0.3333333333333333 * (t / (z * y))) 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(Float64(y / z) / 3.0)) tmp = 0.0 if (Float64(z * 3.0) <= -2e-96) tmp = Float64(Float64(t / Float64(Float64(z * 3.0) * y)) + t_1); elseif (Float64(z * 3.0) <= 4e+29) tmp = Float64(Float64(x - Float64(y / Float64(z * 3.0))) + Float64(Float64(1.0 / z) * Float64(t / Float64(3.0 * y)))); else tmp = Float64(t_1 + Float64(0.3333333333333333 * Float64(t / Float64(z * y)))); 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 ((z * 3.0) <= -2e-96) tmp = (t / ((z * 3.0) * y)) + t_1; elseif ((z * 3.0) <= 4e+29) tmp = (x - (y / (z * 3.0))) + ((1.0 / z) * (t / (3.0 * y))); else tmp = t_1 + (0.3333333333333333 * (t / (z * y))); 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[(N[(y / z), $MachinePrecision] / 3.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * 3.0), $MachinePrecision], -2e-96], N[(N[(t / N[(N[(z * 3.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], If[LessEqual[N[(z * 3.0), $MachinePrecision], 4e+29], N[(N[(x - N[(y / N[(z * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 / z), $MachinePrecision] * N[(t / N[(3.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(0.3333333333333333 * N[(t / N[(z * y), $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{\frac{y}{z}}{3}\\
\mathbf{if}\;z \cdot 3 \leq -2 \cdot 10^{-96}:\\
\;\;\;\;\frac{t}{\left(z \cdot 3\right) \cdot y} + t_1\\
\mathbf{elif}\;z \cdot 3 \leq 4 \cdot 10^{+29}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{t}{3 \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t_1 + 0.3333333333333333 \cdot \frac{t}{z \cdot y}\\
\end{array}
Results
| Original | 3.4 |
|---|---|
| Target | 1.7 |
| Herbie | 0.6 |
if (*.f64 z 3) < -1.9999999999999998e-96Initial program 0.9
Applied egg-rr0.9
if -1.9999999999999998e-96 < (*.f64 z 3) < 3.99999999999999966e29Initial program 10.2
Applied egg-rr0.4
if 3.99999999999999966e29 < (*.f64 z 3) Initial program 0.3
Taylor expanded in t around 0 0.4
Simplified1.1
Applied egg-rr1.1
Taylor expanded in y around 0 0.4
Final simplification0.6
herbie shell --seed 2022210
(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))))