Average Error: 3.6 → 0.4
Time: 3.5s
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 -2.46813702540547299 \cdot 10^{-4} \lor \neg \left(z \cdot 3 \le 1.3585541563890803 \cdot 10^{35}\right):\\ \;\;\;\;\mathsf{fma}\left(0.333333333333333315, \frac{t}{z \cdot y}, x - 0.333333333333333315 \cdot \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{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 -2.46813702540547299 \cdot 10^{-4} \lor \neg \left(z \cdot 3 \le 1.3585541563890803 \cdot 10^{35}\right):\\
\;\;\;\;\mathsf{fma}\left(0.333333333333333315, \frac{t}{z \cdot y}, x - 0.333333333333333315 \cdot \frac{y}{z}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{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 VAR;
	if ((((z * 3.0) <= -0.0002468137025405473) || !((z * 3.0) <= 1.3585541563890803e+35))) {
		VAR = fma(0.3333333333333333, (t / (z * y)), (x - (0.3333333333333333 * (y / z))));
	} else {
		VAR = ((x - (y / (z * 3.0))) + ((1.0 / (z * 3.0)) * (t / 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.8
Herbie0.4
\[\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) < -0.0002468137025405473 or 1.3585541563890803e+35 < (* z 3.0)

    1. Initial program 0.4

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

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

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

    if -0.0002468137025405473 < (* z 3.0) < 1.3585541563890803e+35

    1. Initial program 9.4

      \[\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-identity9.4

      \[\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}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot 3 \le -2.46813702540547299 \cdot 10^{-4} \lor \neg \left(z \cdot 3 \le 1.3585541563890803 \cdot 10^{35}\right):\\ \;\;\;\;\mathsf{fma}\left(0.333333333333333315, \frac{t}{z \cdot y}, x - 0.333333333333333315 \cdot \frac{y}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - \frac{y}{z \cdot 3}\right) + \frac{1}{z \cdot 3} \cdot \frac{t}{y}\\ \end{array}\]

Reproduce

herbie shell --seed 2020103 +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))))