# Avoid recalculating X^q when f(p): X.^1 ... X.^p

**URL:** <https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491>\
**Category:** Performance\
**Created:** [January 10, 2019, 7:56pm UTC](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491 "2019-01-10T19:56:05Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![taqtiqa-mark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/taqtiqa-mark/32/4383_2.png) [@taqtiqa-mark](https://discourse.julialang.org/u/taqtiqa-mark)\
**Post date:** [January 12, 2019, 10:21pm UTC](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491/6 "2019-01-12T22:21:06Z")

</div>

> [@stevengj](#):
>
> if you only get cache misses infrequently, then the performance of the `^n` exponentiation is probably irrelevant, and I would tend to just use `pc.x .^ n` to maximize accuracy.

Thank you for the heads-up about performance and accuracy, for those following along, see @stevengj’s [efficient `X^p, p=1...n` script here.](https://discourse.julialang.org/t/efficient-creation-of-power-series-matrix-or-array-of-arrays/18988/7)

Just to be clear, the ‘cache’ misses you mention refer to the `PowerCache` in Max’s code above?

---

_[View the full topic](https://discourse.julialang.org/t/avoid-recalculating-x-q-when-f-p-x-1-x-p/19491)._
