or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

core-arithmetic.mdelementary-functions.mdelliptic-modular-functions.mdindex.mdlinear-algebra.mdmathematical-constants.mdnumerical-calculus.mdpattern-recognition.mdsignal-processing.mdspecial-functions.mdvisualization.md

special-functions.mddocs/

0

# Special Functions

1

2

Advanced mathematical functions including gamma functions, zeta functions, Bessel functions, hypergeometric functions, elliptic functions, and other special functions from mathematical physics and number theory.

3

4

## Capabilities

5

6

### Gamma Function and Related

7

8

The gamma function and related special functions.

9

10

```python { .api }

11

def gamma(x):

12

"""

13

Gamma function Γ(x).

14

15

Args:

16

x: Input number

17

18

Returns:

19

Γ(x) = ∫₀^∞ t^(x-1) e^(-t) dt

20

"""

21

22

def rgamma(x):

23

"""

24

Reciprocal gamma function 1/Γ(x).

25

26

Args:

27

x: Input number

28

29

Returns:

30

1/Γ(x)

31

"""

32

33

def loggamma(x):

34

"""

35

Logarithm of gamma function ln|Γ(x)|.

36

37

Args:

38

x: Input number

39

40

Returns:

41

ln|Γ(x)|

42

"""

43

44

def factorial(n):

45

"""

46

Factorial function n!.

47

48

Args:

49

n: Non-negative integer or real number

50

51

Returns:

52

n! = Γ(n+1)

53

"""

54

55

def fac(n):

56

"""

57

Factorial function (alias for factorial).

58

59

Args:

60

n: Non-negative integer or real number

61

62

Returns:

63

n!

64

"""

65

66

def fac2(n):

67

"""

68

Double factorial n!!.

69

70

Args:

71

n: Integer

72

73

Returns:

74

n!! (product of every second integer)

75

"""

76

77

def binomial(n, k):

78

"""

79

Binomial coefficient C(n,k) = n!/(k!(n-k)!).

80

81

Args:

82

n, k: Numbers

83

84

Returns:

85

Binomial coefficient

86

"""

87

88

def rf(x, n):

89

"""

90

Rising factorial (Pochhammer symbol) (x)_n.

91

92

Args:

93

x: Base

94

n: Count

95

96

Returns:

97

(x)_n = x(x+1)(x+2)...(x+n-1)

98

"""

99

100

def ff(x, n):

101

"""

102

Falling factorial.

103

104

Args:

105

x: Base

106

n: Count

107

108

Returns:

109

x(x-1)(x-2)...(x-n+1)

110

"""

111

```

112

113

### Beta Function

114

115

Beta function and incomplete beta function.

116

117

```python { .api }

118

def beta(x, y):

119

"""

120

Beta function B(x,y).

121

122

Args:

123

x, y: Input numbers

124

125

Returns:

126

B(x,y) = Γ(x)Γ(y)/Γ(x+y)

127

"""

128

129

def betainc(a, b, x1=0, x2=1):

130

"""

131

Incomplete beta function.

132

133

Args:

134

a, b: Shape parameters

135

x1, x2: Integration limits (default: 0, 1)

136

137

Returns:

138

Incomplete beta integral

139

"""

140

```

141

142

### Polygamma Functions

143

144

Polygamma functions (derivatives of logarithm of gamma function).

145

146

```python { .api }

147

def psi(m, x):

148

"""

149

Polygamma function ψ^(m)(x).

150

151

Args:

152

m: Order (0 for digamma, 1 for trigamma, etc.)

153

x: Input number

154

155

Returns:

156

mth derivative of ln(Γ(x))

157

"""

158

159

def digamma(x):

160

"""

161

Digamma function ψ(x) = Γ'(x)/Γ(x).

162

163

Args:

164

x: Input number

165

166

Returns:

167

ψ(x) = d/dx ln(Γ(x))

168

"""

169

170

def polygamma(m, x):

171

"""

172

Polygamma function (alias for psi).

173

174

Args:

175

m: Order

176

x: Input number

177

178

Returns:

179

ψ^(m)(x)

180

"""

181

```

182

183

### Zeta Functions

184

185

Riemann zeta function and related functions.

186

187

```python { .api }

188

def zeta(s):

189

"""

190

Riemann zeta function ζ(s).

191

192

Args:

193

s: Complex number

194

195

Returns:

196

ζ(s) = Σ 1/n^s (for Re(s) > 1)

197

"""

198

199

def altzeta(s):

200

"""

201

Alternating zeta function (Dirichlet eta).

202

203

Args:

204

s: Complex number

205

206

Returns:

207

η(s) = Σ (-1)^(n-1)/n^s

208

"""

209

210

def hurwitz(s, a):

211

"""

212

Hurwitz zeta function ζ(s,a).

213

214

Args:

215

s: Complex number

216

a: Complex number

217

218

Returns:

219

ζ(s,a) = Σ 1/(n+a)^s

220

"""

221

222

def dirichlet(s):

223

"""

224

Dirichlet eta function η(s).

225

226

Args:

227

s: Complex number

228

229

Returns:

230

η(s) = (1-2^(1-s))ζ(s)

231

"""

232

233

def polylog(s, z):

234

"""

235

Polylogarithm Li_s(z).

236

237

Args:

238

s: Order

239

z: Argument

240

241

Returns:

242

Li_s(z) = Σ z^n/n^s

243

"""

244

245

def lerchphi(z, s, a):

246

"""

247

Lerch transcendent Φ(z,s,a).

248

249

Args:

250

z, s, a: Complex numbers

251

252

Returns:

253

Φ(z,s,a) = Σ z^n/(n+a)^s

254

"""

255

256

def stieltjes(n):

257

"""

258

Stieltjes constants γ_n.

259

260

Args:

261

n: Non-negative integer

262

263

Returns:

264

nth Stieltjes constant

265

"""

266

```

