rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

trigsimp exponentially slow on lists #3068

Closed rtoy closed 3 months ago

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 12:44:00 Created by macrakis on 2004-06-03 17:21:42 Original: https://sourceforge.net/p/maxima/bugs/572


trigsimp of a [] list can sometimes take time exponential in the length of the list.

For example:

trigsimp(makelist(sin(i)^2+cos(i)^2,i,1,N))

for N=4,5,... takes 0.12, 0.52, 1.50, 4.45, 13.97 secs.

Also for sin(i)^2.

Of course, it should take linear time.

This doesn't happen

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 12:44:01 Created by macrakis on 2004-06-03 17:22:51 Original: https://sourceforge.net/p/maxima/bugs/572/#58c0


Logged In: YES user_id=588346

Oops, "this doesn't happen" should continue... in other cases, like sin(1)^2, sin(x)^2+cos(x)^2, etc.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 12:44:05 Created by rtoy on 2006-11-09 17:50:14 Original: https://sourceforge.net/p/maxima/bugs/572/#eeff


Logged In: YES user_id=28849

This is probably due to the way trigsimp1 and improve work (share/trigonometry/trgsmp.mac).

It looks like caused by trigsimp1 and improve, which cause quadratic behavior, I think.

I think if trigsimp3 is modified to map(trigsimp1, num(expn))/map(trigsimp1,denom(expn), things will work much faster. Some care must be taken in case expn is not a list, but that's not too difficult.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 12:44:08 Created by rtoy on 2006-11-10 21:51:46 Original: https://sourceforge.net/p/maxima/bugs/572/#ff8a


Logged In: YES user_id=28849

Fixed. trigsimp3 modified to handle each element of the list one at a time instead of trying to do the entire list all at once.

rtoy commented 3 months ago

Imported from SourceForge on 2024-07-07 12:44:11 Created by rtoy on 2006-11-10 21:51:46 Original: https://sourceforge.net/p/maxima/bugs/572/#fd0d