Average Error: 1.5 → 0.6
Time: 6.7s
Precision: binary64
\[x + y \cdot \frac{z - t}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -163.86311167990965:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{elif}\;y \leq 1.72501828309298 \cdot 10^{+46}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{a - t}\right) - \frac{y \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \sqrt{y} \cdot \left(\left(z - t\right) \cdot \frac{\sqrt{y}}{a - t}\right)\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (* y (/ (- z t) (- a t)))))
(FPCore (x y z t a)
 :precision binary64
 (if (<= y -163.86311167990965)
   (fma y (/ (- z t) (- a t)) x)
   (if (<= y 1.72501828309298e+46)
     (- (+ x (/ (* y z) (- a t))) (/ (* y t) (- a t)))
     (+ x (* (sqrt y) (* (- z t) (/ (sqrt y) (- a t))))))))
double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (a - t)));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if (y <= -163.86311167990965) {
		tmp = fma(y, ((z - t) / (a - t)), x);
	} else if (y <= 1.72501828309298e+46) {
		tmp = (x + ((y * z) / (a - t))) - ((y * t) / (a - t));
	} else {
		tmp = x + (sqrt(y) * ((z - t) * (sqrt(y) / (a - t))));
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -163.86311167990965)
		tmp = fma(y, Float64(Float64(z - t) / Float64(a - t)), x);
	elseif (y <= 1.72501828309298e+46)
		tmp = Float64(Float64(x + Float64(Float64(y * z) / Float64(a - t))) - Float64(Float64(y * t) / Float64(a - t)));
	else
		tmp = Float64(x + Float64(sqrt(y) * Float64(Float64(z - t) * Float64(sqrt(y) / Float64(a - t)))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -163.86311167990965], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.72501828309298e+46], N[(N[(x + N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y * t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[Sqrt[y], $MachinePrecision] * N[(N[(z - t), $MachinePrecision] * N[(N[Sqrt[y], $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;y \leq -163.86311167990965:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\

\mathbf{elif}\;y \leq 1.72501828309298 \cdot 10^{+46}:\\
\;\;\;\;\left(x + \frac{y \cdot z}{a - t}\right) - \frac{y \cdot t}{a - t}\\

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


\end{array}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original1.5
Target0.5
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;y < -8.508084860551241 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if y < -163.86311167990965

    1. Initial program 0.7

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Simplified0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)} \]
    3. Applied *-un-lft-identity_binary640.7

      \[\leadsto \mathsf{fma}\left(y, \frac{z - t}{\color{blue}{1 \cdot \left(a - t\right)}}, x\right) \]
    4. Applied add-cube-cbrt_binary641.5

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

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

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right)} \cdot \frac{\sqrt[3]{z - t}}{a - t}, x\right) \]
    7. Applied pow1_binary641.5

      \[\leadsto \mathsf{fma}\left(y, \left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right) \cdot \color{blue}{{\left(\frac{\sqrt[3]{z - t}}{a - t}\right)}^{1}}, x\right) \]
    8. Applied pow1_binary641.5

      \[\leadsto \mathsf{fma}\left(y, \left(\sqrt[3]{z - t} \cdot \color{blue}{{\left(\sqrt[3]{z - t}\right)}^{1}}\right) \cdot {\left(\frac{\sqrt[3]{z - t}}{a - t}\right)}^{1}, x\right) \]
    9. Applied pow1_binary641.5

      \[\leadsto \mathsf{fma}\left(y, \left(\color{blue}{{\left(\sqrt[3]{z - t}\right)}^{1}} \cdot {\left(\sqrt[3]{z - t}\right)}^{1}\right) \cdot {\left(\frac{\sqrt[3]{z - t}}{a - t}\right)}^{1}, x\right) \]
    10. Applied pow-prod-down_binary641.5

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{{\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right)}^{1}} \cdot {\left(\frac{\sqrt[3]{z - t}}{a - t}\right)}^{1}, x\right) \]
    11. Applied pow-prod-down_binary641.5

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{{\left(\left(\sqrt[3]{z - t} \cdot \sqrt[3]{z - t}\right) \cdot \frac{\sqrt[3]{z - t}}{a - t}\right)}^{1}}, x\right) \]
    12. Simplified0.7

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

    if -163.86311167990965 < y < 1.72501828309297999e46

    1. Initial program 2.1

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Simplified2.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)} \]
    3. Taylor expanded in y around 0 0.5

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

    if 1.72501828309297999e46 < y

    1. Initial program 0.4

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Simplified0.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)} \]
    3. Taylor expanded in y around 0 26.5

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

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

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

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

      \[\leadsto x + \color{blue}{\left(\frac{\sqrt{y}}{1} \cdot \frac{\sqrt{y}}{a - t}\right)} \cdot \left(z - t\right) \]
    8. Applied associate-*l*_binary640.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -163.86311167990965:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{elif}\;y \leq 1.72501828309298 \cdot 10^{+46}:\\ \;\;\;\;\left(x + \frac{y \cdot z}{a - t}\right) - \frac{y \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \sqrt{y} \cdot \left(\left(z - t\right) \cdot \frac{\sqrt{y}}{a - t}\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022131 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisLine from plot-0.2.3.4, B"
  :precision binary64

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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