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, 22 Jun 2020 15:14:37 +0200Coefficient of Polynomial of Differential Forms and displaying List for differential formshttps://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/The coefficient function gives us the coefficient of a polynomial. For example,
g(x)=3*x^(2)
g.coefficient(x^(2))
Just started learning differential forms, so using notation here-
https://ask.sagemath.org/question/40345/differential-forms-best-package/
U = Manifold(4, 'U')
X. < x,y,z,w > = U.chart()
f = U.diff_form(4, 'f')
f[0,1,2,3]=3*x^(2)
f.display()
(f[0,1,2,3]).coefficient(x^(2))
I want to work backwards. For example, given a 4-form named Form, Form[0,1,2,3] gives me the polynomial of the form. I wish to find the coefficient of this polynomial the same way. So from above, I should be getting 3. But I get:
'ChartFunctionRing_with_category.element_class' object has no attribute 'coefficient'.
Question 1: How do I fix this?
Question 2: Suppose I have a list of 4-forms called List. From the link above, I can view every form in List by doing
List[1].display().
However, how do I quickly view all the forms?
List.display() gives me an error so can I only view the forms term by term?
QuestionMon, 22 Jun 2020 01:32:55 +0200https://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/Answer by rburing for <p>The coefficient function gives us the coefficient of a polynomial. For example,</p>
<p>g(x)=3*x^(2)</p>
<p>g.coefficient(x^(2))</p>
<p>Just started learning differential forms, so using notation here-
<a href="https://ask.sagemath.org/question/40345/differential-forms-best-package/">https://ask.sagemath.org/question/403...</a></p>
<p>U = Manifold(4, 'U')</p>
<p>X. < x,y,z,w > = U.chart()</p>
<p>f = U.diff_form(4, 'f')</p>
<p>f[0,1,2,3]=3*x^(2)</p>
<p>f.display()</p>
<p>(f[0,1,2,3]).coefficient(x^(2))</p>
<p>I want to work backwards. For example, given a 4-form named Form, Form[0,1,2,3] gives me the polynomial of the form. I wish to find the coefficient of this polynomial the same way. So from above, I should be getting 3. But I get:</p>
<p>'ChartFunctionRing_with_category.element_class' object has no attribute 'coefficient'. </p>
<p>Question 1: How do I fix this?</p>
<p>Question 2: Suppose I have a list of 4-forms called List. From the link above, I can view every form in List by doing
List[1].display(). </p>
<p>However, how do I quickly view all the forms? </p>
<p>List.display() gives me an error so can I only view the forms term by term?</p>
<p>Question</p>
https://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/?answer=52143#post-id-521431)
sage: f[0,1,2,3].expr().coefficient(x^2)
3
2)
sage: List = [f]*3
sage: show(LatexExpr('[' + ','.join(latex(f.display()) for f in List) + ']'))
$$[f = 3 \\, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w,f = 3 \\, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w,f = 3 \\, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w]$$Mon, 22 Jun 2020 13:55:55 +0200https://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/?answer=52143#post-id-52143Comment by whatupmatt for <p>1)</p>
<pre><code>sage: f[0,1,2,3].expr().coefficient(x^2)
3
</code></pre>
<p>2)</p>
<pre><code>sage: List = [f]*3
sage: show(LatexExpr('[' + ','.join(latex(f.display()) for f in List) + ']'))
</code></pre>
<p>$$[f = 3 \, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w,f = 3 \, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w,f = 3 \, x^{2} \mathrm{d} x\wedge \mathrm{d} y\wedge \mathrm{d} z\wedge \mathrm{d} w]$$</p>
https://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/?comment=52145#post-id-52145Great, thanks for your help.Mon, 22 Jun 2020 15:14:37 +0200https://ask.sagemath.org/question/52136/coefficient-of-polynomial-of-differential-forms-and-displaying-list-for-differential-forms/?comment=52145#post-id-52145