267

268

### Number Theory Functions

269

270

Functions related to prime numbers and number theory.

271

272

```python { .api }

273

def primepi(x):

274

"""

275

Prime counting function π(x).

276

277

Args:

278

x: Real number

279

280

Returns:

281

Number of primes ≤ x

282

"""

283

284

def primepi2(x):

285

"""

286

Offset logarithmic integral π₂(x).

287

288

Args:

289

x: Real number

290

291

Returns:

292

π₂(x) = π(x) - π(√x)

293

"""

294

295

def primezeta(s):

296

"""

297

Prime zeta function P(s).

298

299

Args:

300

s: Complex number

301

302

Returns:

303

P(s) = Σ 1/p^s (sum over primes p)

304

"""

305

306

def riemannr(x):

307

"""

308

Riemann R function.

309

310

Args:

311

x: Real number

312

313

Returns:

314

R(x) = Σ μ(k)/k * li(x^(1/k))

315

"""

316

317

def mangoldt(n):

318

"""

319

Von Mangoldt function Λ(n).

320

321

Args:

322

n: Positive integer

323

324

Returns:

325

ln(p) if n = p^k for prime p, 0 otherwise

326

"""

327

328

def secondzeta(x):

329

"""

330

Second Chebyshev function ψ(x).

331

332

Args:

333

x: Real number

334

335

Returns:

336

ψ(x) = Σ Λ(n) for n ≤ x

337

"""

338

```

339

340

### Error Functions

341

342

Error function and related integrals.

343

344

```python { .api }

345

def erf(x):

346

"""

347

Error function erf(x).

348

349

Args:

350

x: Input number

351

352

Returns:

353

erf(x) = (2/√π) ∫₀^x e^(-t²) dt

354

"""

355

356

def erfc(x):

357

"""

358

Complementary error function erfc(x).

359

360

Args:

361

x: Input number

362

363

Returns:

364

erfc(x) = 1 - erf(x)

365

"""

366

367

def erfi(x):

368

"""

369

Imaginary error function erfi(x).

370

371

Args:

372

x: Input number

373

374

Returns:

375

erfi(x) = -i * erf(ix)

376

"""

377

378

def erfinv(x):

379

"""

380

Inverse error function.

381

382

Args:

383

x: Input number (-1 < x < 1)

384

385

Returns:

386

Inverse of erf(x)

387

"""

388

389

def npdf(x, mu=0, sigma=1):

390

"""

391

Normal probability density function.

392

393

Args:

394

x: Input value

395

mu: Mean (default 0)

396

sigma: Standard deviation (default 1)

397

398

Returns:

399

PDF of normal distribution

400

"""

401

402

def ncdf(x, mu=0, sigma=1):

403

"""

404

Normal cumulative distribution function.

405

406

Args:

407

x: Input value

408

mu: Mean (default 0)

409

sigma: Standard deviation (default 1)

410

411

Returns:

412

CDF of normal distribution

413

"""

414

```

415

416

### Exponential Integrals

417

418

Exponential integral and related functions.

419

420

```python { .api }

421

def expint(n, x):

422

"""

423

Exponential integral E_n(x).

424

425

Args:

426

n: Order

427

x: Input number

428

429

Returns:

430

E_n(x) = ∫₁^∞ e^(-xt)/t^n dt

431

"""

432

433

def e1(x):

434

"""

435

Exponential integral E₁(x).

436

437

Args:

438

x: Input number

439

440

Returns:

441

E₁(x) = ∫_x^∞ e^(-t)/t dt

442

"""

443

444

def ei(x):

445

"""

446

Exponential integral Ei(x).

447

448

Args:

449

x: Input number

450

451

Returns:

452

Ei(x) = ∫_{-∞}^x e^t/t dt

453

"""

454

455

def li(x):

456

"""

457

Logarithmic integral li(x).

458

459

Args:

460

x: Input number

461

462

Returns:

463

li(x) = ∫₀^x dt/ln(t)

464

"""

465

466

def ci(x):

467

"""

468

Cosine integral Ci(x).

469

470

Args:

471

x: Input number

472

473

Returns:

474

Ci(x) = -∫_x^∞ cos(t)/t dt

475

"""

476

477

def si(x):

478

"""

479

Sine integral Si(x).

480

481

Args:

482

x: Input number

483

484

Returns:

485

Si(x) = ∫₀^x sin(t)/t dt

486

"""

487

488

def chi(x):

489

"""

490

Hyperbolic cosine integral Chi(x).

491

492

Args:

493

x: Input number

494

495

Returns:

496

Chi(x) = ∫₀^x (cosh(t)-1)/t dt

497

"""

498

499

def shi(x):

500

"""

501

Hyperbolic sine integral Shi(x).

502

503

Args:

504

x: Input number

505

506

Returns:

507

Shi(x) = ∫₀^x sinh(t)/t dt

508

"""

509

```

