?

Average Error: 17.06% → 1.22%
Time: 11.0s
Precision: binary64
Cost: 7240

?

\[x + \frac{\left(y - z\right) \cdot t}{a - z} \]
\[\begin{array}{l} t_1 := \frac{y - z}{a - z}\\ \mathbf{if}\;t \leq -2 \cdot 10^{-94}:\\ \;\;\;\;x + t \cdot t_1\\ \mathbf{elif}\;t \leq 10^{-209}:\\ \;\;\;\;x + \frac{t \cdot \left(y - z\right)}{a - z}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t_1, t, x\right)\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) t) (- a z))))
(FPCore (x y z t a)
 :precision binary64
 (let* ((t_1 (/ (- y z) (- a z))))
   (if (<= t -2e-94)
     (+ x (* t t_1))
     (if (<= t 1e-209) (+ x (/ (* t (- y z)) (- a z))) (fma t_1 t x)))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * t) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
	double t_1 = (y - z) / (a - z);
	double tmp;
	if (t <= -2e-94) {
		tmp = x + (t * t_1);
	} else if (t <= 1e-209) {
		tmp = x + ((t * (y - z)) / (a - z));
	} else {
		tmp = fma(t_1, t, x);
	}
	return tmp;
}
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(Float64(y - z) * t) / Float64(a - z)))
end
function code(x, y, z, t, a)
	t_1 = Float64(Float64(y - z) / Float64(a - z))
	tmp = 0.0
	if (t <= -2e-94)
		tmp = Float64(x + Float64(t * t_1));
	elseif (t <= 1e-209)
		tmp = Float64(x + Float64(Float64(t * Float64(y - z)) / Float64(a - z)));
	else
		tmp = fma(t_1, t, x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * t), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -2e-94], N[(x + N[(t * t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1e-209], N[(x + N[(N[(t * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * t + x), $MachinePrecision]]]]
x + \frac{\left(y - z\right) \cdot t}{a - z}
\begin{array}{l}
t_1 := \frac{y - z}{a - z}\\
\mathbf{if}\;t \leq -2 \cdot 10^{-94}:\\
\;\;\;\;x + t \cdot t_1\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_1, t, x\right)\\


\end{array}

Error?

Target

Original17.06%
Target0.85%
Herbie1.22%
\[\begin{array}{l} \mathbf{if}\;t < -1.0682974490174067 \cdot 10^{-39}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \mathbf{elif}\;t < 3.9110949887586375 \cdot 10^{-141}:\\ \;\;\;\;x + \frac{\left(y - z\right) \cdot t}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y - z}{a - z} \cdot t\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if t < -1.9999999999999999e-94

    1. Initial program 26.75

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

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

      [Start]26.75

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

      associate-*l/ [<=]1.01

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

    if -1.9999999999999999e-94 < t < 1e-209

    1. Initial program 0.54

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

    if 1e-209 < t

    1. Initial program 20.33

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

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

      [Start]20.33

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

      +-commutative [=>]20.33

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

      associate-*l/ [<=]1.81

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

      fma-def [=>]1.81

      \[ \color{blue}{\mathsf{fma}\left(\frac{y - z}{a - z}, t, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.22

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

Alternatives

Alternative 1
Error35.2%
Cost976
\[\begin{array}{l} t_1 := t \cdot \frac{y}{a - z}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-42}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq -5.4 \cdot 10^{-123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-271}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.45 \cdot 10^{-145}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 2
Error1.22%
Cost969
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-94} \lor \neg \left(t \leq 5 \cdot 10^{-210}\right):\\ \;\;\;\;x + t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t \cdot \left(y - z\right)}{a - z}\\ \end{array} \]
Alternative 3
Error31.92%
Cost844
\[\begin{array}{l} \mathbf{if}\;z \leq -5.1 \cdot 10^{-123}:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-271}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-243}:\\ \;\;\;\;y \cdot \frac{t}{a - z}\\ \mathbf{elif}\;z \leq 1.52 \cdot 10^{-145}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 4
Error23.01%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -9 \cdot 10^{+113} \lor \neg \left(a \leq 1.36 \cdot 10^{+81}\right):\\ \;\;\;\;x + t \cdot \frac{y - z}{a}\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 5
Error22.98%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -195000:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-116}:\\ \;\;\;\;x + \frac{t}{\frac{a}{y}}\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 6
Error23.01%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -300000:\\ \;\;\;\;t + x\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-116}:\\ \;\;\;\;x + \frac{y}{\frac{a}{t}}\\ \mathbf{else}:\\ \;\;\;\;t + x\\ \end{array} \]
Alternative 7
Error1.96%
Cost704
\[x + t \cdot \frac{y - z}{a - z} \]
Alternative 8
Error31.43%
Cost456
\[\begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+114}:\\ \;\;\;\;x\\ \mathbf{elif}\;a \leq 9.4 \cdot 10^{+123}:\\ \;\;\;\;t + x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error45.48%
Cost64
\[x \]

Error

Reproduce?

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

  :herbie-target
  (if (< t -1.0682974490174067e-39) (+ x (* (/ (- y z) (- a z)) t)) (if (< t 3.9110949887586375e-141) (+ x (/ (* (- y z) t) (- a z))) (+ x (* (/ (- y z) (- a z)) t))))

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