Ask Your Question
1

Globally redefine symbolic function in a tensor field

asked 2021-11-11 16:51:30 +0200

keko gravatar image

updated 2021-12-17 13:03:27 +0200

As a simple example, I have the following manifold and chart:

M = Manifold(2, 'M', structure='Lorentzian')
X.<t,r> = M.chart(r"t r:(0,+oo)")

with these functions:

h = function('h')(r)
h0 = function('h0')(r)

Now, I define the following tensor:

A = M.tensor_field(0,2)
A[0,0] = h

If I print A, I get:

[h(r)    0]
[   0    0]

as I expected. However, from now on I want h to be:

h = 2*h0

After setting h=2*h0, if I print A[:] I get the same tensor I had before, instead of A[0,0] = 2*h0.

How can I redefine a symbolic function inside a tensor? I have tried with A.subs and A.apply_map, but none of them did the job.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-11-11 17:28:45 +0200

eric_g gravatar image

You should first define a callable symbolic expression containing 2*h0:

f(r) = 2*h0

and then call

A.apply_map(lambda x: x.substitute_function(function('h'), f))

Then A[:] yields

[2*h0(r)       0]
[      0       0]
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-11-11 16:51:30 +0200

Seen: 208 times

Last updated: Dec 17 '21