Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Redefine symbolic function in a tensor

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:

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=2h0, if I print A[:] I get the same tensor I had before, instead of A[0,0] = 2h0.

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.

Redefine symbolic function in a tensor

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:

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=2h0, h=2*h0, if I print A[:] A[:] I get the same tensor I had before, instead of A[0,0] = 2h0.2*h0.

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

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Redefine symbolic function in a tensor

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:

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.

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Redefine Globally redefine symbolic function in a tensor

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:

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.

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Globally redefine symbolic function in a tensorfunction

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:

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.

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Globally redefine symbolic function

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:

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.

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Globally redefine symbolic function

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:tensor:

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

If I print A, A, I get:

[h(r)    0]
[   0    0]

as I expected. However, from now on I want h 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.

Moreover, can I globally say "from this time on I want h to be 2*h" ? This way, every time I have an expression with h, for example:

f(r) = diff(h,r) + h^2 - 2*h

it will automatically change all, instead of having to change it in every single function.

Globally redefine symbolic function

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.

Moreover, can I globally say "from this time on I want h to be 2*h2*h0" ? This way, for every time I have an expression with function of h, that I already defined, for example:

f(r) = diff(h,r) + h^2 - 2*h

when I make the global change h=2*h0, it will automatically change all, f(r) instead of having to manually change it in every single function.

Globally redefine symbolic function

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.

Moreover, can I globally say "from this time on I want h to be 2*h0" ? This way, for every function of h that I already defined, for example:

f(r) = diff(h,r) + h^2 - 2*h

when I make the global change h=2*h0, it will automatically change f(r) instead of having to manually change it in every single function.

Globally redefine symbolic function

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.

Moreover, can I globally say "from this time on I want h to be 2*h0" ? This way, for every function of h that I already defined, for example:

f(r) = diff(h,r) + h^2 - 2*h

when I make the global change h=2*h0, it will automatically change f(r) instead of having to manually change it in every single function.

Globally redefine symbolic functionfunction in a tensor field

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.

Moreover, can I globally say "from this time on I want h to be 2*h0" ? This way, for every function of h that I already defined, for example:

f(r) = diff(h,r) + h^2 - 2*h

when I make the global change h=2*h0, it will automatically change f(r) instead of having to manually change it in every single function.