Ask Your Question

quirky's profile - activity

2022-09-21 22:18:44 +0200 received badge  Popular Question (source)
2020-02-05 10:09:21 +0200 received badge  Nice Question (source)
2020-02-05 00:22:20 +0200 answered a question How are symbolic derivatives composed in quaternions?

With this demonstration of 'LatexExpr' you have given me all the answers I need. Thanks, rburing! Looking around, I have found Sage, LaTeX and Friends (https://doc.sagemath.org/html/en/tuto...) LaTeX macros (https://doc.sagemath.org/html/en/refe...) and Using SageTeX (https://doc.sagemath.org/html/en/tuto...). None of them contain the string "LatexExpr." If you can suggest documentation for it, I would appreciate seeing it, but I now consider this question answered.

If I can figure out how to upvote or thumbs-up your avatar, I will do so.

2020-02-04 23:33:41 +0200 commented question How are symbolic derivatives composed in quaternions?

I get two lines. The first is equivalent to what you have suggested, but in 3 dimensions. The second is the LaTeX massaging of a comparable formula, the kind of result I would dearly love to produce in the quaternion example. (Quaternions are the natural 'coordinates' for describing Maxwell's Equations and related physics.) [This continuation is necessary because I hit the maximum number of characters in the preceding post.]

2020-02-04 23:29:12 +0200 commented question How are symbolic derivatives composed in quaternions?

That is a big step in the right direction! The individual function components make it through the operator. Perhaps I am asking too much, but here is a script implementing your change (now in 3 dimensions) and generating two lines of output.

%display latex
N.<x,y,z> = QQ[]
Q.<i,j,k> = QuaternionAlgebra(SR,-1,-1)
def qd(u):
     w = j*(derivative(u[0],y) + derivative(u[1],y)*i + derivative(u[2],y)*j + derivative(u[3],y)*k)
     return w
f = function('a')(x,y,z) + function('b')(x,y,z)*i + function('c')(x,y,z)*j + function('d')(x,y,z)*k
g = qd(f)
show(g)
E.<u,v,w> = EuclideanSpace()
F = E.scalar_field(function('f')(u,v,w), name='F')
from sage.manifolds.operators import *
grad(F).display()

When I run this script, I get two lines...

2020-02-04 22:14:10 +0200 received badge  Student (source)
2020-02-04 22:04:45 +0200 asked a question How are symbolic derivatives composed in quaternions?

The scripts below were run in: Sage Cell Server, version: 'SageMath version 9.0, Release Date: 2020-01-01' I am a new user of SageMath. I have previously used math packages, but SageMath is above and beyond all I have encountered before. It also has remarkably comprehensive documentation. In particular I have found Vector calculus with SageMath and Sage Reference Manual: Quaternion Algebras (insufficient karma to post links). I note that the latter is dated Jan 01, 2020. The examples below are drawn from those two sources. I am searching for calculus tools in the quaternion algebra package. I want to do something like this, which works in EuclideanSpace:

Sage: %display latex
Sage: from sage.manifolds.operators import *
Sage: E.<x,y,z> = EuclideanSpace()
Sage: F = E.scalar_field(function('f')(x,y,z), name='F')
Sage: grad(F).display()
grad(F) = d(f)/dx e_x + d(f)/dy e_y + d(f)/dz e_z The EucliedanSpace also knows how to pretty-print it with LaTeX.

This is as close as I have gotten with quaternions:

Sage: N.<a,b,c,d,y> = QQ[]
Sage: Q.<i,j,k> = QuaternionAlgebra(SR,-1,-1)
Sage: def qd(u):
Sage:     w = j*(diff(u[0],y) + diff(u[1],y)*i + diff(u[2],y)*j + diff(u[3],y)*k)
Sage:     return w
Sage: b = sin(y)
Sage: f = a+b*i+c*j+d*k
Sage: t = qd(f)
Sage: show(t)
(-cos(y))*k

This is the correct quaternion result, but I want to change the declaration of "b" so that I get something like (-d(f)/dy) * k. Here are the problems that concern me.

1. "diff" does not correctly handle "f" as an argument. It returns 0.
2. The definition in the function "qd" (quaternion derivative) of w should contain 3 more rows, but this one is enough to illustrate my main issue: If "b" is not defined as a specific function (e.g. sin(y)), "diff" returns 0. I would like it to return the derivative display formula, as the Euclidean example does.
3. Replacing show(t) with t.display() returns error messages such as "object has no attribute 'blah_blah'" and "raise AttributeError(dummy_error_message)." There may still be some work in progress here.

I hope there is presently a solution within SageMath. Please adapt the second script or give me an example script.

If not, I am reasonably competent with Python 3. If someone can give me links to the relevant source for the EuclideanSpace methods of "grad" and "function" and to the QuaternionAlgebra source for "diff," I may be able to add a method or two to the QuaternionAlgebra implementation and advance the development of that part of the system, or at least register myself as a beta-tester.

Thanks very much for any help you can give me!