Average Error: 0.0 → 0.0
Time: 1.0s
Precision: binary64
Cost: 320
\[re \cdot im + im \cdot re \]
\[re \cdot \left(im + im\right) \]
(FPCore im_sqr (re im) :precision binary64 (+ (* re im) (* im re)))
(FPCore im_sqr (re im) :precision binary64 (* re (+ im im)))
double im_sqr(double re, double im) {
	return (re * im) + (im * re);
}
double im_sqr(double re, double im) {
	return re * (im + im);
}
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
real(8) function im_sqr(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    im_sqr = re * (im + im)
end function
public static double im_sqr(double re, double im) {
	return (re * im) + (im * re);
}
public static double im_sqr(double re, double im) {
	return re * (im + im);
}
def im_sqr(re, im):
	return (re * im) + (im * re)
def im_sqr(re, im):
	return re * (im + im)
function im_sqr(re, im)
	return Float64(Float64(re * im) + Float64(im * re))
end
function im_sqr(re, im)
	return Float64(re * Float64(im + im))
end
function tmp = im_sqr(re, im)
	tmp = (re * im) + (im * re);
end
function tmp = im_sqr(re, im)
	tmp = re * (im + im);
end
im$95$sqr[re_, im_] := N[(N[(re * im), $MachinePrecision] + N[(im * re), $MachinePrecision]), $MachinePrecision]
im$95$sqr[re_, im_] := N[(re * N[(im + im), $MachinePrecision]), $MachinePrecision]
re \cdot im + im \cdot re
re \cdot \left(im + im\right)

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[re \cdot im + im \cdot re \]
  2. Simplified0.0

    \[\leadsto \color{blue}{re \cdot \left(im + im\right)} \]
    Proof
    (*.f64 re (+.f64 im im)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 im re) (*.f64 im re))): 1 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> *-commutative_binary64 (*.f64 re im)) (*.f64 im re)): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

    \[\leadsto re \cdot \left(im + im\right) \]

Reproduce

herbie shell --seed 2022291 
(FPCore im_sqr (re im)
  :name "math.square on complex, imaginary part"
  :precision binary64
  (+ (* re im) (* im re)))