Average Error: 3.5 → 1.0
Time: 5.7s
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.5357642338074745 \cdot 10^{112}:\\ \;\;\;\;\left(x - \frac{1}{\frac{z \cdot 3}{y}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \le 3.513750229300045 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{1}{z}}{\frac{y}{\frac{t}{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\frac{y}{z}}{\sqrt[3]{3}}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \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.5357642338074745 \cdot 10^{112}:\\
\;\;\;\;\left(x - \frac{1}{\frac{z \cdot 3}{y}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\

\mathbf{elif}\;z \cdot 3 \le 3.513750229300045 \cdot 10^{89}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{1}{z}}{\frac{y}{\frac{t}{3}}}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, x, -\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\frac{y}{z}}{\sqrt[3]{3}}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\

\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 (((z * 3.0) <= -1.5357642338074745e+112)) {
		temp = ((x - (1.0 / ((z * 3.0) / y))) + (t / ((z * 3.0) * y)));
	} else {
		double temp_1;
		if (((z * 3.0) <= 3.513750229300045e+89)) {
			temp_1 = (fma(1.0, x, -((y / 3.0) * (1.0 / z))) + fma((1.0 / z), (-(y / 3.0) + (y / 3.0)), ((1.0 / z) / (y / (t / 3.0)))));
		} else {
			temp_1 = (fma(1.0, x, -((1.0 / (cbrt(3.0) * cbrt(3.0))) * ((y / z) / cbrt(3.0)))) + fma((1.0 / z), (-(y / 3.0) + (y / 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.5
Target1.6
Herbie1.0
\[\left(x - \frac{y}{z \cdot 3}\right) + \frac{\frac{t}{z \cdot 3}}{y}\]

Derivation

  1. Split input into 3 regimes
  2. if (* z 3.0) < -1.5357642338074745e+112

    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 clear-num0.8

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

    if -1.5357642338074745e+112 < (* z 3.0) < 3.513750229300045e+89

    1. Initial program 5.9

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

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

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

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

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(-\frac{y}{3}, \frac{1}{z}, \frac{y}{3} \cdot \frac{1}{z}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    9. Applied associate-+l+1.9

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

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \color{blue}{\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity1.9

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{\color{blue}{1 \cdot t}}{z \cdot 3}}{y}\right)\]
    13. Applied times-frac1.9

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\color{blue}{\frac{1}{z} \cdot \frac{t}{3}}}{y}\right)\]
    14. Applied associate-/l*1.0

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

    if 3.513750229300045e+89 < (* 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. Using strategy rm
    3. Applied associate-/r*1.1

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

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

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

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(-\frac{y}{3}, \frac{1}{z}, \frac{y}{3} \cdot \frac{1}{z}\right)\right)} + \frac{\frac{t}{z \cdot 3}}{y}\]
    9. Applied associate-+l+1.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \left(\mathsf{fma}\left(-\frac{y}{3}, \frac{1}{z}, \frac{y}{3} \cdot \frac{1}{z}\right) + \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    10. Simplified1.1

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \color{blue}{\mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)}\]
    11. Using strategy rm
    12. Applied add-cube-cbrt1.1

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{y}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
    13. Applied *-un-lft-identity1.1

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{\color{blue}{1 \cdot y}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
    14. Applied times-frac1.2

      \[\leadsto \mathsf{fma}\left(1, x, -\color{blue}{\left(\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{y}{\sqrt[3]{3}}\right)} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
    15. Applied associate-*l*1.2

      \[\leadsto \mathsf{fma}\left(1, x, -\color{blue}{\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \left(\frac{y}{\sqrt[3]{3}} \cdot \frac{1}{z}\right)}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
    16. Simplified1.2

      \[\leadsto \mathsf{fma}\left(1, x, -\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \color{blue}{\frac{\frac{y}{z}}{\sqrt[3]{3}}}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -1.5357642338074745 \cdot 10^{112}:\\ \;\;\;\;\left(x - \frac{1}{\frac{z \cdot 3}{y}}\right) + \frac{t}{\left(z \cdot 3\right) \cdot y}\\ \mathbf{elif}\;z \cdot 3 \le 3.513750229300045 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{y}{3} \cdot \frac{1}{z}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{1}{z}}{\frac{y}{\frac{t}{3}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, x, -\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}} \cdot \frac{\frac{y}{z}}{\sqrt[3]{3}}\right) + \mathsf{fma}\left(\frac{1}{z}, \left(-\frac{y}{3}\right) + \frac{y}{3}, \frac{\frac{t}{z \cdot 3}}{y}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(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))))