
(FPCore im_sqr (re im) :precision binary64 (+ (* re im) (* im re)))
double im_sqr(double re, double im) {
return (re * im) + (im * re);
}
real(8) function im_sqr(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
im_sqr = (re * im) + (im * re)
end function
public static double im_sqr(double re, double im) {
return (re * im) + (im * re);
}
def im_sqr(re, im): return (re * im) + (im * re)
function im_sqr(re, im) return Float64(Float64(re * im) + Float64(im * re)) end
function tmp = im_sqr(re, im) tmp = (re * im) + (im * re); end
im$95$sqr[re_, im_] := N[(N[(re * im), $MachinePrecision] + N[(im * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot im + im \cdot re
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 1 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore im_sqr (re im) :precision binary64 (+ (* re im) (* im re)))
double im_sqr(double re, double im) {
return (re * im) + (im * re);
}
real(8) function im_sqr(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
im_sqr = (re * im) + (im * re)
end function
public static double im_sqr(double re, double im) {
return (re * im) + (im * re);
}
def im_sqr(re, im): return (re * im) + (im * re)
function im_sqr(re, im) return Float64(Float64(re * im) + Float64(im * re)) end
function tmp = im_sqr(re, im) tmp = (re * im) + (im * re); end
im$95$sqr[re_, im_] := N[(N[(re * im), $MachinePrecision] + N[(im * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot im + im \cdot re
\end{array}
NOTE: re and im should be sorted in increasing order before calling this function. (FPCore im_sqr (re im) :precision binary64 (* re (+ im im)))
assert(re < im);
double im_sqr(double re, double im) {
return re * (im + im);
}
NOTE: re and im should be sorted in increasing order before calling this function.
real(8) function im_sqr(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
im_sqr = re * (im + im)
end function
assert re < im;
public static double im_sqr(double re, double im) {
return re * (im + im);
}
[re, im] = sort([re, im]) def im_sqr(re, im): return re * (im + im)
re, im = sort([re, im]) function im_sqr(re, im) return Float64(re * Float64(im + im)) end
re, im = num2cell(sort([re, im])){:}
function tmp = im_sqr(re, im)
tmp = re * (im + im);
end
NOTE: re and im should be sorted in increasing order before calling this function. im$95$sqr[re_, im_] := N[(re * N[(im + im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[re, im] = \mathsf{sort}([re, im])\\
\\
re \cdot \left(im + im\right)
\end{array}
Initial program 100.0%
*-commutative100.0%
distribute-lft-out99.6%
Simplified99.6%
Final simplification99.6%
herbie shell --seed 2023271
(FPCore im_sqr (re im)
:name "math.square on complex, imaginary part"
:precision binary64
(+ (* re im) (* im re)))