
(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 11 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%
Simplified100.0%
Final simplification100.0%
(FPCore (a b) :precision binary64 (if (<= (* b b) 0.0001) (+ (pow a 4.0) -1.0) (+ (pow b 4.0) (* (* b b) (+ 4.0 (* (* a a) 2.0))))))
double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0001) {
tmp = pow(a, 4.0) + -1.0;
} else {
tmp = pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0)));
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if ((b * b) <= 0.0001d0) then
tmp = (a ** 4.0d0) + (-1.0d0)
else
tmp = (b ** 4.0d0) + ((b * b) * (4.0d0 + ((a * a) * 2.0d0)))
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if ((b * b) <= 0.0001) {
tmp = Math.pow(a, 4.0) + -1.0;
} else {
tmp = Math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0)));
}
return tmp;
}
def code(a, b): tmp = 0 if (b * b) <= 0.0001: tmp = math.pow(a, 4.0) + -1.0 else: tmp = math.pow(b, 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))) return tmp
function code(a, b) tmp = 0.0 if (Float64(b * b) <= 0.0001) tmp = Float64((a ^ 4.0) + -1.0); else tmp = Float64((b ^ 4.0) + Float64(Float64(b * b) * Float64(4.0 + Float64(Float64(a * a) * 2.0)))); end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if ((b * b) <= 0.0001) tmp = (a ^ 4.0) + -1.0; else tmp = (b ^ 4.0) + ((b * b) * (4.0 + ((a * a) * 2.0))); end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[N[(b * b), $MachinePrecision], 0.0001], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(N[(a * a), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \cdot b \leq 0.0001:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{else}:\\
\;\;\;\;{b}^{4} + \left(b \cdot b\right) \cdot \left(4 + \left(a \cdot a\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f64 b b) < 1.00000000000000005e-4Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 99.4%
if 1.00000000000000005e-4 < (*.f64 b b) Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around inf 95.0%
*-commutative95.0%
unpow295.0%
unpow295.0%
Simplified95.0%
Final simplification97.1%
(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 2.7e-5)
(+ (+ (* 4.0 (* b b)) (pow b 4.0)) -1.0)
(if (<= a 2.8e+36)
(+ (pow a 4.0) -1.0)
(if (<= a 2e+54) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 2.7e-5) {
tmp = ((4.0 * (b * b)) + pow(b, 4.0)) + -1.0;
} else if (a <= 2.8e+36) {
tmp = pow(a, 4.0) + -1.0;
} else if (a <= 2e+54) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 2.7d-5) then
tmp = ((4.0d0 * (b * b)) + (b ** 4.0d0)) + (-1.0d0)
else if (a <= 2.8d+36) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if (a <= 2d+54) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 2.7e-5) {
tmp = ((4.0 * (b * b)) + Math.pow(b, 4.0)) + -1.0;
} else if (a <= 2.8e+36) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if (a <= 2e+54) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 2.7e-5: tmp = ((4.0 * (b * b)) + math.pow(b, 4.0)) + -1.0 elif a <= 2.8e+36: tmp = math.pow(a, 4.0) + -1.0 elif a <= 2e+54: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 2.7e-5) tmp = Float64(Float64(Float64(4.0 * Float64(b * b)) + (b ^ 4.0)) + -1.0); elseif (a <= 2.8e+36) tmp = Float64((a ^ 4.0) + -1.0); elseif (a <= 2e+54) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 2.7e-5) tmp = ((4.0 * (b * b)) + (b ^ 4.0)) + -1.0; elseif (a <= 2.8e+36) tmp = (a ^ 4.0) + -1.0; elseif (a <= 2e+54) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 2.7e-5], N[(N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 2.8e+36], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 2e+54], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;\left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right) + -1\\
\mathbf{elif}\;a \leq 2.8 \cdot 10^{+36}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;a \leq 2 \cdot 10^{+54}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 2.6999999999999999e-5Initial program 99.9%
Taylor expanded in a around 0 84.1%
+-commutative84.1%
fma-def84.1%
unpow284.1%
Simplified84.1%
fma-udef84.1%
+-commutative84.1%
Applied egg-rr84.1%
if 2.6999999999999999e-5 < a < 2.8000000000000001e36Initial program 99.5%
associate--l+99.5%
unpow299.5%
unpow199.5%
sqr-pow99.5%
associate-*r*99.5%
Simplified99.7%
Taylor expanded in b around 0 76.2%
if 2.8000000000000001e36 < a < 2.0000000000000002e54Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if 2.0000000000000002e54 < a Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
Final simplification87.4%
(FPCore (a b)
:precision binary64
(if (<= a 1.45)
(+ (* (* b b) (+ 4.0 (* b b))) -1.0)
(if (<= a 3.2e+36)
(pow a 4.0)
(if (<= a 2.8e+55) (+ (* (* b b) (* b b)) -1.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 1.45) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 3.2e+36) {
tmp = pow(a, 4.0);
} else if (a <= 2.8e+55) {
tmp = ((b * b) * (b * b)) + -1.0;
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 1.45d0) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else if (a <= 3.2d+36) then
tmp = a ** 4.0d0
else if (a <= 2.8d+55) then
tmp = ((b * b) * (b * b)) + (-1.0d0)
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.45) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 3.2e+36) {
tmp = Math.pow(a, 4.0);
} else if (a <= 2.8e+55) {
tmp = ((b * b) * (b * b)) + -1.0;
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.45: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 elif a <= 3.2e+36: tmp = math.pow(a, 4.0) elif a <= 2.8e+55: tmp = ((b * b) * (b * b)) + -1.0 else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.45) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); elseif (a <= 3.2e+36) tmp = a ^ 4.0; elseif (a <= 2.8e+55) tmp = Float64(Float64(Float64(b * b) * Float64(b * b)) + -1.0); else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.45) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; elseif (a <= 3.2e+36) tmp = a ^ 4.0; elseif (a <= 2.8e+55) tmp = ((b * b) * (b * b)) + -1.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.45], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 3.2e+36], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 2.8e+55], N[(N[(N[(b * b), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.45:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{elif}\;a \leq 3.2 \cdot 10^{+36}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 2.8 \cdot 10^{+55}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1.44999999999999996Initial program 99.9%
Taylor expanded in a around 0 84.0%
+-commutative84.0%
fma-def84.0%
unpow284.0%
Simplified84.0%
fma-udef84.0%
metadata-eval84.0%
pow-prod-up83.9%
pow-prod-down83.9%
pow283.9%
distribute-rgt-out83.9%
Applied egg-rr83.9%
if 1.44999999999999996 < a < 3.1999999999999999e36 or 2.8000000000000001e55 < a Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in a around inf 94.9%
if 3.1999999999999999e36 < a < 2.8000000000000001e55Initial program 100.0%
Taylor expanded in a around 0 100.0%
+-commutative100.0%
fma-def100.0%
unpow2100.0%
Simplified100.0%
fma-udef100.0%
metadata-eval100.0%
pow-prod-up100.0%
pow-prod-down100.0%
pow2100.0%
distribute-rgt-out100.0%
Applied egg-rr100.0%
Taylor expanded in b around inf 100.0%
unpow2100.0%
Simplified100.0%
Final simplification86.7%
(FPCore (a b)
:precision binary64
(if (<= a 1.9)
(+ (* (* b b) (+ 4.0 (* b b))) -1.0)
(if (<= a 2.1e+36)
(pow a 4.0)
(if (<= a 1.1e+55) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 1.9) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 2.1e+36) {
tmp = pow(a, 4.0);
} else if (a <= 1.1e+55) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 1.9d0) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else if (a <= 2.1d+36) then
tmp = a ** 4.0d0
else if (a <= 1.1d+55) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 1.9) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 2.1e+36) {
tmp = Math.pow(a, 4.0);
} else if (a <= 1.1e+55) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 1.9: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 elif a <= 2.1e+36: tmp = math.pow(a, 4.0) elif a <= 1.1e+55: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 1.9) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); elseif (a <= 2.1e+36) tmp = a ^ 4.0; elseif (a <= 1.1e+55) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 1.9) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; elseif (a <= 2.1e+36) tmp = a ^ 4.0; elseif (a <= 1.1e+55) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 1.9], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 2.1e+36], N[Power[a, 4.0], $MachinePrecision], If[LessEqual[a, 1.1e+55], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 1.9:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{elif}\;a \leq 2.1 \cdot 10^{+36}:\\
\;\;\;\;{a}^{4}\\
\mathbf{elif}\;a \leq 1.1 \cdot 10^{+55}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 1.8999999999999999Initial program 99.9%
Taylor expanded in a around 0 84.0%
+-commutative84.0%
fma-def84.0%
unpow284.0%
Simplified84.0%
fma-udef84.0%
metadata-eval84.0%
pow-prod-up83.9%
pow-prod-down83.9%
pow283.9%
distribute-rgt-out83.9%
Applied egg-rr83.9%
if 1.8999999999999999 < a < 2.10000000000000004e36 or 1.10000000000000005e55 < a Initial program 99.9%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified99.9%
Taylor expanded in a around inf 94.9%
if 2.10000000000000004e36 < a < 1.10000000000000005e55Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
Final simplification86.7%
(FPCore (a b)
:precision binary64
(if (<= a 2.7e-5)
(+ (* (* b b) (+ 4.0 (* b b))) -1.0)
(if (<= a 2.15e+36)
(+ (pow a 4.0) -1.0)
(if (<= a 2.2e+54) (pow b 4.0) (pow a 4.0)))))
double code(double a, double b) {
double tmp;
if (a <= 2.7e-5) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 2.15e+36) {
tmp = pow(a, 4.0) + -1.0;
} else if (a <= 2.2e+54) {
tmp = pow(b, 4.0);
} else {
tmp = pow(a, 4.0);
}
return tmp;
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: tmp
if (a <= 2.7d-5) then
tmp = ((b * b) * (4.0d0 + (b * b))) + (-1.0d0)
else if (a <= 2.15d+36) then
tmp = (a ** 4.0d0) + (-1.0d0)
else if (a <= 2.2d+54) then
tmp = b ** 4.0d0
else
tmp = a ** 4.0d0
end if
code = tmp
end function
public static double code(double a, double b) {
double tmp;
if (a <= 2.7e-5) {
tmp = ((b * b) * (4.0 + (b * b))) + -1.0;
} else if (a <= 2.15e+36) {
tmp = Math.pow(a, 4.0) + -1.0;
} else if (a <= 2.2e+54) {
tmp = Math.pow(b, 4.0);
} else {
tmp = Math.pow(a, 4.0);
}
return tmp;
}
def code(a, b): tmp = 0 if a <= 2.7e-5: tmp = ((b * b) * (4.0 + (b * b))) + -1.0 elif a <= 2.15e+36: tmp = math.pow(a, 4.0) + -1.0 elif a <= 2.2e+54: tmp = math.pow(b, 4.0) else: tmp = math.pow(a, 4.0) return tmp
function code(a, b) tmp = 0.0 if (a <= 2.7e-5) tmp = Float64(Float64(Float64(b * b) * Float64(4.0 + Float64(b * b))) + -1.0); elseif (a <= 2.15e+36) tmp = Float64((a ^ 4.0) + -1.0); elseif (a <= 2.2e+54) tmp = b ^ 4.0; else tmp = a ^ 4.0; end return tmp end
function tmp_2 = code(a, b) tmp = 0.0; if (a <= 2.7e-5) tmp = ((b * b) * (4.0 + (b * b))) + -1.0; elseif (a <= 2.15e+36) tmp = (a ^ 4.0) + -1.0; elseif (a <= 2.2e+54) tmp = b ^ 4.0; else tmp = a ^ 4.0; end tmp_2 = tmp; end
code[a_, b_] := If[LessEqual[a, 2.7e-5], N[(N[(N[(b * b), $MachinePrecision] * N[(4.0 + N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 2.15e+36], N[(N[Power[a, 4.0], $MachinePrecision] + -1.0), $MachinePrecision], If[LessEqual[a, 2.2e+54], N[Power[b, 4.0], $MachinePrecision], N[Power[a, 4.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\
\mathbf{elif}\;a \leq 2.15 \cdot 10^{+36}:\\
\;\;\;\;{a}^{4} + -1\\
\mathbf{elif}\;a \leq 2.2 \cdot 10^{+54}:\\
\;\;\;\;{b}^{4}\\
\mathbf{else}:\\
\;\;\;\;{a}^{4}\\
\end{array}
\end{array}
if a < 2.6999999999999999e-5Initial program 99.9%
Taylor expanded in a around 0 84.1%
+-commutative84.1%
fma-def84.1%
unpow284.1%
Simplified84.1%
fma-udef84.1%
metadata-eval84.1%
pow-prod-up84.1%
pow-prod-down84.1%
pow284.1%
distribute-rgt-out84.1%
Applied egg-rr84.1%
if 2.6999999999999999e-5 < a < 2.15000000000000002e36Initial program 99.5%
associate--l+99.5%
unpow299.5%
unpow199.5%
sqr-pow99.5%
associate-*r*99.5%
Simplified99.7%
Taylor expanded in b around 0 76.2%
if 2.15000000000000002e36 < a < 2.1999999999999999e54Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in b around inf 100.0%
if 2.1999999999999999e54 < a Initial program 100.0%
associate--l+100.0%
unpow2100.0%
unpow1100.0%
sqr-pow100.0%
associate-*r*100.0%
Simplified100.0%
Taylor expanded in a around inf 100.0%
Final simplification87.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 73.5%
+-commutative73.5%
fma-def73.5%
unpow273.5%
Simplified73.5%
fma-udef73.5%
metadata-eval73.5%
pow-prod-up73.4%
pow-prod-down73.4%
pow273.4%
distribute-rgt-out73.4%
Applied egg-rr73.4%
Final simplification73.4%
(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 73.5%
+-commutative73.5%
fma-def73.5%
unpow273.5%
Simplified73.5%
fma-udef73.5%
metadata-eval73.5%
pow-prod-up73.4%
pow-prod-down73.4%
pow273.4%
distribute-rgt-out73.4%
Applied egg-rr73.4%
Taylor expanded in b around inf 71.7%
unpow271.7%
Simplified71.7%
Final simplification71.7%
(FPCore (a b) :precision binary64 (+ (* 4.0 (* b b)) -1.0))
double code(double a, double b) {
return (4.0 * (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)) + (-1.0d0)
end function
public static double code(double a, double b) {
return (4.0 * (b * b)) + -1.0;
}
def code(a, b): return (4.0 * (b * b)) + -1.0
function code(a, b) return Float64(Float64(4.0 * Float64(b * b)) + -1.0) end
function tmp = code(a, b) tmp = (4.0 * (b * b)) + -1.0; end
code[a_, b_] := N[(N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \left(b \cdot b\right) + -1
\end{array}
Initial program 99.9%
Taylor expanded in a around 0 73.5%
+-commutative73.5%
fma-def73.5%
unpow273.5%
Simplified73.5%
Taylor expanded in b around 0 50.4%
unpow250.4%
Simplified50.4%
Final simplification50.4%
(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%
associate--l+99.9%
unpow299.9%
unpow199.9%
sqr-pow99.9%
associate-*r*99.9%
Simplified100.0%
Taylor expanded in b around 0 68.6%
Taylor expanded in a around 0 27.9%
Final simplification27.9%
herbie shell --seed 2023261
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))