
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}
(FPCore (x) :precision binary64 (- 1.0 (+ (* x 0.253) (* 0.12 (* x x)))))
double code(double x) {
return 1.0 - ((x * 0.253) + (0.12 * (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - ((x * 0.253d0) + (0.12d0 * (x * x)))
end function
public static double code(double x) {
return 1.0 - ((x * 0.253) + (0.12 * (x * x)));
}
def code(x): return 1.0 - ((x * 0.253) + (0.12 * (x * x)))
function code(x) return Float64(1.0 - Float64(Float64(x * 0.253) + Float64(0.12 * Float64(x * x)))) end
function tmp = code(x) tmp = 1.0 - ((x * 0.253) + (0.12 * (x * x))); end
code[x_] := N[(1.0 - N[(N[(x * 0.253), $MachinePrecision] + N[(0.12 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \left(x \cdot 0.253 + 0.12 \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 99.8%
distribute-rgt-in99.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (if (or (<= x -4.0) (not (<= x 2.1))) (* x (* x -0.12)) 1.5334083333333333))
double code(double x) {
double tmp;
if ((x <= -4.0) || !(x <= 2.1)) {
tmp = x * (x * -0.12);
} else {
tmp = 1.5334083333333333;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if ((x <= (-4.0d0)) .or. (.not. (x <= 2.1d0))) then
tmp = x * (x * (-0.12d0))
else
tmp = 1.5334083333333333d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((x <= -4.0) || !(x <= 2.1)) {
tmp = x * (x * -0.12);
} else {
tmp = 1.5334083333333333;
}
return tmp;
}
def code(x): tmp = 0 if (x <= -4.0) or not (x <= 2.1): tmp = x * (x * -0.12) else: tmp = 1.5334083333333333 return tmp
function code(x) tmp = 0.0 if ((x <= -4.0) || !(x <= 2.1)) tmp = Float64(x * Float64(x * -0.12)); else tmp = 1.5334083333333333; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((x <= -4.0) || ~((x <= 2.1))) tmp = x * (x * -0.12); else tmp = 1.5334083333333333; end tmp_2 = tmp; end
code[x_] := If[Or[LessEqual[x, -4.0], N[Not[LessEqual[x, 2.1]], $MachinePrecision]], N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision], 1.5334083333333333]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \lor \neg \left(x \leq 2.1\right):\\
\;\;\;\;x \cdot \left(x \cdot -0.12\right)\\
\mathbf{else}:\\
\;\;\;\;1.5334083333333333\\
\end{array}
\end{array}
if x < -4 or 2.10000000000000009 < x Initial program 99.7%
flip-+99.6%
associate-*r/77.8%
metadata-eval77.8%
swap-sqr77.8%
metadata-eval77.8%
*-commutative77.8%
cancel-sign-sub-inv77.8%
metadata-eval77.8%
Applied egg-rr77.8%
*-commutative77.8%
associate-/l*99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 97.6%
Taylor expanded in x around inf 97.7%
*-commutative97.7%
unpow297.7%
associate-*l*97.6%
Simplified97.6%
if -4 < x < 2.10000000000000009Initial program 100.0%
flip-+100.0%
associate-*r/100.0%
metadata-eval100.0%
swap-sqr100.0%
metadata-eval100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/l*100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 20.2%
Taylor expanded in x around 0 20.2%
Final simplification61.9%
(FPCore (x) :precision binary64 (if (<= x -4.0) (* x (* x -0.12)) (if (<= x 2.1) 1.5334083333333333 (* (* x x) -0.12))))
double code(double x) {
double tmp;
if (x <= -4.0) {
tmp = x * (x * -0.12);
} else if (x <= 2.1) {
tmp = 1.5334083333333333;
} else {
tmp = (x * x) * -0.12;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4.0d0)) then
tmp = x * (x * (-0.12d0))
else if (x <= 2.1d0) then
tmp = 1.5334083333333333d0
else
tmp = (x * x) * (-0.12d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4.0) {
tmp = x * (x * -0.12);
} else if (x <= 2.1) {
tmp = 1.5334083333333333;
} else {
tmp = (x * x) * -0.12;
}
return tmp;
}
def code(x): tmp = 0 if x <= -4.0: tmp = x * (x * -0.12) elif x <= 2.1: tmp = 1.5334083333333333 else: tmp = (x * x) * -0.12 return tmp
function code(x) tmp = 0.0 if (x <= -4.0) tmp = Float64(x * Float64(x * -0.12)); elseif (x <= 2.1) tmp = 1.5334083333333333; else tmp = Float64(Float64(x * x) * -0.12); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4.0) tmp = x * (x * -0.12); elseif (x <= 2.1) tmp = 1.5334083333333333; else tmp = (x * x) * -0.12; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4.0], N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1], 1.5334083333333333, N[(N[(x * x), $MachinePrecision] * -0.12), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;x \cdot \left(x \cdot -0.12\right)\\
\mathbf{elif}\;x \leq 2.1:\\
\;\;\;\;1.5334083333333333\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot -0.12\\
\end{array}
\end{array}
if x < -4Initial program 99.8%
flip-+99.7%
associate-*r/81.5%
metadata-eval81.5%
swap-sqr81.5%
metadata-eval81.5%
*-commutative81.5%
cancel-sign-sub-inv81.5%
metadata-eval81.5%
Applied egg-rr81.5%
*-commutative81.5%
associate-/l*99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 96.6%
Taylor expanded in x around inf 96.7%
*-commutative96.7%
unpow296.7%
associate-*l*96.7%
Simplified96.7%
if -4 < x < 2.10000000000000009Initial program 100.0%
flip-+100.0%
associate-*r/100.0%
metadata-eval100.0%
swap-sqr100.0%
metadata-eval100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
*-commutative100.0%
associate-/l*100.0%
associate-*l*100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around inf 20.2%
Taylor expanded in x around 0 20.2%
if 2.10000000000000009 < x Initial program 99.6%
flip-+99.6%
associate-*r/74.9%
metadata-eval74.9%
swap-sqr74.9%
metadata-eval74.9%
*-commutative74.9%
cancel-sign-sub-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
*-commutative74.9%
associate-/l*99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
Final simplification62.0%
(FPCore (x) :precision binary64 (if (<= x -4.0) (* x (* x -0.12)) (if (<= x 2.1) (- 1.0 (* x 0.253)) (* (* x x) -0.12))))
double code(double x) {
double tmp;
if (x <= -4.0) {
tmp = x * (x * -0.12);
} else if (x <= 2.1) {
tmp = 1.0 - (x * 0.253);
} else {
tmp = (x * x) * -0.12;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= (-4.0d0)) then
tmp = x * (x * (-0.12d0))
else if (x <= 2.1d0) then
tmp = 1.0d0 - (x * 0.253d0)
else
tmp = (x * x) * (-0.12d0)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= -4.0) {
tmp = x * (x * -0.12);
} else if (x <= 2.1) {
tmp = 1.0 - (x * 0.253);
} else {
tmp = (x * x) * -0.12;
}
return tmp;
}
def code(x): tmp = 0 if x <= -4.0: tmp = x * (x * -0.12) elif x <= 2.1: tmp = 1.0 - (x * 0.253) else: tmp = (x * x) * -0.12 return tmp
function code(x) tmp = 0.0 if (x <= -4.0) tmp = Float64(x * Float64(x * -0.12)); elseif (x <= 2.1) tmp = Float64(1.0 - Float64(x * 0.253)); else tmp = Float64(Float64(x * x) * -0.12); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= -4.0) tmp = x * (x * -0.12); elseif (x <= 2.1) tmp = 1.0 - (x * 0.253); else tmp = (x * x) * -0.12; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, -4.0], N[(x * N[(x * -0.12), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.1], N[(1.0 - N[(x * 0.253), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * -0.12), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4:\\
\;\;\;\;x \cdot \left(x \cdot -0.12\right)\\
\mathbf{elif}\;x \leq 2.1:\\
\;\;\;\;1 - x \cdot 0.253\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot -0.12\\
\end{array}
\end{array}
if x < -4Initial program 99.8%
flip-+99.7%
associate-*r/81.5%
metadata-eval81.5%
swap-sqr81.5%
metadata-eval81.5%
*-commutative81.5%
cancel-sign-sub-inv81.5%
metadata-eval81.5%
Applied egg-rr81.5%
*-commutative81.5%
associate-/l*99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 96.6%
Taylor expanded in x around inf 96.7%
*-commutative96.7%
unpow296.7%
associate-*l*96.7%
Simplified96.7%
if -4 < x < 2.10000000000000009Initial program 100.0%
Taylor expanded in x around 0 99.6%
*-commutative99.6%
Simplified99.6%
if 2.10000000000000009 < x Initial program 99.6%
flip-+99.6%
associate-*r/74.9%
metadata-eval74.9%
swap-sqr74.9%
metadata-eval74.9%
*-commutative74.9%
cancel-sign-sub-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
*-commutative74.9%
associate-/l*99.6%
associate-*l*99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in x around inf 98.4%
Taylor expanded in x around inf 98.5%
*-commutative98.5%
unpow298.5%
Simplified98.5%
Final simplification98.6%
(FPCore (x) :precision binary64 (- 1.0 (* x (+ 0.253 (* x 0.12)))))
double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (x * (0.253d0 + (x * 0.12d0)))
end function
public static double code(double x) {
return 1.0 - (x * (0.253 + (x * 0.12)));
}
def code(x): return 1.0 - (x * (0.253 + (x * 0.12)))
function code(x) return Float64(1.0 - Float64(x * Float64(0.253 + Float64(x * 0.12)))) end
function tmp = code(x) tmp = 1.0 - (x * (0.253 + (x * 0.12))); end
code[x_] := N[(1.0 - N[(x * N[(0.253 + N[(x * 0.12), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - x \cdot \left(0.253 + x \cdot 0.12\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (- 1.0 (* 0.12 (* x x))))
double code(double x) {
return 1.0 - (0.12 * (x * x));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - (0.12d0 * (x * x))
end function
public static double code(double x) {
return 1.0 - (0.12 * (x * x));
}
def code(x): return 1.0 - (0.12 * (x * x))
function code(x) return Float64(1.0 - Float64(0.12 * Float64(x * x))) end
function tmp = code(x) tmp = 1.0 - (0.12 * (x * x)); end
code[x_] := N[(1.0 - N[(0.12 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - 0.12 \cdot \left(x \cdot x\right)
\end{array}
Initial program 99.8%
Taylor expanded in x around inf 98.0%
unpow298.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x) :precision binary64 1.5334083333333333)
double code(double x) {
return 1.5334083333333333;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.5334083333333333d0
end function
public static double code(double x) {
return 1.5334083333333333;
}
def code(x): return 1.5334083333333333
function code(x) return 1.5334083333333333 end
function tmp = code(x) tmp = 1.5334083333333333; end
code[x_] := 1.5334083333333333
\begin{array}{l}
\\
1.5334083333333333
\end{array}
Initial program 99.8%
flip-+99.8%
associate-*r/88.0%
metadata-eval88.0%
swap-sqr88.0%
metadata-eval88.0%
*-commutative88.0%
cancel-sign-sub-inv88.0%
metadata-eval88.0%
Applied egg-rr88.0%
*-commutative88.0%
associate-/l*99.8%
associate-*l*99.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 61.9%
Taylor expanded in x around 0 9.8%
Final simplification9.8%
herbie shell --seed 2023199
(FPCore (x)
:name "Numeric.SpecFunctions:invIncompleteGamma from math-functions-0.1.5.2, A"
:precision binary64
(- 1.0 (* x (+ 0.253 (* x 0.12)))))