?

Average Error: 2.3 → 1.5
Time: 11.1s
Precision: binary64
Cost: 1865

?

\[\frac{x - y}{z - y} \cdot t \]
\[\begin{array}{l} t_1 := \frac{x - y}{z - y} \cdot t\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-301} \lor \neg \left(t_1 \leq 0\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* (/ (- x y) (- z y)) t))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* (/ (- x y) (- z y)) t)))
   (if (or (<= t_1 -1e-301) (not (<= t_1 0.0))) t_1 (/ (* (- x y) t) z))))
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 = ((x - y) / (z - y)) * t;
	double tmp;
	if ((t_1 <= -1e-301) || !(t_1 <= 0.0)) {
		tmp = t_1;
	} else {
		tmp = ((x - y) * t) / z;
	}
	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) :: tmp
    t_1 = ((x - y) / (z - y)) * t
    if ((t_1 <= (-1d-301)) .or. (.not. (t_1 <= 0.0d0))) then
        tmp = t_1
    else
        tmp = ((x - y) * t) / z
    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 = ((x - y) / (z - y)) * t;
	double tmp;
	if ((t_1 <= -1e-301) || !(t_1 <= 0.0)) {
		tmp = t_1;
	} else {
		tmp = ((x - y) * t) / z;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x - y) / (z - y)) * t
def code(x, y, z, t):
	t_1 = ((x - y) / (z - y)) * t
	tmp = 0
	if (t_1 <= -1e-301) or not (t_1 <= 0.0):
		tmp = t_1
	else:
		tmp = ((x - y) * t) / z
	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(Float64(x - y) / Float64(z - y)) * t)
	tmp = 0.0
	if ((t_1 <= -1e-301) || !(t_1 <= 0.0))
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(x - y) * t) / z);
	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 = ((x - y) / (z - y)) * t;
	tmp = 0.0;
	if ((t_1 <= -1e-301) || ~((t_1 <= 0.0)))
		tmp = t_1;
	else
		tmp = ((x - y) * t) / z;
	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[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-301], N[Not[LessEqual[t$95$1, 0.0]], $MachinePrecision]], t$95$1, N[(N[(N[(x - y), $MachinePrecision] * t), $MachinePrecision] / z), $MachinePrecision]]]
\frac{x - y}{z - y} \cdot t
\begin{array}{l}
t_1 := \frac{x - y}{z - y} \cdot t\\
\mathbf{if}\;t_1 \leq -1 \cdot 10^{-301} \lor \neg \left(t_1 \leq 0\right):\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original2.3
Target2.3
Herbie1.5
\[\frac{t}{\frac{z - y}{x - y}} \]

Derivation?

  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t) < -1.00000000000000007e-301 or 0.0 < (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t)

    1. Initial program 1.5

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

    if -1.00000000000000007e-301 < (*.f64 (/.f64 (-.f64 x y) (-.f64 z y)) t) < 0.0

    1. Initial program 9.5

      \[\frac{x - y}{z - y} \cdot t \]
    2. Simplified1.9

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

      [Start]9.5

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

      associate-*l/ [=>]0.2

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

      associate-*r/ [<=]1.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x - y}{z - y} \cdot t \leq -1 \cdot 10^{-301} \lor \neg \left(\frac{x - y}{z - y} \cdot t \leq 0\right):\\ \;\;\;\;\frac{x - y}{z - y} \cdot t\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(x - y\right) \cdot t}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error17.7
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-12} \lor \neg \left(y \leq 2.8 \cdot 10^{-123}\right) \land \left(y \leq 2.6 \cdot 10^{-73} \lor \neg \left(y \leq 4.5 \cdot 10^{+29}\right)\right):\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \end{array} \]
Alternative 2
Error23.2
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{+75}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107} \lor \neg \left(y \leq 1.4 \cdot 10^{-56}\right) \land y \leq 9.6 \cdot 10^{+23}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 3
Error16.8
Cost977
\[\begin{array}{l} \mathbf{if}\;y \leq -1.12 \cdot 10^{-11}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 10^{-54} \lor \neg \left(y \leq 0.00022\right):\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \end{array} \]
Alternative 4
Error18.6
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{t}{z - y}\\ t_2 := t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-12}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-56}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error16.8
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -1.2 \cdot 10^{-11}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 1.95 \cdot 10^{-107}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-56}:\\ \;\;\;\;t \cdot \frac{y}{y - z}\\ \mathbf{elif}\;y \leq 0.00035:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \end{array} \]
Alternative 6
Error16.8
Cost976
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{-12}:\\ \;\;\;\;t \cdot \left(1 - \frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-107}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{-55}:\\ \;\;\;\;\frac{-y}{\frac{z - y}{t}}\\ \mathbf{elif}\;y \leq 33:\\ \;\;\;\;x \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \end{array} \]
Alternative 7
Error26.7
Cost849
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107} \lor \neg \left(y \leq 1.65 \cdot 10^{-56}\right) \land y \leq 8.6 \cdot 10^{+21}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 8
Error26.2
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-73}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.75 \cdot 10^{+22}:\\ \;\;\;\;t \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 9
Error26.2
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -9.6 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107}:\\ \;\;\;\;x \cdot \frac{t}{z}\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{-73}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+22}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 10
Error26.3
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{-12}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-107}:\\ \;\;\;\;\frac{x}{\frac{z}{t}}\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-73}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+22}:\\ \;\;\;\;\frac{t}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 11
Error7.6
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+83}:\\ \;\;\;\;\frac{t}{\frac{y}{y - x}}\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{+99}:\\ \;\;\;\;\left(x - y\right) \cdot \frac{t}{z - y}\\ \mathbf{else}:\\ \;\;\;\;\frac{t}{\frac{y - z}{y}}\\ \end{array} \]
Alternative 12
Error40.1
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023031 
(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))