
(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))
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;
}
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
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;
}
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
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 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
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]
\begin{array}{l}
\\
\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
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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))
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;
}
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
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;
}
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
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 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
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]
\begin{array}{l}
\\
\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
\end{array}
(FPCore (v w r)
:precision binary64
(+
(+
3.0
(-
(/ 2.0 (* r r))
(* (* r w) (* (/ (fma v -0.25 0.375) (- 1.0 v)) (* r w)))))
-4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / (r * r)) - ((r * w) * ((fma(v, -0.25, 0.375) / (1.0 - v)) * (r * w))))) + -4.5;
}
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(r * w) * Float64(Float64(fma(v, -0.25, 0.375) / Float64(1.0 - v)) * Float64(r * w))))) + -4.5) end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(N[(N[(v * -0.25 + 0.375), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \left(\frac{2}{r \cdot r} - \left(r \cdot w\right) \cdot \left(\frac{\mathsf{fma}\left(v, -0.25, 0.375\right)}{1 - v} \cdot \left(r \cdot w\right)\right)\right)\right) + -4.5
\end{array}
Initial program 84.2%
Simplified86.8%
associate-/r/86.8%
associate-*r*78.2%
swap-sqr99.7%
associate-*r*99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-commutative99.7%
associate-*l*99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-udef99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r) :precision binary64 (+ (/ (/ 2.0 r) r) (- -1.5 (* (fma v -0.25 0.375) (/ (* r w) (/ (- 1.0 v) (* r w)))))))
double code(double v, double w, double r) {
return ((2.0 / r) / r) + (-1.5 - (fma(v, -0.25, 0.375) * ((r * w) / ((1.0 - v) / (r * w)))));
}
function code(v, w, r) return Float64(Float64(Float64(2.0 / r) / r) + Float64(-1.5 - Float64(fma(v, -0.25, 0.375) * Float64(Float64(r * w) / Float64(Float64(1.0 - v) / Float64(r * w)))))) end
code[v_, w_, r_] := N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-1.5 - N[(N[(v * -0.25 + 0.375), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] / N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{2}{r}}{r} + \left(-1.5 - \mathsf{fma}\left(v, -0.25, 0.375\right) \cdot \frac{r \cdot w}{\frac{1 - v}{r \cdot w}}\right)
\end{array}
Initial program 84.2%
Simplified96.9%
associate-*r*99.7%
*-un-lft-identity99.7%
times-frac99.7%
Applied egg-rr99.7%
clear-num99.7%
frac-times99.7%
metadata-eval99.7%
div-inv99.7%
/-rgt-identity99.7%
*-un-lft-identity99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(+
-4.5
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ (- 1.0 v) (* r w)) (/ 1.0 (* r w))))))))
double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w))))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (-4.5d0) + (3.0d0 + ((2.0d0 / (r * r)) - ((0.125d0 * (3.0d0 + (v * (-2.0d0)))) / (((1.0d0 - v) / (r * w)) * (1.0d0 / (r * w))))))
end function
public static double code(double v, double w, double r) {
return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w))))));
}
def code(v, w, r): return -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w))))))
function code(v, w, r) return Float64(-4.5 + Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(Float64(1.0 - v) / Float64(r * w)) * Float64(1.0 / Float64(r * w))))))) end
function tmp = code(v, w, r) tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / (((1.0 - v) / (r * w)) * (1.0 / (r * w)))))); end
code[v_, w_, r_] := N[(-4.5 + N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(0.125 * N[(3.0 + N[(v * -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4.5 + \left(3 + \left(\frac{2}{r \cdot r} - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1 - v}{r \cdot w} \cdot \frac{1}{r \cdot w}}\right)\right)
\end{array}
Initial program 84.2%
Simplified86.8%
associate-*r*96.9%
*-commutative96.9%
*-un-lft-identity96.9%
associate-*r*99.7%
times-frac99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (<= w 1e+190)
(+
-1.5
(+ t_0 (* (/ (+ -0.375 (* v 0.25)) (- 1.0 v)) (* r (* w (* r w))))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.25)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 1e+190) {
tmp = -1.5 + (t_0 + (((-0.375 + (v * 0.25)) / (1.0 - v)) * (r * (w * (r * w)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
}
return tmp;
}
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) :: tmp
t_0 = 2.0d0 / (r * r)
if (w <= 1d+190) then
tmp = (-1.5d0) + (t_0 + ((((-0.375d0) + (v * 0.25d0)) / (1.0d0 - v)) * (r * (w * (r * w)))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.25d0)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if (w <= 1e+190) {
tmp = -1.5 + (t_0 + (((-0.375 + (v * 0.25)) / (1.0 - v)) * (r * (w * (r * w)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if w <= 1e+190: tmp = -1.5 + (t_0 + (((-0.375 + (v * 0.25)) / (1.0 - v)) * (r * (w * (r * w))))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if (w <= 1e+190) tmp = Float64(-1.5 + Float64(t_0 + Float64(Float64(Float64(-0.375 + Float64(v * 0.25)) / Float64(1.0 - v)) * Float64(r * Float64(w * Float64(r * w)))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if (w <= 1e+190) tmp = -1.5 + (t_0 + (((-0.375 + (v * 0.25)) / (1.0 - v)) * (r * (w * (r * w))))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[w, 1e+190], N[(-1.5 + N[(t$95$0 + N[(N[(N[(-0.375 + N[(v * 0.25), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * N[(r * N[(w * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;w \leq 10^{+190}:\\
\;\;\;\;-1.5 + \left(t_0 + \frac{-0.375 + v \cdot 0.25}{1 - v} \cdot \left(r \cdot \left(w \cdot \left(r \cdot w\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\end{array}
\end{array}
if w < 1.0000000000000001e190Initial program 86.1%
Simplified88.8%
add-sqr-sqrt58.6%
pow258.6%
*-commutative58.6%
sqrt-prod45.6%
sqrt-prod23.1%
add-sqr-sqrt49.7%
Applied egg-rr49.7%
*-commutative49.7%
unpow-prod-down45.6%
pow245.6%
add-sqr-sqrt88.8%
pow288.8%
associate-*r*97.4%
Applied egg-rr97.4%
if 1.0000000000000001e190 < w Initial program 65.7%
Simplified65.7%
associate-/r/65.7%
associate-*r*65.7%
swap-sqr99.9%
associate-*r*99.9%
+-commutative99.9%
distribute-rgt-in99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
metadata-eval99.9%
fma-udef99.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.9%
associate-*r*99.9%
Simplified99.9%
Final simplification97.7%
(FPCore (v w r) :precision binary64 (if (or (<= v -12500000.0) (not (<= v 0.15))) (+ -4.5 (+ 3.0 (- (/ 2.0 (* r r)) (* (* r w) (* w (* r 0.25)))))) (+ -1.5 (+ (/ (/ 2.0 r) r) (* -0.375 (* (* r w) (* r w)))))))
double code(double v, double w, double r) {
double tmp;
if ((v <= -12500000.0) || !(v <= 0.15)) {
tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w))));
}
return tmp;
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
real(8) :: tmp
if ((v <= (-12500000.0d0)) .or. (.not. (v <= 0.15d0))) then
tmp = (-4.5d0) + (3.0d0 + ((2.0d0 / (r * r)) - ((r * w) * (w * (r * 0.25d0)))))
else
tmp = (-1.5d0) + (((2.0d0 / r) / r) + ((-0.375d0) * ((r * w) * (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if ((v <= -12500000.0) || !(v <= 0.15)) {
tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if (v <= -12500000.0) or not (v <= 0.15): tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * (w * (r * 0.25))))) else: tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w)))) return tmp
function code(v, w, r) tmp = 0.0 if ((v <= -12500000.0) || !(v <= 0.15)) tmp = Float64(-4.5 + Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); else tmp = Float64(-1.5 + Float64(Float64(Float64(2.0 / r) / r) + Float64(-0.375 * Float64(Float64(r * w) * Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if ((v <= -12500000.0) || ~((v <= 0.15))) tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * (w * (r * 0.25))))); else tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[Or[LessEqual[v, -12500000.0], N[Not[LessEqual[v, 0.15]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision] + N[(-0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;v \leq -12500000 \lor \neg \left(v \leq 0.15\right):\\
\;\;\;\;-4.5 + \left(3 + \left(\frac{2}{r \cdot r} - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(\frac{\frac{2}{r}}{r} + -0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.25e7 or 0.149999999999999994 < v Initial program 83.2%
Simplified87.6%
associate-/r/87.6%
associate-*r*80.1%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.6%
associate-*r*99.6%
Simplified99.6%
if -1.25e7 < v < 0.149999999999999994Initial program 85.6%
Simplified85.6%
Taylor expanded in v around 0 75.6%
*-commutative75.6%
unpow275.6%
unpow275.6%
swap-sqr98.6%
unpow298.6%
Simplified98.6%
unpow298.6%
Applied egg-rr98.6%
associate-/r*98.6%
div-inv98.6%
*-un-lft-identity98.6%
times-frac98.6%
metadata-eval98.6%
Applied egg-rr98.6%
associate-*r/98.6%
un-div-inv98.6%
Applied egg-rr98.6%
Final simplification99.2%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -12500000.0) (not (<= v 0.15)))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.25))))))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* w (* r 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -12500000.0) || !(v <= 0.15)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
}
return tmp;
}
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) :: tmp
t_0 = 2.0d0 / (r * r)
if ((v <= (-12500000.0d0)) .or. (.not. (v <= 0.15d0))) then
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.25d0)))))
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (w * (r * 0.375d0)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -12500000.0) || !(v <= 0.15)) {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25)))));
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -12500000.0) or not (v <= 0.15): tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -12500000.0) || !(v <= 0.15)) tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.25)))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(w * Float64(r * 0.375)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -12500000.0) || ~((v <= 0.15))) tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.25))))); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (w * (r * 0.375))))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -12500000.0], N[Not[LessEqual[v, 0.15]], $MachinePrecision]], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -12500000 \lor \neg \left(v \leq 0.15\right):\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.25\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -1.25e7 or 0.149999999999999994 < v Initial program 83.2%
Simplified87.6%
associate-/r/87.6%
associate-*r*80.1%
swap-sqr99.8%
associate-*r*99.8%
+-commutative99.8%
distribute-rgt-in99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.6%
associate-*r*99.6%
Simplified99.6%
if -1.25e7 < v < 0.149999999999999994Initial program 85.6%
Simplified85.6%
associate-/r/85.6%
associate-*r*75.6%
swap-sqr99.6%
associate-*r*99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-commutative99.7%
associate-*l*99.7%
metadata-eval99.7%
metadata-eval99.7%
fma-udef99.7%
Applied egg-rr99.7%
Taylor expanded in v around 0 98.6%
associate-*r*98.7%
Simplified98.7%
Final simplification99.2%
(FPCore (v w r) :precision binary64 (+ -1.5 (+ (/ 2.0 (* r r)) (* -0.375 (* (* r w) (* r w))))))
double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.375 * ((r * w) * (r * w))));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = (-1.5d0) + ((2.0d0 / (r * r)) + ((-0.375d0) * ((r * w) * (r * w))))
end function
public static double code(double v, double w, double r) {
return -1.5 + ((2.0 / (r * r)) + (-0.375 * ((r * w) * (r * w))));
}
def code(v, w, r): return -1.5 + ((2.0 / (r * r)) + (-0.375 * ((r * w) * (r * w))))
function code(v, w, r) return Float64(-1.5 + Float64(Float64(2.0 / Float64(r * r)) + Float64(-0.375 * Float64(Float64(r * w) * Float64(r * w))))) end
function tmp = code(v, w, r) tmp = -1.5 + ((2.0 / (r * r)) + (-0.375 * ((r * w) * (r * w)))); end
code[v_, w_, r_] := N[(-1.5 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1.5 + \left(\frac{2}{r \cdot r} + -0.375 \cdot \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right)\right)
\end{array}
Initial program 84.2%
Simplified86.8%
Taylor expanded in v around 0 74.2%
*-commutative74.2%
unpow274.2%
unpow274.2%
swap-sqr89.4%
unpow289.4%
Simplified89.4%
unpow289.4%
Applied egg-rr89.4%
Final simplification89.4%
herbie shell --seed 2024019
(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))