Skip to content
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

RFC: Add cis(z) function, exp(iz) #142

Closed
4 tasks done
rreusser opened this issue Sep 26, 2017 · 5 comments
Closed
4 tasks done

RFC: Add cis(z) function, exp(iz) #142

rreusser opened this issue Sep 26, 2017 · 5 comments
Labels
Accepted RFC feature request which has been accepted. Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. RFC Request for comments. Feature requests and proposed changes.

Comments

@rreusser
Copy link
Member

rreusser commented Sep 26, 2017

Checklist

Please ensure the following tasks are completed before filing an issue.

  • Read and understood the Code of Conduct.
  • Searched for existing issues and pull requests.
  • If this is a general question, searched the FAQ for an existing answer.
  • If this is a feature request, the issue name begins with RFC:.

Description

Description of the issue (or feature request).

Add cis function. Usage would be:

  • cis(x): returns [cos(x), sin(x)]
  • cis([0, 0], x): returns [cos(x), sin(x)] in-place
  • cis(x, y): returns [exp(-y) cos(x), exp(-y) sin(x)]
  • cis([0, 0], x, y): returns [exp(-y) cos(x), exp(-y) sin(x)] in-place

Note for the last two cases: exp(ix) is generalized to complex z, exp(iz). If z = x + iy, then this is exp(i (x + iy)) = exp(ix - y) = exp(-y) * (cos(x) + i sin(x)), hence the -y in the above formulas.

Other

Any other information relevant to this issue (or feature request)? This may include screenshots, references, stack traces, sample output, and/or implementation notes.

@kgryte
Copy link
Member

kgryte commented Sep 26, 2017

Should we make the interface polymorphic or have two separate implementations:

@stdlib/math/base/special/cis
@stdlib/math/base/complex/cis

where the latter is aliased ccis?

@kgryte kgryte added Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. Needs Discussion Needs further discussion. RFC Request for comments. Feature requests and proposed changes. labels Sep 26, 2017
@rreusser
Copy link
Member Author

rreusser commented Sep 26, 2017

Yeah, it's unambiguous but I wasn't sure whether it was desirable. Perhaps base is not the place for polymorphic implementations. It feels just slightly weird to have cis in special though since it's definitely for complex numbers.

(Though really, cis(x) is just shorthand for cis(x, 0) making it slightly less polymorphic-feeling.)

@kgryte
Copy link
Member

kgryte commented Sep 26, 2017

Then, for now, maybe we just focus on the complex use case and put in base/complex.

@rreusser
Copy link
Member Author

That seems valid. If imag === 0.0, then we can avoid the exp so it's not like it's wasting too many cpu cycles.

@kgryte
Copy link
Member

kgryte commented Sep 26, 2017

Awesome! Sounds good!

@kgryte kgryte added Accepted RFC feature request which has been accepted. and removed Needs Discussion Needs further discussion. labels Sep 26, 2017
@rreusser rreusser changed the title RFC: Add cis(x) function, exp(ix) RFC: Add cis(z) function, exp(iz) Sep 27, 2017
Planeshifter pushed a commit that referenced this issue Mar 1, 2024
PR-URL: #142
Closes: #776

Reviewed-by: Pranav <85227306+Pranavchiku@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted RFC feature request which has been accepted. Feature Issue or pull request for adding a new feature. Math Issue or pull request specific to math functionality. RFC Request for comments. Feature requests and proposed changes.
Projects
None yet
Development

No branches or pull requests

2 participants