Writing L-functions in Python (or any other language)

  • #1
DAntanov
5
1
TL;DR Summary
I am interested in the steps to implement L-functions (of any kind) in python.
Not many code examples exist for how one would go about writing an L-function. Can anyone give me a step-by-step run down of how to do this and/or link me to relevant resources?
 
Technology news on Phys.org
  • #2
CORRECTION: This misinterprets what the OP meant by L-function. (See posts #6 and #7)
Here is a simple example in many languages, including Python.
A Python L-function:
def adder(x):
    return lambda y: x + y
add5 = adder(5)
add5(1)
6
 
Last edited:
  • Like
Likes DAntanov
  • #3
What kind of L-functions are we talking about? At first I assumed it was automorphic, but after the first reply I am lost.
 
  • #4
martinbn said:
What kind of L-functions are we talking about? At first I assumed it was automorphic, but after the first reply I am lost.
My guess is that the OP is asking about lambda functions. @FactChecker is making the same assumption.
 
  • #5
DAntanov said:
TL;DR Summary: I am interested in the steps to implement L-functions (of any kind) in python.

Not many code examples exist for how one would go about writing an L-function.
Assuming that what you're really asking about are lambda functions, there are tons of examples online. Here are just a few (search string -- python lambda function)
https://www.w3schools.com/python/python_lambda.asp
https://realpython.com/python-lambda/
https://www.programiz.com/python-programming/anonymous-function
https://www.learnbyexample.org/python-lambda-function/

Many other programming languages also provide support for user-defined lambda functions.
 
  • #6
If the OP means Dirichlet L-functions, then chapters 25 and 27 of the NIST Digital Library of Mathematical Functions seem to be a good place to start. However since none of the Methods of Computation, Tables, or Software sections mention Dirichlet L-functions - except § 25.21(ix) which states "No research software has been found for these functions" - I suspect they have not been implemented in any language.
 
  • Like
Likes FactChecker
  • #7
pasmith said:
If the OP means Dirichlet L-functions, then chapters 25 and 27 of the NIST Digital Library of Mathematical Functions seem to be a good place to start. However since none of the Methods of Computation, Tables, or Software sections mention Dirichlet L-functions - except § 25.21(ix) which states "No research software has been found for these functions" - I suspect they have not been implemented in any language.
This elaborates my question perfectly. I'm sorry for the vague language in my last post. I am curious about automorphic and Dirichlet L-functions, and became very lost after the first few replies here. I stumbled upon these fairly plain implementations on github: https://github.com/JamesShakarji/L-Function-Types
 
  • Like
Likes FactChecker

1. What is an L-function in mathematical terms?

An L-function is a complex function defined by a Dirichlet series, often associated with number theory and related fields. It typically generalizes the Riemann zeta function and has connections to the distribution of prime numbers, modular forms, and other arithmetic objects.

2. How do I start writing an L-function in Python?

To write an L-function in Python, you can start by defining a function that calculates its Dirichlet series. This involves creating a series sum where each term is a function of the primes or coefficients derived from number-theoretic or geometric objects. Using libraries like SymPy or mpmath can help handle complex numbers and high-precision arithmetic required for such calculations.

3. What are the key components of an L-function in a programming context?

In programming, key components of an L-function include the coefficients, which are often related to arithmetic or geometric data, and the Euler product or Dirichlet series representation. Efficient computation of these components, error handling, and convergence considerations are crucial for accurate implementations.

4. Can you provide a simple example of an L-function in Python?

Yes, a simple example is the Riemann zeta function, a special case of an L-function. Here's a basic implementation in Python:

def zeta(s, n_terms=100):    return sum(1 / (k ** s) for k in range(1, n_terms + 1))
This function calculates the Riemann zeta function at s using the first n_terms of the series.

5. What are common challenges in writing L-functions in programming languages?

Common challenges include managing numerical stability and precision, especially for complex values and high values of parameters. Handling the convergence of series and products, optimizing performance for large inputs, and accurately modeling the mathematical properties of L-functions (like functional equations and analytic continuation) are also significant challenges.

Similar threads

  • Programming and Computer Science
4
Replies
107
Views
5K
  • Programming and Computer Science
Replies
1
Views
281
  • Programming and Computer Science
Replies
10
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
3
Views
1K
  • Programming and Computer Science
Replies
3
Views
719
  • Programming and Computer Science
Replies
3
Views
319
  • Programming and Computer Science
Replies
1
Views
694
Replies
46
Views
3K
Replies
6
Views
1K
Back
Top