Average Error: 11.0 → 0.7
Time: 10.7s
Precision: binary64
Cost: 8265
\[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 \lor \neg \left(t_1 \leq 4 \cdot 10^{+94}\right):\\ \;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 + x\\ \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 (or (<= t_1 (- INFINITY)) (not (<= t_1 4e+94)))
     (fma y (/ (- z t) (- a t)) x)
     (+ t_1 x))))
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)) || !(t_1 <= 4e+94)) {
		tmp = fma(y, ((z - t) / (a - t)), x);
	} else {
		tmp = t_1 + x;
	}
	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)) || !(t_1 <= 4e+94))
		tmp = fma(y, Float64(Float64(z - t) / Float64(a - t)), x);
	else
		tmp = Float64(t_1 + x);
	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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 4e+94]], $MachinePrecision]], N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(t$95$1 + x), $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 \lor \neg \left(t_1 \leq 4 \cdot 10^{+94}\right):\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)\\

\mathbf{else}:\\
\;\;\;\;t_1 + x\\


\end{array}

Error

Target

Original11.0
Target1.3
Herbie0.7
\[x + \frac{y}{\frac{a - t}{z - t}} \]

Derivation

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

    1. Initial program 44.0

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, \frac{z - t}{a - t}, x\right)} \]
      Proof
      (fma.f64 y (/.f64 (-.f64 z t) (-.f64 a t)) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (/.f64 (-.f64 z t) (-.f64 a t))) x)): 0 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t))) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)))): 2 points increase in error, 0 points decrease in error

    if -inf.0 < (/.f64 (*.f64 y (-.f64 z t)) (-.f64 a t)) < 4.0000000000000001e94

    1. Initial program 0.2

      \[x + \frac{y \cdot \left(z - t\right)}{a - t} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

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

Alternatives

Alternative 1
Error0.6
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 4 \cdot 10^{+94}\right):\\ \;\;\;\;x + \frac{y}{\frac{a - t}{z - t}}\\ \mathbf{else}:\\ \;\;\;\;t_1 + x\\ \end{array} \]
Alternative 2
Error17.0
Cost1372
\[\begin{array}{l} t_1 := x + z \cdot \frac{y}{a}\\ \mathbf{if}\;x \leq -6.4 \cdot 10^{+42}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{+21}:\\ \;\;\;\;x - y \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-44}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-119}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;x \leq 15200000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5 \cdot 10^{+59}:\\ \;\;\;\;x + y \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{+83}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 3
Error16.9
Cost1108
\[\begin{array}{l} \mathbf{if}\;x \leq -6.4 \cdot 10^{+42}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq -4.1 \cdot 10^{+21}:\\ \;\;\;\;x - y \cdot \frac{t}{a}\\ \mathbf{elif}\;x \leq -4.5 \cdot 10^{-37}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-116}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;x \leq 450000:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 4
Error4.8
Cost969
\[\begin{array}{l} \mathbf{if}\;x \leq -4.4 \cdot 10^{-187} \lor \neg \left(x \leq 1.92 \cdot 10^{-121}\right):\\ \;\;\;\;x + \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{z - t}{a - t}\\ \end{array} \]
Alternative 5
Error10.5
Cost841
\[\begin{array}{l} \mathbf{if}\;t \leq -5 \cdot 10^{-17} \lor \neg \left(t \leq 2.4 \cdot 10^{-91}\right):\\ \;\;\;\;x - \frac{y}{\frac{a}{t} + -1}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \end{array} \]
Alternative 6
Error11.9
Cost840
\[\begin{array}{l} \mathbf{if}\;t \leq -3.3 \cdot 10^{+44}:\\ \;\;\;\;x + y \cdot \left(1 - \frac{z}{t}\right)\\ \mathbf{elif}\;t \leq 3.3 \cdot 10^{-90}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - t \cdot \frac{y}{a - t}\\ \end{array} \]
Alternative 7
Error15.0
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -1.35 \cdot 10^{+50} \lor \neg \left(t \leq 4.4 \cdot 10^{-85}\right):\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{a}\\ \end{array} \]
Alternative 8
Error14.9
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1.2 \cdot 10^{+49}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{-94}:\\ \;\;\;\;x + \frac{y}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 9
Error1.3
Cost704
\[x + \frac{y}{\frac{a - t}{z - t}} \]
Alternative 10
Error20.4
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -7.2 \cdot 10^{-66}:\\ \;\;\;\;y + x\\ \mathbf{elif}\;t \leq 5.4 \cdot 10^{-157}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 11
Error29.6
Cost64
\[x \]

Error

Reproduce

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