ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 05 Apr 2021 15:42:48 +0200Evaluating a form field at a point on vectorshttps://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/I am having trouble matching up terminology in my textbook (Hubbard's *Vector Calculus*) against SageMath operators. I'd like to understand how to solve the following example problem with Sage:
> Let `phi = cos(x z) * dx /\ dy` be a 2-form on `R^3`. Evaluate it at the point `(1, 2, pi)` on the vectors `[1, 0, 1], [2, 2, 3]`.
The expected answer is:
```
cos (1 * pi) * Matrix([1, 2], [0, 2]).det() = -2
```
So far I have pieced together the following:
E.<x,y,z> = EuclideanSpace(3, 'E')
f = E.diff_form(2, 'f')
f[1, 2] = cos(x * z)
point = E((1,2,pi), name='point')
anchor = f.at(point)
v1 = vector([1, 0, 1])
v2 = vector([2, 2, 3])
show(anchor(v1, v2))
which fails with the error:
> `TypeError: the argument no. 1 must be a module element`
To construct a vector in `E`, I tried:
p1 = E(v1.list())
p2 = E(v2.list())
show(anchor(p1, p2))
but that fails with the same error. What's the right way to construct two vectors in `E`?Sat, 03 Apr 2021 20:34:41 +0200https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/Comment by slelievre for <p>I am having trouble matching up terminology in my textbook (Hubbard's <em>Vector Calculus</em>) against SageMath operators. I'd like to understand how to solve the following example problem with Sage:</p>
<blockquote>
<p>Let <code>phi = cos(x z) * dx /\ dy</code> be a 2-form on <code>R^3</code>. Evaluate it at the point <code>(1, 2, pi)</code> on the vectors <code>[1, 0, 1], [2, 2, 3]</code>.</p>
</blockquote>
<p>The expected answer is:</p>
<p><code>
cos (1 * pi) * Matrix([1, 2], [0, 2]).det() = -2
</code></p>
<p>So far I have pieced together the following:</p>
<pre><code>E.<x,y,z> = EuclideanSpace(3, 'E')
f = E.diff_form(2, 'f')
f[1, 2] = cos(x * z)
point = E((1,2,pi), name='point')
anchor = f.at(point)
v1 = vector([1, 0, 1])
v2 = vector([2, 2, 3])
show(anchor(v1, v2))
</code></pre>
<p>which fails with the error:</p>
<blockquote>
<p><code>TypeError: the argument no. 1 must be a module element</code></p>
</blockquote>
<p>To construct a vector in <code>E</code>, I tried:</p>
<pre><code>p1 = E(v1.list())
p2 = E(v2.list())
show(anchor(p1, p2))
</code></pre>
<p>but that fails with the same error. What's the right way to construct two vectors in <code>E</code>?</p>
https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?comment=56506#post-id-56506Also asked at [Stack Overflow question 66934629: Evaluating a form field at a point on vectors in SageMath](https://stackoverflow.com/questions/66934629).Mon, 05 Apr 2021 15:42:48 +0200https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?comment=56506#post-id-56506Comment by eric_g for <p>I am having trouble matching up terminology in my textbook (Hubbard's <em>Vector Calculus</em>) against SageMath operators. I'd like to understand how to solve the following example problem with Sage:</p>
<blockquote>
<p>Let <code>phi = cos(x z) * dx /\ dy</code> be a 2-form on <code>R^3</code>. Evaluate it at the point <code>(1, 2, pi)</code> on the vectors <code>[1, 0, 1], [2, 2, 3]</code>.</p>
</blockquote>
<p>The expected answer is:</p>
<p><code>
cos (1 * pi) * Matrix([1, 2], [0, 2]).det() = -2
</code></p>
<p>So far I have pieced together the following:</p>
<pre><code>E.<x,y,z> = EuclideanSpace(3, 'E')
f = E.diff_form(2, 'f')
f[1, 2] = cos(x * z)
point = E((1,2,pi), name='point')
anchor = f.at(point)
v1 = vector([1, 0, 1])
v2 = vector([2, 2, 3])
show(anchor(v1, v2))
</code></pre>
<p>which fails with the error:</p>
<blockquote>
<p><code>TypeError: the argument no. 1 must be a module element</code></p>
</blockquote>
<p>To construct a vector in <code>E</code>, I tried:</p>
<pre><code>p1 = E(v1.list())
p2 = E(v2.list())
show(anchor(p1, p2))
</code></pre>
<p>but that fails with the same error. What's the right way to construct two vectors in <code>E</code>?</p>
https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?comment=56504#post-id-56504Motivated by your question, I've opened the ticket https://trac.sagemath.org/ticket/31609 to add a method `vector()` in order to easily create vectors at a given point.Mon, 05 Apr 2021 11:13:01 +0200https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?comment=56504#post-id-56504Answer by slelievre for <p>I am having trouble matching up terminology in my textbook (Hubbard's <em>Vector Calculus</em>) against SageMath operators. I'd like to understand how to solve the following example problem with Sage:</p>
<blockquote>
<p>Let <code>phi = cos(x z) * dx /\ dy</code> be a 2-form on <code>R^3</code>. Evaluate it at the point <code>(1, 2, pi)</code> on the vectors <code>[1, 0, 1], [2, 2, 3]</code>.</p>
</blockquote>
<p>The expected answer is:</p>
<p><code>
cos (1 * pi) * Matrix([1, 2], [0, 2]).det() = -2
</code></p>
<p>So far I have pieced together the following:</p>
<pre><code>E.<x,y,z> = EuclideanSpace(3, 'E')
f = E.diff_form(2, 'f')
f[1, 2] = cos(x * z)
point = E((1,2,pi), name='point')
anchor = f.at(point)
v1 = vector([1, 0, 1])
v2 = vector([2, 2, 3])
show(anchor(v1, v2))
</code></pre>
<p>which fails with the error:</p>
<blockquote>
<p><code>TypeError: the argument no. 1 must be a module element</code></p>
</blockquote>
<p>To construct a vector in <code>E</code>, I tried:</p>
<pre><code>p1 = E(v1.list())
p2 = E(v2.list())
show(anchor(p1, p2))
</code></pre>
<p>but that fails with the same error. What's the right way to construct two vectors in <code>E</code>?</p>
https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?answer=56484#post-id-56484Almost there.
Evaluate the 2-form at point `p` on vectors based at `p`.
sage: T = E.tangent_space(point)
sage: T
Tangent space at Point point on the Euclidean space E
sage: pv1 = T(v1)
sage: pv2 = T(v2)
sage: pv1
Vector at Point point on the Euclidean space E
sage: pv2
Vector at Point point on the Euclidean space E
sage: anchor(pv1, pv2)
-2
Sat, 03 Apr 2021 23:38:43 +0200https://ask.sagemath.org/question/56483/evaluating-a-form-field-at-a-point-on-vectors/?answer=56484#post-id-56484