510

511

### Lambert W Function and Inverse Functions

512

513

The Lambert W function and related inverse special functions.

514

515

```python { .api }

516

def lambertw(z, k=0):

517

"""

518

Lambert W function W_k(z), the inverse of f(w) = w*exp(w).

519

520

Args:

521

z: Input number

522

k: Branch index (integer), default 0

523

524

Returns:

525

W_k(z) such that W_k(z) * exp(W_k(z)) = z

526

"""

527

```

528

529

### Fresnel Integrals

530

531

Fresnel sine and cosine integrals.

532

533

```python { .api }

534

def fresnels(x):

535

"""

536

Fresnel sine integral S(x).

537

538

Args:

539

x: Input number

540

541

Returns:

542

S(x) = ∫₀^x sin(πt²/2) dt

543

"""

544

545

def fresnelc(x):

546

"""

547

Fresnel cosine integral C(x).

548

549

Args:

550

x: Input number

551

552

Returns:

553

C(x) = ∫₀^x cos(πt²/2) dt

554

"""

555

```

556

557

### Bessel Functions

558

559

Bessel functions of various kinds.

560

561

```python { .api }

562

def besselj(n, x):

563

"""

564

Bessel function of the first kind J_n(x).

565

566

Args:

567

n: Order

568

x: Argument

569

570

Returns:

571

J_n(x)

572

"""

573

574

def j0(x):

575

"""

576

Bessel function J₀(x).

577

578

Args:

579

x: Argument

580

581

Returns:

582

J₀(x)

583

"""

584

585

def j1(x):

586

"""

587

Bessel function J₁(x).

588

589

Args:

590

x: Argument

591

592

Returns:

593

J₁(x)

594

"""

595

596

def bessely(n, x):

597

"""

598

Bessel function of the second kind Y_n(x).

599

600

Args:

601

n: Order

602

x: Argument

603

604

Returns:

605

Y_n(x)

606

"""

607

608

def besseli(n, x):

609

"""

610

Modified Bessel function of the first kind I_n(x).

611

612

Args:

613

n: Order

614

x: Argument

615

616

Returns:

617

I_n(x)

618

"""

619

620

def besselk(n, x):

621

"""

622

Modified Bessel function of the second kind K_n(x).

623

624

Args:

625

n: Order

626

x: Argument

627

628

Returns:

629

K_n(x)

630

"""

631

632

def hankel1(n, x):

633

"""

634

Hankel function of the first kind H₁_n(x).

635

636

Args:

637

n: Order

638

x: Argument

639

640

Returns:

641

H₁_n(x) = J_n(x) + i*Y_n(x)

642

"""

643

644

def hankel2(n, x):

645

"""

646

Hankel function of the second kind H₂_n(x).

647

648

Args:

649

n: Order

650

x: Argument

651

652

Returns:

653

H₂_n(x) = J_n(x) - i*Y_n(x)

654

"""

655

656

def besseljzero(n, k):

657

"""

658

kth zero of Bessel function J_n(x).

659

660

Args:

661

n: Order

662

k: Zero index (1, 2, 3, ...)

663

664

Returns:

665

kth positive zero of J_n(x)

666

"""

667

668

def besselyzero(n, k):

669

"""

670

kth zero of Bessel function Y_n(x).

671

672

Args:

673

n: Order

674

k: Zero index (1, 2, 3, ...)

675

676

Returns:

677

kth positive zero of Y_n(x)

678

"""

679

```

680

681

### Hypergeometric Functions

682

683

Generalized hypergeometric functions.

684

685

