
(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 10 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))) (+ (* (+ 0.375 (* -0.25 v)) (/ (* (* r w) (* r w)) (- 1.0 v))) 4.5)))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (((0.375 + (-0.25 * v)) * (((r * w) * (r * w)) / (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.375d0 + ((-0.25d0) * v)) * (((r * w) * (r * w)) / (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.375 + (-0.25 * v)) * (((r * w) * (r * w)) / (1.0 - v))) + 4.5);
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - (((0.375 + (-0.25 * v)) * (((r * w) * (r * w)) / (1.0 - v))) + 4.5)
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.375 + Float64(-0.25 * v)) * Float64(Float64(Float64(r * w) * Float64(r * w)) / Float64(1.0 - v))) + 4.5)) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - (((0.375 + (-0.25 * v)) * (((r * w) * (r * w)) / (1.0 - v))) + 4.5); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(r * w), $MachinePrecision] * N[(r * w), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - \left(\left(0.375 + -0.25 \cdot v\right) \cdot \frac{\left(r \cdot w\right) \cdot \left(r \cdot w\right)}{1 - v} + 4.5\right)
\end{array}
Initial program 84.0%
Simplified87.9%
div-inv87.9%
distribute-lft-in87.9%
metadata-eval87.9%
associate-*r*87.9%
metadata-eval87.9%
associate-*r*96.8%
*-commutative96.8%
clear-num96.9%
associate-*r*99.8%
pow299.8%
*-commutative99.8%
Applied egg-rr99.8%
unpow299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (or (<= v -41000000.0) (not (<= v 9.8e-36)))
(- t_0 (+ 4.5 (* (* r w) (* (* r w) 0.25))))
(- t_0 (+ 4.5 (* (* r w) (* 0.375 (* r w))))))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -41000000.0) || !(v <= 9.8e-36)) {
tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25)));
} else {
tmp = t_0 - (4.5 + ((r * w) * (0.375 * (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) :: t_0
real(8) :: tmp
t_0 = 3.0d0 + (2.0d0 / (r * r))
if ((v <= (-41000000.0d0)) .or. (.not. (v <= 9.8d-36))) then
tmp = t_0 - (4.5d0 + ((r * w) * ((r * w) * 0.25d0)))
else
tmp = t_0 - (4.5d0 + ((r * w) * (0.375d0 * (r * w))))
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -41000000.0) || !(v <= 9.8e-36)) {
tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25)));
} else {
tmp = t_0 - (4.5 + ((r * w) * (0.375 * (r * w))));
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if (v <= -41000000.0) or not (v <= 9.8e-36): tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25))) else: tmp = t_0 - (4.5 + ((r * w) * (0.375 * (r * w)))) return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if ((v <= -41000000.0) || !(v <= 9.8e-36)) tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25)))); else tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(0.375 * Float64(r * w))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if ((v <= -41000000.0) || ~((v <= 9.8e-36))) tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25))); else tmp = t_0 - (4.5 + ((r * w) * (0.375 * (r * w)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -41000000.0], N[Not[LessEqual[v, 9.8e-36]], $MachinePrecision]], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(0.375 * N[(r * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -41000000 \lor \neg \left(v \leq 9.8 \cdot 10^{-36}\right):\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(0.375 \cdot \left(r \cdot w\right)\right)\right)\\
\end{array}
\end{array}
if v < -4.1e7 or 9.7999999999999994e-36 < v Initial program 79.5%
Simplified86.4%
associate-/r/86.4%
associate-*r*83.7%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.3%
if -4.1e7 < v < 9.7999999999999994e-36Initial program 89.8%
Simplified89.8%
associate-/r/89.8%
associate-*r*84.4%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r)))))
(if (or (<= v -41000000.0) (not (<= v 9.8e-36)))
(- t_0 (+ 4.5 (* (* r w) (* (* r w) 0.25))))
(- t_0 (+ 4.5 (* (* r w) (* w (* r 0.375))))))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -41000000.0) || !(v <= 9.8e-36)) {
tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25)));
} else {
tmp = t_0 - (4.5 + ((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 = 3.0d0 + (2.0d0 / (r * r))
if ((v <= (-41000000.0d0)) .or. (.not. (v <= 9.8d-36))) then
tmp = t_0 - (4.5d0 + ((r * w) * ((r * w) * 0.25d0)))
else
tmp = t_0 - (4.5d0 + ((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 = 3.0 + (2.0 / (r * r));
double tmp;
if ((v <= -41000000.0) || !(v <= 9.8e-36)) {
tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25)));
} else {
tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375))));
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) tmp = 0 if (v <= -41000000.0) or not (v <= 9.8e-36): tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25))) else: tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))) return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) tmp = 0.0 if ((v <= -41000000.0) || !(v <= 9.8e-36)) tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25)))); else tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); tmp = 0.0; if ((v <= -41000000.0) || ~((v <= 9.8e-36))) tmp = t_0 - (4.5 + ((r * w) * ((r * w) * 0.25))); else tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))); end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -41000000.0], N[Not[LessEqual[v, 9.8e-36]], $MachinePrecision]], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
\mathbf{if}\;v \leq -41000000 \lor \neg \left(v \leq 9.8 \cdot 10^{-36}\right):\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\end{array}
\end{array}
if v < -4.1e7 or 9.7999999999999994e-36 < v Initial program 79.5%
Simplified86.4%
associate-/r/86.4%
associate-*r*83.7%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 99.3%
if -4.1e7 < v < 9.7999999999999994e-36Initial program 89.8%
Simplified89.8%
associate-/r/89.8%
associate-*r*84.4%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
associate-*r*99.8%
Simplified99.8%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ 2.0 (* r r))))
(t_1 (+ 4.5 (* (* r w) (* (* r w) 0.25)))))
(if (<= v -41000000.0)
(- t_0 t_1)
(if (<= v 1.55e-8)
(- t_0 (+ 4.5 (* (* r w) (* w (* r 0.375)))))
(- (+ 3.0 (/ (/ 2.0 r) r)) t_1)))))
double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double t_1 = 4.5 + ((r * w) * ((r * w) * 0.25));
double tmp;
if (v <= -41000000.0) {
tmp = t_0 - t_1;
} else if (v <= 1.55e-8) {
tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375))));
} else {
tmp = (3.0 + ((2.0 / r) / r)) - 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 3.0d0 + (2.0d0 / (r * r))
t_1 = 4.5d0 + ((r * w) * ((r * w) * 0.25d0))
if (v <= (-41000000.0d0)) then
tmp = t_0 - t_1
else if (v <= 1.55d-8) then
tmp = t_0 - (4.5d0 + ((r * w) * (w * (r * 0.375d0))))
else
tmp = (3.0d0 + ((2.0d0 / r) / r)) - t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + (2.0 / (r * r));
double t_1 = 4.5 + ((r * w) * ((r * w) * 0.25));
double tmp;
if (v <= -41000000.0) {
tmp = t_0 - t_1;
} else if (v <= 1.55e-8) {
tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375))));
} else {
tmp = (3.0 + ((2.0 / r) / r)) - t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + (2.0 / (r * r)) t_1 = 4.5 + ((r * w) * ((r * w) * 0.25)) tmp = 0 if v <= -41000000.0: tmp = t_0 - t_1 elif v <= 1.55e-8: tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))) else: tmp = (3.0 + ((2.0 / r) / r)) - t_1 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(2.0 / Float64(r * r))) t_1 = Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25))) tmp = 0.0 if (v <= -41000000.0) tmp = Float64(t_0 - t_1); elseif (v <= 1.55e-8) tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))); else tmp = Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - t_1); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + (2.0 / (r * r)); t_1 = 4.5 + ((r * w) * ((r * w) * 0.25)); tmp = 0.0; if (v <= -41000000.0) tmp = t_0 - t_1; elseif (v <= 1.55e-8) tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))); else tmp = (3.0 + ((2.0 / r) / r)) - t_1; end tmp_2 = tmp; end
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[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -41000000.0], N[(t$95$0 - t$95$1), $MachinePrecision], If[LessEqual[v, 1.55e-8], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{2}{r \cdot r}\\
t_1 := 4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\\
\mathbf{if}\;v \leq -41000000:\\
\;\;\;\;t_0 - t_1\\
\mathbf{elif}\;v \leq 1.55 \cdot 10^{-8}:\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(3 + \frac{\frac{2}{r}}{r}\right) - t_1\\
\end{array}
\end{array}
if v < -4.1e7Initial program 79.8%
Simplified85.1%
associate-/r/85.1%
associate-*r*81.9%
swap-sqr99.9%
associate-*r*99.9%
distribute-lft-in99.9%
metadata-eval99.9%
associate-*r*99.9%
metadata-eval99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.5%
if -4.1e7 < v < 1.55e-8Initial program 89.5%
Simplified89.5%
associate-/r/89.5%
associate-*r*84.5%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around 0 99.8%
associate-*r*99.8%
Simplified99.8%
if 1.55e-8 < v Initial program 78.5%
Simplified87.9%
associate-/r/87.9%
associate-*r*85.3%
swap-sqr99.6%
associate-*r*99.6%
distribute-lft-in99.6%
metadata-eval99.6%
associate-*r*99.6%
metadata-eval99.6%
*-commutative99.6%
*-commutative99.6%
Applied egg-rr99.6%
associate-/r*46.0%
div-inv46.0%
*-un-lft-identity46.0%
times-frac46.0%
metadata-eval46.0%
Applied egg-rr99.7%
associate-*r/46.0%
associate-*l/45.9%
associate-*r/46.0%
*-rgt-identity46.0%
Simplified99.7%
Taylor expanded in v around inf 99.0%
Final simplification99.5%
(FPCore (v w r)
:precision binary64
(let* ((t_0 (+ 3.0 (/ (/ 2.0 r) r)))
(t_1 (+ 4.5 (* (* r w) (* (* r w) 0.25)))))
(if (<= v -3.1e-52)
(- (+ 3.0 (/ 2.0 (* r r))) t_1)
(if (<= v 4e-37)
(- t_0 (+ 4.5 (* (* r w) (* w (* r 0.375)))))
(- t_0 t_1)))))
double code(double v, double w, double r) {
double t_0 = 3.0 + ((2.0 / r) / r);
double t_1 = 4.5 + ((r * w) * ((r * w) * 0.25));
double tmp;
if (v <= -3.1e-52) {
tmp = (3.0 + (2.0 / (r * r))) - t_1;
} else if (v <= 4e-37) {
tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375))));
} else {
tmp = t_0 - 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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 3.0d0 + ((2.0d0 / r) / r)
t_1 = 4.5d0 + ((r * w) * ((r * w) * 0.25d0))
if (v <= (-3.1d-52)) then
tmp = (3.0d0 + (2.0d0 / (r * r))) - t_1
else if (v <= 4d-37) then
tmp = t_0 - (4.5d0 + ((r * w) * (w * (r * 0.375d0))))
else
tmp = t_0 - t_1
end if
code = tmp
end function
public static double code(double v, double w, double r) {
double t_0 = 3.0 + ((2.0 / r) / r);
double t_1 = 4.5 + ((r * w) * ((r * w) * 0.25));
double tmp;
if (v <= -3.1e-52) {
tmp = (3.0 + (2.0 / (r * r))) - t_1;
} else if (v <= 4e-37) {
tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375))));
} else {
tmp = t_0 - t_1;
}
return tmp;
}
def code(v, w, r): t_0 = 3.0 + ((2.0 / r) / r) t_1 = 4.5 + ((r * w) * ((r * w) * 0.25)) tmp = 0 if v <= -3.1e-52: tmp = (3.0 + (2.0 / (r * r))) - t_1 elif v <= 4e-37: tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))) else: tmp = t_0 - t_1 return tmp
function code(v, w, r) t_0 = Float64(3.0 + Float64(Float64(2.0 / r) / r)) t_1 = Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25))) tmp = 0.0 if (v <= -3.1e-52) tmp = Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - t_1); elseif (v <= 4e-37) tmp = Float64(t_0 - Float64(4.5 + Float64(Float64(r * w) * Float64(w * Float64(r * 0.375))))); else tmp = Float64(t_0 - t_1); end return tmp end
function tmp_2 = code(v, w, r) t_0 = 3.0 + ((2.0 / r) / r); t_1 = 4.5 + ((r * w) * ((r * w) * 0.25)); tmp = 0.0; if (v <= -3.1e-52) tmp = (3.0 + (2.0 / (r * r))) - t_1; elseif (v <= 4e-37) tmp = t_0 - (4.5 + ((r * w) * (w * (r * 0.375)))); else tmp = t_0 - t_1; end tmp_2 = tmp; end
code[v_, w_, r_] := Block[{t$95$0 = N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[v, -3.1e-52], N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[v, 4e-37], N[(t$95$0 - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(w * N[(r * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - t$95$1), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 3 + \frac{\frac{2}{r}}{r}\\
t_1 := 4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\\
\mathbf{if}\;v \leq -3.1 \cdot 10^{-52}:\\
\;\;\;\;\left(3 + \frac{2}{r \cdot r}\right) - t_1\\
\mathbf{elif}\;v \leq 4 \cdot 10^{-37}:\\
\;\;\;\;t_0 - \left(4.5 + \left(r \cdot w\right) \cdot \left(w \cdot \left(r \cdot 0.375\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 - t_1\\
\end{array}
\end{array}
if v < -3.0999999999999999e-52Initial program 81.1%
Simplified86.1%
associate-/r/86.1%
associate-*r*83.1%
swap-sqr99.9%
associate-*r*99.9%
distribute-lft-in99.9%
metadata-eval99.9%
associate-*r*99.9%
metadata-eval99.9%
*-commutative99.9%
*-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in v around inf 99.5%
if -3.0999999999999999e-52 < v < 4.00000000000000027e-37Initial program 89.3%
Simplified89.3%
associate-/r/89.3%
associate-*r*83.7%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
associate-/r*56.6%
div-inv56.6%
*-un-lft-identity56.6%
times-frac56.6%
metadata-eval56.6%
Applied egg-rr99.8%
associate-*r/56.6%
associate-*l/56.5%
associate-*r/56.6%
*-rgt-identity56.6%
Simplified99.8%
Taylor expanded in v around 0 99.8%
associate-*r*99.8%
Simplified99.8%
if 4.00000000000000027e-37 < v Initial program 79.2%
Simplified87.7%
associate-/r/87.7%
associate-*r*85.4%
swap-sqr99.7%
associate-*r*99.7%
distribute-lft-in99.7%
metadata-eval99.7%
associate-*r*99.7%
metadata-eval99.7%
*-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
associate-/r*49.8%
div-inv49.8%
*-un-lft-identity49.8%
times-frac49.8%
metadata-eval49.8%
Applied egg-rr99.7%
associate-*r/49.8%
associate-*l/49.7%
associate-*r/49.8%
*-rgt-identity49.8%
Simplified99.7%
Taylor expanded in v around inf 99.1%
Final simplification99.5%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) (+ 4.5 (* (* r w) (* (* r w) (/ (+ 0.375 (* -0.25 v)) (- 1.0 v)))))))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * ((0.375 + (-0.25 * v)) / (1.0 - v)))));
}
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))) - (4.5d0 + ((r * w) * ((r * w) * ((0.375d0 + ((-0.25d0) * v)) / (1.0d0 - v)))))
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * ((0.375 + (-0.25 * v)) / (1.0 - v)))));
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * ((0.375 + (-0.25 * v)) / (1.0 - v)))))
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * Float64(Float64(0.375 + Float64(-0.25 * v)) / Float64(1.0 - v)))))) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * ((0.375 + (-0.25 * v)) / (1.0 - v))))); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * N[(N[(0.375 + N[(-0.25 * v), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - \left(4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot \frac{0.375 + -0.25 \cdot v}{1 - v}\right)\right)
\end{array}
Initial program 84.0%
Simplified87.9%
associate-/r/87.9%
associate-*r*84.0%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) (+ 4.5 (* (* r w) (* (* r w) 0.25)))))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * 0.25)));
}
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))) - (4.5d0 + ((r * w) * ((r * w) * 0.25d0)))
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * 0.25)));
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * 0.25)))
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(4.5 + Float64(Float64(r * w) * Float64(Float64(r * w) * 0.25)))) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - (4.5 + ((r * w) * ((r * w) * 0.25))); end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.5 + N[(N[(r * w), $MachinePrecision] * N[(N[(r * w), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - \left(4.5 + \left(r \cdot w\right) \cdot \left(\left(r \cdot w\right) \cdot 0.25\right)\right)
\end{array}
Initial program 84.0%
Simplified87.9%
associate-/r/87.9%
associate-*r*84.0%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in v around inf 93.8%
Final simplification93.8%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ 2.0 (* r r))) 4.5))
double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 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))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + (2.0 / (r * r))) - 4.5;
}
def code(v, w, r): return (3.0 + (2.0 / (r * r))) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + (2.0 / (r * r))) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{2}{r \cdot r}\right) - 4.5
\end{array}
Initial program 84.0%
Simplified87.9%
associate-/r/87.9%
associate-*r*84.0%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in w around 0 54.1%
Final simplification54.1%
(FPCore (v w r) :precision binary64 (- (+ 3.0 (/ (/ 2.0 r) r)) 4.5))
double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 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)) - 4.5d0
end function
public static double code(double v, double w, double r) {
return (3.0 + ((2.0 / r) / r)) - 4.5;
}
def code(v, w, r): return (3.0 + ((2.0 / r) / r)) - 4.5
function code(v, w, r) return Float64(Float64(3.0 + Float64(Float64(2.0 / r) / r)) - 4.5) end
function tmp = code(v, w, r) tmp = (3.0 + ((2.0 / r) / r)) - 4.5; end
code[v_, w_, r_] := N[(N[(3.0 + N[(N[(2.0 / r), $MachinePrecision] / r), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(3 + \frac{\frac{2}{r}}{r}\right) - 4.5
\end{array}
Initial program 84.0%
Simplified87.9%
associate-/r/87.9%
associate-*r*84.0%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in w around 0 54.1%
associate-/r*54.1%
div-inv54.1%
*-un-lft-identity54.1%
times-frac54.1%
metadata-eval54.1%
Applied egg-rr54.1%
associate-*r/54.1%
associate-*l/54.0%
associate-*r/54.1%
*-rgt-identity54.1%
Simplified54.1%
Final simplification54.1%
(FPCore (v w r) :precision binary64 -1.5)
double code(double v, double w, double r) {
return -1.5;
}
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
end function
public static double code(double v, double w, double r) {
return -1.5;
}
def code(v, w, r): return -1.5
function code(v, w, r) return -1.5 end
function tmp = code(v, w, r) tmp = -1.5; end
code[v_, w_, r_] := -1.5
\begin{array}{l}
\\
-1.5
\end{array}
Initial program 84.0%
Simplified87.9%
associate-/r/87.9%
associate-*r*84.0%
swap-sqr99.8%
associate-*r*99.8%
distribute-lft-in99.8%
metadata-eval99.8%
associate-*r*99.8%
metadata-eval99.8%
*-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in w around 0 54.1%
Taylor expanded in r around inf 12.3%
Final simplification12.3%
herbie shell --seed 2024018
(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))