
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) - 1.0d0
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}
(FPCore (a b) :precision binary64 (+ (pow (hypot a b) 4.0) (fma b (* b 4.0) -1.0)))
double code(double a, double b) {
return pow(hypot(a, b), 4.0) + fma(b, (b * 4.0), -1.0);
}
function code(a, b) return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(b * 4.0), -1.0)) end
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)
\end{array}
Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
unpow199.9%
sqr-pow99.9%
unpow399.9%
pow-plus100.0%
metadata-eval100.0%
unpow1/2100.0%
hypot-def100.0%
metadata-eval100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a b)
:precision binary64
(if (<= a 0.024)
(+ (+ (pow b 4.0) (* 4.0 (* b b))) -1.0)
(if (<= a 6.2e+74)
(+ (+ (pow a 4.0) (* (* a a) (* (* b b) 2.0))) -1.0)
(+ (pow a 4.0) -1.0))))
double code(double a, double b) {
double tmp;
if (a <= 0.024) {
tmp = (pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
} else if (a <= 6.2e+74) {
tmp = (pow(a, 4.0) + ((a * a) * ((b * b) * 2.0))) + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 0.024d0) then
tmp = ((b ** 4.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
else if (a <= 6.2d+74) then
tmp = ((a ** 4.0d0) + ((a * a) * ((b * b) * 2.0d0))) + (-1.0d0)
else
tmp = (a ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 0.024) {
tmp = (Math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
} else if (a <= 6.2e+74) {
tmp = (Math.pow(a, 4.0) + ((a * a) * ((b * b) * 2.0))) + -1.0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 0.024: tmp = (math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0 elif a <= 6.2e+74: tmp = (math.pow(a, 4.0) + ((a * a) * ((b * b) * 2.0))) + -1.0 else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= 0.024) tmp = Float64(Float64((b ^ 4.0) + Float64(4.0 * Float64(b * b))) + -1.0); elseif (a <= 6.2e+74) tmp = Float64(Float64((a ^ 4.0) + Float64(Float64(a * a) * Float64(Float64(b * b) * 2.0))) + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 0.024) tmp = ((b ^ 4.0) + (4.0 * (b * b))) + -1.0; elseif (a <= 6.2e+74) tmp = ((a ^ 4.0) + ((a * a) * ((b * b) * 2.0))) + -1.0; else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 0.024], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 6.2e+74], N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(N[(b * b), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 0.024:\\
\;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{elif}\;a \leq 6.2 \cdot 10^{+74}:\\
\;\;\;\;\left({a}^{4} + \left(a \cdot a\right) \cdot \left(\left(b \cdot b\right) \cdot 2\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if a < 0.024Initial program 99.9%
Taylor expanded in a around 0 85.9%
+-commutative85.9%
unpow285.9%
*-commutative85.9%
associate-*r*85.9%
fma-def85.9%
Simplified85.9%
fma-udef85.9%
+-commutative85.9%
associate-*r*85.9%
Applied egg-rr85.9%
if 0.024 < a < 6.20000000000000043e74Initial program 99.5%
Taylor expanded in b around 0 89.9%
unpow289.9%
unpow289.9%
Simplified89.9%
Taylor expanded in a around inf 89.9%
unpow289.9%
unpow289.9%
associate-*r*89.9%
*-commutative89.9%
associate-*r*89.9%
Simplified89.9%
if 6.20000000000000043e74 < a Initial program 100.0%
Taylor expanded in b around 0 88.0%
unpow288.0%
unpow288.0%
Simplified88.0%
Taylor expanded in a around inf 100.0%
Final simplification88.9%
(FPCore (a b) :precision binary64 (+ (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) -1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0;
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) + -1.0
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (a b) :precision binary64 (if (<= a 0.48) (+ (+ (pow b 4.0) (* 4.0 (* b b))) -1.0) (+ (pow a 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= 0.48) {
tmp = (pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 0.48d0) then
tmp = ((b ** 4.0d0) + (4.0d0 * (b * b))) + (-1.0d0)
else
tmp = (a ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 0.48) {
tmp = (Math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 0.48: tmp = (math.pow(b, 4.0) + (4.0 * (b * b))) + -1.0 else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= 0.48) tmp = Float64(Float64((b ^ 4.0) + Float64(4.0 * Float64(b * b))) + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 0.48) tmp = ((b ^ 4.0) + (4.0 * (b * b))) + -1.0; else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 0.48], N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 0.48:\\
\;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if a < 0.47999999999999998Initial program 99.9%
Taylor expanded in a around 0 85.9%
+-commutative85.9%
unpow285.9%
*-commutative85.9%
associate-*r*85.9%
fma-def85.9%
Simplified85.9%
fma-udef85.9%
+-commutative85.9%
associate-*r*85.9%
Applied egg-rr85.9%
if 0.47999999999999998 < a Initial program 99.9%
Taylor expanded in b around 0 88.5%
unpow288.5%
unpow288.5%
Simplified88.5%
Taylor expanded in a around inf 90.2%
Final simplification87.1%
(FPCore (a b) :precision binary64 (if (<= a 1.2) (+ (* b (* b (fma b b 4.0))) -1.0) (+ (pow a 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= 1.2) {
tmp = (b * (b * fma(b, b, 4.0))) + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
function code(a, b) tmp = 0.0 if (a <= 1.2) tmp = Float64(Float64(b * Float64(b * fma(b, b, 4.0))) + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
code[a_, b_] := If[LessEqual[a, 1.2], N[(N[(b * N[(b * N[(b * b + 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.2:\\
\;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if a < 1.19999999999999996Initial program 99.9%
Taylor expanded in a around 0 85.9%
+-commutative85.9%
unpow285.9%
*-commutative85.9%
associate-*r*85.9%
fma-def85.9%
Simplified85.9%
fma-udef85.9%
+-commutative85.9%
associate-*r*85.9%
Applied egg-rr85.9%
Taylor expanded in b around 0 85.9%
metadata-eval85.9%
pow-plus85.9%
unpow385.9%
associate-*r*85.8%
unpow285.8%
distribute-rgt-in85.8%
fma-udef85.8%
associate-*l*85.9%
Simplified85.9%
if 1.19999999999999996 < a Initial program 99.9%
Taylor expanded in b around 0 88.5%
unpow288.5%
unpow288.5%
Simplified88.5%
Taylor expanded in a around inf 90.2%
Final simplification87.0%
(FPCore (a b) :precision binary64 (if (<= a 6.2) (+ (+ (* 4.0 (* b b)) (* (* b b) (* b b))) -1.0) (+ (pow a 4.0) -1.0)))
double code(double a, double b) {
double tmp;
if (a <= 6.2) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else {
tmp = pow(a, 4.0) + -1.0;
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 6.2d0) then
tmp = ((4.0d0 * (b * b)) + ((b * b) * (b * b))) + (-1.0d0)
else
tmp = (a ** 4.0d0) + (-1.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 6.2) {
tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
} else {
tmp = Math.pow(a, 4.0) + -1.0;
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 6.2: tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0 else: tmp = math.pow(a, 4.0) + -1.0 return tmp
function code(a, b) tmp = 0.0 if (a <= 6.2) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))) + -1.0); else tmp = Float64((a ^ 4.0) + -1.0); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 6.2) tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0; else tmp = (a ^ 4.0) + -1.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 6.2], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 6.2:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4} + -1\\
\end{array}
\end{array}
if a < 6.20000000000000018Initial program 99.9%
Taylor expanded in a around 0 85.9%
+-commutative85.9%
unpow285.9%
*-commutative85.9%
associate-*r*85.9%
fma-def85.9%
Simplified85.9%
fma-udef85.9%
+-commutative85.9%
associate-*r*85.9%
Applied egg-rr85.9%
metadata-eval84.6%
pow-prod-up84.5%
pow-prod-down84.5%
pow284.5%
Applied egg-rr85.8%
if 6.20000000000000018 < a Initial program 99.9%
Taylor expanded in b around 0 88.5%
unpow288.5%
unpow288.5%
Simplified88.5%
Taylor expanded in a around inf 90.2%
Final simplification87.0%
(FPCore (a b) :precision binary64 (+ (+ (* 4.0 (* b b)) (* (* b b) (* b b))) -1.0))
double code(double a, double b) {
return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((4.0d0 * (b * b)) + ((b * b) * (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0;
}
def code(a, b): return ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0
function code(a, b) return Float64(Float64(Float64(4.0 * Float64(b * b)) + Float64(Float64(b * b) * Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((4.0 * (b * b)) + ((b * b) * (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(4 \cdot \left(b \cdot b\right) + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 70.4%
+-commutative70.4%
unpow270.4%
*-commutative70.4%
associate-*r*70.4%
fma-def70.4%
Simplified70.4%
fma-udef70.4%
+-commutative70.4%
associate-*r*70.4%
Applied egg-rr70.4%
metadata-eval69.4%
pow-prod-up69.4%
pow-prod-down69.4%
pow269.4%
Applied egg-rr70.3%
Final simplification70.3%
(FPCore (a b) :precision binary64 (+ (* (* b b) (+ 4.0 (* b b))) -1.0))
double code(double a, double b) {
return ((b * b) * (4.0 + (b * b))) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * (4.0 + (b * b))) + -1.0;
}
def code(a, b): return ((b * b) * (4.0 + (b * b))) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 70.4%
+-commutative70.4%
unpow270.4%
*-commutative70.4%
associate-*r*70.4%
fma-def70.4%
Simplified70.4%
fma-udef70.4%
+-commutative70.4%
associate-*r*70.4%
Applied egg-rr70.4%
+-commutative70.4%
metadata-eval70.4%
pow-prod-up70.3%
pow270.3%
pow270.3%
distribute-lft-out70.3%
Applied egg-rr70.3%
Final simplification70.3%
(FPCore (a b) :precision binary64 (+ (* (* b b) (* b b)) -1.0))
double code(double a, double b) {
return ((b * b) * (b * b)) + -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((b * b) * (b * b)) + (-1.0d0)
end function
public static double code(double a, double b) {
return ((b * b) * (b * b)) + -1.0;
}
def code(a, b): return ((b * b) * (b * b)) + -1.0
function code(a, b) return Float64(Float64(Float64(b * b) * Float64(b * b)) + -1.0) end
function tmp = code(a, b) tmp = ((b * b) * (b * b)) + -1.0; end
code[a_, b_] := N[(N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 70.4%
+-commutative70.4%
unpow270.4%
*-commutative70.4%
associate-*r*70.4%
fma-def70.4%
Simplified70.4%
Taylor expanded in b around inf 69.4%
metadata-eval69.4%
pow-prod-up69.4%
pow-prod-down69.4%
pow269.4%
Applied egg-rr69.4%
Final simplification69.4%
(FPCore (a b) :precision binary64 (if (<= b 0.48) -1.0 (* b (* b 4.0))))
double code(double a, double b) {
double tmp;
if (b <= 0.48) {
tmp = -1.0;
} else {
tmp = b * (b * 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (b <= 0.48d0) then
tmp = -1.0d0
else
tmp = b * (b * 4.0d0)
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (b <= 0.48) {
tmp = -1.0;
} else {
tmp = b * (b * 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if b <= 0.48: tmp = -1.0 else: tmp = b * (b * 4.0) return tmp
function code(a, b) tmp = 0.0 if (b <= 0.48) tmp = -1.0; else tmp = Float64(b * Float64(b * 4.0)); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (b <= 0.48) tmp = -1.0; else tmp = b * (b * 4.0); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[b, 0.48], -1.0, N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 0.48:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;b \cdot \left(b \cdot 4\right)\\
\end{array}
\end{array}
if b < 0.47999999999999998Initial program 99.9%
Taylor expanded in b around 0 83.8%
unpow283.8%
unpow283.8%
Simplified83.8%
Taylor expanded in a around 0 51.0%
fma-neg51.0%
unpow251.0%
metadata-eval51.0%
Simplified51.0%
Taylor expanded in b around 0 33.9%
if 0.47999999999999998 < b Initial program 99.9%
Taylor expanded in b around 0 73.2%
unpow273.2%
unpow273.2%
Simplified73.2%
Taylor expanded in a around 0 45.6%
fma-neg45.6%
unpow245.6%
metadata-eval45.6%
Simplified45.6%
Taylor expanded in b around inf 45.7%
unpow245.7%
*-commutative45.7%
associate-*r*45.7%
Simplified45.7%
Final simplification36.6%
(FPCore (a b) :precision binary64 (+ -1.0 (* b (* b 4.0))))
double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (-1.0d0) + (b * (b * 4.0d0))
end function
public static double code(double a, double b) {
return -1.0 + (b * (b * 4.0));
}
def code(a, b): return -1.0 + (b * (b * 4.0))
function code(a, b) return Float64(-1.0 + Float64(b * Float64(b * 4.0))) end
function tmp = code(a, b) tmp = -1.0 + (b * (b * 4.0)); end
code[a_, b_] := N[(-1.0 + N[(b * N[(b * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 + b \cdot \left(b \cdot 4\right)
\end{array}
Initial program 99.9%
Taylor expanded in b around 0 81.4%
unpow281.4%
unpow281.4%
Simplified81.4%
Taylor expanded in a around 0 49.8%
fma-neg49.8%
unpow249.8%
metadata-eval49.8%
Simplified49.8%
fma-udef49.8%
*-commutative49.8%
associate-*l*49.8%
Applied egg-rr49.8%
Final simplification49.8%
(FPCore (a b) :precision binary64 -1.0)
double code(double a, double b) {
return -1.0;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = -1.0d0
end function
public static double code(double a, double b) {
return -1.0;
}
def code(a, b): return -1.0
function code(a, b) return -1.0 end
function tmp = code(a, b) tmp = -1.0; end
code[a_, b_] := -1.0
\begin{array}{l}
\\
-1
\end{array}
Initial program 99.9%
Taylor expanded in b around 0 81.4%
unpow281.4%
unpow281.4%
Simplified81.4%
Taylor expanded in a around 0 49.8%
fma-neg49.8%
unpow249.8%
metadata-eval49.8%
Simplified49.8%
Taylor expanded in b around 0 26.4%
Final simplification26.4%
herbie shell --seed 2023275
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))