```python { .api }

686

def hyper(a_s, b_s, z):

687

"""

688

Generalized hypergeometric function.

689

690

Args:

691

a_s: List of numerator parameters

692

b_s: List of denominator parameters

693

z: Argument

694

695

Returns:

696

pFq hypergeometric function

697

"""

698

699

def hyp0f1(b, z):

700

"""

701

Confluent hypergeometric limit function ₀F₁(;b;z).

702

703

Args:

704

b: Parameter

705

z: Argument

706

707

Returns:

708

₀F₁(;b;z)

709

"""

710

711

def hyp1f1(a, b, z):

712

"""

713

Confluent hypergeometric function ₁F₁(a;b;z).

714

715

Args:

716

a, b: Parameters

717

z: Argument

718

719

Returns:

720

₁F₁(a;b;z) = M(a,b,z)

721

"""

722

723

def hyp2f1(a, b, c, z):

724

"""

725

Gauss hypergeometric function ₂F₁(a,b;c;z).

726

727

Args:

728

a, b, c: Parameters

729

z: Argument

730

731

Returns:

732

₂F₁(a,b;c;z)

733

"""

734

735

def hyperu(a, b, z):

736

"""

737

Confluent hypergeometric function of the second kind U(a,b,z).

738

739

Args:

740

a, b: Parameters

741

z: Argument

742

743

Returns:

744

U(a,b,z)

745

"""

746

747

def meijerg(a_s, b_s, z):

748

"""

749

Meijer G-function.

750

751

Args:

752

a_s: List of a-parameters

753

b_s: List of b-parameters

754

z: Argument

755

756

Returns:

757

Meijer G-function

758

"""

759

760

def appellf1(a, b1, b2, c, x, y):

761

"""

762

Appell hypergeometric function F₁.

763

764

Args:

765

a, b1, b2, c: Parameters

766

x, y: Arguments

767

768

Returns:

769

F₁(a;b₁,b₂;c;x,y)

770

"""

771

772

def appellf2(a, b1, b2, c1, c2, x, y):

773

"""

774

Appell hypergeometric function F₂.

775

776

Args:

777

a, b1, b2, c1, c2: Parameters

778

x, y: Arguments

779

780

Returns:

781

F₂(a;b₁,b₂;c₁,c₂;x,y)

782

"""

783

784

def appellf3(a1, a2, b1, b2, c, x, y):

785

"""

786

Appell hypergeometric function F₃.

787

788

Args:

789

a1, a2, b1, b2, c: Parameters

790

x, y: Arguments

791

792

Returns:

793

F₃(a₁,a₂;b₁,b₂;c;x,y)

794

"""

795

796

def appellf4(a, b, c1, c2, x, y):

797

"""

798

Appell hypergeometric function F₄.

799

800

Args:

801

a, b, c1, c2: Parameters

802

x, y: Arguments

803

804

Returns:

805

F₄(a,b;c₁,c₂;x,y)

806

"""

807

808

def hyp1f2(a, b1, b2, z):

809

"""

810

Hypergeometric function ₁F₂(a;b₁,b₂;z).

811

812

Args:

813

a: Numerator parameter

814

b1, b2: Denominator parameters

815

z: Argument

816

817

Returns:

818

₁F₂(a;b₁,b₂;z)

819

"""

820

821

def hyp2f2(a1, a2, b1, b2, z):

822

"""

823

Hypergeometric function ₂F₂(a₁,a₂;b₁,b₂;z).

824

825

Args:

826

a1, a2: Numerator parameters

827

b1, b2: Denominator parameters

828

z: Argument

829

830

Returns:

831

₂F₂(a₁,a₂;b₁,b₂;z)

832

"""

833

834

def hyp2f0(a1, a2, z):

835

"""

836

Hypergeometric function ₂F₀(a₁,a₂;;z).

837

838

Args:

839

a1, a2: Numerator parameters

840

z: Argument

841

842

Returns:

843

₂F₀(a₁,a₂;;z)

844

"""

845

846

def hyp2f3(a1, a2, b1, b2, b3, z):

847

"""

848

Hypergeometric function ₂F₃(a₁,a₂;b₁,b₂,b₃;z).

849

850

Args:

851

a1, a2: Numerator parameters

852

b1, b2, b3: Denominator parameters

853

z: Argument

854

855

Returns:

856

₂F₃(a₁,a₂;b₁,b₂,b₃;z)

857

"""

858

859

def hyp3f2(a1, a2, a3, b1, b2, z):

860

"""

861

Hypergeometric function ₃F₂(a₁,a₂,a₃;b₁,b₂;z).

862

863

Args:

864

a1, a2, a3: Numerator parameters

865

b1, b2: Denominator parameters

866

z: Argument

867

868

Returns:

869

₃F₂(a₁,a₂,a₃;b₁,b₂;z)

870

"""

871

872

def hyper2d(a_s, b_s, z1, z2):

873

"""

874

2D hypergeometric function.

875

876

Args:

877

a_s: List of numerator parameters

878

b_s: List of denominator parameters

879

z1, z2: Arguments

880

881

Returns:

882

2D hypergeometric function

883

"""

884

885

def bihyper(a_s, b_s, z):

886

"""

887

Bilateral hypergeometric function.

888

889

Args:

890

a_s: List of a-parameters

891

b_s: List of b-parameters

892

z: Argument

893

894

Returns:

895

Bilateral hypergeometric series

896

"""

897

898

def hypercomb(a_s, b_s, z_s, **kwargs):

899

"""

900

Linear combination of hypergeometric functions.

901

902

Args:

903

a_s: List of a-parameter lists

904

b_s: List of b-parameter lists

905

z_s: List of arguments

906

**kwargs: Additional options

907

908

Returns:

909

Linear combination result

910

"""

911

```

912

913

### Orthogonal Polynomials

914

915

Classical orthogonal polynomials and related functions.

916

917

