Tampilkan postingan dengan label approximation. Tampilkan semua postingan
Tampilkan postingan dengan label approximation. Tampilkan semua postingan

TI 84 Plus CE TI-Basic and TI Nspire CX II Python: Gamma by Multiplication Recursion Property

TI 84 Plus CE TI-Basic and TI Nspire CX II Python:   Gamma by Multiplication Recursion Property


Introduction


The program calculates the gamma function for any real positive number in tenths by the multiplication recursion:


Γ(x + 1) = x * Γ(x)


For example:  


Γ(2.5)

= 1.5 * Γ(1.5)

= 1.5 * 0.5 * Γ(0.5)

≈ 1.5 * 0.5 * 1.772453851

≈ 1.329340388


Reduce x by 1 until 1 is in between 0.1 and 1. 


Gamma Values:


Γ(0.1) = 9.513507699

Γ(0.2) = 4.590843712

Γ(0.3) = 2.991568988

Γ(0.4) = 2.218159544

Γ(0.5) = 1.772453851

Γ(0.6) = 1.489192249

Γ(0.7) = 1.298055333

Γ(0.8) = 1.164229714

Γ(0.9) = 1.068628702

Γ(1) = 1


TI-84 Plus CE Program: GAMMATEN

TI-Basic


Notes:


*  To get the small L to create lists with custom names, get the character with the key strokes:  [ 2nd ] ( list ), OPS, B.  L.   In this listing, I will write L^ to symbolize the lower case L.


* L^TEN is a custom list.


Program listing:


{9.513507699, 4.590843712, 2.991568988, 

2.218159544, 1.772453851, 1.489192249,

1.298055333, 1.164229714, 1.068628702

1}→L^TEN

ClrHome

Disp "GAMMA X (NEAREST 0.1)"

Input "X≥0.1, X?",X

round(X,1)→X

fPart(X)*10→F

If F=0:10→F

1→G

While X>1

G*(X-1)→G

X-1→X

End

G*L^TEN(F)→G

Disp "EST. GAMMA: ", G


TI-NSpire Python Script:  gammaten.py


The code is defined as a function.   


def gammaten(x):

  lten=[9.513507699]

  lten.append(4.590843712)

  lten.append(2.991568988)

  lten.append(2.218159544)

  lten.append(1.772453851)

  lten.append(1.489192249)

  lten.append(1.298055333)

  lten.append(1.164229714)

  lten.append(1.068628702)

  lten.append(1)

  #print("gamma(x) to the nearest 0.1")

  x=round(x,1)

  f=round(10*(x-int(x))-1)

  g=1

  while x>1:

    x-=1

    g*=x

  g*=lten[f]

  return [g,f]


# list[-1] gets last item too

# round integers for accurate results!

# 2022-06-13 EWS


Eddie 


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


HP Prime: Curve Fitting to Approximate the Zeta Function

HP Prime:  Curve Fitting to Approximate the Zeta Function


Introduction



Here are three approximations for the zeta functions for the positive real numbers x.  For the test data, I used the interval 2 ≤ x ≤ 12.   


For the even integers, exact values are given, otherwise decimal approximations are given.


2,  ζ(2) = π^2 / 6

3,  ζ(3) ≈ 1.202056903

4,  ζ(4) = π^4 / 90

5,  ζ(5) ≈ 1.036927755

6,  ζ(6) = π^6 / 945

7,  ζ(7) ≈ 1.008349277

8,  ζ(8) = π^8 / 9450

9,  ζ(9) ≈ 1.002008392

10,  ζ(10) = π^10 / 93555

11,  ζ(11) ≈ 1.000494189

12,  ζ(12) = 691 * π^12 / 638512875


For x → ∞, ζ → 1


Here are results from three curve fits.  I have tried to include curve fits of at least 10^-2.


Inverse Regression:  Y = A / X + B


Y = 1.42232589936/X+0.81893671619


Average Absolute Error:  5.49240669397ᴇ−2





Logistic Regression:  Y = A / (1 - B * (e^(C * X))


Y = 1.00164385688/(1-2.09727867903*e^(-0.839946048322*X))


Average Absolute Error:  1.41745186091ᴇ−3





Custom Regression:  Y = A + B / X + C X + D X^2


Y = -0.269041227527+(3.20690850188/X)+0.163810293025*X-6.77810226165ᴇ−3*X^2


Average Absolute Error:  1.05418780589ᴇ−2


HP Prime Program:


EXPORT zetamatrix()

BEGIN

LOCAL R,C;

M1:=MAKEMAT(1,11,4);

M2:=MAKEMAT(approx(CAS.Zeta(I+1)),11,1);

FOR R FROM 1 TO 11 DO

M1(R,2):=approx(1/(R+1));

M1(R,3):=approx(R+1);

M1(R,4):=approx((R+1)^2);

END;


END;





Coming up:  Python Week:  August 1 to August 5, 2022

Next Post:  August 2, 2022


Eddie


All original content copyright, © 2011-2022.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


Backlink 9999 Traffic Super

Order Now...!!!!