Ask Your Question

Revision history [back]

Unexpected results defining a scalar field

I want to define a scalar field on 3-dimensional Euclidean space that just returns the norm of the length of the vector to the origin. The following attempt fails in a way that I do not understand: note the factor of 2 on the z coordinate!

sage: E = EuclideanSpace(3)
sage: Ecoords = E.cartesian_coordinates()
sage: Ecoords
Chart (E^3, (x, y, z))
sage: E.scalar_field(norm(vector(Ecoords)))
Scalar field on the Euclidean space E^3
sage: scalarfield = E.scalar_field(norm(vector(Ecoords)))
sage: scalarfield.display()
E^3 → ℝ
(x, y, z) ↦ sqrt(x^2 + y^2 + 2*z^2)

This looks to appear because the z coordinate appears twice in the vectorized coordinates:

sage: vector(Ecoords)
(z, x, y, z)

I could blindly work around this but hoping to understand what is going on.