```python { .api }

918

def legendre(n, x):

919

"""

920

Legendre polynomial P_n(x).

921

922

Args:

923

n: Degree (non-negative integer)

924

x: Argument

925

926

Returns:

927

P_n(x)

928

"""

929

930

def legenp(n, m, x):

931

"""

932

Associated Legendre function of the first kind P_n^m(x).

933

934

Args:

935

n: Degree

936

m: Order

937

x: Argument

938

939

Returns:

940

P_n^m(x)

941

"""

942

943

def legenq(n, m, x):

944

"""

945

Associated Legendre function of the second kind Q_n^m(x).

946

947

Args:

948

n: Degree

949

m: Order

950

x: Argument

951

952

Returns:

953

Q_n^m(x)

954

"""

955

956

def chebyt(n, x):

957

"""

958

Chebyshev polynomial of the first kind T_n(x).

959

960

Args:

961

n: Degree

962

x: Argument

963

964

Returns:

965

T_n(x) = cos(n*arccos(x))

966

"""

967

968

def chebyu(n, x):

969

"""

970

Chebyshev polynomial of the second kind U_n(x).

971

972

Args:

973

n: Degree

974

x: Argument

975

976

Returns:

977

U_n(x) = sin((n+1)*arccos(x))/sin(arccos(x))

978

"""

979

980

def hermite(n, x):

981

"""

982

Hermite polynomial H_n(x).

983

984

Args:

985

n: Degree (non-negative integer)

986

x: Argument

987

988

Returns:

989

H_n(x) (physicist's convention)

990

"""

991

992

def laguerre(n, a, x):

993

"""

994

Generalized Laguerre polynomial L_n^(a)(x).

995

996

Args:

997

n: Degree

998

a: Parameter (default 0 for simple Laguerre)

999

x: Argument

1000

1001

Returns:

1002

L_n^(a)(x)

1003

"""

1004

1005

def gegenbauer(n, a, x):

1006

"""

1007

Gegenbauer (ultraspherical) polynomial C_n^(a)(x).

1008

1009

Args:

1010

n: Degree

1011

a: Parameter

1012

x: Argument

1013

1014

Returns:

1015

C_n^(a)(x)

1016

"""

1017

1018

def spherharm(l, m, theta, phi):

1019

"""

1020

Spherical harmonic Y_l^m(θ,φ).

1021

1022

Args:

1023

l: Degree (l ≥ 0)

1024

m: Order (|m| ≤ l)

1025

theta: Polar angle (0 ≤ θ ≤ π)

1026

phi: Azimuthal angle (0 ≤ φ < 2π)

1027

1028

Returns:

1029

Y_l^m(θ,φ)

1030

"""

1031

1032

def jacobi(n, a, b, x):

1033

"""

1034

Jacobi polynomial P_n^(a,b)(x).

1035

1036

Args:

1037

n: Degree

1038

a, b: Parameters (a, b > -1)

1039

x: Argument

1040

1041

Returns:

1042

P_n^(a,b)(x)

1043

"""

1044

```

1045

1046

### Parabolic Cylinder Functions

1047

1048

Parabolic cylinder functions and related Weber functions.

1049

1050

```python { .api }

1051

def pcfd(n, z):

1052

"""

1053

Parabolic cylinder function D_n(z).

1054

1055

Args:

1056

n: Order

1057

z: Argument

1058

1059

Returns:

1060

D_n(z)

1061

"""

1062

1063

def pcfu(a, x):

1064

"""

1065

Parabolic cylinder function U(a,x).

1066

1067

Args:

1068

a: Parameter

1069

x: Argument

1070

1071

Returns:

1072

U(a,x)

1073

"""

1074

1075

def pcfv(a, x):

1076

"""

1077

Parabolic cylinder function V(a,x).

1078

1079

Args:

1080

a: Parameter

1081

x: Argument

1082

1083

Returns:

1084

V(a,x)

1085

"""

1086

1087

def pcfw(a, x):

1088

"""

1089

Parabolic cylinder function W(a,x).

1090

1091

Args:

1092

a: Parameter

1093

x: Argument

1094

1095

Returns:

1096

W(a,x)

1097

"""

1098

```

1099

1100

### Airy Functions

1101

1102

Airy functions and their zeros.

1103

1104

```python { .api }

1105

def airyai(z):

1106

"""

1107

Airy function Ai(z).

1108

1109

Args:

1110

z: Argument (real or complex)

1111

1112

Returns:

1113

Ai(z)

1114

"""

1115

1116

def airybi(z):

1117

"""

1118

Airy function Bi(z).

1119

1120

Args:

1121

z: Argument (real or complex)

1122

1123

Returns:

1124

Bi(z)

1125

"""

1126

1127

def airyaizero(k):

1128

"""

1129

kth zero of Airy function Ai(x).

1130

1131

Args:

1132

k: Zero index (1, 2, 3, ...)

1133

1134

Returns:

1135

kth negative zero of Ai(x)

1136

"""

1137

1138

def airybizero(k):

1139

"""

1140

kth zero of Airy function Bi(x).

1141

1142

Args:

1143

k: Zero index (1, 2, 3, ...)

1144

1145

Returns:

1146

kth negative zero of Bi(x)

1147

"""

1148

1149

def scorergi(z):

1150

"""

1151

Scorer function Gi(z).

1152

1153

Args:

1154

z: Argument

1155

1156

Returns:

1157

Gi(z)

1158

"""

1159

1160

def scorerhi(z):

1161

"""

1162

Scorer function Hi(z).

1163

1164

Args:

1165

z: Argument

1166

1167

Returns:

1168

Hi(z)

1169

"""

1170

```

1171

1172

### Extended Bessel Function Variants

1173

1174

Additional Bessel function variants and related cylindrical functions.

1175

1176

