Average Error: 17.5 → 0.9
Time: 17.6s
Precision: 64
$\left(y \cdot y - y\right) \cdot {x}^{\left(y - 2\right)}$
$\begin{array}{l} \mathbf{if}\;y \le -2.76537328933368 \cdot 10^{-142}:\\ \;\;\;\;\left(\left(y - 1\right) \cdot \left({x}^{\left(\frac{y - 2}{2}\right)} \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right)\right) \cdot y\\ \mathbf{elif}\;y \le 7.78563079656421 \cdot 10^{-72}:\\ \;\;\;\;\left({x}^{\left(\frac{y - 2}{2}\right)} \cdot \left(y \cdot y - y\right)\right) \cdot {x}^{\left(\frac{y - 2}{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(y - 1\right) \cdot {x}^{\left(y - 2\right)}\right)\\ \end{array}$
\left(y \cdot y - y\right) \cdot {x}^{\left(y - 2\right)}
\begin{array}{l}
\mathbf{if}\;y \le -2.76537328933368 \cdot 10^{-142}:\\
\;\;\;\;\left(\left(y - 1\right) \cdot \left({x}^{\left(\frac{y - 2}{2}\right)} \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right)\right) \cdot y\\

\mathbf{elif}\;y \le 7.78563079656421 \cdot 10^{-72}:\\
\;\;\;\;\left({x}^{\left(\frac{y - 2}{2}\right)} \cdot \left(y \cdot y - y\right)\right) \cdot {x}^{\left(\frac{y - 2}{2}\right)}\\

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

\end{array}
double f(double y, double x) {
double r19643940 = y;
double r19643941 = r19643940 * r19643940;
double r19643942 = r19643941 - r19643940;
double r19643943 = x;
double r19643944 = 2.0;
double r19643945 = r19643940 - r19643944;
double r19643946 = pow(r19643943, r19643945);
double r19643947 = r19643942 * r19643946;
return r19643947;
}


double f(double y, double x) {
double r19643948 = y;
double r19643949 = -2.76537328933368e-142;
bool r19643950 = r19643948 <= r19643949;
double r19643951 = 1.0;
double r19643952 = r19643948 - r19643951;
double r19643953 = x;
double r19643954 = 2.0;
double r19643955 = r19643948 - r19643954;
double r19643956 = r19643955 / r19643954;
double r19643957 = pow(r19643953, r19643956);
double r19643958 = r19643957 * r19643957;
double r19643959 = r19643952 * r19643958;
double r19643960 = r19643959 * r19643948;
double r19643961 = 7.78563079656421e-72;
bool r19643962 = r19643948 <= r19643961;
double r19643963 = r19643948 * r19643948;
double r19643964 = r19643963 - r19643948;
double r19643965 = r19643957 * r19643964;
double r19643966 = r19643965 * r19643957;
double r19643967 = pow(r19643953, r19643955);
double r19643968 = r19643952 * r19643967;
double r19643969 = r19643948 * r19643968;
double r19643970 = r19643962 ? r19643966 : r19643969;
double r19643971 = r19643950 ? r19643960 : r19643970;
return r19643971;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Split input into 3 regimes
2. ## if y < -2.76537328933368e-142

1. Initial program 21.3

$\left(y \cdot y - y\right) \cdot {x}^{\left(y - 2\right)}$
2. Using strategy rm
3. Applied *-un-lft-identity21.3

$\leadsto \left(y \cdot y - \color{blue}{1 \cdot y}\right) \cdot {x}^{\left(y - 2\right)}$
4. Applied distribute-rgt-out--21.3

$\leadsto \color{blue}{\left(y \cdot \left(y - 1\right)\right)} \cdot {x}^{\left(y - 2\right)}$
5. Applied associate-*l*1.9

$\leadsto \color{blue}{y \cdot \left(\left(y - 1\right) \cdot {x}^{\left(y - 2\right)}\right)}$
6. Using strategy rm
7. Applied sqr-pow2.0

$\leadsto y \cdot \left(\left(y - 1\right) \cdot \color{blue}{\left({x}^{\left(\frac{y - 2}{2}\right)} \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right)}\right)$

## if -2.76537328933368e-142 < y < 7.78563079656421e-72

1. Initial program 11.0

$\left(y \cdot y - y\right) \cdot {x}^{\left(y - 2\right)}$
2. Using strategy rm
3. Applied sqr-pow11.1

$\leadsto \left(y \cdot y - y\right) \cdot \color{blue}{\left({x}^{\left(\frac{y - 2}{2}\right)} \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right)}$
4. Applied associate-*r*0.3

$\leadsto \color{blue}{\left(\left(y \cdot y - y\right) \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right) \cdot {x}^{\left(\frac{y - 2}{2}\right)}}$

## if 7.78563079656421e-72 < y

1. Initial program 24.8

$\left(y \cdot y - y\right) \cdot {x}^{\left(y - 2\right)}$
2. Using strategy rm
3. Applied *-un-lft-identity24.8

$\leadsto \left(y \cdot y - \color{blue}{1 \cdot y}\right) \cdot {x}^{\left(y - 2\right)}$
4. Applied distribute-rgt-out--24.8

$\leadsto \color{blue}{\left(y \cdot \left(y - 1\right)\right)} \cdot {x}^{\left(y - 2\right)}$
5. Applied associate-*l*0.4

$\leadsto \color{blue}{y \cdot \left(\left(y - 1\right) \cdot {x}^{\left(y - 2\right)}\right)}$
3. Recombined 3 regimes into one program.
4. Final simplification0.9

$\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.76537328933368 \cdot 10^{-142}:\\ \;\;\;\;\left(\left(y - 1\right) \cdot \left({x}^{\left(\frac{y - 2}{2}\right)} \cdot {x}^{\left(\frac{y - 2}{2}\right)}\right)\right) \cdot y\\ \mathbf{elif}\;y \le 7.78563079656421 \cdot 10^{-72}:\\ \;\;\;\;\left({x}^{\left(\frac{y - 2}{2}\right)} \cdot \left(y \cdot y - y\right)\right) \cdot {x}^{\left(\frac{y - 2}{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(\left(y - 1\right) \cdot {x}^{\left(y - 2\right)}\right)\\ \end{array}$

# Reproduce

herbie shell --seed 1
(FPCore (y x)
:name "(y*y-y)*(x^(y-2))"
(* (- (* y y) y) (pow x (- y 2))))