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.Tue, 20 Feb 2024 12:57:19 +0100Matrix norm using sup normhttps://ask.sagemath.org/question/76114/matrix-norm-using-sup-norm/ Hi all,
I want to make some modifications in the matrix norm. I'm trying to find $\sup_{x\neq0} \frac{\lVert Ax \rVert}{\lVert x \rVert}$
with different norms defined over denominator and numerator. As all other norms are defined I'm just curious about the source codes of them and also interested to see how to get the supremum or infimum in sage where $x\in V$ where V is a vector space.KaunilTue, 20 Feb 2024 12:57:19 +0100https://ask.sagemath.org/question/76114/Computing element norm from its conjugates in towered extension fieldshttps://ask.sagemath.org/question/60275/computing-element-norm-from-its-conjugates-in-towered-extension-fields/Hi!
I'm trying to compute the norm of an element by using the product of its conjugates.
This works fine for extensions of prime fields, but seems to give me results different than expected for extension towers.
Example from BLS12-381 curve:
field_modulus = 4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787
Fp = GF(field_modulus)
R.<x> = Fp[]
Fp2.<u> = Fp.extension(x^2 + 1)
R2.<y> = Fp2[]
Fp6.<v> = Fp2.extension(y^3 - (u+1))
# This works for Fp2, which is an extension of a prime field
elem_fp2 = Fp2([1, 1])
fp2_norm_from_conjugates = elem_fp2 * elem_fp2 ^ field_modulus
elem_fp2.norm() == fp2_norm_from_conjugates
# But not for the towered extension Fp6
elem_fp6 = Fp6([1, 1, Fp2([2, 3])])
fp6_norm_from_conjugates = elem_fp6 * (elem_fp6 ^ field_modulus) * (elem_fp6 ^ (field_modulus^2))
elem_fp6.norm() == fp6_norm_from_conjugates
# False
What I am expecting from the above is that `norm()` maps an element from the extension field to an element in the base field, i.e. `elem_fp2.norm()` to return an element of `Fp` and ` elem_fp6.norm()` an element of `Fp2`.
This is indeed true when I use the `norm()` method (which, under the hood uses `matrix().determinant()`), but fails when using the element's conjugates in the towered field.
(I'm using pages 57-58 of the [Finite Fields] (https ://archive.org/details/finitefields0000lidl_a8r3/) book as reference, which states that I should just be able to multiply the elements and all its conjugates to get the norm):
`\alpha * \alpha^q * ... * \alpha^(q^m-1)`
Am I doing something wrong?mmagicianWed, 15 Dec 2021 16:23:38 +0100https://ask.sagemath.org/question/60275/test if v.norm <> zero pbhttps://ask.sagemath.org/question/48872/test-if-vnorm-zero-pb/ HI
I do not understand why if v.norm !=0 does not work here.
**ZeroDivisionError: rational division by zero**
def normalizeVectorL(vectorList) :
vNormList=[]
for l in vectorList :
lMatrixList=[]
for v in l :
v=vector(v)
z=zero_vector(v.length())
#if v != z :
if v.norm() != 0 :
show("v :\t",v,"v.norm() :\t",v.norm())
lMatrixList.append(matrix(v/v.norm()).transpose())
else :
lMatrixList.append(matrix(v).transpose())
vNormList.append(lMatrixList)
return vNormList
VVVlist=[]
VVVlist0=[]
VVVlist0.append([1,1,1])
VVVlist0.append([1,1,2])
VVVlist0.append([1,0,0])
VVVlist.append(VVVlist0)
VVVlist1=[]
VVVlist1.append([1,3,1])
VVVlist1.append([1,2,2])
VVVlist1.append([0,0,0])
VVVlist.append(VVVlist1)
show(VVVlist)
show(normalizeVectorList(VVVlist))
ortolljMon, 25 Nov 2019 11:46:00 +0100https://ask.sagemath.org/question/48872/Norm in UniversalCyclotomicFieldhttps://ask.sagemath.org/question/44623/norm-in-universalcyclotomicfield/ Hi,
I'm trying to work with vectors in the `UniversalCyclotomicField`, But I can't find a way to make the norm work. I'm writing the following code :
sage: a = vector([E(8)])
sage: a.norm()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-5b5ddb3f4c99> in <module>()
----> 1 a.norm()
/home/[name]/SageMath/local/lib/python2.7/site-packages/sage/modules/free_module_element.pyx in sage.modules.free_module_element.FreeModuleElement.norm (build/cythonized/sage/modules/free_module_element.c:12840)()
1671 sqrt(5)
1672 """
-> 1673 abs_self = [abs(x) for x in self]
1674 if p == Infinity:
1675 return max(abs_self)
TypeError: bad operand type for abs(): 'UniversalCyclotomicField_with_category.element_class'
And having no luck with it. Does any of you know a workaround allowing me to stay in exact calculations ?
Thanks in advanceAssombranceMon, 10 Dec 2018 17:22:04 +0100https://ask.sagemath.org/question/44623/Simplify vector vs. its normhttps://ask.sagemath.org/question/43470/simplify-vector-vs-its-norm/ In the following I compute the matrix `mrot` which shall rotate the vector `v` to the unit vector pointing into the x-direction. This does indeed work, except that the last printout for verification, `view(u*mrot)`, looks complicated, despite the fact that it should just be (1, 0, 0). How would I let sage reduce the enormous formulas for the vector components?
v1 = var('v1');
v2 = var('v2');
v3 = var('v3');
e1 = vector([1,0,0]);
v = vector([v1, v2, v3]);
u = v/v.norm();
#u = v;
view(["u=", u], sep=" ");
z=u.cross_product(e1);
#z=e1.cross_product(u);
view(["z=", z]);
c=u.dot_product(e1);
view(["c=",c]);
mat=Matrix( [[0, -z[3-1], z[2-1]], [z[3-1], 0, -z[1-1]], [-z[2-1], z[1-1], 0]] );
#view([mat, mat*mat]);
mrot=-(matrix.identity(3) + mat + (1/(1+c)) * mat*mat);
view(u*mrot);HaraldSat, 25 Aug 2018 22:40:11 +0200https://ask.sagemath.org/question/43470/complex normhttps://ask.sagemath.org/question/38289/complex-norm/As a newbie, I must be missing something, but here is the question:
With this setup:
var('a', domain=CC)
a.norm()
a.norm().simplify()
The last line displays as a^2, but should be |a|^2 .
What am I missing?normvcrMon, 17 Jul 2017 22:33:41 +0200https://ask.sagemath.org/question/38289/typeset complex norm is missing absolute valuehttps://ask.sagemath.org/question/38288/typeset-complex-norm-is-missing-absolute-value/ As a newbie, I must be missing something, but here is the question:
With this setup:
var('a', domain=CC)
a.norm()
a.norm().simplify()
The last line displays as a^2, but should be |a|^2 .
What am I missing?normvcrMon, 17 Jul 2017 22:32:20 +0200https://ask.sagemath.org/question/38288/1-Norm Matrix, Vektorhttps://ask.sagemath.org/question/32296/1-norm-matrix-vektor/Is the a way to specifiy the norm of Matrix or Vektor?
I need the 1-norm
A.norm(1)?
v.norm(1)? Something like thisthethaWed, 20 Jan 2016 13:32:12 +0100https://ask.sagemath.org/question/32296/Number Fields and the Normhttps://ask.sagemath.org/question/8343/number-fields-and-the-norm/Hello,
I am currently very confused about how to use [Number Fields in Sage].(http://www.sagemath.org/doc/reference/sage/rings/number_field/number_field.html).
Things are not working.
Specifically I would like the norm of $\mathbb{Z}[\zeta_5]$ which should be a homogeneous polynomial of degree 4.
I tried:
>K.<g> = NumberField(1+x+x^2+x^3+x^4)
>a,b,c,d=var('a b c d')
>(a+b\*g+c\*g^2+d\*g^3).norm()
However that did not work.
I also tried:
>K.<g>=CyclotomicField(5); K
>a,b,c,d=var('a b c d')
>(a+b\*g+c\*g^2+d\*g^3).norm()
Instead of returning the norm in the Cyclotomic ring, this simply gave me the norm over the complex numbers, that is multiplication by the complex conjugate. These two things are very different, and the norm of the complex number is not at all correct. (It should be degree 4 not degree 2)
Any help is greatly appreciated, thank youEric NaslundMon, 26 Sep 2011 14:21:30 +0200https://ask.sagemath.org/question/8343/symbolic vector normhttps://ask.sagemath.org/question/8804/symbolic-vector-norm/I can't get Sage to produce the norm or even just compute `w[1]^2` in the code below. I keep getting a "not implemented" error. Have I made a simple mistake here, or is there a way around this? Thanks for the help. I haven't done much with matrix computations in Sage yet and am trying to learn my way around.
var('x,y')
a=matrix([[1,2],[-3,0]])
v=vector([x,y])
w=a*v.column()
w.norm()calc314Mon, 19 Mar 2012 16:25:19 +0100https://ask.sagemath.org/question/8804/Norm in a quadratic spacehttps://ask.sagemath.org/question/8763/norm-in-a-quadratic-space/Hi
I'm working in a vector space where the inner product is not the usual one and I would need to access directly to the norm induced by inner product. I found how to create such a space but the 'norm' function gives me the usual norm, which is not the one I want.
Here is an example :
SP=matrix(QQ,[[2,0],[0,3]])
V=VectorSpace(QQ,2,inner_product_matrix=SP)
What I want to compute is e.g.
e0=V.0
e0.inner_product(e0)
while `e0.norm()` gives me 1 (wrong answer for me)
I assume this should be possible directly. Any idea how ?
Thanks,BertrandThu, 01 Mar 2012 11:29:43 +0100https://ask.sagemath.org/question/8763/