Average Error: 3.6 → 0.5
Time: 3.8s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;z \cdot 3 \le -1.29452495187302556 \cdot 10^{-26} \lor \neg \left(z \cdot 3 \le 1.65639586377778049 \cdot 10^{-42}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{3 \cdot \left(z \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \end{array}\]
\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}
\begin{array}{l}
\mathbf{if}\;z \cdot 3 \le -1.29452495187302556 \cdot 10^{-26} \lor \neg \left(z \cdot 3 \le 1.65639586377778049 \cdot 10^{-42}\right):\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{3 \cdot \left(z \cdot y\right)}\\

\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\

\end{array}
double code(double x, double y, double z, double t) {
	return ((double) (((double) (x - ((double) (y / ((double) (z * 3.0)))))) + ((double) (t / ((double) (((double) (z * 3.0)) * y))))));
}
double code(double x, double y, double z, double t) {
	double VAR;
	if (((((double) (z * 3.0)) <= -1.2945249518730256e-26) || !(((double) (z * 3.0)) <= 1.6563958637777805e-42))) {
		VAR = ((double) (((double) (x - ((double) (y / ((double) (z * 3.0)))))) + ((double) (t / ((double) (3.0 * ((double) (z * y))))))));
	} else {
		VAR = ((double) (((double) (x - ((double) (y / ((double) (z * 3.0)))))) + ((double) (((double) (1.0 / z)) * ((double) (((double) (t / 3.0)) / y))))));
	}
	return VAR;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original3.6
Target1.7
Herbie0.5
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 2 regimes
  2. if (* z 3.0) < -1.2945249518730256e-26 or 1.6563958637777805e-42 < (* z 3.0)

    1. Initial program 0.6

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Taylor expanded around 0 0.6

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\color{blue}{3 \cdot \left(z \cdot y\right)}}\]

    if -1.2945249518730256e-26 < (* z 3.0) < 1.6563958637777805e-42

    1. Initial program 12.4

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied associate-/r*3.5

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{t}{z \cdot 3}}{y}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity3.5

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{\color{blue}{1 \cdot y}}\]
    6. Applied *-un-lft-identity3.5

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{1 \cdot y}\]
    7. Applied times-frac3.5

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{1 \cdot y}\]
    8. Applied times-frac0.3

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{\frac{1}{z}}{1} \cdot \frac{\frac{t}{3}}{y}}\]
    9. Simplified0.3

      \[\leadsto \left(x - \frac{y}{z \cdot 3}\right) + \color{blue}{\frac{1}{z}} \cdot \frac{\frac{t}{3}}{y}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -1.29452495187302556 \cdot 10^{-26} \lor \neg \left(z \cdot 3 \le 1.65639586377778049 \cdot 10^{-42}\right):\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{3 \cdot \left(z \cdot y\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z} \cdot \frac{\frac{t}{3}}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020123 
(FPCore (x y z t)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, H"
  :precision binary64

  :herbie-target
  (+ (- x (/ y (* z 3))) (/ (/ t (* z 3)) y))

  (+ (- x (/ y (* z 3))) (/ t (* (* z 3) y))))