Skip to content

Commit

Permalink
Merge pull request #26597 from jpreiss/quat_log
Browse files Browse the repository at this point in the history
Public name for quaternion logarithm
  • Loading branch information
asmeurer committed May 15, 2024
2 parents 986893a + 5907eae commit 031fb01
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ Jaime R <38530589+Jaime02@users.noreply.github.com>
Jaime Resano <gemailpersonal02@gmail.com>
Jainul Vaghasia <jainulvaghasia@gmail.com> <jainulvaghasia@D-10-157-53-226.dhcp4.washington.edu>
Jakub Wilk <jwilk@jwilk.net>
James A. Preiss <jamesalanpreiss@gmail.com> jpreiss <jamesalanpreiss@gmail.com>
James Abbatiello <abbeyj@gmail.com>
James Aspnes <aspnes@cs.yale.edu>
James Brandon Milam <jmilam343@gmail.com>
Expand Down
8 changes: 4 additions & 4 deletions sympy/algebras/quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,22 +972,22 @@ def exp(self):

return Quaternion(a, b, c, d)

def _ln(self):
"""Returns the natural logarithm of the quaternion (_ln(q)).
def log(self):
r"""Returns the logarithm of the quaternion, given by $\log q$.
Examples
========
>>> from sympy import Quaternion
>>> q = Quaternion(1, 2, 3, 4)
>>> q._ln()
>>> q.log()
log(sqrt(30))
+ 2*sqrt(29)*acos(sqrt(30)/30)/29*i
+ 3*sqrt(29)*acos(sqrt(30)/30)/29*j
+ 4*sqrt(29)*acos(sqrt(30)/30)/29*k
"""
# _ln(q) = _ln||q|| + v/||v||*arccos(a/||q||)
# log(q) = log||q|| + v/||v||*arccos(a/||q||)
q = self
vector_norm = sqrt(q.b**2 + q.c**2 + q.d**2)
q_norm = q.norm()
Expand Down
2 changes: 1 addition & 1 deletion sympy/algebras/tests/test_quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_quaternion_functions():
2 * sqrt(29) * E * sin(sqrt(29)) / 29,
3 * sqrt(29) * E * sin(sqrt(29)) / 29,
4 * sqrt(29) * E * sin(sqrt(29)) / 29)
assert q1._ln() == \
assert q1.log() == \
Quaternion(log(sqrt(30)),
2 * sqrt(29) * acos(sqrt(30)/30) / 29,
3 * sqrt(29) * acos(sqrt(30)/30) / 29,
Expand Down

0 comments on commit 031fb01

Please sign in to comment.