#!/usr/bin/env python # coding: utf-8 # # Pullback with large symbolic expressions # ## exp version # # This worksheet is relative the `ask.sagemath` question [*Pullback computation hanging*](https://ask.sagemath.org/question/40852/pullback-computation-hanging/) # In[1]: version() # In[2]: get_ipython().run_line_magic('display', 'latex') # In[3]: M = Manifold(3, 'M') X. = M.chart() N = Manifold(3, 'N') XN. = N.chart() omega = N.diff_form(2) omega[0,1] = 2*b2/a^3 omega[0,2] = -2*b1/a^3 omega[1,2] = -2/a^2 omega.display() # We enforce the use of the $\exp$ representation of $\cosh$ and $\sinh$: # In[4]: cosh_e(x) = (exp(x) + exp(-x))/2 sinh_e(x) = (exp(x) - exp(-x))/2 # In[5]: r = sqrt(x^2+y^2+z^2) t = var('t', domain='real') STSa = r^(1/2)*(r*cosh_e(2*r*t) - z*sinh_e(2*r*t))^(-1/2) STSb1 = (x*sinh_e(2*r*t)/r)*STSa STSb2 = (y*sinh_e(2*r*t)/r)*STSa STS = M.diffeomorphism(N, [STSa, STSb1, STSb2]) STS.display() # In[6]: get_ipython().run_line_magic('time', 'STS.jacobian_matrix()[0,0]') # In[7]: get_ipython().run_line_magic('time', 's = STS.pullback(omega)') s # The number of characters in each of the non-vanishing components of $s$: # In[8]: [len(str(s[ind])) for ind in [(0,1), (0,2), (1,2)]] # The first 1000 characters of $s_{01}$: # In[9]: print(str(s[0,1])[:1000]) # In[ ]: