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

Triangular number/ Termial function support #53

Open
tolik518 opened this issue Jan 11, 2025 · 2 comments · May be fixed by #101
Open

Triangular number/ Termial function support #53

tolik518 opened this issue Jan 11, 2025 · 2 comments · May be fixed by #101
Labels
proposal Open for discussion

Comments

@tolik518
Copy link
Owner

Wikipedia: https://en.wikipedia.org/wiki/Triangular_number#Alternative_name

Proposal: https://www.reddit.com/r/unexpectedfactorial/comments/1hyux2u/comment/m6l7eai/

@tolik518 tolik518 added the proposal Open for discussion label Jan 11, 2025
@Aras14HD
Copy link
Contributor

Aras14HD commented Mar 12, 2025

So for the implementation, it should mesh well with the current system, so we need to be able to calculate the to a huge level (and maybe decimal). For that some formulas:

For small integers we can use the simple formula: n? = (n*(n+1))/2

For small decimals we can expand this formula:

n? = (n*(n+1))/2
n? = (n!/(n-2)!)/2
x? = (gamma(x+1)/gamma(x-1))/2

For large integers (approximate):

n? = n*(n+1)/2

m = floor(log10(n))

n? = k*l/2*10^2m
n? = k*10^m*l*10^m/2

k*10^m = n
k = n/10^m
l = (n+1)/10^m

For very large integers (digits):

log10(n?) = log10((n*(n+1))/2)
 = log10(n^2+n)-log10(2) | drop inconsequential n
 ~ 2*log10(n)-log10(2)

For too large numbers (tower), don't do anything, it scales by square, so the number of digits doubles, which doesn't even change a decimal. Even if they put a thousand question marks, it would just be a difference of 300, and only if it's just a one layer tower.

I'll try to derive a formula for an approximation later, maybe based on sterling's formula. Edit: Tried, don't thinks it's possible or necessary (scales comparatively slowly). Edit2: found a simple one!

For the regex it will be some more, the base is simple, but we will need to add multiple chain regexes, their core should be something on the lines of: ([!?\.\(\)\d]+!)(?), ([!?\.\(\)\d]+?)(?) and ([!?\.\(\)\d]+?)(!+)

The task types are going to be pretty straightforward. The result types however are more tricky because of chaining. The Calculation enum would not make any sense to keep, Factorial would take its place, but with one significant change (beside naming), levels would become steps and contain a new Step enum, that keeps track of what type of calculation was done (terminal or k-factorial) storing the level for factorials. (Alternatively we could just use 0 for terminals. That wouldn't scale further, but does it ever need to?)

I don't know when I will get to it, just wanted to take some notes.

@tolik518
Copy link
Owner Author

I don't understand enough math to comment on your formulas. It looks like there's no good approximation formulas out there. If you come up with a good one, it has probably a good chance to be called after you.

I also agree regarding the Calculation-enum. Level "0" should be enough, but as far as I understand "n??? = ((n?)?)?" as there is nothing comparable to multi-factorials - so there should be logic to treat n?? and (n?)? the same.

@Aras14HD Aras14HD linked a pull request Mar 14, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal Open for discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants