| Alternative 1 | |
|---|---|
| Accuracy | 49.7% |
| Cost | 6464 |
\[\sin re
\]
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
(FPCore (re im) :precision binary64 (let* ((t_0 (cbrt (* 0.5 (sin re))))) (fma (pow (* im t_0) 2.0) t_0 (sin re))))
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 = cbrt((0.5 * sin(re)));
return fma(pow((im * t_0), 2.0), t_0, sin(re));
}
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 = cbrt(Float64(0.5 * sin(re))) return fma((Float64(im * t_0) ^ 2.0), t_0, sin(re)) 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[Power[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[Power[N[(im * t$95$0), $MachinePrecision], 2.0], $MachinePrecision] * t$95$0 + N[Sin[re], $MachinePrecision]), $MachinePrecision]]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\begin{array}{l}
t_0 := \sqrt[3]{0.5 \cdot \sin re}\\
\mathsf{fma}\left({\left(im \cdot t_0\right)}^{2}, t_0, \sin re\right)
\end{array}
Initial program 53.1%
Simplified53.1%
[Start]53.1 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\] |
|---|---|
sub0-neg [=>]53.1 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(e^{\color{blue}{-im}} + e^{im}\right)
\] |
Taylor expanded in im around 0 53.9%
Simplified53.9%
[Start]53.9 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(2 + {im}^{2}\right)
\] |
|---|---|
unpow2 [=>]53.9 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(2 + \color{blue}{im \cdot im}\right)
\] |
Applied egg-rr54.2%
[Start]53.9 | \[ \left(0.5 \cdot \sin re\right) \cdot \left(2 + im \cdot im\right)
\] |
|---|---|
+-commutative [=>]53.9 | \[ \left(0.5 \cdot \sin re\right) \cdot \color{blue}{\left(im \cdot im + 2\right)}
\] |
distribute-rgt-in [=>]53.9 | \[ \color{blue}{\left(im \cdot im\right) \cdot \left(0.5 \cdot \sin re\right) + 2 \cdot \left(0.5 \cdot \sin re\right)}
\] |
add-cube-cbrt [=>]53.9 | \[ \left(im \cdot im\right) \cdot \color{blue}{\left(\left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right) \cdot \sqrt[3]{0.5 \cdot \sin re}\right)} + 2 \cdot \left(0.5 \cdot \sin re\right)
\] |
associate-*r* [=>]53.9 | \[ \color{blue}{\left(\left(im \cdot im\right) \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right)\right) \cdot \sqrt[3]{0.5 \cdot \sin re}} + 2 \cdot \left(0.5 \cdot \sin re\right)
\] |
associate-*r* [=>]53.9 | \[ \left(\left(im \cdot im\right) \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right)\right) \cdot \sqrt[3]{0.5 \cdot \sin re} + \color{blue}{\left(2 \cdot 0.5\right) \cdot \sin re}
\] |
metadata-eval [=>]53.9 | \[ \left(\left(im \cdot im\right) \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right)\right) \cdot \sqrt[3]{0.5 \cdot \sin re} + \color{blue}{1} \cdot \sin re
\] |
*-un-lft-identity [<=]53.9 | \[ \left(\left(im \cdot im\right) \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right)\right) \cdot \sqrt[3]{0.5 \cdot \sin re} + \color{blue}{\sin re}
\] |
fma-def [=>]53.9 | \[ \color{blue}{\mathsf{fma}\left(\left(im \cdot im\right) \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right), \sqrt[3]{0.5 \cdot \sin re}, \sin re\right)}
\] |
pow2 [=>]53.9 | \[ \mathsf{fma}\left(\color{blue}{{im}^{2}} \cdot \left(\sqrt[3]{0.5 \cdot \sin re} \cdot \sqrt[3]{0.5 \cdot \sin re}\right), \sqrt[3]{0.5 \cdot \sin re}, \sin re\right)
\] |
pow2 [=>]53.9 | \[ \mathsf{fma}\left({im}^{2} \cdot \color{blue}{{\left(\sqrt[3]{0.5 \cdot \sin re}\right)}^{2}}, \sqrt[3]{0.5 \cdot \sin re}, \sin re\right)
\] |
pow-prod-down [=>]54.2 | \[ \mathsf{fma}\left(\color{blue}{{\left(im \cdot \sqrt[3]{0.5 \cdot \sin re}\right)}^{2}}, \sqrt[3]{0.5 \cdot \sin re}, \sin re\right)
\] |
Final simplification54.2%
| Alternative 1 | |
|---|---|
| Accuracy | 49.7% |
| Cost | 6464 |
| Alternative 2 | |
|---|---|
| Accuracy | 26.1% |
| Cost | 64 |
herbie shell --seed 2023157
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))