New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
evalf() returns symbolic expression or sum of complex conjugates #19615
Comments
You need In [29]: M=sqrt(Matrix([
...: [ 1, 1],
...: [-1, 1]]))
In [30]: M
Out[30]:
1/2
⎛⎡1 1⎤⎞
⎜⎢ ⎥⎟
⎝⎣-1 1⎦⎠
In [31]: M.doit()
Out[31]:
⎡ _______ _______ _______ _______⎤
⎢ ╲╱ 1 - ⅈ ╲╱ 1 + ⅈ ⅈ⋅╲╱ 1 + ⅈ ⅈ⋅╲╱ 1 - ⅈ ⎥
⎢ ───────── + ───────── - ─────────── + ───────────⎥
⎢ 2 2 2 2 ⎥
⎢ ⎥
⎢ _______ _______ _______ _______ ⎥
⎢ ⅈ⋅╲╱ 1 - ⅈ ⅈ⋅╲╱ 1 + ⅈ ╲╱ 1 - ⅈ ╲╱ 1 + ⅈ ⎥
⎢- ─────────── + ─────────── ───────── + ───────── ⎥
⎣ 2 2 2 2 ⎦
In [32]: M.doit().rewrite(exp)
Out[32]:
⎡ -ⅈ⋅π ⅈ⋅π ⅈ⋅π -ⅈ⋅π ⎤
⎢ ───── ─── ─── ─────⎥
⎢ 4 ___ 8 4 ___ 8 4 ___ 8 4 ___ 8 ⎥
⎢ ╲╱ 2 ⋅ℯ ╲╱ 2 ⋅ℯ ╲╱ 2 ⋅ⅈ⋅ℯ ╲╱ 2 ⋅ⅈ⋅ℯ ⎥
⎢ ──────────── + ────────── - ──────────── + ──────────────⎥
⎢ 2 2 2 2 ⎥
⎢ ⎥
⎢ -ⅈ⋅π ⅈ⋅π -ⅈ⋅π ⅈ⋅π ⎥
⎢ ───── ─── ───── ─── ⎥
⎢ 4 ___ 8 4 ___ 8 4 ___ 8 4 ___ 8 ⎥
⎢ ╲╱ 2 ⋅ⅈ⋅ℯ ╲╱ 2 ⋅ⅈ⋅ℯ ╲╱ 2 ⋅ℯ ╲╱ 2 ⋅ℯ ⎥
⎢- ────────────── + ──────────── ──────────── + ────────── ⎥
⎣ 2 2 2 2 ⎦ Unfortunately it isn't possible to rewrite that as cos because In [36]: exp(I*pi/8)
Out[36]:
ⅈ⋅π
───
8
ℯ
In [37]: exp(I*pi/8).rewrite(cos)
Out[37]:
________ ________
╱ √2 1 ╱ 1 √2
╱ ── + ─ + ⅈ⋅ ╱ ─ - ──
╲╱ 4 2 ╲╱ 2 4
In [38]: cos(pi/8)
Out[38]:
________
╱ √2 1
╱ ── + ─
╲╱ 4 2 |
Thanks, I just realized that So points 2) and 3) refers still to bugs. Sympy doesn't symbolically evaluate expressions of types It could learn to solve it automatically as |
sqrt
is not evaluated symbolically and neitherevalf()
is transforming it to numbers.Compared to:
Output here contains
(1 - I)**0.5/2 + (1 + I)**0.5/2
. That should be automatically simplified as it is possible:= sqrt(sqrt(2))*cos(pi/8) = sqrt(sqrt(2))*sqrt(sqrt(2)/4 + 1/2)
So according to examples there are three not related bugs by themselves:
The text was updated successfully, but these errors were encountered: