?

Average Error: 12.8 → 3.3
Time: 8.1s
Precision: binary64
Cost: 976

?

\[\frac{x \cdot \left(y + z\right)}{z} \]
\[\begin{array}{l} t_0 := x \cdot \frac{y + z}{z}\\ t_1 := \frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{-89}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-258}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+81}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* x (/ (+ y z) z))) (t_1 (/ (* x (+ y z)) z)))
   (if (<= x -6.5e-89)
     (+ x (* x (/ y z)))
     (if (<= x -3.5e-260)
       t_1
       (if (<= x 8.6e-258) t_0 (if (<= x 2.1e+81) t_1 t_0))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double t_0 = x * ((y + z) / z);
	double t_1 = (x * (y + z)) / z;
	double tmp;
	if (x <= -6.5e-89) {
		tmp = x + (x * (y / z));
	} else if (x <= -3.5e-260) {
		tmp = t_1;
	} else if (x <= 8.6e-258) {
		tmp = t_0;
	} else if (x <= 2.1e+81) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x * (y + z)) / z
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = x * ((y + z) / z)
    t_1 = (x * (y + z)) / z
    if (x <= (-6.5d-89)) then
        tmp = x + (x * (y / z))
    else if (x <= (-3.5d-260)) then
        tmp = t_1
    else if (x <= 8.6d-258) then
        tmp = t_0
    else if (x <= 2.1d+81) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
public static double code(double x, double y, double z) {
	double t_0 = x * ((y + z) / z);
	double t_1 = (x * (y + z)) / z;
	double tmp;
	if (x <= -6.5e-89) {
		tmp = x + (x * (y / z));
	} else if (x <= -3.5e-260) {
		tmp = t_1;
	} else if (x <= 8.6e-258) {
		tmp = t_0;
	} else if (x <= 2.1e+81) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y + z)) / z
def code(x, y, z):
	t_0 = x * ((y + z) / z)
	t_1 = (x * (y + z)) / z
	tmp = 0
	if x <= -6.5e-89:
		tmp = x + (x * (y / z))
	elif x <= -3.5e-260:
		tmp = t_1
	elif x <= 8.6e-258:
		tmp = t_0
	elif x <= 2.1e+81:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y + z)) / z)
end
function code(x, y, z)
	t_0 = Float64(x * Float64(Float64(y + z) / z))
	t_1 = Float64(Float64(x * Float64(y + z)) / z)
	tmp = 0.0
	if (x <= -6.5e-89)
		tmp = Float64(x + Float64(x * Float64(y / z)));
	elseif (x <= -3.5e-260)
		tmp = t_1;
	elseif (x <= 8.6e-258)
		tmp = t_0;
	elseif (x <= 2.1e+81)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y + z)) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = x * ((y + z) / z);
	t_1 = (x * (y + z)) / z;
	tmp = 0.0;
	if (x <= -6.5e-89)
		tmp = x + (x * (y / z));
	elseif (x <= -3.5e-260)
		tmp = t_1;
	elseif (x <= 8.6e-258)
		tmp = t_0;
	elseif (x <= 2.1e+81)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[(y + z), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[x, -6.5e-89], N[(x + N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -3.5e-260], t$95$1, If[LessEqual[x, 8.6e-258], t$95$0, If[LessEqual[x, 2.1e+81], t$95$1, t$95$0]]]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := x \cdot \frac{y + z}{z}\\
t_1 := \frac{x \cdot \left(y + z\right)}{z}\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{-89}:\\
\;\;\;\;x + x \cdot \frac{y}{z}\\

\mathbf{elif}\;x \leq -3.5 \cdot 10^{-260}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 8.6 \cdot 10^{-258}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{+81}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.8
Target3.2
Herbie3.3
\[\frac{x}{\frac{z}{y + z}} \]

Derivation?

  1. Split input into 3 regimes
  2. if x < -6.50000000000000034e-89

    1. Initial program 16.6

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Simplified0.7

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      Proof

      [Start]16.6

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

      rational.json-simplify-2 [=>]16.6

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

      rational.json-simplify-49 [=>]0.7

      \[ \color{blue}{x \cdot \frac{y + z}{z}} \]
    3. Taylor expanded in y around 0 5.5

      \[\leadsto \color{blue}{\frac{y \cdot x}{z} + x} \]
    4. Simplified0.7

      \[\leadsto \color{blue}{x + x \cdot \frac{y}{z}} \]
      Proof

      [Start]5.5

      \[ \frac{y \cdot x}{z} + x \]

      rational.json-simplify-1 [=>]5.5

      \[ \color{blue}{x + \frac{y \cdot x}{z}} \]

      rational.json-simplify-49 [=>]0.7

      \[ x + \color{blue}{x \cdot \frac{y}{z}} \]

    if -6.50000000000000034e-89 < x < -3.5e-260 or 8.5999999999999992e-258 < x < 2.0999999999999999e81

    1. Initial program 4.7

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

    if -3.5e-260 < x < 8.5999999999999992e-258 or 2.0999999999999999e81 < x

    1. Initial program 23.3

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Simplified3.7

      \[\leadsto \color{blue}{x \cdot \frac{y + z}{z}} \]
      Proof

      [Start]23.3

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

      rational.json-simplify-2 [=>]23.3

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

      rational.json-simplify-49 [=>]3.7

      \[ \color{blue}{x \cdot \frac{y + z}{z}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.5 \cdot 10^{-89}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-260}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{-258}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+81}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error20.6
Cost848
\[\begin{array}{l} t_0 := x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -9.4 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-61}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-112}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 820:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error20.9
Cost848
\[\begin{array}{l} t_0 := y \cdot \frac{x}{z}\\ \mathbf{if}\;y \leq -6 \cdot 10^{+190}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -9.5 \cdot 10^{+119}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-66}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+27}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error21.0
Cost848
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1 \cdot 10^{+191}:\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{elif}\;y \leq -3.6 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-66}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+26}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
Alternative 4
Error20.8
Cost848
\[\begin{array}{l} t_0 := \frac{y \cdot x}{z}\\ \mathbf{if}\;y \leq -6 \cdot 10^{+190}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{+116}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -8.5 \cdot 10^{-66}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+30}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]
Alternative 5
Error4.4
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{y + z}{z}\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-283}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error3.3
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{y + z}{z}\\ \mathbf{if}\;z \leq -2.8 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.35 \cdot 10^{-271}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error3.3
Cost712
\[\begin{array}{l} t_0 := x + x \cdot \frac{y}{z}\\ \mathbf{if}\;z \leq -6 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.2 \cdot 10^{-271}:\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error25.4
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023074 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

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

  (/ (* x (+ y z)) z))