```python { .api }

1177

def struveh(n, z):

1178

"""

1179

Struve function H_n(z).

1180

1181

Args:

1182

n: Order

1183

z: Argument

1184

1185

Returns:

1186

H_n(z)

1187

"""

1188

1189

def struvel(n, z):

1190

"""

1191

Modified Struve function L_n(z).

1192

1193

Args:

1194

n: Order

1195

z: Argument

1196

1197

Returns:

1198

L_n(z)

1199

"""

1200

1201

def angerj(n, z):

1202

"""

1203

Anger function J_n(z).

1204

1205

Args:

1206

n: Order

1207

z: Argument

1208

1209

Returns:

1210

J_n(z)

1211

"""

1212

1213

def webere(n, z):

1214

"""

1215

Weber function E_n(z).

1216

1217

Args:

1218

n: Order

1219

z: Argument

1220

1221

Returns:

1222

E_n(z)

1223

"""

1224

1225

def lommels1(mu, nu, z):

1226

"""

1227

Lommel function s_μ,ν(z).

1228

1229

Args:

1230

mu, nu: Parameters

1231

z: Argument

1232

1233

Returns:

1234

s_μ,ν(z)

1235

"""

1236

1237

def lommels2(mu, nu, z):

1238

"""

1239

Lommel function S_μ,ν(z).

1240

1241

Args:

1242

mu, nu: Parameters

1243

z: Argument

1244

1245

Returns:

1246

S_μ,ν(z)

1247

"""

1248

1249

def whitm(k, m, z):

1250

"""

1251

Whittaker function M_k,m(z).

1252

1253

Args:

1254

k, m: Parameters

1255

z: Argument

1256

1257

Returns:

1258

M_k,m(z)

1259

"""

1260

1261

def whitw(k, m, z):

1262

"""

1263

Whittaker function W_k,m(z).

1264

1265

Args:

1266

k, m: Parameters

1267

z: Argument

1268

1269

Returns:

1270

W_k,m(z)

1271

"""

1272

1273

def ber(n, x):

1274

"""

1275

Kelvin function ber_n(x).

1276

1277

Args:

1278

n: Order

1279

x: Argument (real)

1280

1281

Returns:

1282

ber_n(x)

1283

"""

1284

1285

def bei(n, x):

1286

"""

1287

Kelvin function bei_n(x).

1288

1289

Args:

1290

n: Order

1291

x: Argument (real)

1292

1293

Returns:

1294

bei_n(x)

1295

"""

1296

1297

def ker(n, x):

1298

"""

1299

Kelvin function ker_n(x).

1300

1301

Args:

1302

n: Order

1303

x: Argument (real)

1304

1305

Returns:

1306

ker_n(x)

1307

"""

1308

1309

def kei(n, x):

1310

"""

1311

Kelvin function kei_n(x).

1312

1313

Args:

1314

n: Order

1315

x: Argument (real)

1316

1317

Returns:

1318

kei_n(x)

1319

"""

1320

1321

def coulombc(l, eta):

1322

"""

1323

Coulomb wave function phase shift C_l(η).

1324

1325

Args:

1326

l: Angular momentum quantum number

1327

eta: Sommerfeld parameter

1328

1329

Returns:

1330

C_l(η)

1331

"""

1332

1333

def coulombf(l, eta, rho):

1334

"""

1335

Regular Coulomb wave function F_l(η,ρ).

1336

1337

Args:

1338

l: Angular momentum quantum number

1339

eta: Sommerfeld parameter

1340

rho: Radial parameter

1341

1342

Returns:

1343

F_l(η,ρ)

1344

"""

1345

1346

def coulombg(l, eta, rho):

1347

"""

1348

Irregular Coulomb wave function G_l(η,ρ).

1349

1350

Args:

1351

l: Angular momentum quantum number

1352

eta: Sommerfeld parameter

1353

rho: Radial parameter

1354

1355

Returns:

1356

G_l(η,ρ)

1357

"""

1358

```

1359

1360

### Elliptic Functions and Integrals

1361

1362

Extended elliptic functions beyond the basic ones.

1363

1364

```python { .api }

1365

def elliprc(x, y):

1366

"""

1367

Carlson elliptic integral RC(x,y).

1368

1369

Args:

1370

x, y: Arguments

1371

1372

Returns:

1373

RC(x,y) = ∫₀^∞ dt/((t+x)√(t+y))/2

1374

"""

1375

1376

def elliprj(x, y, z, p):

1377

"""

1378

Carlson elliptic integral RJ(x,y,z,p).

1379

1380

Args:

1381

x, y, z, p: Arguments

1382

1383

Returns:

1384

RJ(x,y,z,p)

1385

"""

1386

1387

def elliprf(x, y, z):

1388

"""

1389

Carlson elliptic integral RF(x,y,z).

1390

1391

Args:

1392

x, y, z: Arguments

1393

1394

Returns:

1395

RF(x,y,z)

1396

"""

1397

1398

def elliprd(x, y, z):

1399

"""

1400

Carlson elliptic integral RD(x,y,z).

1401

1402

Args:

1403

x, y, z: Arguments

1404

1405

Returns:

1406

RD(x,y,z)

1407

"""

1408

1409

def elliprg(x, y, z):

1410

"""

1411

Carlson elliptic integral RG(x,y,z).

1412

1413

Args:

1414

x, y, z: Arguments

1415

1416

Returns:

1417

RG(x,y,z)

1418

"""

1419

1420

def jacobi(kind, u, m):

1421

"""

1422

Jacobi elliptic functions sn, cn, dn.

1423

1424

Args:

1425

kind: Function type ('sn', 'cn', 'dn', 'ns', 'nc', 'nd', etc.)

1426

u: Argument

1427

m: Parameter (0 ≤ m ≤ 1)

1428

1429

Returns:

1430

Specified Jacobi elliptic function

1431

"""

1432

1433

def agm(a, b):

1434

"""

1435

Arithmetic-geometric mean of a and b.

1436

1437

Args:

1438

a, b: Arguments

1439

1440

Returns:

1441

AGM(a,b)

1442

"""

1443

```

