Improve fixed-point tangent calculation for division-less operations and accuracy

Open
#33 5 comments 0 reactions 1 assignee View on GitHub

@jouae is already working on this.

Since Mar 2, 2025.

Assessment

This issue has not been assessed yet.

Description

When calculating the twin_tan(), division is used, specifically $\frac{\sin x}{\cos x}$

// twin_tan()
return ((s << 15) / c) << 1;

To minimize the use of the division operator, you can refer to the division implementation mentioned in https://hackmd.io/@sysprog/linux-intdiv, which describes the implementation in jemalloc to avoid direct use of the division operator.

Currently, testing and experimental data are needed to confirm that using this division method in twin_tan within mado can achieve faster calculation times.

As for the other issue, it's whether twin_tan can be improved further, including enhancements in precision and calculation speed.

Perhaps coordinate rotation digital computer(CORDIC) cloud be a solution.

The note here provide a quick overview of the mathematical principles behind conventional CORDIC and scaling-free CORDIC.

Reference:

  1. https://hackmd.io/@sysprog/linux-intdiv
  2. https://github.com/Max-Gulda/Cordic-Math
  3. https://hackmd.io/@jouae/mado_trig
Dominant language
C
Stars
118
Forks
25
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/mado

All issues in sysprog21/mado

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.