Average Error: 11.8 → 1.3
Time: 12.0s
Precision: binary64
Cost: 1864
\[\frac{x \cdot \left(y - z\right)}{t - z} \]
\[\begin{array}{l} t_1 := \frac{x \cdot \left(y - z\right)}{t - z}\\ t_2 := x \cdot \frac{z - y}{z - t}\\ \mathbf{if}\;t_1 \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+280}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* x (- y z)) (- t z))) (t_2 (* x (/ (- z y) (- z t)))))
   (if (<= t_1 0.0) t_2 (if (<= t_1 5e+280) t_1 t_2))))
double code(double x, double y, double z, double t) {
	return (x * (y - z)) / (t - z);
}
double code(double x, double y, double z, double t) {
	double t_1 = (x * (y - z)) / (t - z);
	double t_2 = x * ((z - y) / (z - t));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_2;
	} else if (t_1 <= 5e+280) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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)) / (t - z)
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 = (x * (y - z)) / (t - z)
    t_2 = x * ((z - y) / (z - t))
    if (t_1 <= 0.0d0) then
        tmp = t_2
    else if (t_1 <= 5d+280) then
        tmp = t_1
    else
        tmp = t_2
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t) {
	return (x * (y - z)) / (t - z);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = (x * (y - z)) / (t - z);
	double t_2 = x * ((z - y) / (z - t));
	double tmp;
	if (t_1 <= 0.0) {
		tmp = t_2;
	} else if (t_1 <= 5e+280) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	return (x * (y - z)) / (t - z)
def code(x, y, z, t):
	t_1 = (x * (y - z)) / (t - z)
	t_2 = x * ((z - y) / (z - t))
	tmp = 0
	if t_1 <= 0.0:
		tmp = t_2
	elif t_1 <= 5e+280:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	return Float64(Float64(x * Float64(y - z)) / Float64(t - z))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(x * Float64(y - z)) / Float64(t - z))
	t_2 = Float64(x * Float64(Float64(z - y) / Float64(z - t)))
	tmp = 0.0
	if (t_1 <= 0.0)
		tmp = t_2;
	elseif (t_1 <= 5e+280)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = (x * (y - z)) / (t - z);
end
function tmp_2 = code(x, y, z, t)
	t_1 = (x * (y - z)) / (t - z);
	t_2 = x * ((z - y) / (z - t));
	tmp = 0.0;
	if (t_1 <= 0.0)
		tmp = t_2;
	elseif (t_1 <= 5e+280)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(z - y), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 0.0], t$95$2, If[LessEqual[t$95$1, 5e+280], t$95$1, t$95$2]]]]
\frac{x \cdot \left(y - z\right)}{t - z}
\begin{array}{l}
t_1 := \frac{x \cdot \left(y - z\right)}{t - z}\\
t_2 := x \cdot \frac{z - y}{z - t}\\
\mathbf{if}\;t_1 \leq 0:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+280}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.8
Target2.3
Herbie1.3
\[\frac{x}{\frac{t - z}{y - z}} \]

Derivation

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

    1. Initial program 18.2

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

      \[\leadsto \color{blue}{\left(z - y\right) \cdot \frac{x}{z - t}} \]
      Proof
      (*.f64 (-.f64 z y) (/.f64 x (-.f64 z t))): 0 points increase in error, 0 points decrease in error
      (Rewrite=> *-commutative_binary64 (*.f64 (/.f64 x (-.f64 z t)) (-.f64 z y))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/r/_binary64 (/.f64 x (/.f64 (-.f64 z t) (-.f64 z y)))): 28 points increase in error, 82 points decrease in error
      (/.f64 x (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 (-.f64 z t) (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (*.f64 (Rewrite<= metadata-eval (/.f64 -1 -1)) (/.f64 (-.f64 z t) (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (Rewrite<= times-frac_binary64 (/.f64 (*.f64 -1 (-.f64 z t)) (*.f64 -1 (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 z t))) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 z t))) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 z) t)) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 z)) t) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (Rewrite<= +-commutative_binary64 (+.f64 t (neg.f64 z))) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (Rewrite<= sub-neg_binary64 (-.f64 t z)) (*.f64 -1 (-.f64 z y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 z y))))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 z) y)))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 z)) y))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (Rewrite<= +-commutative_binary64 (+.f64 y (neg.f64 z))))): 0 points increase in error, 0 points decrease in error
      (/.f64 x (/.f64 (-.f64 t z) (Rewrite<= sub-neg_binary64 (-.f64 y z)))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z))): 62 points increase in error, 32 points decrease in error
    3. Taylor expanded in y around 0 18.2

      \[\leadsto \color{blue}{-1 \cdot \frac{y \cdot x}{z - t} + \frac{z \cdot x}{z - t}} \]
    4. Simplified1.8

      \[\leadsto \color{blue}{x \cdot \frac{z - y}{z - t}} \]
      Proof
      (*.f64 x (/.f64 (-.f64 z y) (-.f64 z t))): 0 points increase in error, 0 points decrease in error
      (*.f64 x (Rewrite=> div-sub_binary64 (-.f64 (/.f64 z (-.f64 z t)) (/.f64 y (-.f64 z t))))): 1 points increase in error, 3 points decrease in error
      (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 (/.f64 z (-.f64 z t)) x) (*.f64 (/.f64 y (-.f64 z t)) x))): 1 points increase in error, 5 points decrease in error
      (-.f64 (Rewrite<= associate-/r/_binary64 (/.f64 z (/.f64 (-.f64 z t) x))) (*.f64 (/.f64 y (-.f64 z t)) x)): 52 points increase in error, 9 points decrease in error
      (-.f64 (/.f64 z (/.f64 (-.f64 z t) x)) (Rewrite<= associate-/r/_binary64 (/.f64 y (/.f64 (-.f64 z t) x)))): 34 points increase in error, 22 points decrease in error
      (-.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z x) (-.f64 z t))) (/.f64 y (/.f64 (-.f64 z t) x))): 45 points increase in error, 48 points decrease in error
      (-.f64 (/.f64 (*.f64 z x) (-.f64 z t)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 y x) (-.f64 z t)))): 16 points increase in error, 35 points decrease in error
      (Rewrite<= unsub-neg_binary64 (+.f64 (/.f64 (*.f64 z x) (-.f64 z t)) (neg.f64 (/.f64 (*.f64 y x) (-.f64 z t))))): 0 points increase in error, 0 points decrease in error
      (+.f64 (/.f64 (*.f64 z x) (-.f64 z t)) (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (/.f64 (*.f64 y x) (-.f64 z t))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 -1 (/.f64 (*.f64 y x) (-.f64 z t))) (/.f64 (*.f64 z x) (-.f64 z t)))): 0 points increase in error, 0 points decrease in error

    if -0.0 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 5.0000000000000002e280

    1. Initial program 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{t - z} \leq 0:\\ \;\;\;\;x \cdot \frac{z - y}{z - t}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{t - z} \leq 5 \cdot 10^{+280}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{t - z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{z - y}{z - t}\\ \end{array} \]

Alternatives

Alternative 1
Error18.6
Cost1108
\[\begin{array}{l} t_1 := \frac{x \cdot y}{t - z}\\ t_2 := \frac{x}{1 - \frac{t}{z}}\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{-175}:\\ \;\;\;\;x \cdot \frac{z}{z - t}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.491350890860227 \cdot 10^{-7}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 8.465691406656736 \cdot 10^{+23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.1577269041135693 \cdot 10^{+47}:\\ \;\;\;\;x - \frac{y}{\frac{z}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error16.7
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{y - z}{t}\\ t_2 := x \cdot \frac{z}{z - t}\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{-68}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.276969419280598 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.1577269041135693 \cdot 10^{+47}:\\ \;\;\;\;x - \frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq 5.5066311012486035 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error16.8
Cost976
\[\begin{array}{l} t_1 := x \cdot \frac{z}{z - t}\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{-68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.276969419280598 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \frac{y - z}{t}\\ \mathbf{elif}\;z \leq 3.1577269041135693 \cdot 10^{+47}:\\ \;\;\;\;x - \frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;z \leq 1.2704109431304478 \cdot 10^{+61}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{t}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error19.5
Cost712
\[\begin{array}{l} t_1 := \frac{x}{1 - \frac{t}{z}}\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{-175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error19.5
Cost712
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-175}:\\ \;\;\;\;x \cdot \frac{z}{z - t}\\ \mathbf{elif}\;z \leq 4.9 \cdot 10^{-113}:\\ \;\;\;\;\frac{x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{1 - \frac{t}{z}}\\ \end{array} \]
Alternative 6
Error39.6
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{-208}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-139}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error26.0
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{-68}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7.276969419280598 \cdot 10^{-19}:\\ \;\;\;\;x \cdot \frac{y}{t}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error26.0
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{-68}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 7.276969419280598 \cdot 10^{-19}:\\ \;\;\;\;\frac{x}{\frac{t}{y}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error2.3
Cost576
\[x \cdot \frac{z - y}{z - t} \]
Alternative 10
Error40.1
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022291 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
  :precision binary64

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

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