1444

1445

### Additional Number Theory Functions

1446

1447

Additional functions related to number theory and special sequences.

1448

1449

```python { .api }

1450

def bell(n):

1451

"""

1452

Bell number B_n.

1453

1454

Args:

1455

n: Non-negative integer

1456

1457

Returns:

1458

B_n (number of partitions of set with n elements)

1459

"""

1460

1461

def polyexp(s, z):

1462

"""

1463

Polyexponential function.

1464

1465

Args:

1466

s: Parameter

1467

z: Argument

1468

1469

Returns:

1470

Polyexponential Exp_s(z)

1471

"""

1472

1473

def stirling1(n, k):

1474

"""

1475

Stirling number of the first kind.

1476

1477

Args:

1478

n, k: Non-negative integers

1479

1480

Returns:

1481

s(n,k) - unsigned Stirling number of first kind

1482

"""

1483

1484

def stirling2(n, k):

1485

"""

1486

Stirling number of the second kind.

1487

1488

Args:

1489

n, k: Non-negative integers

1490

1491

Returns:

1492

S(n,k) - Stirling number of second kind

1493

"""

1494

1495

def fibonacci(n):

1496

"""

1497

Fibonacci number F_n.

1498

1499

Args:

1500

n: Integer (can be negative)

1501

1502

Returns:

1503

F_n (Fibonacci number)

1504

"""

1505

1506

def fib(n):

1507

"""

1508

Fibonacci number (alias for fibonacci).

1509

1510

Args:

1511

n: Integer

1512

1513

Returns:

1514

F_n

1515

"""

1516

1517

def nzeros(t):

1518

"""

1519

Number of zeta zeros with imaginary part ≤ t.

1520

1521

Args:

1522

t: Real number

1523

1524

Returns:

1525

Count of Riemann zeta zeros

1526

"""

1527

1528

def backlunds(t):

1529

"""

1530

Bounds from Backlund's theorem for zeta zeros.

1531

1532

Args:

1533

t: Real number

1534

1535

Returns:

1536

Backlund bounds

1537

"""

1538

1539

def bernoulli(n):

1540

"""

1541

Bernoulli number B_n.

1542

1543

Args:

1544

n: Non-negative integer

1545

1546

Returns:

1547

B_n (Bernoulli number)

1548

"""

1549

1550

def bernfrac(n):

1551

"""

1552

Bernoulli number as exact fraction.

1553

1554

Args:

1555

n: Non-negative integer

1556

1557

Returns:

1558

B_n as fraction

1559

"""

1560

1561

def bernpoly(n, x):

1562

"""

1563

Bernoulli polynomial B_n(x).

1564

1565

Args:

1566

n: Non-negative integer

1567

x: Argument

1568

1569

Returns:

1570

B_n(x) (Bernoulli polynomial)

1571

"""

1572

1573

def eulernum(n):

1574

"""

1575

Euler number E_n.

1576

1577

Args:

1578

n: Non-negative integer

1579

1580

Returns:

1581

E_n (Euler number)

1582

"""

1583

1584

def eulerpoly(n, x):

1585

"""

1586

Euler polynomial E_n(x).

1587

1588

Args:

1589

n: Non-negative integer

1590

x: Argument

1591

1592

Returns:

1593

E_n(x) (Euler polynomial)

1594

"""

1595

1596

def harmonic(n):

1597

"""

1598

Harmonic number H_n.

1599

1600

Args:

1601

n: Positive integer or real number

1602

1603

Returns:

1604

H_n = 1 + 1/2 + ... + 1/n

1605

"""

1606

1607

def cyclotomic(n, x):

1608

"""

1609

Cyclotomic polynomial Φ_n(x).

1610

1611

Args:

1612

n: Positive integer

1613

x: Argument

1614

1615

Returns:

1616

Φ_n(x) (cyclotomic polynomial)

1617

"""

1618

1619

def unitroots(n):

1620

"""

1621

List of n-th roots of unity.

1622

1623

Args:

1624

n: Positive integer

1625

1626

Returns:

1627

List of complex n-th roots of unity

1628

"""

1629

1630

def barnesg(z):

1631

"""

1632

Barnes G-function G(z).

1633

1634

Args:

1635

z: Input number

1636

1637

Returns:

1638

G(z) (Barnes G-function)

1639

"""

1640

1641

def superfac(n):

1642

"""

1643

Superfactorial of n.

1644

1645

Args:

1646

n: Non-negative integer

1647

1648

Returns:

1649

1! × 2! × ... × n!

1650

"""

1651

1652

def hyperfac(n):

1653

"""

1654

Hyperfactorial of n.

1655

1656

Args:

1657

n: Non-negative integer

1658

1659

Returns:

1660

1^1 × 2^2 × ... × n^n

1661

"""

1662

1663

def clsin(x):

1664

"""

1665

Clausen sine function Cl_2(x).

1666

1667

Args:

1668

x: Input number

1669

1670

Returns:

1671

Cl_2(x) = -∫₀^x ln|2sin(t/2)| dt

1672

"""

1673

1674

def clcos(x):

1675

"""

1676

Clausen cosine function.

1677

1678

Args:

1679

x: Input number

1680

1681

Returns:

1682

Clausen cosine function

1683

"""

1684

1685

def gammainc(s, a, b=None):

1686

"""

1687

Incomplete gamma function.

1688

1689

Args:

1690

s: Parameter

1691

a: Lower limit

1692

b: Upper limit (optional)

1693

1694

Returns:

1695

Incomplete gamma function

1696

"""

1697

1698

def gammaprod(a_s, b_s):

1699

"""

1700

Product of gamma functions.

1701

1702

Args:

1703

a_s: List of numerator arguments

1704

b_s: List of denominator arguments

1705

1706

Returns:

1707

∏Γ(a_i) / ∏Γ(b_j)

1708

"""

1709

1710

def grampoint(n):

1711

"""

1712

n-th Gram point.

1713

1714

Args:

1715

n: Integer

1716

1717

Returns:

1718

n-th Gram point

1719

"""

1720

1721

def siegeltheta(t):

1722

"""

1723

Siegel theta function.

1724

1725

Args:

1726

t: Real number

1727

1728

Returns:

1729

ϑ(t) (Siegel theta function)

1730

"""

1731

1732

def siegelz(t):

1733

"""

1734

Siegel Z function.

1735

1736

Args:

1737

t: Real number

1738

1739

Returns:

1740

Z(t) (Siegel Z function)

1741

"""

1742

1743

def zetazero(n):

1744

"""

1745

n-th zero of Riemann zeta function.

1746

1747

Args:

1748

n: Positive integer

1749

1750

Returns:

1751

n-th nontrivial zero of ζ(s)

1752

"""

1753

```

