| Alternative 1 | |
|---|---|
| Error | 0.08% |
| Cost | 19712 |
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + e^{-im}\right)
\]
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
(FPCore (re im) :precision binary64 (let* ((t_0 (* 0.5 (sin re)))) (+ (/ t_0 (exp im)) (* t_0 (exp im)))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
return (t_0 / exp(im)) + (t_0 * exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
t_0 = 0.5d0 * sin(re)
code = (t_0 / exp(im)) + (t_0 * exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
return (t_0 / Math.exp(im)) + (t_0 * Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
def code(re, im): t_0 = 0.5 * math.sin(re) return (t_0 / math.exp(im)) + (t_0 * math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function code(re, im) t_0 = Float64(0.5 * sin(re)) return Float64(Float64(t_0 / exp(im)) + Float64(t_0 * exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
function tmp = code(re, im) t_0 = 0.5 * sin(re); tmp = (t_0 / exp(im)) + (t_0 * exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / N[Exp[im], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\frac{t_0}{e^{im}} + t_0 \cdot e^{im}
\end{array}
Results
Initial program 0.08
Simplified0.08
[Start]0.08 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\] |
|---|---|
sub0-neg [=>]0.08 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + e^{im}\right)
\] |
Applied egg-rr0.08
Applied egg-rr0.07
Final simplification0.07
| Alternative 1 | |
|---|---|
| Error | 0.08% |
| Cost | 19712 |
| Alternative 2 | |
|---|---|
| Error | 1.14% |
| Cost | 13696 |
| Alternative 3 | |
|---|---|
| Error | 1.34% |
| Cost | 13376 |
| Alternative 4 | |
|---|---|
| Error | 1.35% |
| Cost | 13248 |
| Alternative 5 | |
|---|---|
| Error | 1.34% |
| Cost | 6976 |
| Alternative 6 | |
|---|---|
| Error | 1.93% |
| Cost | 6464 |
| Alternative 7 | |
|---|---|
| Error | 50.65% |
| Cost | 576 |
| Alternative 8 | |
|---|---|
| Error | 50.65% |
| Cost | 576 |
| Alternative 9 | |
|---|---|
| Error | 50.95% |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))