Skip to content

Added some series-based functions (exp, cos, sin, ...) #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hakanai
Copy link

@hakanai hakanai commented May 26, 2022

Added:

  • exp (by infinite series)
  • cos (by infinite series)
  • sin (by infinite series)
  • tan (by cos/sin)
  • cosh (by infinite series)
  • sinh (by infinite series)
  • tanh (by cosh/sinh)

Not added:

  • ln - might not be too hard but converges very slowly so need another trick
  • arcsin(x) = arctan(x / √(1 - x²))
  • arccos(x) = arctan(√(1 - x²) / x)
  • arctan - conceivably possible to do similarly, but the series only converges for small values, so need to use Euler's trick
  • arsinh(x) = ln(√(1 + x²) + x)
  • arcosh(x) = ln(x + √(x - 1)√(x + 1)) = ln(√(x² - 1) + x)
  • artanh(x) = ½ ln(x + 1) - ½ ln(1 - x)

Added:
- exp (by infinite series)
- cos (by infinite series)
- sin (by infinite series)
- tan (by cos/sin)
- cosh (by infinite series)
- sinh (by infinite series)
- tanh (by cosh/sinh)
@hakanai
Copy link
Author

hakanai commented May 26, 2022

I'm still unsure about the way I handled precision here.

I could have tried to use the precision of the number used as input, but the problem is that the decimal mode can currently be null, which can't work for these things because they always need to know when to stop.

Also I haven't actually signed the commit, but it isn't a complete solution either, so I'll worry about that if it gets even remotely close to usable. :(

@CLAassistant
Copy link

CLAassistant commented May 26, 2022

CLA assistant check
All committers have signed the CLA.

@ionspin
Copy link
Owner

ionspin commented May 26, 2022

Awesome, thanks for the contribution! It will take me some time to go through it in detail and understand everything so please have patience, especially since I can only get some time to work on the library on the weekend. And don't worry about the signature.

The decimal mode was long overdue for a refactor so I'll try to combine that with changes here.

@ionspin
Copy link
Owner

ionspin commented Jun 19, 2022

I haven't forgotten about this, but I'm still short on time. It's top of my priority list for the library.

@ionspin ionspin added this to the 0.4.0 milestone May 8, 2023
@ionspin ionspin self-assigned this May 8, 2023
@sergeych
Copy link

sergeych commented Jun 3, 2024

why isn't it yet merged? any problems with it? Btw, missing precision could be taken from the decimal size of the argument + n, usually it works fairy well. Also you can provide some kind of epsilon parameter instead.

@ionspin could you please merge it or like?

@ionspin
Copy link
Owner

ionspin commented Jun 3, 2024

@sergeych Unfortunately I haven't had the time to properly go through this pull request and it's also related to decimal mode refactor which is a big undertaking, so that's why this pull request hasn't been merged for a long time, and by the way things are looking it's going to stay that way for some time to come.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants