Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


2 Pages12>
Options
Go to last post Go to first unread
Offline overlord  
#1 Posted : 07 June 2021 23:07:11(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Gamma function,
Lower Incomplete Gamma function,
Upper Incomplete Gamma function,
with almost instant speed and high precision.

Regards

gamma.sm (35kb) downloaded 12 time(s). <---- least accurate
gamma_r2.sm (12kb) downloaded 14 time(s).
gamma_r3.sm (12kb) downloaded 10 time(s).
gamma_r4.sm (14kb) downloaded 12 time(s).
gamma_r5.sm (12kb) downloaded 14 time(s).
gamma_r6.sm (18kb) downloaded 6 time(s).
gamma_r7.sm (29kb) downloaded 13 time(s).
gamma_r8.sm (32kb) downloaded 10 time(s).
gamma_r9.sm (37kb) downloaded 18 time(s). <----imaginary numbers added

2021-06-13_07-19.png

Edited by user 13 June 2021 07:28:04(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline overlord  
#2 Posted : 08 June 2021 20:57:24(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Thanks, will explore.

AboveMax.PNG

Main limitation is smath floating points.
Python gives much more accurate results with same algorithms.
Try the other one for gamma calculation.

gamma_r2.sm (12kb) downloaded 14 time(s).

2021-06-08_21-01.png

Edited by user 08 June 2021 21:10:53(UTC)  | Reason: Not specified

Offline Jean Giraud  
#3 Posted : 09 June 2021 01:21:30(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
Try the other one for gamma calculation.

round(■ ,■ ,■ ) ... undefined
H.T.Davis [Abramowitz & Stegun] -> very objective.
In the mean time I'm finishing two superb applications examples
... examples based on your first Gamma(a,x) version,
Thanks for that one, gorgeous ... Jean.

gamma_r2 [H.T.Davis].sm (58kb) downloaded 11 time(s).



Offline overlord  
#4 Posted : 09 June 2021 01:55:03(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: overlord Go to Quoted Post
Try the other one for gamma calculation.

round(■ ,■ ,■ ) ... undefined
H.T.Davis [Abramowitz & Stegun] -> very objective.
In the mean time I'm finishing two superb applications examples
... examples based on your first Gamma(a,x) version,
Thanks for that one, gorgeous ... Jean.

Undefined because you have an old version of smath.
Round(#,#,#) is not parsed through your program.
Use trunc() instead. And with more constants.

gamma_r3.sm (12kb) downloaded 10 time(s).

2021-06-09_01-52.png
Offline overlord  
#5 Posted : 09 June 2021 02:34:03(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Technically this should be the most accurate one.

gamma_r4.sm (14kb) downloaded 12 time(s).

2021-06-09_04-52.png

Edited by user 09 June 2021 04:54:04(UTC)  | Reason: Not specified

Offline Jean Giraud  
#6 Posted : 09 June 2021 03:34:29(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
As offered ... two applications.
Now, the old Rooster is going in the bed marmite ... Jean.

gamma(a,x) Applications.sm (24kb) downloaded 14 time(s).
Offline overlord  
#7 Posted : 09 June 2021 04:08:00(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
As offered ... two applications.
Now, the old Rooster is going in the bed marmite ... Jean.

gamma(a,x) Applications.sm (24kb) downloaded 14 time(s).

I suggest you to change gamma function with gamma_r4.
It is 3 times faster and much more precise.
Offline Jean Giraud  
#8 Posted : 09 June 2021 19:46:58(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
I suggest you to change gamma function with gamma_r4.
It is 3 times faster and much more precise.

Thanks for gamma_r4
1. NO gain timing both applications
2. gamma_r4 Does NOT solve ... first version solves.
Offline overlord  
#9 Posted : 09 June 2021 20:06:13(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Thanks for gamma_r4
1. NO gain timing both applications
2. gamma_r4 Does NOT solve ... first version solves.

Speed may differ between linux and windows.
gamma_r4 is faster 3 times in linux.
What do you mean by 'does not solve'?
How should this page look like?

gamma(a,x) Applications.pdf (126kb) downloaded 10 time(s).
Offline Jean Giraud  
#10 Posted : 09 June 2021 20:19:23(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
What do you mean by 'does not solve'?


SR.4.PNG

Offline overlord  
#11 Posted : 09 June 2021 20:36:55(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: overlord Go to Quoted Post
What do you mean by 'does not solve'?


SR.4.PNG


I think this is the same bug I mentioned earlier. Some functions don't like to be in another function.

2021-06-06_14-44.png

Solution was to put a line but that method is not working in this case.

gamma.png

@Andrey or @Davide has to look at this.
Offline overlord  
#12 Posted : 09 June 2021 22:03:46(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
1. NO gain timing both applications

Latest version is faster about 4 times.

faster_gamma.png
Offline overlord  
#13 Posted : 09 June 2021 22:23:05(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: overlord Go to Quoted Post
What do you mean by 'does not solve'?


SR.4.PNG


It solves, not with conventional methods.
They tend to give errors, not gamma_r4's fault.
alglib is the answer, it usually gives result.

gamma_solve.png

Edited by user 10 June 2021 03:17:02(UTC)  | Reason: Not specified

Offline Jean Giraud  
#14 Posted : 10 June 2021 03:50:11(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
It solves, not with conventional methods.
They tend to give errors, not gamma_r4's fault.
alglib is the answer, it usually gives result.

Good rescue ... OK.
As it looks, sr4 resides at the kernel level.
Thus, it plots but not solve(,,,,)
because not scalar wrt 'x' for the solve bloc.
Offline overlord  
#15 Posted : 10 June 2021 04:06:36(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Good rescue ... OK.
As it looks, sr4 resides at the kernel level.
Thus, it plots but not solve(,,,,)
because not scalar wrt 'x' for the solve bloc.

Nope, not related with kernel, blocks, scalability, etc.
It is probably a bug of solve(), roots(), FindRoot().
Gamma Function has nothing to do with it.
Even very simple ones suffer from this too.
Check below.

2021-06-10_04-03.png

Edited by user 10 June 2021 04:26:33(UTC)  | Reason: Not specified

Offline overlord  
#16 Posted : 10 June 2021 04:22:56(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
It seems solve(), roots(), FindRoot() doesn't like if statements.
I have updated the bugreport in Bugs and Problems > solve() bug.
Using cases() seems to solve the issue. Check the sample below.

gamma_r5.sm (12kb) downloaded 14 time(s).

2021-06-10_04-19.png

Edited by user 10 June 2021 04:41:57(UTC)  | Reason: Not specified

Offline Jean Giraud  
#17 Posted : 10 June 2021 17:16:16(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
Check the sample below

Doctored version confirmed.
Offline overlord  
#18 Posted : 11 June 2021 04:56:05(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
gamma_r5 has a serious flaw. It can't calculate a<0.5.
My bad, should check it carefully. Corrected page is below.
Refactored so it is faster, also get rid of recursive call.
I had to get around some smath bugs with line, if/cases, recursive.
Correlation of them gives weird errors.
Hope this version solves all issues and be the last one.
I know I have flooded this topic too much, sorry for inconvenience.

Regards

gamma_r6.sm (18kb) downloaded 6 time(s).

PS: gamma for negative non-integer values support corrected

2021-06-11_08-40.png

Edited by user 11 June 2021 08:43:39(UTC)  | Reason: Not specified

Offline Jean Giraud  
#19 Posted : 11 June 2021 16:16:24(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,868
Canada

Was thanked: 980 time(s) in 808 post(s)
Originally Posted by: overlord Go to Quoted Post
I know I have flooded this topic too much

You may not like my verdicts:
1. on-line faster has no or little interest, neither up ^307.
2. Your first version runs fine the two applications.
3. The champion is the long time ago published Alvaro Γ(x)
4. for these two applications [2] & [3] are same
but => [3] drops timing [2] from 24 s down 18 s
The drop in timing results from Alvaro Γ(x)
running at the kernel scalar level.
BTW, my original H.T. Davis sanity Mathcad & Alvaro Γ(x)
By same token, thanks Alvaro for your Γ(x).
Cheers ... Jean

Maths Special Gamma(a,x) Incomplete APPLICATIONS [Alvaro G(x)].sm (27kb) downloaded 11 time(s).
Offline overlord  
#20 Posted : 11 June 2021 18:45:20(UTC)
overlord


Rank: Advanced Member

Groups: Registered
Joined: 23/07/2013(UTC)
Posts: 1,124
Turkey

Was thanked: 506 time(s) in 337 post(s)
Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: overlord Go to Quoted Post
I know I have flooded this topic too much

You may not like my verdicts:
1. on-line faster has no or little interest, neither up ^307.
2. Your first version runs fine the two applications.
3. The champion is the long time ago published Alvaro Γ(x)
4. for these two applications [2] & [3] are same
but => [3] drops timing [2] from 24 s down 18 s
The drop in timing results from Alvaro Γ(x)
running at the kernel scalar level.
BTW, my original H.T. Davis sanity Mathcad & Alvaro Γ(x)
By same token, thanks Alvaro for your Γ(x).
Cheers ... Jean

Maths Special Gamma(a,x) Incomplete APPLICATIONS [Alvaro G(x)].sm (27kb) downloaded 11 time(s).

1. 10^308 feature added for fully use IEEE capability.
2. gamma_r6 runs every possible applications.
3. don't want to disrespect, Alvaro's is a single line awesome code.
4. mine has same algorithm with more features, with faster calculation.
4. gamma_r6 is faster from gamma_r2 and gamma_r3 while trying to have all feature.

gamma_r6_app.sm (34kb) downloaded 12 time(s).

Here is a side by side comparison with Alvaro's algorithm with mine.
On linux, gamma_r6 is faster about 20 percent.






Users browsing this topic
Similar Topics
Incomplete Gamma Functions (Bugs & Problems)
by overlord 06/06/2021 14:45:29(UTC)
2 Pages12>
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.