?

Average Error: 25.25% → 8.4%
Time: 15.0s
Precision: binary64
Cost: 8905

?

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

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


\end{array}

Error?

Target

Original25.25%
Target13.68%
Herbie8.4%
\[\begin{array}{l} \mathbf{if}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < -1.3664970889390727 \cdot 10^{-7}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \mathbf{elif}\;\left(x + y\right) - \frac{\left(z - t\right) \cdot y}{a - t} < 1.4754293444577233 \cdot 10^{-239}:\\ \;\;\;\;\frac{y \cdot \left(a - z\right) - x \cdot t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;\left(y + x\right) - \left(\left(z - t\right) \cdot \frac{1}{a - t}\right) \cdot y\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < -2.00000000000000004e-194 or 0.0 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t)))

    1. Initial program 19.58

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

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

      [Start]19.58

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

      associate--l+ [=>]19.39

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

      sub-neg [=>]19.39

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

      +-commutative [=>]19.39

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

      neg-mul-1 [=>]19.39

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

      associate-*l/ [<=]8.47

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

      associate-*r* [=>]8.47

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

      fma-def [=>]8.46

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

      mul-1-neg [=>]8.46

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

      neg-sub0 [=>]8.46

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

      div-sub [=>]8.46

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

      associate--r- [=>]8.46

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

      neg-sub0 [<=]8.46

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

      +-commutative [=>]8.46

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

      sub-neg [<=]8.46

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

      div-sub [<=]8.46

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

    if -2.00000000000000004e-194 < (-.f64 (+.f64 x y) (/.f64 (*.f64 (-.f64 z t) y) (-.f64 a t))) < 0.0

    1. Initial program 83.94

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

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

      [Start]83.94

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

      associate--l+ [=>]50.04

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

      sub-neg [=>]50.04

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

      +-commutative [=>]50.04

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

      neg-mul-1 [=>]50.04

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

      associate-*l/ [<=]48.91

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

      associate-*r* [=>]48.91

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

      fma-def [=>]48.91

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

      mul-1-neg [=>]48.91

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

      neg-sub0 [=>]48.91

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

      div-sub [=>]48.91

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

      associate--r- [=>]48.91

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

      neg-sub0 [<=]48.91

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

      +-commutative [=>]48.91

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

      sub-neg [<=]48.91

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

      div-sub [<=]48.91

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

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

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

      [Start]56.24

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

      +-commutative [=>]56.24

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

      associate-+l+ [=>]7.87

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

      associate-/l* [=>]7.84

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

      distribute-lft1-in [=>]7.84

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

      metadata-eval [=>]7.84

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

      mul0-lft [=>]7.84

      \[ x + \left(\frac{y}{\frac{t}{z - a}} + \color{blue}{0}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification8.4

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

Alternatives

Alternative 1
Error8.23%
Cost2633
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-194} \lor \neg \left(t_1 \leq 0\right):\\ \;\;\;\;x + \left(y - \frac{y}{\frac{a - t}{z - t}}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\ \end{array} \]
Alternative 2
Error16.65%
Cost1104
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;a \leq -2.1 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.35 \cdot 10^{-150}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \mathbf{elif}\;a \leq 6.6 \cdot 10^{-41}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{+30}:\\ \;\;\;\;x + \frac{y \cdot \left(z - a\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error16.55%
Cost1104
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;a \leq -5 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 2.7 \cdot 10^{-151}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\ \mathbf{elif}\;a \leq 8 \cdot 10^{-43}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \mathbf{elif}\;a \leq 2.5 \cdot 10^{+29}:\\ \;\;\;\;x + \frac{y \cdot \left(z - a\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error15.78%
Cost1100
\[\begin{array}{l} t_1 := \left(x + y\right) - \frac{y}{\frac{a}{z}}\\ \mathbf{if}\;a \leq -4.6 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.7 \cdot 10^{-221}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z - a}}\\ \mathbf{elif}\;a \leq 1.25 \cdot 10^{+26}:\\ \;\;\;\;x + \frac{1}{\frac{t - a}{y \cdot z}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error21.51%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -3.2 \cdot 10^{-40} \lor \neg \left(a \leq 3 \cdot 10^{+36}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - a}{t}\\ \end{array} \]
Alternative 6
Error17.52%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -4.1 \cdot 10^{+61} \lor \neg \left(a \leq 5 \cdot 10^{+202}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t - a}\\ \end{array} \]
Alternative 7
Error17.41%
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -1.02 \cdot 10^{+60} \lor \neg \left(a \leq 5.4 \cdot 10^{+202}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y}{\frac{t - a}{z}}\\ \end{array} \]
Alternative 8
Error22.75%
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -2.75 \cdot 10^{-39} \lor \neg \left(a \leq 2.7 \cdot 10^{+22}\right):\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z}{t}\\ \end{array} \]
Alternative 9
Error22.61%
Cost712
\[\begin{array}{l} \mathbf{if}\;a \leq -1.45 \cdot 10^{-39}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;a \leq 1.3 \cdot 10^{+24}:\\ \;\;\;\;x + \frac{y}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 10
Error32.04%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -2.4 \cdot 10^{+206}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{+165}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error42.16%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.75 \cdot 10^{-142}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-204}:\\ \;\;\;\;y\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error44.97%
Cost64
\[x \]

Error

Reproduce?

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

  :herbie-target
  (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) -1.3664970889390727e-7) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y)) (if (< (- (+ x y) (/ (* (- z t) y) (- a t))) 1.4754293444577233e-239) (/ (- (* y (- a z)) (* x t)) (- a t)) (- (+ y x) (* (* (- z t) (/ 1.0 (- a t))) y))))

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