As part of an audio peaking filter calculation, I need to implement hyperbolic sine ("sinh") function in a fixed-point arithmetic (fixed-point DSP processor).

What is the proper way to do this?

  • $\begingroup$ I would look into implementing it with CORDIC. $\endgroup$ – MBaz May 6 '19 at 14:51
  • $\begingroup$ What fixed-point processor are you using? And are you sure that your fixed-point processor must compute the coefficients? $\endgroup$ – robert bristow-johnson May 6 '19 at 19:33
  • $\begingroup$ Yes, definitely needs to be computed on a DSP, unfortunately. $\endgroup$ – Danijel May 7 '19 at 12:55

Be careful with that version of the Cookbook. I did not actually write it, although I gave permission to Doug to write it. He has a few typographic errors. The original has been moved. I think this is maybe where it lives now but there appears to be a CR/LF problem with the file.

Anyway, to do trancendentals with a fixed-point processor is difficult but possible. First you need a mathematical description of the transcendental function in terms of arithmetic operations that your fixed-point processor knows how to do. These are usually an infinite series that is truncated to a finite length. I have some expressions of these common transcendentals here.

The other thing you have to worry about is scaling of the coefficients to be integer values. Do you know how to do that in fixed point? That is fundamental.

Then finally the $\sinh(\cdot)$ is expressed in terms of the exponential function which is described in that Wikipedia article you cited.

Conceptually, doing fixed-point math is not too hard, but it is sorta a bitch. You must worry about both precision and about overflow.

| improve this answer | |
  • $\begingroup$ Thanks. Good news is that I have natural exponent function available as a 3rd party library for this processor, so I'm just going to use that. It's gonna cost me two exponent calculations, subtraction and a shift: (exp(x)-exp(-x))>>2. I can probably live with that for now. $\endgroup$ – Danijel May 7 '19 at 12:58
  • $\begingroup$ fine, but you still gotta deal with the scaling that comes with your 3rd-party lib. what is this fixed-point DSP? how big are your words? are they 32-bit? where is the binary point in your fixed-point words? $\endgroup$ – robert bristow-johnson May 7 '19 at 18:53
  • $\begingroup$ the exp lib takes q25 as input, and gives q15 at output, so my sinh is q16 at best. but that's just start of a long journey... $\endgroup$ – Danijel May 14 '19 at 13:31

If you have lots of memory, I would recommend that you use a look-up table. You could use Matlab/Octave/Python to generate the look-up table in C/C++. You can combine a look-up table with interpolation in order to reduce the memory requirements. You can exploit the symmetry of the sinh function in order to reduce the memory requirements by half.

Second option, use Cordic.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.