Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Feature] Proposal for Comprehensive Mathematical Module in Amber

Open Ph0enixKM opened this issue 1 year ago • 3 comments

We could start with a mininal version of such library and then we could extend it with other functions. Some of the most important ones could be the following:

Rounding

  • [x] ceil(x: Num): Num - rounds up to the nearest integer
  • [x] floor(x: Num): Num - rounds down to the nearest
  • [x] round(x: Num): Num - rounds to the nearest integer

Absolute and sign

  • [x] abs(x: Num): Num - absolute value
  • [ ] sign(x: Num): Num - sign function, returns -1, 0, or 1 depending on the sign of x

Min / Max

  • [ ] min(a: Num, b: Num): Num
  • [ ] max(a: Num, b: Num): Num

Optional: Power, root, exponential, logarithms and trigonometric

These can be easily evaluated using bc with flag -l

  • [ ] pow(base: Num, exponent: Num): Num - power function
  • [ ] sqrt(x: Num): Num - square root
  • [ ] exp(x: Num): Num - exponential function
  • [ ] log(x: Num): Num - natural logarithm
  • [ ] log10(x: Num): Num - base-10 logarithm
  • [ ] sin(x: Num): Num - sine
  • [ ] cos(x: Num): Num - cosine
  • [ ] tan(x: Num): Num - tangent

Ph0enixKM avatar Jun 13 '24 22:06 Ph0enixKM

(perhaps exp, log, sin/cos, tan are not necessary)

FedericoCeratto avatar Jun 20 '24 13:06 FedericoCeratto

You're right @FedericoCeratto. That's not the most important thing right now

Ph0enixKM avatar Jun 22 '24 12:06 Ph0enixKM

As today we have some of them, it is enough?

Mte90 avatar Sep 12 '24 09:09 Mte90