Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote


Here is a short snippet that seems (to me) to give incorrect answers. I get the expected answer for u (i.e., A^{a}) but for v I was expecting B^{a} but instead I get B^{a} + B^{a} + B^{a}. That seems incorrect to me. I might also note that if I comment out the LaTeXForm property for B{#} then I get the expected results for both u and v.





def truncate (obj,n):

    ans = Ex(0)

    for i in range (0,n+1):
       foo := @(obj).
       bah = Ex("eps = " + str(i))
       keep_weight (foo, bah)
       ans = ans + foo

    return ans

u := A^{a}.
v := B^{a}.

u = truncate (u,2);
v = truncate (v,2);
asked in Bug reports by (1.5k points)

1 Answer

+1 vote
Best answer

Well spotted. It has nothing to do with LaTeXForm per se, but rather with the fact that a property was defined for B{#}, and lookup of labelled properties (Weight is a labelled property, with in your case eps being the label) containing a bug.

Now fixed in github. Thanks.

answered by (54.1k points)
selected by

Hi Kasper,
Thanks for the quick fix and the explanation. It works.