Average Error: 2.3 → 8.1
Time: 10.0s
Precision: binary64
Cost: 1368
\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} t_1 := \frac{y - x}{\frac{y - z}{t}}\\ t_2 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -6.6395987094230575 \cdot 10^{+131}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{-150}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 2.663055089225907 \cdot 10^{+113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.0854625007987907 \cdot 10^{+142}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7.319036850923115 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (- y x) (/ (- y z) t))) (t_2 (/ t (- 1.0 (/ z y)))))
   (if (<= y -6.6395987094230575e+131)
     t_2
     (if (<= y -1e-190)
       t_1
       (if (<= y 1e-150)
         (* t (/ (- x y) z))
         (if (<= y 2.663055089225907e+113)
           t_1
           (if (<= y 1.0854625007987907e+142)
             t_2
             (if (<= y 7.319036850923115e+179)
               t_1
               (* t (- 1.0 (/ x y)))))))))))
double code(double x, double y, double z, double t) {
	return ((x - y) / (z - y)) * t;
}
double code(double x, double y, double z, double t) {
	double t_1 = (y - x) / ((y - z) / t);
	double t_2 = t / (1.0 - (z / y));
	double tmp;
	if (y <= -6.6395987094230575e+131) {
		tmp = t_2;
	} else if (y <= -1e-190) {
		tmp = t_1;
	} else if (y <= 1e-150) {
		tmp = t * ((x - y) / z);
	} else if (y <= 2.663055089225907e+113) {
		tmp = t_1;
	} else if (y <= 1.0854625007987907e+142) {
		tmp = t_2;
	} else if (y <= 7.319036850923115e+179) {
		tmp = t_1;
	} else {
		tmp = t * (1.0 - (x / y));
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = ((x - y) / (z - y)) * t
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = (y - x) / ((y - z) / t)
    t_2 = t / (1.0d0 - (z / y))
    if (y <= (-6.6395987094230575d+131)) then
        tmp = t_2
    else if (y <= (-1d-190)) then
        tmp = t_1
    else if (y <= 1d-150) then
        tmp = t * ((x - y) / z)
    else if (y <= 2.663055089225907d+113) then
        tmp = t_1
    else if (y <= 1.0854625007987907d+142) then
        tmp = t_2
    else if (y <= 7.319036850923115d+179) then
        tmp = t_1
    else
        tmp = t * (1.0d0 - (x / y))
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return ((x - y) / (z - y)) * t;
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (y - x) / ((y - z) / t);
	double t_2 = t / (1.0 - (z / y));
	double tmp;
	if (y <= -6.6395987094230575e+131) {
		tmp = t_2;
	} else if (y <= -1e-190) {
		tmp = t_1;
	} else if (y <= 1e-150) {
		tmp = t * ((x - y) / z);
	} else if (y <= 2.663055089225907e+113) {
		tmp = t_1;
	} else if (y <= 1.0854625007987907e+142) {
		tmp = t_2;
	} else if (y <= 7.319036850923115e+179) {
		tmp = t_1;
	} else {
		tmp = t * (1.0 - (x / y));
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x - y) / (z - y)) * t
def code(x, y, z, t):
	t_1 = (y - x) / ((y - z) / t)
	t_2 = t / (1.0 - (z / y))
	tmp = 0
	if y <= -6.6395987094230575e+131:
		tmp = t_2
	elif y <= -1e-190:
		tmp = t_1
	elif y <= 1e-150:
		tmp = t * ((x - y) / z)
	elif y <= 2.663055089225907e+113:
		tmp = t_1
	elif y <= 1.0854625007987907e+142:
		tmp = t_2
	elif y <= 7.319036850923115e+179:
		tmp = t_1
	else:
		tmp = t * (1.0 - (x / y))
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x - y) / Float64(z - y)) * t)
end
function code(x, y, z, t)
	t_1 = Float64(Float64(y - x) / Float64(Float64(y - z) / t))
	t_2 = Float64(t / Float64(1.0 - Float64(z / y)))
	tmp = 0.0
	if (y <= -6.6395987094230575e+131)
		tmp = t_2;
	elseif (y <= -1e-190)
		tmp = t_1;
	elseif (y <= 1e-150)
		tmp = Float64(t * Float64(Float64(x - y) / z));
	elseif (y <= 2.663055089225907e+113)
		tmp = t_1;
	elseif (y <= 1.0854625007987907e+142)
		tmp = t_2;
	elseif (y <= 7.319036850923115e+179)
		tmp = t_1;
	else
		tmp = Float64(t * Float64(1.0 - Float64(x / y)));
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x - y) / (z - y)) * t;
end
function tmp_2 = code(x, y, z, t)
	t_1 = (y - x) / ((y - z) / t);
	t_2 = t / (1.0 - (z / y));
	tmp = 0.0;
	if (y <= -6.6395987094230575e+131)
		tmp = t_2;
	elseif (y <= -1e-190)
		tmp = t_1;
	elseif (y <= 1e-150)
		tmp = t * ((x - y) / z);
	elseif (y <= 2.663055089225907e+113)
		tmp = t_1;
	elseif (y <= 1.0854625007987907e+142)
		tmp = t_2;
	elseif (y <= 7.319036850923115e+179)
		tmp = t_1;
	else
		tmp = t * (1.0 - (x / y));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y - x), $MachinePrecision] / N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t / N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6.6395987094230575e+131], t$95$2, If[LessEqual[y, -1e-190], t$95$1, If[LessEqual[y, 1e-150], N[(t * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.663055089225907e+113], t$95$1, If[LessEqual[y, 1.0854625007987907e+142], t$95$2, If[LessEqual[y, 7.319036850923115e+179], t$95$1, N[(t * N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{y - x}{\frac{y - z}{t}}\\
t_2 := \frac{t}{1 - \frac{z}{y}}\\
\mathbf{if}\;y \leq -6.6395987094230575 \cdot 10^{+131}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq -1 \cdot 10^{-190}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 10^{-150}:\\
\;\;\;\;t \cdot \frac{x - y}{z}\\

\mathbf{elif}\;y \leq 2.663055089225907 \cdot 10^{+113}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 1.0854625007987907 \cdot 10^{+142}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 7.319036850923115 \cdot 10^{+179}:\\
\;\;\;\;t_1\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.3
Target2.2
Herbie8.1
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation

  1. Split input into 4 regimes
  2. if y < -6.6395987094230575e131 or 2.663055089225907e113 < y < 1.08546250079879065e142

    1. Initial program 0.1

      \[\frac{x - y}{z - y} \cdot t \]
    2. Applied egg-rr0.1

      \[\leadsto \color{blue}{\frac{t}{\frac{z - y}{x - y}}} \]
    3. Taylor expanded in x around 0 9.1

      \[\leadsto \frac{t}{\color{blue}{-1 \cdot \frac{z - y}{y}}} \]
    4. Simplified9.1

      \[\leadsto \frac{t}{\color{blue}{1 - \frac{z}{y}}} \]

    if -6.6395987094230575e131 < y < -1e-190 or 1.00000000000000001e-150 < y < 2.663055089225907e113 or 1.08546250079879065e142 < y < 7.31903685092311492e179

    1. Initial program 1.8

      \[\frac{x - y}{z - y} \cdot t \]
    2. Simplified6.1

      \[\leadsto \color{blue}{\left(y - x\right) \cdot \frac{t}{y - z}} \]
    3. Applied egg-rr6.6

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

    if -1e-190 < y < 1.00000000000000001e-150

    1. Initial program 6.4

      \[\frac{x - y}{z - y} \cdot t \]
    2. Taylor expanded in z around inf 11.5

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

    if 7.31903685092311492e179 < y

    1. Initial program 0.1

      \[\frac{x - y}{z - y} \cdot t \]
    2. Taylor expanded in z around 0 7.3

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{x - y}{y}\right)} \cdot t \]
    3. Simplified7.3

      \[\leadsto \color{blue}{\left(1 - \frac{x}{y}\right)} \cdot t \]
  3. Recombined 4 regimes into one program.
  4. Final simplification8.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.6395987094230575 \cdot 10^{+131}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-190}:\\ \;\;\;\;\frac{y - x}{\frac{y - z}{t}}\\ \mathbf{elif}\;y \leq 10^{-150}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 2.663055089225907 \cdot 10^{+113}:\\ \;\;\;\;\frac{y - x}{\frac{y - z}{t}}\\ \mathbf{elif}\;y \leq 1.0854625007987907 \cdot 10^{+142}:\\ \;\;\;\;\frac{t}{1 - \frac{z}{y}}\\ \mathbf{elif}\;y \leq 7.319036850923115 \cdot 10^{+179}:\\ \;\;\;\;\frac{y - x}{\frac{y - z}{t}}\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error16.6
Cost1108
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -3.7 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-280}:\\ \;\;\;\;\frac{t \cdot x}{z - y}\\ \mathbf{elif}\;y \leq 4.194420665911374 \cdot 10^{-32}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 4.145718126844842 \cdot 10^{+107}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 7.319036850923115 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 2
Error16.4
Cost976
\[\begin{array}{l} t_1 := \frac{t}{1 - \frac{z}{y}}\\ \mathbf{if}\;y \leq -3.7 \cdot 10^{-70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.194420665911374 \cdot 10^{-32}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{elif}\;y \leq 4.145718126844842 \cdot 10^{+107}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \mathbf{elif}\;y \leq 7.319036850923115 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \end{array} \]
Alternative 3
Error19.6
Cost712
\[\begin{array}{l} t_1 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -1 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.194420665911374 \cdot 10^{-32}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error19.6
Cost712
\[\begin{array}{l} t_1 := t - \frac{t}{\frac{y}{x}}\\ \mathbf{if}\;y \leq -5 \cdot 10^{-82}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.194420665911374 \cdot 10^{-32}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error16.7
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -9.362998485213771 \cdot 10^{-35}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 4.194420665911374 \cdot 10^{-32}:\\ \;\;\;\;t \cdot \frac{x - y}{z}\\ \mathbf{else}:\\ \;\;\;\;t - \frac{t}{\frac{y}{x}}\\ \end{array} \]
Alternative 6
Error25.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-70}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 198149958486560.6:\\ \;\;\;\;\frac{t \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 7
Error24.9
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-70}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 198149958486560.6:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 8
Error24.9
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-70}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 198149958486560.6:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error39.6
Cost64
\[t \]

Error

Reproduce

herbie shell --seed 2022228 
(FPCore (x y z t)
  :name "Numeric.Signal.Multichannel:$cput from hsignal-0.2.7.1"
  :precision binary64

  :herbie-target
  (/ t (/ (- z y) (- x y)))

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