Menu

#572 trigsimp exponentially slow on lists

closed
nobody
5
2006-11-10
2004-06-03
No

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

Discussion

  • Stavros Macrakis

    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.

     
  • Robert Dodier

    Robert Dodier - 2006-07-31
    • labels: --> Lisp Core - Trigonometry
     
  • Raymond Toy

    Raymond Toy - 2006-11-09

    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.

     
  • Raymond Toy

    Raymond Toy - 2006-11-10
    • status: open --> closed
     
  • Raymond Toy

    Raymond Toy - 2006-11-10

    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.

     

Log in to post a comment.