?

Average Error: 2.06% → 2.28%
Time: 12.3s
Precision: binary64
Cost: 969

?

\[x + y \cdot \frac{z - t}{a - t} \]
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{-162} \lor \neg \left(t \leq 4.5 \cdot 10^{-209}\right):\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - 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 (or (<= t -2e-162) (not (<= t 4.5e-209)))
   (+ x (* y (/ (- z t) (- a t))))
   (+ x (/ (* y (- z t)) (- a 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 ((t <= -2e-162) || !(t <= 4.5e-209)) {
		tmp = x + (y * ((z - t) / (a - t)));
	} else {
		tmp = x + ((y * (z - t)) / (a - t));
	}
	return tmp;
}
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    code = x + (y * ((z - t) / (a - t)))
end function
real(8) function code(x, y, z, t, a)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8) :: tmp
    if ((t <= (-2d-162)) .or. (.not. (t <= 4.5d-209))) then
        tmp = x + (y * ((z - t) / (a - t)))
    else
        tmp = x + ((y * (z - t)) / (a - t))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
	return x + (y * ((z - t) / (a - t)));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((t <= -2e-162) || !(t <= 4.5e-209)) {
		tmp = x + (y * ((z - t) / (a - t)));
	} else {
		tmp = x + ((y * (z - t)) / (a - t));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + (y * ((z - t) / (a - t)))
def code(x, y, z, t, a):
	tmp = 0
	if (t <= -2e-162) or not (t <= 4.5e-209):
		tmp = x + (y * ((z - t) / (a - t)))
	else:
		tmp = x + ((y * (z - t)) / (a - t))
	return tmp
function code(x, y, z, t, a)
	return Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if ((t <= -2e-162) || !(t <= 4.5e-209))
		tmp = Float64(x + Float64(y * Float64(Float64(z - t) / Float64(a - t))));
	else
		tmp = Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t)));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + (y * ((z - t) / (a - t)));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((t <= -2e-162) || ~((t <= 4.5e-209)))
		tmp = x + (y * ((z - t) / (a - t)));
	else
		tmp = x + ((y * (z - t)) / (a - t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -2e-162], N[Not[LessEqual[t, 4.5e-209]], $MachinePrecision]], N[(x + N[(y * N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x + y \cdot \frac{z - t}{a - t}
\begin{array}{l}
\mathbf{if}\;t \leq -2 \cdot 10^{-162} \lor \neg \left(t \leq 4.5 \cdot 10^{-209}\right):\\
\;\;\;\;x + y \cdot \frac{z - t}{a - t}\\

\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - t}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.06%
Target0.65%
Herbie2.28%
\[\begin{array}{l} \mathbf{if}\;y < -8.508084860551241 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \mathbf{elif}\;y < 2.894426862792089 \cdot 10^{-49}:\\ \;\;\;\;x + \left(y \cdot \left(z - t\right)\right) \cdot \frac{1}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a - t}\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if t < -1.99999999999999991e-162 or 4.4999999999999998e-209 < t

    1. Initial program 1.38

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

    if -1.99999999999999991e-162 < t < 4.4999999999999998e-209

    1. Initial program 5.25

      \[x + y \cdot \frac{z - t}{a - t} \]
    2. Simplified6.54

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

      [Start]5.25

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

      associate-*r/ [=>]6.54

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

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

Alternatives

Alternative 1
Error2.62%
Cost7748
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - t}{a - t}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{+73}:\\ \;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a - t}, x\right)\\ \mathbf{elif}\;t_1 \leq 2 \cdot 10^{+82}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - t}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{t - z}{\frac{a - t}{y}}\\ \end{array} \]
Alternative 2
Error2.93%
Cost2249
\[\begin{array}{l} t_1 := x + y \cdot \frac{z - t}{a - t}\\ \mathbf{if}\;t_1 \leq -4 \cdot 10^{+98} \lor \neg \left(t_1 \leq 2 \cdot 10^{+82}\right):\\ \;\;\;\;x - \frac{t - z}{\frac{a - t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{y \cdot \left(z - t\right)}{a - t}\\ \end{array} \]
Alternative 3
Error40.98%
Cost1572
\[\begin{array}{l} t_1 := y \cdot \frac{z}{a - t}\\ \mathbf{if}\;y \leq -3.4 \cdot 10^{+126}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq -1.42 \cdot 10^{+88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -6.8 \cdot 10^{-15}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{-92}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-35}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+237}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+280}:\\ \;\;\;\;y \cdot \frac{-t}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 4
Error24.54%
Cost1368
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{y}{a - t}\\ t_2 := x + \frac{t}{\frac{t - a}{y}}\\ \mathbf{if}\;x \leq -2.6 \cdot 10^{-60}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-98}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8 \cdot 10^{-202}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+45}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+75}:\\ \;\;\;\;x - y \cdot \frac{z - t}{t}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error24.8%
Cost1236
\[\begin{array}{l} t_1 := \left(z - t\right) \cdot \frac{y}{a - t}\\ \mathbf{if}\;t \leq -5.2 \cdot 10^{+94}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq -51000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -6.2 \cdot 10^{-82}:\\ \;\;\;\;x - t \cdot \frac{y}{a}\\ \mathbf{elif}\;t \leq 0.014:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{elif}\;t \leq 2.25 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 6
Error1.64%
Cost1220
\[\begin{array}{l} t_1 := \frac{z - t}{a - t}\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+302}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot t_1\\ \end{array} \]
Alternative 7
Error23.91%
Cost1106
\[\begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-60} \lor \neg \left(x \leq -4.2 \cdot 10^{-98}\right) \land \left(x \leq -3.6 \cdot 10^{-204} \lor \neg \left(x \leq 110000000000\right)\right):\\ \;\;\;\;x + \frac{t}{\frac{t - a}{y}}\\ \mathbf{else}:\\ \;\;\;\;\left(z - t\right) \cdot \frac{y}{a - t}\\ \end{array} \]
Alternative 8
Error16.18%
Cost973
\[\begin{array}{l} \mathbf{if}\;t \leq -2 \cdot 10^{+57}:\\ \;\;\;\;x + \frac{y}{\frac{a - t}{-t}}\\ \mathbf{elif}\;t \leq -7.4 \cdot 10^{-11} \lor \neg \left(t \leq 3.5 \cdot 10^{-17}\right):\\ \;\;\;\;x - y \cdot \frac{z - t}{t}\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \frac{z - t}{a}\\ \end{array} \]
Alternative 9
Error38.64%
Cost848
\[\begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{-60}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-98}:\\ \;\;\;\;z \cdot \frac{y}{a}\\ \mathbf{elif}\;x \leq -7.6 \cdot 10^{-206}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-290}:\\ \;\;\;\;y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 10
Error21.83%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -1 \cdot 10^{-10}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{-17}:\\ \;\;\;\;x + y \cdot \frac{z}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 11
Error21.81%
Cost712
\[\begin{array}{l} \mathbf{if}\;t \leq -2.5 \cdot 10^{-8}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{-18}:\\ \;\;\;\;x + z \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 12
Error32.17%
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -9.6 \cdot 10^{+26}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;t \leq 8.6 \cdot 10^{-212}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + y\\ \end{array} \]
Alternative 13
Error45.66%
Cost64
\[x \]

Error

Reproduce?

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

  :herbie-target
  (if (< y -8.508084860551241e-17) (+ x (* y (/ (- z t) (- a t)))) (if (< y 2.894426862792089e-49) (+ x (* (* y (- z t)) (/ 1.0 (- a t)))) (+ x (* y (/ (- z t) (- a t))))))

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