?

Average Accuracy: 62.0% → 85.5%
Time: 22.1s
Precision: binary64
Cost: 1362

?

\[x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z} \]
\[\begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+213} \lor \neg \left(z \leq 1.5 \cdot 10^{+50} \lor \neg \left(z \leq 6.1 \cdot 10^{+125}\right) \land z \leq 1.5 \cdot 10^{+203}\right):\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\ \end{array} \]
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y z) (- t x)) (- a z))))
(FPCore (x y z t a)
 :precision binary64
 (if (or (<= z -6.2e+213)
         (not (or (<= z 1.5e+50) (and (not (<= z 6.1e+125)) (<= z 1.5e+203)))))
   (+ t (/ (- x t) (/ z (- y a))))
   (+ x (* (- t x) (/ (- y z) (- a z))))))
double code(double x, double y, double z, double t, double a) {
	return x + (((y - z) * (t - x)) / (a - z));
}
double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z <= -6.2e+213) || !((z <= 1.5e+50) || (!(z <= 6.1e+125) && (z <= 1.5e+203)))) {
		tmp = t + ((x - t) / (z / (y - a)));
	} else {
		tmp = x + ((t - x) * ((y - z) / (a - z)));
	}
	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 - x)) / (a - z))
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 ((z <= (-6.2d+213)) .or. (.not. (z <= 1.5d+50) .or. (.not. (z <= 6.1d+125)) .and. (z <= 1.5d+203))) then
        tmp = t + ((x - t) / (z / (y - a)))
    else
        tmp = x + ((t - x) * ((y - z) / (a - z)))
    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 - x)) / (a - z));
}
public static double code(double x, double y, double z, double t, double a) {
	double tmp;
	if ((z <= -6.2e+213) || !((z <= 1.5e+50) || (!(z <= 6.1e+125) && (z <= 1.5e+203)))) {
		tmp = t + ((x - t) / (z / (y - a)));
	} else {
		tmp = x + ((t - x) * ((y - z) / (a - z)));
	}
	return tmp;
}
def code(x, y, z, t, a):
	return x + (((y - z) * (t - x)) / (a - z))
def code(x, y, z, t, a):
	tmp = 0
	if (z <= -6.2e+213) or not ((z <= 1.5e+50) or (not (z <= 6.1e+125) and (z <= 1.5e+203))):
		tmp = t + ((x - t) / (z / (y - a)))
	else:
		tmp = x + ((t - x) * ((y - z) / (a - z)))
	return tmp
function code(x, y, z, t, a)
	return Float64(x + Float64(Float64(Float64(y - z) * Float64(t - x)) / Float64(a - z)))
end
function code(x, y, z, t, a)
	tmp = 0.0
	if ((z <= -6.2e+213) || !((z <= 1.5e+50) || (!(z <= 6.1e+125) && (z <= 1.5e+203))))
		tmp = Float64(t + Float64(Float64(x - t) / Float64(z / Float64(y - a))));
	else
		tmp = Float64(x + Float64(Float64(t - x) * Float64(Float64(y - z) / Float64(a - z))));
	end
	return tmp
end
function tmp = code(x, y, z, t, a)
	tmp = x + (((y - z) * (t - x)) / (a - z));
