?

Average Error: 12.6 → 1.7
Time: 9.1s
Precision: binary64
Cost: 712

?

\[\frac{x \cdot \left(y + z\right)}{z} \]
\[\begin{array}{l} t_0 := \left(1 + \frac{y}{z}\right) \cdot x\\ \mathbf{if}\;x \leq -5 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 10^{-104}:\\ \;\;\;\;\frac{y \cdot x}{z} + x\\ \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 (* (+ 1.0 (/ y z)) x)))
   (if (<= x -5e-42) t_0 (if (<= x 1e-104) (+ (/ (* y x) z) x) 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 = (1.0 + (y / z)) * x;
	double tmp;
	if (x <= -5e-42) {
		tmp = t_0;
	} else if (x <= 1e-104) {
		tmp = ((y * x) / z) + x;
	} 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) :: tmp
    t_0 = (1.0d0 + (y / z)) * x
    if (x <= (-5d-42)) then
        tmp = t_0
    else if (x <= 1d-104) then
        tmp = ((y * x) / z) + x
    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 = (1.0 + (y / z)) * x;
	double tmp;
	if (x <= -5e-42) {
		tmp = t_0;
	} else if (x <= 1e-104) {
		tmp = ((y * x) / z) + x;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y + z)) / z
def code(x, y, z):
	t_0 = (1.0 + (y / z)) * x
	tmp = 0
	if x <= -5e-42:
		tmp = t_0
	elif x <= 1e-104:
		tmp = ((y * x) / z) + x
	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(Float64(1.0 + Float64(y / z)) * x)
	tmp = 0.0
	if (x <= -5e-42)
		tmp = t_0;
	elseif (x <= 1e-104)
		tmp = Float64(Float64(Float64(y * x) / z) + x);
	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 = (1.0 + (y / z)) * x;
	tmp = 0.0;
	if (x <= -5e-42)
		tmp = t_0;
	elseif (x <= 1e-104)
		tmp = ((y * x) / z) + x;
	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[(N[(1.0 + N[(y / z), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]}, If[LessEqual[x, -5e-42], t$95$0, If[LessEqual[x, 1e-104], N[(N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision] + x), $MachinePrecision], t$95$0]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \left(1 + \frac{y}{z}\right) \cdot x\\
\mathbf{if}\;x \leq -5 \cdot 10^{-42}:\\
\;\;\;\;t_0\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.6
Target3.0
Herbie1.7
\[\frac{x}{\frac{z}{y + z}} \]

Derivation?

  1. Split input into 2 regimes
  2. if x < -5.00000000000000003e-42 or 9.99999999999999927e-105 < x

    1. Initial program 17.5

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Taylor expanded in y around 0 6.0

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

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

    if -5.00000000000000003e-42 < x < 9.99999999999999927e-105

    1. Initial program 6.4

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Taylor expanded in y around 0 3.3

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

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

Alternatives

Alternative 1
Error19.2
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -1.55 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{-106}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error3.3
Cost448
\[\left(1 + \frac{y}{z}\right) \cdot x \]
Alternative 3
Error25.6
Cost64
\[x \]

Error

Reproduce?

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