Ask Your Question

tolga's profile - activity

2024-04-09 20:41:16 +0200 commented question How to stop code after a given time

I think there was something like alarm and AlarmInterrupt. Maybe you can use them with try and except.

2024-03-25 14:16:48 +0200 received badge  Popular Question (source)
2024-03-25 06:49:59 +0200 answered a question Simple complex definite integral fails

The default Maxima solver needs assumptions to set floor((%i+1)/(2*%pi)) as shown in the message. You can either give su

2024-02-27 14:04:56 +0200 commented answer Defining new operators with specific rules

Actually, I am not very happy but I think this is a fair solution to the problem.

2024-02-26 17:34:14 +0200 marked best answer Defining new operators with specific rules

I would like to define new derivative operators dd1 and dd2. They should follow the following rules (dd being either dd1 or dd2 - They follow the same rules.):

dd(a+b)=dd(a)+dd(b);
dd(a*b)=b*dd(a)+a*dd(b);
dd(-a)=-dd(a);
dd(1/a)=-1/a^2*dd(a);
dd(c)=0;
dd(c*a)=c*dd(a);
dd(a**c)=c*a**(c-1)*dd(a);

where c is a symbolic variable or a number of any kind and, a and b are scalar field functions on a manifold.

If the code is something like the following:

# First operator
def dd1(x):
    ...

# Second operator
def dd2(x):
    ...

Man = Manifold(4, 'Man', r'\mathcal{Man}')
CO.<t,r,th,ph> = Man.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
a=Man.scalar_field(function('a')(*CO))
b=Man.scalar_field(function('b')(*CO))
c=var('c')

Then, it should produce these sample outputs for the following inputs:

Input> dd1(a)
Outpt> dd1(a)

Input> dd1(dd2(a))
Outpt> dd1(dd2(a))

Input> dd2(a*b)
Outpt> b*dd2(a)+a*dd2(b)

Input> dd1(c*a)
Outpt> c*dd1(a)

Input> dd2(dd1(c*a))
Outpt> c*dd2(dd1(a))

Input> dd1(-a)
Outpt> -dd1(a)

Input> dd2(c)
Outpt> 0

Input> dd1(7)
Outpt> 0
2024-02-26 16:21:12 +0200 received badge  Self-Learner (source)
2024-02-26 06:10:48 +0200 edited answer Defining new operators with specific rules

The following code seems to do the job. However, it looks very clumsy and I would be very happy to receive comments. ##

2024-02-25 07:23:06 +0200 commented question show() for equations is not working

The version on the repository is rather old. I would suggest that you install the latest version using conda/mamba easil

2024-02-19 14:32:55 +0200 edited answer Defining new operators with specific rules

The following code seems to do the job. However, it looks very clumsy and I would be very happy to receive comments. fr

2024-02-19 14:31:46 +0200 answered a question Defining new operators with specific rules

The following seems to do the job. However, it looks very clumsy and I would be very happy to receive comments. from sa

2024-02-11 11:27:59 +0200 asked a question Defining new operators with specific rules

Defining new operators with specific rules I would like to define new derivative operators dd1 and dd2. They should foll

2024-01-13 18:42:01 +0200 received badge  Notable Question (source)
2024-01-12 20:52:34 +0200 commented question Computing the Chern–Pontryagin invariant

I do not think that you will need loops. Please check this page to see that the Kretschmann scalar is defined and calcul

2023-12-24 08:31:02 +0200 commented question 2r^2 interpreted as 2^2