end
function tmp_2 = code(x, y, z, t, a)
	tmp = 0.0;
	if ((z <= -6.2e+213) || ~(((z <= 1.5e+50) || (~((z <= 6.1e+125)) && (z <= 1.5e+203)))))
		tmp = t + ((x - t) / (z / (y - a)));
	else
		tmp = x + ((t - x) * ((y - z) / (a - z)));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - z), $MachinePrecision] * N[(t - x), $MachinePrecision]), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -6.2e+213], N[Not[Or[LessEqual[z, 1.5e+50], And[N[Not[LessEqual[z, 6.1e+125]], $MachinePrecision], LessEqual[z, 1.5e+203]]]], $MachinePrecision]], N[(t + N[(N[(x - t), $MachinePrecision] / N[(z / N[(y - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * N[(N[(y - z), $MachinePrecision] / N[(a - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
x + \frac{\left(y - z\right) \cdot \left(t - x\right)}{a - z}
\begin{array}{l}
\mathbf{if}\;z \leq -6.2 \cdot 10^{+213} \lor \neg \left(z \leq 1.5 \cdot 10^{+50} \lor \neg \left(z \leq 6.1 \cdot 10^{+125}\right) \land z \leq 1.5 \cdot 10^{+203}\right):\\
\;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original62.0%
Target80.4%
Herbie85.5%
\[\begin{array}{l} \mathbf{if}\;z < -1.2536131056095036 \cdot 10^{+188}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \mathbf{elif}\;z < 4.446702369113811 \cdot 10^{+64}:\\ \;\;\;\;x + \frac{y - z}{\frac{a - z}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{y}{z} \cdot \left(t - x\right)\\ \end{array} \]

Derivation?

  1. Split input into 2 regimes
  2. if z < -6.19999999999999981e213 or 1.4999999999999999e50 < z < 6.09999999999999977e125 or 1.5e203 < z

    1. Initial program 29.7%

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

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

      [Start]29.7

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

      associate-*l/ [<=]66.3

      \[ x + \color{blue}{\frac{y - z}{a - z} \cdot \left(t - x\right)} \]
    3. Taylor expanded in z around inf 61.8%

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

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

      [Start]61.8

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

      +-commutative [=>]61.8

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

      associate--l+ [=>]61.8

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

      associate-*r/ [=>]61.8

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

      associate-*r/ [=>]61.8

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

      div-sub [<=]61.8

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

      distribute-lft-out-- [=>]61.8

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

      associate-*r/ [<=]61.8

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

      mul-1-neg [=>]61.8

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

      unsub-neg [=>]61.8

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

      distribute-rgt-out-- [=>]61.8

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

      associate-/l* [=>]82.9

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

    if -6.19999999999999981e213 < z < 1.4999999999999999e50 or 6.09999999999999977e125 < z < 1.5e203

    1. Initial program 72.7%

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

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

      [Start]72.7

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

      associate-*l/ [<=]86.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -6.2 \cdot 10^{+213} \lor \neg \left(z \leq 1.5 \cdot 10^{+50} \lor \neg \left(z \leq 6.1 \cdot 10^{+125}\right) \land z \leq 1.5 \cdot 10^{+203}\right):\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y - z}{a - z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy61.5%
Cost2028
\[\begin{array}{l} t_1 := \left(y - z\right) \cdot \frac{t}{a - z}\\ t_2 := x + \left(t - x\right) \cdot \frac{y}{a}\\ t_3 := t \cdot \frac{y - z}{a - z}\\ \mathbf{if}\;a \leq -3.8 \cdot 10^{+196}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.9 \cdot 10^{+132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.7 \cdot 10^{+72}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.4 \cdot 10^{-184}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 6 \cdot 10^{-190}:\\ \;\;\;\;t + \frac{\left(y - a\right) \cdot \left(x - t\right)}{z}\\ \mathbf{elif}\;a \leq 2.1 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 4.1 \cdot 10^{+68}:\\ \;\;\;\;x \cdot \left(\frac{z - y}{a - z} + 1\right)\\ \mathbf{elif}\;a \leq 1.35 \cdot 10^{+100}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 2.9 \cdot 10^{+133}:\\ \;\;\;\;x + \frac{z \cdot \left(x - t\right)}{a}\\ \mathbf{elif}\;a \leq 1.35 \cdot 10^{+136}:\\ \;\;\;\;\frac{x \cdot \left(-a\right)}{z}\\ \mathbf{elif}\;a \leq 8.2 \cdot 10^{+194}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t - x}{\frac{a}{y}}\\ \end{array} \]
Alternative 2
Accuracy44.9%
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{a}\right)\\ \mathbf{if}\;z \leq -5.8 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-215}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-267}:\\ \;\;\;\;t \cdot \frac{y}{a - z}\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 3
Accuracy45.0%
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(1 - \frac{y}{a}\right)\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -1.55 \cdot 10^{-215}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{-267}:\\ \;\;\;\;t \cdot \frac{y}{a - z}\\ \mathbf{elif}\;z \leq 3.55 \cdot 10^{-6}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{z} \cdot \left(z - y\right)\\ \end{array} \]
Alternative 4
Accuracy72.6%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -1.4 \cdot 10^{+25} \lor \neg \left(z \leq 1.45 \cdot 10^{-6}\right):\\ \;\;\;\;t + \frac{x - t}{\frac{z}{y - a}}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t - x}{\frac{a}{y}}\\ \end{array} \]
Alternative 5
Accuracy38.8%
Cost844
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-206}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-209}:\\ \;\;\;\;t \cdot \frac{y}{a - z}\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-12}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 6
Accuracy61.1%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -1.1 \cdot 10^{+14} \lor \neg \left(z \leq 1.9 \cdot 10^{-11}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \end{array} \]
Alternative 7
Accuracy65.4%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -29500000000000 \lor \neg \left(z \leq 3.1 \cdot 10^{-13}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot \frac{y}{a}\\ \end{array} \]
Alternative 8
Accuracy65.3%
Cost841
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+15} \lor \neg \left(z \leq 2.8 \cdot 10^{-7}\right):\\ \;\;\;\;t \cdot \frac{y - z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t - x}{\frac{a}{y}}\\ \end{array} \]
Alternative 9
Accuracy55.8%
Cost777
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{+16} \lor \neg \left(z \leq 3.1 \cdot 10^{-7}\right):\\ \;\;\;\;t \cdot \frac{-z}{a - z}\\ \mathbf{else}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \end{array} \]
Alternative 10
Accuracy55.8%
Cost776
\[\begin{array}{l} \mathbf{if}\;z \leq -19500000000000:\\ \;\;\;\;\frac{-t}{-1 + \frac{a}{z}}\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{-8}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \frac{-z}{a - z}\\ \end{array} \]
Alternative 11
Accuracy38.2%
Cost716
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-206}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{-209}:\\ \;\;\;\;y \cdot \frac{t}{a}\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 12
Accuracy38.2%
Cost716
\[\begin{array}{l} \mathbf{if}\;z \leq -3.8 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-206}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4.3 \cdot 10^{-209}:\\ \;\;\;\;\frac{y}{\frac{a}{t}}\\ \mathbf{elif}\;z \leq 1.42 \cdot 10^{-5}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 13
Accuracy51.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+190}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq 1.4 \cdot 10^{+57}:\\ \;\;\;\;x + t \cdot \frac{y}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{z} \cdot \left(z - y\right)\\ \end{array} \]
Alternative 14
Accuracy41.3%
Cost328
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{+178}:\\ \;\;\;\;t\\ \mathbf{elif}\;z \leq 6 \cdot 10^{-6}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 15
Accuracy28.1%
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023147 
(FPCore (x y z t a)
  :name "Graphics.Rendering.Chart.Axis.Types:invLinMap from Chart-1.5.3"
  :precision binary64

  :herbie-target
  (if (< z -1.2536131056095036e+188) (- t (* (/ y z) (- t x))) (if (< z 4.446702369113811e+64) (+ x (/ (- y z) (/ (- a z) (- t x)))) (- t (* (/ y z) (- t x)))))

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