Average Error: 11.2 → 0.6
Time: 5.0s
Precision: binary64
\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -166269836987335460:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{elif}\;y \leq 4.180122896346843 \cdot 10^{-151}:\\ \;\;\;\;\frac{y \cdot z}{a - t} + \left(x - \frac{y \cdot t}{a - t}\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{1}{\frac{a - t}{z - t}}\\ \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 -166269836987335460.0)
   (fma y (/ (- z t) (- a t)) x)
   (if (<= y 4.180122896346843e-151)
     (+ (/ (* y z) (- a t)) (- x (/ (* y t) (- a t))))
     (+ x (* y (/ 1.0 (/ (- a t) (- z 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 <= -166269836987335460.0) {
		tmp = fma(y, ((z - t) / (a - t)), x);
	} else if (y <= 4.180122896346843e-151) {
		tmp = ((y * z) / (a - t)) + (x - ((y * t) / (a - t)));
	} else {
		tmp = x + (y * (1.0 / ((a - t) / (z - t))));
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t)))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if (y <= -166269836987335460.0)
		tmp = fma(y, Float64(Float64(z - t) / Float64(a - t)), x);
	elseif (y <= 4.180122896346843e-151)
		tmp = Float64(Float64(Float64(y * z) / Float64(a - t)) + Float64(x - Float64(Float64(y * t) / Float64(a - t))));
	else
		tmp = Float64(x + Float64(y * Float64(1.0 / Float64(Float64(a - t) / Float64(z - t)))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[LessEqual[y, -166269836987335460.0], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 4.180122896346843e-151], N[(N[(N[(y * z), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + N[(x - N[(N[(y * t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(1.0 / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;y \leq -166269836987335460:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\

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

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


\end{array}

Error

Target

Original11.2
Target1.1
Herbie0.6
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

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

    1. Initial program 25.0

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

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

    if -166269836987335456 < y < 4.18012289634684304e-151

    1. Initial program 0.4

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Simplified2.0

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

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

    if 4.18012289634684304e-151 < y

    1. Initial program 15.5

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
    2. Applied egg-rr1.0

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

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

Reproduce

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

  :herbie-target
  (+ x (/ y (/ (- a t) (- z t))))

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