
(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 (+ (+ (/ 2.0 (* r r)) -1.5) (/ (- (* v -0.25) -0.375) (* (+ v -1.0) (pow (* r w) -2.0)))))
double code(double v, double w, double r) {
return ((2.0 / (r * r)) + -1.5) + (((v * -0.25) - -0.375) / ((v + -1.0) * pow((r * w), -2.0)));
}
real(8) function code(v, w, r)
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((2.0d0 / (r * r)) + (-1.5d0)) + (((v * (-0.25d0)) - (-0.375d0)) / ((v + (-1.0d0)) * ((r * w) ** (-2.0d0))))
end function
public static double code(double v, double w, double r) {
return ((2.0 / (r * r)) + -1.5) + (((v * -0.25) - -0.375) / ((v + -1.0) * Math.pow((r * w), -2.0)));
}
def code(v, w, r): return ((2.0 / (r * r)) + -1.5) + (((v * -0.25) - -0.375) / ((v + -1.0) * math.pow((r * w), -2.0)))
function code(v, w, r) return Float64(Float64(Float64(2.0 / Float64(r * r)) + -1.5) + Float64(Float64(Float64(v * -0.25) - -0.375) / Float64(Float64(v + -1.0) * (Float64(r * w) ^ -2.0)))) end
function tmp = code(v, w, r) tmp = ((2.0 / (r * r)) + -1.5) + (((v * -0.25) - -0.375) / ((v + -1.0) * ((r * w) ^ -2.0))); end
code[v_, w_, r_] := N[(N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] + -1.5), $MachinePrecision] + N[(N[(N[(v * -0.25), $MachinePrecision] - -0.375), $MachinePrecision] / N[(N[(v + -1.0), $MachinePrecision] * N[Power[N[(r * w), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{2}{r \cdot r} + -1.5\right) + \frac{v \cdot -0.25 - -0.375}{\left(v + -1\right) \cdot {\left(r \cdot w\right)}^{-2}}
\end{array}
Initial program 82.7%
Simplified95.7%
*-commutative95.7%
clear-num95.7%
*-commutative95.7%
associate-*r*85.3%
un-div-inv85.3%
fma-udef85.3%
metadata-eval85.3%
associate-*l*85.2%
*-commutative85.2%
metadata-eval85.2%
distribute-rgt-in85.2%
+-commutative85.2%
clear-num85.2%
Applied egg-rr99.8%
frac-2neg99.8%
div-inv99.8%
div-inv99.8%
distribute-lft-neg-in99.8%
pow-flip99.8%
metadata-eval99.8%
Applied egg-rr99.8%
associate-*r/99.8%
*-rgt-identity99.8%
distribute-lft-neg-out99.8%
distribute-neg-frac99.8%
associate-/l*95.5%
distribute-neg-frac95.5%
neg-sub095.5%
associate--r-95.5%
metadata-eval95.5%
neg-sub095.5%
fma-udef95.5%
*-commutative95.5%
+-commutative95.5%
*-commutative95.5%
associate--r+95.5%
metadata-eval95.5%
Simplified95.5%
expm1-log1p-u94.3%
expm1-udef94.3%
associate-/r/94.3%
frac-times98.3%
*-un-lft-identity98.3%
Applied egg-rr98.3%
expm1-def98.3%
expm1-log1p99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(+
(+
3.0
(-
(/ 2.0 (* r r))
(/
(* 0.125 (+ 3.0 (* v -2.0)))
(* (/ 1.0 (* r w)) (/ (- 1.0 v) (* r w))))))
-4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -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 + (v * (-2.0d0)))) / ((1.0d0 / (r * w)) * ((1.0d0 - v) / (r * w)))))) + (-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 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((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(0.125 * Float64(3.0 + Float64(v * -2.0))) / Float64(Float64(1.0 / Float64(r * w)) * Float64(Float64(1.0 - v) / Float64(r * w)))))) + -4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / (r * r)) - ((0.125 * (3.0 + (v * -2.0))) / ((1.0 / (r * w)) * ((1.0 - v) / (r * w)))))) + -4.5; end
code[v_, w_, r_] := N[(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[(1.0 / N[(r * w), $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - v), $MachinePrecision] / N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \left(\frac{2}{r \cdot r} - \frac{0.125 \cdot \left(3 + v \cdot -2\right)}{\frac{1}{r \cdot w} \cdot \frac{1 - v}{r \cdot w}}\right)\right) + -4.5
\end{array}
Initial program 82.7%
Simplified85.2%
associate-*r*95.3%
*-commutative95.3%
*-un-lft-identity95.3%
associate-*r*99.4%
times-frac99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (v w r)
:precision binary64
(if (<= r 220.0)
(+ -1.5 (+ (/ (/ 2.0 r) r) (* -0.375 (* (* r w) (* r w)))))
(+
-4.5
(+
3.0
(-
(/ 2.0 (* r r))
(* (* r w) (/ (* r (* w (+ (* v -0.25) 0.375))) (- 1.0 v))))))))
double code(double v, double w, double r) {
double tmp;
if (r <= 220.0) {
tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w))));
} else {
tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * ((r * (w * ((v * -0.25) + 0.375))) / (1.0 - v)))));
}
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 (r <= 220.0d0) then
tmp = (-1.5d0) + (((2.0d0 / r) / r) + ((-0.375d0) * ((r * w) * (r * w))))
else
tmp = (-4.5d0) + (3.0d0 + ((2.0d0 / (r * r)) - ((r * w) * ((r * (w * ((v * (-0.25d0)) + 0.375d0))) / (1.0d0 - v)))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double tmp;
if (r <= 220.0) {
tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w))));
} else {
tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * ((r * (w * ((v * -0.25) + 0.375))) / (1.0 - v)))));
}
return tmp;
}
def code(v, w, r): tmp = 0 if r <= 220.0: tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w)))) else: tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * ((r * (w * ((v * -0.25) + 0.375))) / (1.0 - v))))) return tmp
function code(v, w, r) tmp = 0.0 if (r <= 220.0) tmp = Float64(-1.5 + Float64(Float64(Float64(2.0 / r) / r) + Float64(-0.375 * Float64(Float64(r * w) * Float64(r * w))))); else tmp = Float64(-4.5 + Float64(3.0 + Float64(Float64(2.0 / Float64(r * r)) - Float64(Float64(r * w) * Float64(Float64(r * Float64(w * Float64(Float64(v * -0.25) + 0.375))) / Float64(1.0 - v)))))); end return tmp end
function tmp_2 = code(v, w, r) tmp = 0.0; if (r <= 220.0) tmp = -1.5 + (((2.0 / r) / r) + (-0.375 * ((r * w) * (r * w)))); else tmp = -4.5 + (3.0 + ((2.0 / (r * r)) - ((r * w) * ((r * (w * ((v * -0.25) + 0.375))) / (1.0 - v))))); end tmp_2 = tmp; end
code[v_, w_, r_] := If[LessEqual[r, 220.0], 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], N[(-4.5 + N[(3.0 + N[(N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision] - N[(N[(r * w), $MachinePrecision] * N[(N[(r * N[(w * N[(N[(v * -0.25), $MachinePrecision] + 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;r \leq 220:\\
\;\;\;\;-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)\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(\frac{2}{r \cdot r} - \left(r \cdot w\right) \cdot \frac{r \cdot \left(w \cdot \left(v \cdot -0.25 + 0.375\right)\right)}{1 - v}\right)\right)\\
\end{array}
\end{array}
if r < 220Initial program 82.6%
Simplified84.1%
Taylor expanded in v around 0 77.0%
*-commutative77.0%
unpow277.0%
unpow277.0%
swap-sqr96.6%
unpow296.6%
Simplified96.6%
unpow296.6%
Applied egg-rr96.6%
expm1-log1p-u95.0%
expm1-udef95.0%
div-inv95.0%
pow295.0%
pow-flip95.0%
metadata-eval95.0%
Applied egg-rr95.0%
expm1-def95.0%
expm1-log1p96.7%
Simplified96.7%
metadata-eval96.7%
pow-flip96.6%
pow296.6%
div-inv96.6%
associate-/r*96.6%
Applied egg-rr96.6%
if 220 < r Initial program 83.1%
Simplified89.3%
associate-/r/89.3%
associate-*r*77.6%
swap-sqr98.1%
associate-*r*98.1%
+-commutative98.1%
distribute-rgt-in98.1%
*-commutative98.1%
associate-*l*99.8%
metadata-eval99.8%
metadata-eval99.8%
fma-udef99.8%
Applied egg-rr99.8%
Taylor expanded in r around 0 93.5%
Final simplification95.9%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (/ 2.0 (* r r))))
(if (or (<= v -300000000000.0) (not (<= v 3.1e-35)))
(- (+ t_0 -1.5) (* (* (* r w) (* r w)) 0.25))
(+ -4.5 (+ 3.0 (- t_0 (* (* r w) (* r (* w 0.375)))))))))
double code(double v, double w, double r) {
double t_0 = 2.0 / (r * r);
double tmp;
if ((v <= -300000000000.0) || !(v <= 3.1e-35)) {
tmp = (t_0 + -1.5) - (((r * w) * (r * w)) * 0.25);
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r * (w * 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 <= (-300000000000.0d0)) .or. (.not. (v <= 3.1d-35))) then
tmp = (t_0 + (-1.5d0)) - (((r * w) * (r * w)) * 0.25d0)
else
tmp = (-4.5d0) + (3.0d0 + (t_0 - ((r * w) * (r * (w * 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 <= -300000000000.0) || !(v <= 3.1e-35)) {
tmp = (t_0 + -1.5) - (((r * w) * (r * w)) * 0.25);
} else {
tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r * (w * 0.375)))));
}
return tmp;
}
def code(v, w, r): t_0 = 2.0 / (r * r) tmp = 0 if (v <= -300000000000.0) or not (v <= 3.1e-35): tmp = (t_0 + -1.5) - (((r * w) * (r * w)) * 0.25) else: tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r * (w * 0.375))))) return tmp
function code(v, w, r) t_0 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -300000000000.0) || !(v <= 3.1e-35)) tmp = Float64(Float64(t_0 + -1.5) - Float64(Float64(Float64(r * w) * Float64(r * w)) * 0.25)); else tmp = Float64(-4.5 + Float64(3.0 + Float64(t_0 - Float64(Float64(r * w) * Float64(r * Float64(w * 0.375)))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 2.0 / (r * r); tmp = 0.0; if ((v <= -300000000000.0) || ~((v <= 3.1e-35))) tmp = (t_0 + -1.5) - (((r * w) * (r * w)) * 0.25); else tmp = -4.5 + (3.0 + (t_0 - ((r * w) * (r * (w * 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, -300000000000.0], N[Not[LessEqual[v, 3.1e-35]], $MachinePrecision]], N[(N[(t$95$0 + -1.5), $MachinePrecision] - N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision], N[(-4.5 + N[(3.0 + N[(t$95$0 - N[(N[(r * w), $MachinePrecision] * N[(r * N[(w * 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 -300000000000 \lor \neg \left(v \leq 3.1 \cdot 10^{-35}\right):\\
\;\;\;\;\left(t_0 + -1.5\right) - \left(\left(r \cdot w\right) \cdot \left(r \cdot w\right)\right) \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;-4.5 + \left(3 + \left(t_0 - \left(r \cdot w\right) \cdot \left(r \cdot \left(w \cdot 0.375\right)\right)\right)\right)\\
\end{array}
\end{array}
if v < -3e11 or 3.10000000000000012e-35 < v Initial program 78.9%
Simplified96.6%
*-commutative96.6%
clear-num96.6%
*-commutative96.6%
associate-*r*84.1%
un-div-inv84.1%
fma-udef84.1%
metadata-eval84.1%
associate-*l*84.0%
*-commutative84.0%
metadata-eval84.0%
distribute-rgt-in84.0%
+-commutative84.0%
clear-num84.0%
Applied egg-rr99.8%
Taylor expanded in v around inf 78.2%
*-commutative78.2%
unpow278.2%
unpow278.2%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow288.9%
Applied egg-rr99.8%
if -3e11 < v < 3.10000000000000012e-35Initial program 86.4%
Simplified86.4%
associate-/r/86.4%
associate-*r*78.6%
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 0 99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (* (* r w) (* r w))) (t_1 (/ 2.0 (* r r))))
(if (or (<= v -300000000000.0) (not (<= v 3.1e-35)))
(- (+ t_1 -1.5) (* t_0 0.25))
(+ -1.5 (+ t_1 (* -0.375 t_0))))))
double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -300000000000.0) || !(v <= 3.1e-35)) {
tmp = (t_1 + -1.5) - (t_0 * 0.25);
} else {
tmp = -1.5 + (t_1 + (-0.375 * t_0));
}
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) :: t_1
real(8) :: tmp
t_0 = (r * w) * (r * w)
t_1 = 2.0d0 / (r * r)
if ((v <= (-300000000000.0d0)) .or. (.not. (v <= 3.1d-35))) then
tmp = (t_1 + (-1.5d0)) - (t_0 * 0.25d0)
else
tmp = (-1.5d0) + (t_1 + ((-0.375d0) * t_0))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = (r * w) * (r * w);
double t_1 = 2.0 / (r * r);
double tmp;
if ((v <= -300000000000.0) || !(v <= 3.1e-35)) {
tmp = (t_1 + -1.5) - (t_0 * 0.25);
} else {
tmp = -1.5 + (t_1 + (-0.375 * t_0));
}
return tmp;
}
def code(v, w, r): t_0 = (r * w) * (r * w) t_1 = 2.0 / (r * r) tmp = 0 if (v <= -300000000000.0) or not (v <= 3.1e-35): tmp = (t_1 + -1.5) - (t_0 * 0.25) else: tmp = -1.5 + (t_1 + (-0.375 * t_0)) return tmp
function code(v, w, r) t_0 = Float64(Float64(r * w) * Float64(r * w)) t_1 = Float64(2.0 / Float64(r * r)) tmp = 0.0 if ((v <= -300000000000.0) || !(v <= 3.1e-35)) tmp = Float64(Float64(t_1 + -1.5) - Float64(t_0 * 0.25)); else tmp = Float64(-1.5 + Float64(t_1 + Float64(-0.375 * t_0))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = (r * w) * (r * w); t_1 = 2.0 / (r * r); tmp = 0.0; if ((v <= -300000000000.0) || ~((v <= 3.1e-35))) tmp = (t_1 + -1.5) - (t_0 * 0.25); else tmp = -1.5 + (t_1 + (-0.375 * t_0)); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -300000000000.0], N[Not[LessEqual[v, 3.1e-35]], $MachinePrecision]], N[(N[(t$95$1 + -1.5), $MachinePrecision] - N[(t$95$0 * 0.25), $MachinePrecision]), $MachinePrecision], N[(-1.5 + N[(t$95$1 + N[(-0.375 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(r \cdot w\right) \cdot \left(r \cdot w\right)\\
t_1 := \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -300000000000 \lor \neg \left(v \leq 3.1 \cdot 10^{-35}\right):\\
\;\;\;\;\left(t_1 + -1.5\right) - t_0 \cdot 0.25\\
\mathbf{else}:\\
\;\;\;\;-1.5 + \left(t_1 + -0.375 \cdot t_0\right)\\
\end{array}
\end{array}
if v < -3e11 or 3.10000000000000012e-35 < v Initial program 78.9%
Simplified96.6%
*-commutative96.6%
clear-num96.6%
*-commutative96.6%
associate-*r*84.1%
un-div-inv84.1%
fma-udef84.1%
metadata-eval84.1%
associate-*l*84.0%
*-commutative84.0%
metadata-eval84.0%
distribute-rgt-in84.0%
+-commutative84.0%
clear-num84.0%
Applied egg-rr99.8%
Taylor expanded in v around inf 78.2%
*-commutative78.2%
unpow278.2%
unpow278.2%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow288.9%
Applied egg-rr99.8%
if -3e11 < v < 3.10000000000000012e-35Initial program 86.4%
Simplified86.4%
Taylor expanded in v around 0 78.6%
*-commutative78.6%
unpow278.6%
unpow278.6%
swap-sqr99.8%
unpow299.8%
Simplified99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(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 82.7%
Simplified85.3%
Taylor expanded in v around 0 75.9%
*-commutative75.9%
unpow275.9%
unpow275.9%
swap-sqr94.5%
unpow294.5%
Simplified94.5%
unpow294.5%
Applied egg-rr94.5%
Final simplification94.5%
(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(Float64(2.0 / 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[(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}
\\
-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}
Initial program 82.7%
Simplified85.3%
Taylor expanded in v around 0 75.9%
*-commutative75.9%
unpow275.9%
unpow275.9%
swap-sqr94.5%
unpow294.5%
Simplified94.5%
unpow294.5%
Applied egg-rr94.5%
expm1-log1p-u93.3%
expm1-udef93.3%
div-inv93.3%
pow293.3%
pow-flip93.3%
metadata-eval93.3%
Applied egg-rr93.3%
expm1-def93.3%
expm1-log1p94.6%
Simplified94.6%
metadata-eval94.6%
pow-flip94.5%
pow294.5%
div-inv94.5%
associate-/r*94.5%
Applied egg-rr94.5%
Final simplification94.5%
herbie shell --seed 2023307
(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))