1754

1755

### Usage Examples

1756

1757

```python

1758

import mpmath

1759

from mpmath import mp

1760

1761

# Set precision

1762

mp.dps = 25

1763

1764

# Gamma function examples

1765

print(f"Γ(5) = {mp.gamma(5)}") # Should be 4! = 24

1766

print(f"Γ(0.5) = {mp.gamma(0.5)}") # Should be √π

1767

print(f"Γ(1/3) = {mp.gamma(mp.mpf(1)/3)}")

1768

1769

# Zeta function

1770

print(f"ζ(2) = {mp.zeta(2)}") # Should be π²/6

1771

print(f"ζ(3) = {mp.zeta(3)}") # Apéry's constant

1772

1773

# Error function

1774

print(f"erf(1) = {mp.erf(1)}")

1775

print(f"erfc(1) = {mp.erfc(1)}")

1776

1777

# Bessel functions

1778

print(f"J₀(1) = {mp.j0(1)}")

1779

print(f"J₁(1) = {mp.j1(1)}")

1780

print(f"Y₀(1) = {mp.bessely(0, 1)}")

1781

1782

# Complex arguments work

1783

z = mp.mpc(1, 1)

1784

print(f"Γ(1+i) = {mp.gamma(z)}")

1785

print(f"J₀(1+i) = {mp.besselj(0, z)}")

1786

1787

# Hypergeometric functions

1788

print(f"₁F₁(1;2;1) = {mp.hyp1f1(1, 2, 1)}")

1789

print(f"₂F₁(1,1;2;0.5) = {mp.hyp2f1(1, 1, 2, 0.5)}")

1790

1791

# Number theory functions

1792

print(f"π(100) = {mp.primepi(100)}") # Number of primes ≤ 100

1793

1794

# Orthogonal polynomials

1795

print(f"P₂(0.5) = {mp.legendre(2, 0.5)}") # Legendre polynomial

1796

print(f"T₃(0.5) = {mp.chebyt(3, 0.5)}") # Chebyshev polynomial

1797

print(f"H₂(1) = {mp.hermite(2, 1)}") # Hermite polynomial

1798

1799

# Elliptic functions

1800

print(f"K(0.5) = {mp.ellipk(0.5)}") # Complete elliptic integral

1801

print(f"sn(1, 0.5) = {mp.jacobi('sn', 1, 0.5)}") # Jacobi elliptic function

1802

1803

# Airy functions

1804

print(f"Ai(1) = {mp.airyai(1)}")

1805

print(f"Bi(1) = {mp.airybi(1)}")

1806

1807

# Additional Bessel function variants

1808

print(f"H₀⁽¹⁾(1) = {mp.hankel1(0, 1)}") # Hankel function

1809

print(f"I₀(1) = {mp.besseli(0, 1)}") # Modified Bessel I

1810

print(f"K₀(1) = {mp.besselk(0, 1)}") # Modified Bessel K

1811

1812

# Special values and identities

1813

print(f"Γ(1/2) = {mp.gamma(0.5)}")

1814

print(f"√π = {mp.sqrt(mp.pi)}")

1815

print(f"Difference: {mp.gamma(0.5) - mp.sqrt(mp.pi)}")

1816

```