[sage-support] Re: Simplifications and sagemanifold

2022-09-04 Thread Eric Gourgoulhon
Thank you for these instructive benchmarks!

Best wishes,

Eric. 

Le dimanche 4 septembre 2022 à 07:35:18 UTC+2, roger...@gmail.com a écrit :

> Thank you very much Eric! It works perfectly well for my needs.
> I've tested the time spent for calculating the Riemann tensor (restarting 
> the kernel to avoid cache) for three different simplifying methods: the 
> standard, the simplify, and a function that just returns the expression. It 
> makes a huge difference.
>
> For the Kerr-Newman metric, without simplification is ~500x faster 
> (considering the wall time).
>
> - default
> CPU times: user 5min 6s, sys: 4.16 s, total: 5min 10s
> Wall time: 3min
>
> - simplify
> CPU times: user 40.1 s, sys: 359 ms, total: 40.4 s
> Wall time: 27.3 s
>
> - no simplification
> CPU times: user 468 ms, sys: 785 µs, total: 468 ms
> Wall time: 340 ms
>
>
> For the metric given by
>
> [-1, 0, 0, 0]
> [0, h11(t, r, th, ph), h12(t, r, th, ph), h13(t, r, th, ph)]
> [0, h12(t, r, th, ph), h22(t, r, th, ph), h23(t, r, th, ph)]
> [0, h13(t, r, th, ph), h23(t, r, th, ph), h33(t, r, th, ph)]
>
> the results are more even impressive. No simplification is ~4000x faster.
>
> - default
> CPU times: user 40min 26s, sys: 17.9 s, total: 40min 43s
> Wall time: 31min 29s
>
> - simplify
> CPU times: user 3min 10s, sys: 978 ms, total: 3min 11s
> Wall time: 2min 44s
>
> - no simplification
> CPU times: user 715 ms, sys: 14.2 ms, total: 729 ms
> Wall time: 573 ms
>
> Best wishes,
>
> Rogerio
>
> Em sábado, 3 de setembro de 2022 às 12:55:33 UTC-3, egourg...@gmail.com 
> escreveu:
>
>> Le vendredi 2 septembre 2022 à 08:09:23 UTC+2, roger...@gmail.com a 
>> écrit :
>>
>>> Components of tensors in sagemanifolds are nicely simplified through 
>>> methods of chart functions. However, for large and complicated expressions, 
>>> such simplifications are very time consuming. 
>>> Is it possible to turn off these simplifications?
>>
>>
>> Yes, via the method M.set_simplify_function. It suffices to pass a fast 
>> function as argument, like simplify.  
>> For instance:
>>
>> sage: M = Manifold(4, 'M')
>> sage: X. = M.chart()
>> sage: M.set_simplify_function(simplify)
>>
>> NB: the call to M.set_simplify_function must be done after the chart(s) 
>> have been defined. It can also be done chartwise, via
>> X.calculus_method().set_simplify_function(simplify)
>>
>> See 
>>
>> https://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/manifold.html#sage.manifolds.manifold.TopologicalManifold.set_simplify_function
>> for details. 
>>
>> Best wishes,
>>
>> Eric.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/af76ad88-21ab-44c8-a710-b4c09e6c4b77n%40googlegroups.com.


[sage-support] Re: Simplifications and sagemanifold

2022-09-03 Thread Rogerio
Thank you very much Eric! It works perfectly well for my needs.
I've tested the time spent for calculating the Riemann tensor (restarting 
the kernel to avoid cache) for three different simplifying methods: the 
standard, the simplify, and a function that just returns the expression. It 
makes a huge difference.

For the Kerr-Newman metric, without simplification is ~500x faster 
(considering the wall time).

- default
CPU times: user 5min 6s, sys: 4.16 s, total: 5min 10s
Wall time: 3min

- simplify
CPU times: user 40.1 s, sys: 359 ms, total: 40.4 s
Wall time: 27.3 s

- no simplification
CPU times: user 468 ms, sys: 785 µs, total: 468 ms
Wall time: 340 ms


For the metric given by

[-1, 0, 0, 0]
[0, h11(t, r, th, ph), h12(t, r, th, ph), h13(t, r, th, ph)]
[0, h12(t, r, th, ph), h22(t, r, th, ph), h23(t, r, th, ph)]
[0, h13(t, r, th, ph), h23(t, r, th, ph), h33(t, r, th, ph)]

the results are more even impressive. No simplification is ~4000x faster.

- default
CPU times: user 40min 26s, sys: 17.9 s, total: 40min 43s
Wall time: 31min 29s

- simplify
CPU times: user 3min 10s, sys: 978 ms, total: 3min 11s
Wall time: 2min 44s

- no simplification
CPU times: user 715 ms, sys: 14.2 ms, total: 729 ms
Wall time: 573 ms

Best wishes,

Rogerio

Em sábado, 3 de setembro de 2022 às 12:55:33 UTC-3, egourg...@gmail.com 
escreveu:

> Le vendredi 2 septembre 2022 à 08:09:23 UTC+2, roger...@gmail.com a 
> écrit :
>
>> Components of tensors in sagemanifolds are nicely simplified through 
>> methods of chart functions. However, for large and complicated expressions, 
>> such simplifications are very time consuming. 
>> Is it possible to turn off these simplifications?
>
>
> Yes, via the method M.set_simplify_function. It suffices to pass a fast 
> function as argument, like simplify.  
> For instance:
>
> sage: M = Manifold(4, 'M')
> sage: X. = M.chart()
> sage: M.set_simplify_function(simplify)
>
> NB: the call to M.set_simplify_function must be done after the chart(s) 
> have been defined. It can also be done chartwise, via
> X.calculus_method().set_simplify_function(simplify)
>
> See 
>
> https://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/manifold.html#sage.manifolds.manifold.TopologicalManifold.set_simplify_function
> for details. 
>
> Best wishes,
>
> Eric.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/8c5cfa97-847e-44c8-a6c9-fed2d0594841n%40googlegroups.com.


[sage-support] Re: Simplifications and sagemanifold

2022-09-03 Thread Eric Gourgoulhon
Le vendredi 2 septembre 2022 à 08:09:23 UTC+2, roger...@gmail.com a écrit :

> Components of tensors in sagemanifolds are nicely simplified through 
> methods of chart functions. However, for large and complicated expressions, 
> such simplifications are very time consuming. 
> Is it possible to turn off these simplifications?


Yes, via the method M.set_simplify_function. It suffices to pass a fast 
function as argument, like simplify.  
For instance:

sage: M = Manifold(4, 'M')
sage: X. = M.chart()
sage: M.set_simplify_function(simplify)

NB: the call to M.set_simplify_function must be done after the chart(s) 
have been defined. It can also be done chartwise, via
X.calculus_method().set_simplify_function(simplify)

See 
https://doc.sagemath.org/html/en/reference/manifolds/sage/manifolds/manifold.html#sage.manifolds.manifold.TopologicalManifold.set_simplify_function
for details. 

Best wishes,

Eric.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-support/33638357-b06e-4d02-9506-df39f75994dbn%40googlegroups.com.