?

Average Error: 12.8 → 1.6
Time: 28.4s
Precision: binary64
Cost: 7688

?

\[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ t_1 := \left(t_0 - {\left(w \cdot r\right)}^{2} \cdot 0.25\right) - 4.5\\ \mathbf{if}\;v \leq -4 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;v \leq 0.00165:\\ \;\;\;\;t_0 - \left(\frac{r \cdot \left(\left(w \cdot \left(w \cdot r\right)\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
(FPCore (v w r)
 :precision binary64
 (-
  (-
   (+ 3.0 (/ 2.0 (* r r)))
   (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v)))
  4.5))
(FPCore (v w r)
 :precision binary64
 (let* ((t_0 (+ 3.0 (/ 2.0 (* r r))))
        (t_1 (- (- t_0 (* (pow (* w r) 2.0) 0.25)) 4.5)))
   (if (<= v -4e+39)
     t_1
     (if (<= v 0.00165)
       (-
        t_0
        (+
         (/ (* r (* (* w (* w r)) (* 0.125 (- 3.0 (* 2.0 v))))) (- 1.0 v))
         4.5))
       t_1))))
double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
double code(double v, double w, double r) {
	double t_0 = 3.0 + (2.0 / (r * r));
	double t_1 = (t_0 - (pow((w * r), 2.0) * 0.25)) - 4.5;
	double tmp;
	if (v <= -4e+39) {
		tmp = t_1;
	} else if (v <= 0.00165) {
		tmp = t_0 - (((r * ((w * (w * r)) * (0.125 * (3.0 - (2.0 * v))))) / (1.0 - v)) + 4.5);
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
real(8) function code(v, w, r)
    real(8), intent (in) :: v
    real(8), intent (in) :: w
    real(8), intent (in) :: r
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 3.0d0 + (2.0d0 / (r * r))
    t_1 = (t_0 - (((w * r) ** 2.0d0) * 0.25d0)) - 4.5d0
    if (v <= (-4d+39)) then
        tmp = t_1
    else if (v <= 0.00165d0) then
        tmp = t_0 - (((r * ((w * (w * r)) * (0.125d0 * (3.0d0 - (2.0d0 * v))))) / (1.0d0 - v)) + 4.5d0)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double v, double w, double r) {
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
public static double code(double v, double w, double r) {
	double t_0 = 3.0 + (2.0 / (r * r));
	double t_1 = (t_0 - (Math.pow((w * r), 2.0) * 0.25)) - 4.5;
	double tmp;
	if (v <= -4e+39) {
		tmp = t_1;
	} else if (v <= 0.00165) {
		tmp = t_0 - (((r * ((w * (w * r)) * (0.125 * (3.0 - (2.0 * v))))) / (1.0 - v)) + 4.5);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(v, w, r):
	return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
def code(v, w, r):
	t_0 = 3.0 + (2.0 / (r * r))
	t_1 = (t_0 - (math.pow((w * r), 2.0) * 0.25)) - 4.5
	tmp = 0
	if v <= -4e+39:
		tmp = t_1
	elif v <= 0.00165:
		tmp = t_0 - (((r * ((w * (w * r)) * (0.125 * (3.0 - (2.0 * v))))) / (1.0 - v)) + 4.5)
	else:
		tmp = t_1
	return tmp
function code(v, w, r)
	return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5)
end
function code(v, w, r)
	t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r)))
	t_1 = Float64(Float64(t_0 - Float64((Float64(w * r) ^ 2.0) * 0.25)) - 4.5)
	tmp = 0.0
	if (v <= -4e+39)
		tmp = t_1;
	elseif (v <= 0.00165)
		tmp = Float64(t_0 - Float64(Float64(Float64(r * Float64(Float64(w * Float64(w * r)) * Float64(0.125 * Float64(3.0 - Float64(2.0 * v))))) / Float64(1.0 - v)) + 4.5));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp = code(v, w, r)
	tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
end
function tmp_2 = code(v, w, r)
	t_0 = 3.0 + (2.0 / (r * r));
	t_1 = (t_0 - (((w * r) ^ 2.0) * 0.25)) - 4.5;
	tmp = 0.0;
	if (v <= -4e+39)
		tmp = t_1;
	elseif (v <= 0.00165)
		tmp = t_0 - (((r * ((w * (w * r)) * (0.125 * (3.0 - (2.0 * v))))) / (1.0 - v)) + 4.5);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 - N[(N[Power[N[(w * r), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]}, If[LessEqual[v, -4e+39], t$95$1, If[LessEqual[v, 0.00165], N[(t$95$0 - N[(N[(N[(r * N[(N[(w * N[(w * r), $MachinePrecision]), $MachinePrecision] * N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
t_1 := \left(t_0 - {\left(w \cdot r\right)}^{2} \cdot 0.25\right) - 4.5\\
\mathbf{if}\;v \leq -4 \cdot 10^{+39}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;v \leq 0.00165:\\
\;\;\;\;t_0 - \left(\frac{r \cdot \left(\left(w \cdot \left(w \cdot r\right)\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right)\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if v < -3.99999999999999976e39 or 0.00165 < v

    1. Initial program 18.3

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Taylor expanded in v around inf 18.1

      \[\leadsto \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{0.25 \cdot \left({w}^{2} \cdot {r}^{2}\right)}\right) - 4.5 \]
    3. Simplified0.7

      \[\leadsto \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{{\left(w \cdot r\right)}^{2} \cdot 0.25}\right) - 4.5 \]
      Proof

      [Start]18.1

      \[ \left(\left(3 + \frac{2}{r \cdot r}\right) - 0.25 \cdot \left({w}^{2} \cdot {r}^{2}\right)\right) - 4.5 \]

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

      \[ \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{\left({w}^{2} \cdot {r}^{2}\right) \cdot 0.25}\right) - 4.5 \]

      exponential.json-simplify-27 [=>]0.7

      \[ \left(\left(3 + \frac{2}{r \cdot r}\right) - \color{blue}{{\left(w \cdot r\right)}^{2}} \cdot 0.25\right) - 4.5 \]

    if -3.99999999999999976e39 < v < 0.00165

    1. Initial program 8.1

      \[\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]
    2. Simplified8.1

      \[\leadsto \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\left(r \cdot \left(w \cdot w\right)\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right)} \]
      Proof

      [Start]8.1

      \[ \left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5 \]

      rational.json-simplify-45 [=>]8.1

      \[ \color{blue}{\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} + 4.5\right)} \]

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

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \color{blue}{\left(r \cdot \left(\left(w \cdot w\right) \cdot r\right)\right)}}{1 - v} + 4.5\right) \]

      rational.json-simplify-43 [=>]8.1

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{\color{blue}{r \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}}{1 - v} + 4.5\right) \]

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

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\color{blue}{\left(r \cdot \left(w \cdot w\right)\right)} \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]
    3. Applied egg-rr8.1

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\color{blue}{\left(r \cdot \left(w \cdot w\right) + 0\right)} \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]
    4. Simplified2.4

      \[\leadsto \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\color{blue}{\left(w \cdot \left(w \cdot r\right)\right)} \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]
      Proof

      [Start]8.1

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\left(r \cdot \left(w \cdot w\right) + 0\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]

      rational.json-simplify-4 [=>]8.1

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\color{blue}{\left(r \cdot \left(w \cdot w\right)\right)} \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]

      rational.json-simplify-43 [=>]2.4

      \[ \left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\color{blue}{\left(w \cdot \left(w \cdot r\right)\right)} \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;v \leq -4 \cdot 10^{+39}:\\ \;\;\;\;\left(\left(3 + \frac{2}{r \cdot r}\right) - {\left(w \cdot r\right)}^{2} \cdot 0.25\right) - 4.5\\ \mathbf{elif}\;v \leq 0.00165:\\ \;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(\left(w \cdot \left(w \cdot r\right)\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(3 + \frac{2}{r \cdot r}\right) - {\left(w \cdot r\right)}^{2} \cdot 0.25\right) - 4.5\\ \end{array} \]

Alternatives

Alternative 1
Error4.4
Cost8580
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ \mathbf{if}\;t_0 - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} \leq -\infty:\\ \;\;\;\;-0.25 \cdot {\left(w \cdot r\right)}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 - \frac{\left(3 - \left(v + v\right)\right) \cdot \left(\left(r \cdot 0.125\right) \cdot \left(w \cdot \left(w \cdot r\right)\right)\right)}{1 - v}\right) - 4.5\\ \end{array} \]
Alternative 2
Error6.2
Cost3652
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ \mathbf{if}\;t_0 - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v} \leq -\infty:\\ \;\;\;\;\left(t_0 - \frac{w \cdot \left(r \cdot \left(0.375 \cdot \left(w \cdot r\right)\right)\right)}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;\left(t_0 - \frac{\left(3 - \left(v + v\right)\right) \cdot \left(\left(r \cdot 0.125\right) \cdot \left(w \cdot \left(w \cdot r\right)\right)\right)}{1 - v}\right) - 4.5\\ \end{array} \]
Alternative 3
Error6.7
Cost2120
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ t_1 := t_0 - \left(\frac{r \cdot \left(w \cdot \left(\left(w \cdot \left(0.125 \cdot \left(3 - \left(v + v\right)\right)\right)\right) \cdot r\right)\right)}{1 - v} + 4.5\right)\\ \mathbf{if}\;r \leq -5 \cdot 10^{-50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;r \leq 5 \cdot 10^{-57}:\\ \;\;\;\;\left(t_0 - \frac{w \cdot \left(r \cdot \left(0.375 \cdot \left(w \cdot r\right)\right)\right)}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error6.7
Cost2120
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ \mathbf{if}\;r \leq -1 \cdot 10^{-48}:\\ \;\;\;\;t_0 - \left(\frac{r \cdot \left(w \cdot \left(\left(w \cdot \left(0.125 \cdot \left(3 - \left(v + v\right)\right)\right)\right) \cdot r\right)\right)}{1 - v} + 4.5\right)\\ \mathbf{elif}\;r \leq 8 \cdot 10^{-57}:\\ \;\;\;\;\left(t_0 - \frac{w \cdot \left(r \cdot \left(0.375 \cdot \left(w \cdot r\right)\right)\right)}{1 - v}\right) - 4.5\\ \mathbf{else}:\\ \;\;\;\;t_0 - \left(\frac{r \cdot \left(\left(w \cdot \left(w \cdot r\right)\right) \cdot \left(0.125 \cdot \left(3 - 2 \cdot v\right)\right)\right)}{1 - v} + 4.5\right)\\ \end{array} \]
Alternative 5
Error9.4
Cost1996
\[\begin{array}{l} t_0 := 3 + \frac{2}{r \cdot r}\\ t_1 := t_0 - \left(\frac{r \cdot \left(w \cdot \left(v \cdot \left(\left(w \cdot r\right) \cdot -0.25\right)\right)\right)}{1 - v} + 4.5\right)\\ t_2 := t_0 - \left(\frac{r \cdot \left(w \cdot \left(0.375 \cdot \left(w \cdot r\right)\right)\right)}{1 - v} + 4.5\right)\\ \mathbf{if}\;v \leq -1.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;v \leq 0.00165:\\ \;\;\;\;t_2\\ \mathbf{elif}\;v \leq 1.7 \cdot 10^{+202}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error12.3
Cost1472
\[\left(3 + \frac{2}{r \cdot r}\right) - \left(\frac{r \cdot \left(w \cdot \left(0.375 \cdot \left(w \cdot r\right)\right)\right)}{1 - v} + 4.5\right) \]

Error

Reproduce?

herbie shell --seed 2023077 
(FPCore (v w r)
  :name "Rosa's TurbineBenchmark"
  :precision binary64
  (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))