Please check the types in the following code: print("Before var:",type(r)) var('r') print("After var:",type(r)) print("

2023-12-10 08:01:00 +0200 commented question Could someone explain how the answer was calculated

Set S=0 In the for loop: k=1, S=0+1=1 k=2, S=1+2=3 k=3, S=3+3=6 Set S=2 * S = 2 * 6 = 12

2023-12-10 08:00:31 +0200 commented question Could someone explain how the answer was calculated

Set S=0 In the for loop: k=1, S=0+1=1 k=2, S=1+2=3 k=3, S=3+3=6 Set S=2S=26=12

2023-12-10 07:59:02 +0200 commented question Could someone explain how the answer was calculated

Set S=0 In the for loop: k=1, S=0+1=1 k=2, S=1+2=3 k=3, S=3+3=6 Set S=2S=26=12

2023-12-10 07:58:53 +0200 commented question Could someone explain how the answer was calculated

Set S=0 In the for loop: k=1, S=0+1=1 k=2, S=1+2=3 k=3, S=3+3=6 Set S=2S=26=12

2023-11-29 07:12:59 +0200 commented answer I want to calculate the Riemann tensor and Kretschmann scalar for Kerr- De Sitter spacetime but it is taking too long and not giving any answer please help

We can discuss the substitution and simplification if @eric_g 's solution does not fit your needs.

2023-11-28 11:34:14 +0200 commented question I want to calculate the Riemann tensor and Kretschmann scalar for Kerr- De Sitter spacetime but it is taking too long and not giving any answer please help

Please see my answer below.

2023-11-28 11:33:55 +0200 answered a question I want to calculate the Riemann tensor and Kretschmann scalar for Kerr- De Sitter spacetime but it is taking too long and not giving any answer please help

You actually put the functions Delta, rho2, and Sigma in the metric at the beginning. You should use them in a closed fo

2023-11-27 17:58:19 +0200 commented question I want to calculate the Riemann tensor and Kretschmann scalar for Kerr- De Sitter spacetime but it is taking too long and not giving any answer please help

Please check the answer of @eric_g below. If it does not work out, you can gather your code in one cell and paste it her

2023-11-25 18:43:24 +0200 commented question I want to calculate the Riemann tensor and Kretschmann scalar for Kerr- De Sitter spacetime but it is taking too long and not giving any answer please help

As general advice, try to give your metric in a closed form as much as you can. For example, instead of (r^2 + a^2*(cosθ

2023-11-17 04:43:07 +0200 commented question Function defined with an integral

Also try this: def f(x): var('t') return numerical_integral(exp(t^2)/sqrt(t),1,x^2) f(4) As you can see from

2023-11-17 04:36:24 +0200 commented question Function defined with an integral

This can be a workaround: def f(x): var('t') return real(integral(exp(t^2)/sqrt(t),t,1,x^2)) f(4).numerical_ap

2023-11-04 07:26:27 +0200 answered a question Matrix product simple case

Please try C=matrix(QQ,n,n).

2023-11-02 08:22:57 +0200 commented question Symbolic matrix inversion broken?

What is your SageMath version? https://sagecell.sagemath.org/ gives the right answer.

2023-10-26 06:13:16 +0200 answered a question Logarithms

Try canonicalize_radical(): var('alpha,beta,x,y') f=exp(alpha*log(x)+beta*log(y)) print(f.canonicalize_radical())

2023-09-11 06:56:33 +0200 commented question tetrahedron with each face differently colored?

This answer might be helpful: https://ask.sagemath.org/question/37814/how-to-draw-three-pyramids-inside-a-right-prism/

2023-09-10 20:14:02 +0200 received badge  Nice Answer (source)
2023-09-10 09:51:07 +0200 edited answer n*1/n^2 for n = 1,2,3,50.

Please check this: v=[1/n^2 for n in range(1,51)] print(v)

2023-09-10 09:50:14 +0200 edited answer n*1/n^2 for n = 1,2,3,50.

Please check this (): v=[1/n^2 for n in range(1,51)] print(v)

2023-09-10 09:37:39 +0200 answered a question n*1/n^2 for n = 1,2,3,50.

Please check this: v=[1/n^2 for n in range(1,50)] print(v)

2023-08-27 09:16:59 +0200 commented question Jupyter in sagemath 10

Uninstalling and reinstalling might be the easiest solution.

2023-08-02 16:27:53 +0200 commented question Displaying a matrix with scalar fields

Thank you @achrzesz. This is a solution to my problem.

2023-08-02 16:23:28 +0200 commented answer Displaying a matrix with scalar fields

That solves my problem. Thank you.

2023-08-02 16:22:55 +0200 marked best answer Displaying a matrix with scalar fields

I have some scalar fields and a matrix whose elements are these scalar fields. A sample code is the following:

reset()
M=Manifold(4, 'M', r'\mathcal{M}')
BL.<t,r,th,ph> = M.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
f=M.scalar_field(function('f')(*BL))
g=M.scalar_field(function('g')(*BL))
h=M.scalar_field(function('h')(*BL))
h=0
mymatrix=matrix([[f+g,g,h],[f,h,g],[h,g,f]])

f, g, or h can be zero or nonzero (according to some calculations).

When I try to display my matrix with show(mymatrix) or print(mymatrix), I see Scalar field on the 4-dimensional differentiable manifold M instead of the non-zero elements.

What should I do to display my matrix as

[f+g g 0]
[f 0 g]
[0 g f]

preferably without using loops, etc?

2023-08-02 13:12:05 +0200 asked a question Displaying a matrix with scalar fields

Displaying a matrix with scalar fields I have some scalar fields and a matrix whose elements are these scalar fields. A

2023-07-31 19:06:32 +0200 answered a question How to remove radicals from an equation

You can try canonicalize_radical()

2023-07-31 00:51:27 +0200 received badge  Nice Answer (source)
2023-07-27 10:26:01 +0200 commented question Reduced form of symbolic expressions

Keeping everything in h is easier: (Qi*R).subs(relation).simplify_full()

2023-07-27 10:15:26 +0200 commented question Reduced form of symbolic expressions

Maybe it is trivial but can (Qi*R).subs(h==log(q)).simplify_full() solve your problem?

2023-07-18 08:35:38 +0200 commented question how to plot Riemann zeta zeros as fields with one element

Can you post the codes here? They are written in SageMath, right?

2023-07-14 13:43:26 +0200 received badge  Popular Question (source)
2023-07-12 10:59:08 +0200 marked best answer Multiplication of tensor elements

First, without tensor fields:

reset()
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
result=(term1*term2).canonicalize_radical()
print(result)

This gives the result: -1/2*H(x)

However, when term1 and term2 are the elements of tensors as in

reset()
Man=Manifold(4, 'Man', r'\mathcal{M}')
BL.<t,r,th,ph> = Man.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
T1=Man.tensor_field(0,1,[0,0,term1,0])
T2=Man.tensor_field(0,1,[0,0,term2,0])
result=T1[2]*T2[2]
print(result)

I get, 1/2*I*H(x)

I need to get -1/2*H(x) as in the first case. I can solve my problem by using .expr() for the elements of the tensor:

reset()
Man=Manifold(4, 'Man', r'\mathcal{M}')
BL.<t,r,th,ph> = Man.chart(r't r:(0,+oo) th:(0,pi):\theta ph:(0,2*pi):\phi')
H=function('H',imag_part_func=0)(x)
term1=(1/2)*sqrt(2)*sqrt(I*H)
term2=(1/2)*sqrt(2)*sqrt(-I*H)
T1=Man.tensor_field(0,1,[0,0,term1,0])
T2=Man.tensor_field(0,1,[0,0,term2,0])
result=(T1[2].expr()*T2[2].expr()).canonicalize_radical()
print(result)

But is there a way to get the result I needed without .expr()? I think I am missing something about the tensor fields.

2023-07-12 10:44:48 +0200 commented answer Multiplication of tensor elements

Last question: Is there a way to define the function H as a differentiable function (i.e. diff(H,r) is not zero) of only