# Fast Evaluation of Interpolation Function

**URL:** <https://discourse.julialang.org/t/fast-evaluation-of-interpolation-function/58918>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [April 9, 2021, 11:48am UTC](https://discourse.julialang.org/t/fast-evaluation-of-interpolation-function/58918 "2021-04-09T11:48:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 9, 2021, 11:48am UTC](https://discourse.julialang.org/t/fast-evaluation-of-interpolation-function/58918/1 "2021-04-09T11:48:40Z")

</div>

Hi everyone.  
I have a code that depends heavily in this massive interpolated function (a distribution of a property in the Earth). It has X,Y,Z and a Property (Slowness of a wave through the medium).

I evaluate the slowness in 16500 at the same time a bunch of times. I cheated the theory by aproximating the solution evaluating only 330 times. But at the end, when I am trying to refine the results, I always have to evaluate many many times…

Any idea how to:

dS=F\_Sp.(dr2[:, 1], dr2[:, 2], dr2[:, 3])::Array{Float64,1};

much faster?  
Or maybe an alternative to this. Using something different than interpolations?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [April 9, 2021, 12:13pm UTC](https://discourse.julialang.org/t/fast-evaluation-of-interpolation-function/58918/2 "2021-04-09T12:13:03Z")

</div>

This is pretty much impossible to tell without seeing your actual code - have you profiled your function to figure out what the bottleneck is?

Two comments on the one line of code you have posted:

- `dr2[:, 1]` will create a copy, which is often wasteful and can be circumvented by using `@view`.
- The type annotation is almost certain to be irrelevant for performance, so can probably be removed.
