Average Error: 3.7 → 0.9
Time: 4.3s
Precision: 64
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
\[\begin{array}{l} \mathbf{if}\;t \le -3.1738446400054502 \cdot 10^{-58}:\\ \;\;\;\;\left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\ \mathbf{elif}\;t \le 5.128060230407144 \cdot 10^{45}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{\frac{t}{z}}{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}\;t \le -3.1738446400054502 \cdot 10^{-58}:\\
\;\;\;\;\left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\

\mathbf{elif}\;t \le 5.128060230407144 \cdot 10^{45}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\

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

\end{array}
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 temp;
	if ((t <= -3.17384464000545e-58)) {
		temp = ((x - ((1.0 / z) * (y / 3.0))) + (0.3333333333333333 * (t / (z * y))));
	} else {
		double temp_1;
		if ((t <= 5.128060230407144e+45)) {
			temp_1 = ((x - (y / (z * 3.0))) + ((1.0 / (z * 3.0)) * (t / y)));
		} else {
			temp_1 = ((x - ((y / z) / 3.0)) + (((t / z) / 3.0) / y));
		}
		temp = temp_1;
	}
	return temp;
}

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.7
Target1.6
Herbie0.9
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if t < -3.17384464000545e-58

    1. Initial program 0.8

      \[\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*1.8

      \[\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-identity1.8

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

      \[\leadsto \left(x - \color{blue}{\frac{1}{z} \cdot \frac{y}{3}}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
    7. Using strategy rm
    8. Applied associate-/r*1.8

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

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

    if -3.17384464000545e-58 < t < 5.128060230407144e+45

    1. Initial program 6.0

      \[\left(x - \frac{y}{z \cdot 3}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity6.0

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

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

    if 5.128060230407144e+45 < t

    1. Initial program 0.7

      \[\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*2.7

      \[\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-identity2.7

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

      \[\leadsto \left(x - \color{blue}{\frac{1}{z} \cdot \frac{y}{3}}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]
    7. Using strategy rm
    8. Applied associate-/r*2.7

      \[\leadsto \left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + \frac{\color{blue}{\frac{\frac{t}{z}}{3}}}{y}\]
    9. Using strategy rm
    10. Applied associate-*r/2.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -3.1738446400054502 \cdot 10^{-58}:\\ \;\;\;\;\left(x - \frac{1}{z} \cdot \frac{y}{3}\right) + 0.333333333333333315 \cdot \frac{t}{z \cdot y}\\ \mathbf{elif}\;t \le 5.128060230407144 \cdot 10^{45}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{\frac{y}{z}}{3}\right) + \frac{\frac{\frac{t}{z}}{3}}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020053 
(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))))