# Straight line parametrization with diff_map I have the following code:

R2 = Manifold(2, 'R2', latex_name=r'\mathbb{R}^2')
cartesian2d.<x,y> = R2.chart()
R1 = Manifold(1, 'R1', start_index=1, latex_name=r'\mathbb{R}')
cartesian1d.<t> = R1.chart()
A = R2.point((3,2), chart=cartesian2d, name='A')
B = R2.point((-1,2), chart=cartesian2d, name='B')
C_1 = R1.diff_map(R2, t*B.coord()+(1-t)*A.coord())


The last line issues an error TypeError: unable to convert t to an integer.

I want to define a parametrization of a straight line from point A at t=0 to point B at t=1. How to do that?

Daniel

edit retag close merge delete

Sort by » oldest newest most voted

That's because B.coord() returns a tuple, so that the multiplication t*B.coord() is interpreted as a tuple multiplication, which has meaning only if t is an integer, with a result different from what you had in mind:

sage: B.coord()
(-1, 2)
sage: 3*B.coord()
(-1, 2, -1, 2, -1, 2)


So a solution is

sage: C_1 = R1.diff_map(R2, [t*B.coord()[i] + (1-t)*A.coord()[i] for i in range(2)])
sage: C_1.display()
R1 --> R2
t |--> (x, y) = (-4*t + 3, 2)

more

Thanks Eric.

I think SageMath should be able to handle tuple arithmetic, like sum and multiplication by a scalar. This could be very useful.

Daniel