jfk_dora

15 Reputation

3 Badges

4 years, 180 days

MaplePrimes Activity


These are questions asked by jfk_dora

Hi,

I use Maple 2024 (X86 64 LINUX), and am trying to calculate the sum of the prime factors of integers.

My code is as simple as something like this:

SumPrimeFactors := proc(n)
    local f, L, p;
    f := ifactor(n);
    L := [op(f)];
    return add(convert(op(1, p), integer), p in L);  # Sum base primes
end proc:

However, the above code returns the following result when I set n = 360:

> SumPrimeFactors(360);
                                     5 +  (2) +  (3)

while what I had expected is just an integer, 10 (= 5+2+3).
It seems the operation convert(op(1, p), integer) is not working properly, and "(2)" is recognized as an expression, not an integer, even after the convert operation.

I have no idea how I should rectiy it.
I would be glad if someone gives me a way to get it solved.
Thank you very much.

I am still a novice of Maple, but I want to carry out recurvive applications of some formula that involves non-commutative operators X and Y ([X,Y] = XY-YX). I used the following code, but I do not know how to tell Maple a rule that [X,X] = [Y,Y] = 0:

with(Physics);
Setup(mathematicalnotation = true);
Setup(noncommutativeprefix = {X, Y});

Z := X + Y + (1/2)*Commutator(X,Y);
subs(X=Y,Z);

The output is like this:

> Z := X + Y + (1/2)*Commutator(X,Y);
                          Z := X + Y + 1/2 [X, Y][-]

> subs(X=Y,Z);
                              2 Y + 1/2 [Y, Y][-]

The above [Y,Y] must be interpreted as zero, of course.

Thank you very much.

Page 1 of 1