Average Error: 2.9 → 0.2
Time: 16.2s
Precision: 64
\[\left(1 - \frac{o}{p}\right) \cdot r\]
\[\begin{array}{l} \mathbf{if}\;\frac{o}{p} \le -1.255206475680906662837912714020464792079 \cdot 10^{237} \lor \neg \left(\frac{o}{p} \le 9.592123306738074271992242117898291948964 \cdot 10^{191}\right):\\ \;\;\;\;1 \cdot r - \frac{r \cdot o}{p}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{o}{p}\right) \cdot r\\ \end{array}\]
\left(1 - \frac{o}{p}\right) \cdot r
\begin{array}{l}
\mathbf{if}\;\frac{o}{p} \le -1.255206475680906662837912714020464792079 \cdot 10^{237} \lor \neg \left(\frac{o}{p} \le 9.592123306738074271992242117898291948964 \cdot 10^{191}\right):\\
\;\;\;\;1 \cdot r - \frac{r \cdot o}{p}\\

\mathbf{else}:\\
\;\;\;\;\left(1 - \frac{o}{p}\right) \cdot r\\

\end{array}
double f(double o, double p, double r) {
        double r321191 = 1.0;
        double r321192 = o;
        double r321193 = p;
        double r321194 = r321192 / r321193;
        double r321195 = r321191 - r321194;
        double r321196 = r;
        double r321197 = r321195 * r321196;
        return r321197;
}

double f(double o, double p, double r) {
        double r321198 = o;
        double r321199 = p;
        double r321200 = r321198 / r321199;
        double r321201 = -1.2552064756809067e+237;
        bool r321202 = r321200 <= r321201;
        double r321203 = 9.592123306738074e+191;
        bool r321204 = r321200 <= r321203;
        double r321205 = !r321204;
        bool r321206 = r321202 || r321205;
        double r321207 = 1.0;
        double r321208 = r;
        double r321209 = r321207 * r321208;
        double r321210 = r321208 * r321198;
        double r321211 = r321210 / r321199;
        double r321212 = r321209 - r321211;
        double r321213 = r321207 - r321200;
        double r321214 = r321213 * r321208;
        double r321215 = r321206 ? r321212 : r321214;
        return r321215;
}

Error

Bits error versus o

Bits error versus p

Bits error versus r

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (/ o p) < -1.2552064756809067e+237 or 9.592123306738074e+191 < (/ o p)

    1. Initial program 26.9

      \[\left(1 - \frac{o}{p}\right) \cdot r\]
    2. Taylor expanded around 0 0.9

      \[\leadsto \color{blue}{1 \cdot r - \frac{r \cdot o}{p}}\]

    if -1.2552064756809067e+237 < (/ o p) < 9.592123306738074e+191

    1. Initial program 0.1

      \[\left(1 - \frac{o}{p}\right) \cdot r\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{o}{p} \le -1.255206475680906662837912714020464792079 \cdot 10^{237} \lor \neg \left(\frac{o}{p} \le 9.592123306738074271992242117898291948964 \cdot 10^{191}\right):\\ \;\;\;\;1 \cdot r - \frac{r \cdot o}{p}\\ \mathbf{else}:\\ \;\;\;\;\left(1 - \frac{o}{p}\right) \cdot r\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (o p r)
  :name "(1- o/p) * r"
  :precision binary64
  (* (- 1 (/ o p)) r))