# How do I classify the improvement in performance when Hankel functions are replaced with log functions in MatLab?

I am working on a algorithm for acoustic scattering in two dimensions using MatLab, and one of the advantages of this algorithm is that Hankel functions can be replaced with log functions.

For example consider the following:

1. value = 0; tic; for t=1:100000, value = value + besselh(1,1,abs(1+1i)); end; toc
2. value = 0; tic; for t=1:100000, value = value + log(abs(1+1i)); end; toc

Coming from a mathematics background I'm used to analyzing numerical methods in cases such as determining the order of convergence of an ODE/PDE solver or a numerical integration method, along with judging complexity in a program by counting operations.

However in this case, the number of operations is the same (on the surface anyway). So how can the improvement in efficiency be classified in this case? Are empiric results, such as showing that 2) takes much less time than 1), the best I can do in this situation?

Or is there a more formal/rigorous way to classify the improved efficiency?

• Right, the conclusion you can draw is that 1 is slower than 2, which is no surprise. There is nothing to be said about complexity, as there is no input size. An even less about efficiency. Lastly, you are comparing two different things. – Yves Daoust Apr 17 '17 at 16:31
• 1) Has this anything to do with Matlab, specifically? Because then it's offtopic. 2) What's the cost of evaluating besselh vs log? Benchmark the two in isolation! – Raphael Apr 17 '17 at 17:08
• @Raphael: hem, that's precisely what he did. – Yves Daoust Apr 17 '17 at 17:22
• @Raphael No it's not Matlab in general, I would be interested in how they compare in other languages also, C/C++ in particular. – csss Apr 27 '17 at 7:15

• Counting operations is still useful, provided you assign useful weights to the operations. Here, besselh (and probably log) are not operations but function calls; in order to analyse to the degree of precision we require, we need to unfold the declarations of these functions. – Raphael Apr 17 '17 at 19:53