---
title: "Discrete Logarithms"
canonical: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/log.html"
source: "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/log.md"
part: "Lattices and Quadratic Forms"
chapter: "Binary Quadratic Forms"
breadcrumbs:
  - {"title": "Magma Handbook", "source": "https://docs.magma-maths.org/v2.30-1/index.md"}
  - {"title": "Lattices and Quadratic Forms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/index-lattices-quadratic-forms.md"}
  - {"title": "Binary Quadratic Forms", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/index-binary-quadratic-forms.md"}
prev: {"title": "Class Groups", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/class-group.md"}
next: {"title": "Elliptic and Modular Invariants", "source": "https://docs.magma-maths.org/v2.30-1/LatticesQuadraticForms/BinaryQuadraticForms/invar.md"}
intrinsics:
  - {"name": "Log", "signature": "Log(b, x): QuadBinElt, QuadBinElt -> RngIntElt"}
  - {"name": "Log", "signature": "Log(b, x, t): QuadBinElt, QuadBinElt, RngIntElt -> RngIntElt"}
---

# Discrete Logarithms

<a id="function-log-quadbinelt-quadbinelt"></a>
## `Log(b, x): QuadBinElt, QuadBinElt -> RngIntElt`

The discrete logarithm of binary quadratic form $x$ with respect to base $b$, or -1 if Magma can that determine no solution exists. This function exists only for negative discriminant forms. Computation is done via the Pohlig-Hellman algorithm along with a collision search subroutine (a variant of Pollard’s rho method). If the user is unsure whether a solution exists, it is safest to use `Log` with a time limit (see below) to prevent an infinite loop in the collision search.

<a id="function-log-quadbinelt-quadbinelt-rngintelt"></a>
## `Log(b, x, t): QuadBinElt, QuadBinElt, RngIntElt -> RngIntElt`

Searches for up to $t$ seconds for the discrete logarithm of binary quadratic form $x$ with respect to base $b$. This function exists only for negative discriminant forms. If Magma is able to determine no solution exists, then -1 will be returned. If no solution is found within the given time frame, then -2 will be returned. Computation is done via the Pohlig-Hellman algorithm along with a collision search subroutine (a variant of Pollard’s rho method).
