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

Add more functions in math.h #16

Open
jasonmhite opened this issue May 1, 2018 · 8 comments
Open

Add more functions in math.h #16

jasonmhite opened this issue May 1, 2018 · 8 comments

Comments

@jasonmhite
Copy link

jasonmhite commented May 1, 2018

So, wouldn't it make sense to simply implement all/most of the functions (and probably some of the constants) in math.h as primitives, since you're already using it? That should automatically give you most of the functions of a scientific calculator, plus the standard library implementations for those functions are very high quality. Having some of the standard unary operations like exp is also very convenient syntactically, because you can just do something like 5 3 exp * instead of 5 e 3 ^ * or 5 e 3 swap ^ * (I usually think in right to left order). At the very least more transcendental functions like atan and erf since you can't easily implement those in terms of other functions (and even if you could it's not a good idea because of numerical problems).

As another point regarding adding constants like e, pi etc., I feel like it'd make sense to just have those pre-loaded. It's not like anybody wants to customize the value of pi. Trying to add every obscure constant in existence isn't feasible, but the ones in math.h are already there and would be nice simply for numerical correctness.

I don't mind doing the legwork to add them, it's pretty easy. I already did exp, that was what motivated this. I'm interested in building a physical calculator using clac, hence the desire to make it a more complete scientific calculator.

This is relevant to issue #10.

@jasonmhite
Copy link
Author

I've implemented most of the functions over in my own fork if you want to take a look jasonmhite@0414af4 . I've added about 25 new words, mostly from math.h, but also deg2rad and rad2deg words to ease working with the trig functions.

@soveran
Copy link
Owner

soveran commented May 4, 2018

Hey @jasonmhite, thanks a lot for your interest and your contributions! I really hope you've found clac useful for your use case. What kind of work do you do? Physics?

I will prepare a longer reply to this issue and post it later. I will reply to your other issue now.

@jasonmhite
Copy link
Author

jasonmhite commented May 4, 2018

I'm a nuclear engineering grad student, but I dabble in lots of different things and find clac convenient as a quick calculator. I too am a fan of dc and it seems like I first saw clac on a HN post, but I rediscovered it when I was searching for the source to dc because I noticed my version of dc didn't implement exp either, even though it's supposed to. Having exp / ln and trig functions is super important to me because I use them a lot.

PS I will also add documentation for the functions I've added if this is something you do want to include after we get it fixed up to your satisfaction.

@soveran
Copy link
Owner

soveran commented May 19, 2018

@jasonmhite I'm sorry for the long delay, I have been extremely busy and I still am! But don't worry, we will get this done eventually :-)

@jasonmhite
Copy link
Author

No worries, I sympathize. Fortunately I'm not running any critical infrastructure on top of clac ;).

@soveran
Copy link
Owner

soveran commented May 19, 2018

Thanks! First I was busy with the GDPR thing, now with some visits. I hope I'll have some time next week.

@jasonmhite
Copy link
Author

image

@soveran
Copy link
Owner

soveran commented May 26, 2018

Almost over! Now it's only a matter of replying to customers who have questions. I'll go back to this issue tomorrow morning (finally).

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

No branches or pull requests

2 participants