HP Forums
[HP41] Lambda Modular function; question - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: [HP41] Lambda Modular function; question (/thread-19366.html)



[HP41] Lambda Modular function; question - floppy - 12-31-2022 12:17 PM

Hello,
is anywhere a program to calculate the points of lambda with an HP41? RPN or RPN in MOD or Microcode in MOD? with complex numbers.
In Wiki, there is a curve https://en.wikipedia.org/wiki/Modular_lambda_function#/media/File:Lambda_function.svg
First I would like to calculate several points of
a) lambda(i*x) then
b) (e^(1/e))*(1-lambda(i*x)) then..
x between 0 and 10.
Any advise is welcome.
(if none exists in HP41 - or HP71 -, I will look at other calculator or PC-computing)


RE: [HP41] Lambda Modular function; question - Ángel Martin - 01-07-2023 11:15 AM

Here's a quick & dirty routine using 12 terms of the q-expansion and the 41Z.
More terms would be needed for better accuracy near the origin in the imaginary axis.

Input: Im(z) in Y, Re(z) in X

Code:

 01*LBL "ZML"
 02 ZENTER^
 03 PI
 04 0
 05 Z*
 06 ZEXP
 07 ENTER^
 08 ENTER^
 09 ENTER^
 10 13504512
 11 CHS
 12 *
 13 5702208
 14 +
 15 *
 16 2320128
 17 -
 18 *
 19 904784
 20 +
 21 *
 22 335872
 23 -
 24 *
 25 117632
 26 +
 27 *
 28 38400
 29 -
 30 *
 31 11488
 32 +
 33 *
 34 3072
 35 -
 36 *
 37 704
 38 +
 39 *
 40 128
 41 -
 42 *
 43 16
 44 +
 45 *
 46 END



RE: [HP41] Lambda Modular function; question - floppy - 01-07-2023 05:38 PM

Thanks. For comparison in python.

Code:
import math as math
from mpmath import *
import matplotlib.pyplot as plt
import numpy as np
#
mp.dps = 25
mp.pretty = True
#
# Knowledge
# https://mpmath.org/doc/current/functions/elliptic.html
# https://mpmath.org/doc/current/functions/hypergeometric.html
# green curve = https://en.wikipedia.org/wiki/Modular_lambda_function#/media/File:Lambda_function.svg
# https://en.wikipedia.org/wiki/Modular_lambda_function
#
def func_fromk(p_in): 
# because p_in must be a number and not an array from np..
    return kfrom(tau=p_in*j)
#
N = 50
Wide = 3.
X = np.arange(0.,Wide,Wide/N)
Y1 = np.zeros(N)
Y2 = np.zeros(N)
#
# Y1 equal this? https://www.desmos.com/calculator/00bdl5omnf?lang=de
#
for i in range(N):
    Y1[i]=(1-((np.abs(func_fromk((Wide/N)*i)))**2))*((np.exp(1))**(1/(np.exp(1))))
    Y2[i]=(np.abs(func_fromk((Wide/N)*i)))**2
#
plt.plot(X,Y1,'r-')
plt.plot(X,Y2,'g-')
#
plt.xlabel('X')
plt.ylabel('.. of X*j (green) and (1-(..of (X*j)))*(e**(1/e)))')
plt.title('lambda of ..')
plt.grid()

# https://matplotlib.org/stable/gallery/lines_bars_and_markers/psd_demo.html#sphx-glr-gallery-lines-bars-and-markers-psd-demo-py
Steps=0.2
Xticks = np.arange(0, Wide, Steps)
plt.xticks(Xticks)
Yticks = np.arange(0, 1.8, Steps)
plt.yticks(Yticks)
plt.show()