Message Boards Message Boards

0
|
2040 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Piecewise function evaluation and Plot too slow

Posted 2 years ago

Please, Could you explain why this code is too slow to evaluate de pwPAMV function, and impossible to Plot? How can I run this in a efficient way?

2 Replies

Since you define fu by recursion, it may be convenient to make fu remember the values that it has already found, to avoid recalculating them over and over:

fu[p_, t_] := 
  fu[p, t] = (1 - 
      Exp[-\[Lambda] (t - vti[[p]])]) + (PSA fu[p - 1, 
       vti[[p]]]) - (1 - 
       Exp[-\[Lambda] (t - vti[[p]])]) (PSA fu[p - 1, vti[[p]]]);
POSTED BY: Gianluca Gorni

Thank you, I could solve the issue with your tip.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract