Mistake in linalg.eig() documentation #2721

Merged
merged 1 commit into from Aug 16, 2013

Conversation

Projects
None yet
2 participants
@abalkin
Contributor

abalkin commented Nov 9, 2012

Proposed commit fixes a mistake in the formula currently written as dot(a[i,:], v[i]) = w[i] * v[:,i]. Here is the demonstration that it is incorrect:

a
array([[ 1.0093272 , 0.73994495, 1.50512547],
[ 0.73994495, 1.085796 , 1.33086593],
[ 1.50512547, 1.33086593, 1.39161296]])
w, v = eig(a)
i = 1
w[i] * v[:,i]
array([-0.20045129, 0.2535517 , -0.03350537])

but

dot(a[i,:], v[i])
-0.0096475519217383288

On the other hand,

dot(a[:,:], v[:,i])
array([-0.20045129, 0.2535517 , -0.03350537])

Explicit ':' slicing of a is redundant, but I think it makes documentation clearer by emphasizing the rank of a.

@abalkin

This comment has been minimized.

Show comment Hide comment
@abalkin

abalkin Nov 9, 2012

Contributor

I don't think the Travis failure is caused by my changes.

2790ERROR: Test a special case for var
2791----------------------------------------------------------------------
2792Traceback (most recent call last):
2793 File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/numpy/ma/tests/test_core.py", line 2731, in test_varstd_specialcases
2794 _ = method(out=mout)
2795 File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/numpy/ma/core.py", line 4778, in std
2796 np.power(out, 0.5, out=out, casting='unsafe')
2797RuntimeWarning: invalid value encountered in power

Contributor

abalkin commented Nov 9, 2012

I don't think the Travis failure is caused by my changes.

2790ERROR: Test a special case for var
2791----------------------------------------------------------------------
2792Traceback (most recent call last):
2793 File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/numpy/ma/tests/test_core.py", line 2731, in test_varstd_specialcases
2794 _ = method(out=mout)
2795 File "/home/travis/virtualenv/python2.7/local/lib/python2.7/site-packages/numpy/ma/core.py", line 4778, in std
2796 np.power(out, 0.5, out=out, casting='unsafe')
2797RuntimeWarning: invalid value encountered in power

@charris

This comment has been minimized.

Show comment Hide comment
@charris

charris Mar 2, 2013

Member

Ping travisbot.

Member

charris commented Mar 2, 2013

Ping travisbot.

@charris charris closed this Mar 2, 2013

@charris charris reopened this Mar 2, 2013

@@ -946,7 +946,7 @@ def eig(a):
The number `w` is an eigenvalue of `a` if there exists a vector
`v` such that ``dot(a,v) = w * v``. Thus, the arrays `a`, `w`, and
- `v` satisfy the equations ``dot(a[i,:], v[i]) = w[i] * v[:,i]``
+ `v` satisfy the equations ``dot(a[:,:], v[:,i]) = w[i] * v[:,i]``

This comment has been minimized.

Show comment Hide comment
@charris

charris Jul 10, 2013

Member

Just dot(a, v[:, i] = w[i] * v[:, i] should do here. With broadcasting the simpler form dot(a, v) = v * w also works.but may be more confusing.

@charris

charris Jul 10, 2013

Member

Just dot(a, v[:, i] = w[i] * v[:, i] should do here. With broadcasting the simpler form dot(a, v) = v * w also works.but may be more confusing.

@abalkin

This comment has been minimized.

Show comment Hide comment
@abalkin

abalkin Jul 11, 2013

Contributor

I think I addressed this in my initial comment: "Explicit ':' slicing of a is redundant, but I think it makes documentation clearer by emphasizing the rank of a."

Contributor

abalkin commented Jul 11, 2013

I think I addressed this in my initial comment: "Explicit ':' slicing of a is redundant, but I think it makes documentation clearer by emphasizing the rank of a."

charris added a commit that referenced this pull request Aug 16, 2013

Merge pull request #2721 from abalkin/master
Mistake in linalg.eig() documentation

@charris charris merged commit 9b10a5f into numpy:master Aug 16, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment