Average Error: 1.3 → 0.5
Time: 12.2s
Precision: binary64
\[x + y \cdot \frac{z - t}{a - t}\]
\[\begin{array}{l} \mathbf{if}\;y \cdot \frac{z - t}{a - t} \leq -\infty:\\ \;\;\;\;\frac{y \cdot z}{a - t}\\ \mathbf{elif}\;y \cdot \frac{z - t}{a - t} \leq 2.836526295028813 \cdot 10^{+287}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \end{array}\]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;y \cdot \frac{z - t}{a - t} \leq -\infty:\\
\;\;\;\;\frac{y \cdot z}{a - t}\\

\mathbf{elif}\;y \cdot \frac{z - t}{a - t} \leq 2.836526295028813 \cdot 10^{+287}:\\
\;\;\;\;y \cdot \frac{z - t}{a - t} + x\\

\mathbf{else}:\\
\;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\

\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 (/ (- z t) (- a t))) (- INFINITY))
   (/ (* y z) (- a t))
   (if (<= (* y (/ (- z t) (- a t))) 2.836526295028813e+287)
     (+ (* y (/ (- z t) (- a t))) x)
     (+ x (/ (- z t) (/ (- a t) y))))))
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 * ((z - t) / (a - t))) <= -((double) INFINITY)) {
		tmp = (y * z) / (a - t);
	} else if ((y * ((z - t) / (a - t))) <= 2.836526295028813e+287) {
		tmp = (y * ((z - t) / (a - t))) + x;
	} else {
		tmp = x + ((z - t) / ((a - t) / y));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original1.3
Target0.5
Herbie0.5
\[\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 (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t))) < -inf.0

    1. Initial program 64.0

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Taylor expanded around inf 16.8

      \[\leadsto \color{blue}{\frac{z \cdot y}{a - t}}\]

    if -inf.0 < (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t))) < 2.8365262950288132e287

    1. Initial program 0.3

      \[x + y \cdot \frac{z - t}{a - t}\]

    if 2.8365262950288132e287 < (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t)))

    1. Initial program 23.7

      \[x + y \cdot \frac{z - t}{a - t}\]
    2. Taylor expanded around 0 28.0

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

      \[\leadsto x + \color{blue}{\frac{\left(z - t\right) \cdot y}{a - t}}\]
    4. Using strategy rm
    5. Applied associate-/l*_binary64_150273.5

      \[\leadsto x + \color{blue}{\frac{z - t}{\frac{a - t}{y}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \cdot \frac{z - t}{a - t} \leq -\infty:\\ \;\;\;\;\frac{y \cdot z}{a - t}\\ \mathbf{elif}\;y \cdot \frac{z - t}{a - t} \leq 2.836526295028813 \cdot 10^{+287}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t} + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z - t}{\frac{a - t}{y}}\\ \end{array}\]

Reproduce

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