ToBasis of a Hodge dual expansion is too slow

133 views
Skip to first unread message

aux...@gmail.com

unread,
Oct 15, 2015, 6:01:34 PM10/15/15
to xAct Tensor Computer Algebra

I'm using xAct 1.1.2 with enhancement of CTensor support in xTerior, for which I would like to thank everyone in the team. One problem I quickly noticed is that the Hodge dual of a 2-form with complicated components takes too long to calculate, as ToBasis takes too long, probably because it scans the expression for the basis forms. Is there a way to make this faster, perhaps by using a CTensor? I suppose it would be faster if I apply the Hodge dual directly to the basis forms, then multiply by the component of each basis, but I'm not aware of a way to do this efficiently.


Kind regards,

Peter

Alfonso Jacinto García Parrado Gómez Lobo

unread,
Oct 16, 2015, 1:05:25 AM10/16/15
to aux...@gmail.com, xAct Tensor Computer Algebra
Dear Peter,

Can you please send an explicit example of this behaviour? Thank you. Alfonso.
________________________________________
From: xa...@googlegroups.com [xa...@googlegroups.com] on behalf of aux...@gmail.com [aux...@gmail.com]
Sent: Thursday, October 15, 2015 10:52 PM
To: xAct Tensor Computer Algebra
Subject: [xAct: 1624] ToBasis of a Hodge dual expansion is too slow

I'm using xAct 1.1.2 with enhancement of CTensor support in xTerior, for which I would like to thank everyone in the team. One problem I quickly noticed is that the Hodge dual of a 2-form with complicated components takes too long to calculate, as ToBasis takes too long, probably because it scans the expression for the basis forms. Is there a way to make this faster, perhaps by using a CTensor? I suppose it would be faster if I apply the Hodge dual directly to the basis forms, then multiply by the component of each basis, but I'm not aware of a way to do this efficiently.


Kind regards,

Peter

--
You received this message because you are subscribed to the Google Groups "xAct Tensor Computer Algebra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xact+uns...@googlegroups.com<mailto:xact+uns...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

Peter

unread,
Oct 16, 2015, 1:12:00 PM10/16/15
to Alfonso Jacinto García Parrado Gómez, xAct Tensor Computer Algebra
On Friday 16 of October 2015 04:58:42 Alfonso Jacinto García Parrado
Gómez Lobo wrote:
> Dear Peter,
>
> Can you please send an explicit example of this behaviour? Thank you.
> Alfonso. ________________________________________

The notebook with the full expressions is attached. I have another
question, about FindPotential. What is the algorithm xTerior is using?
I'm asking because calculating it manually is much faster in the cases I
tried.

Thanks,
Peter
ToBasis slow.nb

Alfonso García-Parrado Gómez-Lobo

unread,
Oct 16, 2015, 4:35:43 PM10/16/15
to Peter, xa...@googlegroups.com
I attach your notebook with your computation done. In principle ToBasis
isn't needed when using the CTensor representation. My comments are in
boldface.


> The notebook with the full expressions is attached. I have another
> question, about FindPotential. What is the algorithm xTerior is using?
> I'm asking because calculating it manually is much faster in the cases I
> tried.
>

It uses the last formula in p. 94 of "M Spivak, Calculus on Manifolds,
Addison Wesley (1965)".

In any case, can you send again an explicit example ? Thanks.

Alfonso.


ToBasis slow.nb

auxsvr

unread,
Oct 19, 2015, 9:25:34 AM10/19/15
to Alfonso García-Parrado Gómez-Lobo, xa...@googlegroups.com
On Friday 16 of October 2015 22:31:26 Alfonso García-Parrado Gómez-Lobo
wrote:
> I attach your notebook with your computation done. In principle
> ToBasis isn't needed when using the CTensor representation. My
> comments are in boldface.

Thank you very much, I had no idea how to accomplish this.

> > The notebook with the full expressions is attached. I have another
> > question, about FindPotential. What is the algorithm xTerior is
> > using? I'm asking because calculating it manually is much faster in
> > the cases I tried.
>
> It uses the last formula in p. 94 of "M Spivak, Calculus on Manifolds,
> Addison Wesley (1965)".
>
> In any case, can you send again an explicit example ? Thanks.

The example is attached. The potential in this case is just a matter of
two integrations.

> Alfonso.

Regards,
Peter
FindPotential problem.nb

Alfonso García-Parrado Gómez-Lobo

unread,
Oct 21, 2015, 11:21:54 AM10/21/15
to auxsvr, xa...@googlegroups.com


> > In any case, can you send again an explicit example ? Thanks.
>
> The example is attached. The potential in this case is just a matter of
> two integrations.
>

Thanks for the example. The problem here is that one needs to do the
integral with all the terms together in the integrand not term by term
as the code currently does (these are the unevaluated integrals which
you see in your notebook when you attempt to find the potential). By
integrating all the terms together one can find a total derivative and
do the integration. Clearly the algorithm in this case has to be
improved and I still need to think what the best way of doing this is.
In the meantime the following patch solves your problem although not as
fast as the direct integration you performed yourself (it takes ~ 25
seconds in my computer). In section 2.10 of xTerior.nb look for the part
starting with the comment (*Simplest cases for grade 1 forms *) and
replace the code there by the following one:


(*Simplest cases for grade 1 forms *)

FindPotential[expr_Diff, point_List, chart_?ChartQ,
options : OptionsPattern[Integrate]] := Part[expr, 1];

FindPotential[factor_ expr_Diff, point_List, chart_?ChartQ,
options : OptionsPattern[Integrate]] :=
Integrate1[(factor /.
Thread[Rule[ScalarsOfChart@chart,
Times[#, t] & /@ (ScalarsOfChart@chart - point) +
point]]) (Part[expr, 1] -
Part[point,
First@Flatten@
Position[ScalarsOfChart@chart, Part[expr, 1]]]), {t, 0, 1},
options];
(* Do the actual integration *)

Integrate1 /: HoldPattern@Plus[var__Integrate1] :=
Integrate[Plus @@ First /@ {var}, {t, 0, 1}];





Alfonso.

Reply all
Reply to author
Forward
0 new messages