?

Average Accuracy: 83.4% → 99.5%
Time: 10.3s
Precision: binary64
Cost: 7620

?

\[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+260}:\\ \;\;\;\;t_1 + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\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
 (let* ((t_1 (/ (* y (- z t)) (- a t))))
   (if (<= t_1 (- INFINITY))
     (fma y (/ (- z t) (- a t)) x)
     (if (<= t_1 2e+260) (+ t_1 x) (+ x (/ y (/ (- 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 t_1 = (y * (z - t)) / (a - t);
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = fma(y, ((z - t) / (a - t)), x);
	} else if (t_1 <= 2e+260) {
		tmp = t_1 + x;
	} else {
		tmp = x + (y / ((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)
	t_1 = Float64(Float64(y * Float64(z - t)) / Float64(a - t))
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = fma(y, Float64(Float64(z - t) / Float64(a - t)), x);
	elseif (t_1 <= 2e+260)
		tmp = Float64(t_1 + x);
	else
		tmp = Float64(x + Float64(y / 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_] := Block[{t$95$1 = N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t$95$1, 2e+260], N[(t$95$1 + x), $MachinePrecision], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
x + \frac{y \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\

\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+260}:\\
\;\;\;\;t_1 + x\\

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


\end{array}

Error?

Target

Original83.4%
Target98.1%
Herbie99.5%
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < -inf.0

    1. Initial program 0.0%

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

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

      [Start]0.0

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

      +-commutative [=>]0.0

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

      associate-*r/ [<=]99.8

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

      fma-def [=>]99.8

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

    if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 2.00000000000000013e260

    1. Initial program 99.6%

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

    if 2.00000000000000013e260 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))

    1. Initial program 11.9%

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

      \[\leadsto \color{blue}{x + \frac{y}{\frac{a - t}{z - t}}} \]
      Proof

      [Start]11.9

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

      associate-/l* [=>]97.7

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

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

Alternatives

Alternative 1
Accuracy99.5%
Cost1993
\[\begin{array}{l} t_1 := \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+260}\right):\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \mathbf{else}:\\ \;\;\;\;t_1 + x\\ \end{array} \]
Alternative 2
Accuracy80.5%
Cost972
\[\begin{array}{l} t_1 := x - t \cdot \frac{y}{a - t}\\ \mathbf{if}\;a \leq -7.2 \cdot 10^{-130}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.25 \cdot 10^{-90}:\\ \;\;\;\;x + y \cdot \frac{t - z}{t}\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]
Alternative 3
Accuracy81.7%
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{-126} \lor \neg \left(t \leq 1.5 \cdot 10^{-106}\right):\\ \;\;\;\;x - t \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \end{array} \]
Alternative 4
Accuracy77.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -2.9 \cdot 10^{-69} \lor \neg \left(t \leq 5 \cdot 10^{-20}\right):\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]
Alternative 5
Accuracy76.7%
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -3.8 \cdot 10^{-75} \lor \neg \left(t \leq 1.6 \cdot 10^{-23}\right):\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot z}{a}\\ \end{array} \]
Alternative 6
Accuracy95.1%
Cost704
\[x + \left(z - t\right) \cdot \frac{y}{a - t} \]
Alternative 7
Accuracy98.1%
Cost704
\[x + \frac{y}{\frac{a - t}{z - t}} \]
Alternative 8
Accuracy69.0%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -3 \cdot 10^{-57}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{-96}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 9
Accuracy58.0%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-223}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-129}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy54.7%
Cost64
\[x \]

Error

Reproduce?

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