Inferensys

Glossary

Polynomial Approximation

A mathematical technique that substitutes non-linear activation functions with low-degree polynomial equivalents, enabling their computation within homomorphic encryption schemes natively restricted to addition and multiplication.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
CRYPTOGRAPHIC COMPUTATION

What is Polynomial Approximation?

The mathematical technique of substituting non-linear functions with low-degree polynomials to enable their evaluation within homomorphic encryption schemes that natively support only addition and multiplication.

Polynomial approximation is the process of replacing non-linear activation functions—such as ReLU, sigmoid, or tanh—with low-degree polynomial equivalents to enable their computation on encrypted data. Because homomorphic encryption schemes like CKKS and BFV only support addition and multiplication natively, any non-polynomial operation must be approximated to execute within the encrypted domain without decryption.

The accuracy of the approximation is governed by the polynomial's degree: higher-degree polynomials yield tighter fits to the original function but consume more of the ciphertext's noise budget and multiplicative depth. Common techniques include Chebyshev approximation and minimax approximation, which minimize the maximum error over a specified input interval, balancing computational cost against inference fidelity in encrypted inference pipelines.

THE CORE OF HE COMPATIBILITY

Key Characteristics of Polynomial Approximation

Polynomial approximation is the critical bridge that enables complex machine learning functions to operate within the constraints of homomorphic encryption schemes, which natively support only addition and multiplication.

01

The Fundamental Constraint

Homomorphic encryption (HE) schemes like CKKS and BFV are algebraically restricted to addition and multiplication operations on ciphertexts. Non-linear functions—such as ReLU, sigmoid, tanh, and max pooling—cannot be evaluated directly. Polynomial approximation replaces these functions with polynomials that can be computed using only the allowed operations.

  • Core Insight: Any continuous function on a closed interval can be uniformly approximated by a polynomial (Weierstrass approximation theorem).
  • Practical Impact: This transforms an incompatible neural network into a circuit evaluable under encryption.
02

Approximation Methodologies

Several mathematical techniques are employed to find the optimal polynomial representation, each with distinct trade-offs in accuracy and computational depth.

  • Minimax Approximation: Finds the polynomial that minimizes the maximum absolute error over the target interval. The Remez algorithm is the standard tool, producing the optimal polynomial for a given degree.
  • Least Squares Fitting: Minimizes the average squared error, often using Chebyshev nodes to avoid Runge's phenomenon at interval boundaries.
  • Taylor Series: A simple local approximation around a single point, but error grows rapidly away from the expansion point, making it unsuitable for wide intervals.
  • Interpolation: Forces the polynomial to match the target function exactly at specific points, but can oscillate wildly between them if not carefully designed.
03

The Depth-Accuracy Trade-off

The choice of polynomial degree directly impacts both the approximation error and the computational cost under encryption.

  • Higher Degree = Better Accuracy: A degree-7 polynomial can approximate ReLU with near-perfect fidelity on a bounded interval, while a degree-3 polynomial introduces noticeable smoothing.
  • Higher Degree = Greater Depth: Each polynomial evaluation consumes the noise budget and requires a specific multiplicative depth. A degree-7 polynomial requires a circuit depth of 3 (using Horner's method or Estrin's scheme), while degree-3 requires depth 2.
  • Bootstrapping Cost: If the required depth exceeds the scheme's native capacity, a computationally expensive bootstrapping operation is needed to refresh the ciphertext, often dominating inference latency.
04

Interval Management and Domain Extension

Polynomial approximations are only accurate within a predefined bounded interval. Inputs outside this range cause catastrophic error divergence.

  • Input Normalization: Neural network activations must be statistically bounded. Techniques like batch normalization and fixed scaling ensure inputs stay within the approximation's valid domain.
  • Piecewise Polynomials: For functions with complex behavior, the domain is split into sub-intervals, each with its own low-degree polynomial. Under HE, selecting the correct sub-interval requires a multiplexer implemented via encrypted comparisons.
  • Composition: Functions like softmax are decomposed into a sequence of approximable primitives: exponential approximation, summation, and reciprocal approximation.
05

Standard ML Replacements

Common neural network activation functions have well-studied polynomial substitutes optimized for HE evaluation.

  • ReLU → Square or Low-Degree Polynomial: The standard ReLU, max(0, x), is replaced by or a degree-4 minimax polynomial that closely tracks the ReLU shape on [-1, 1].
  • Sigmoid / Tanh → Low-Degree Minimax: These smooth functions are well-approximated by degree-3 or degree-5 polynomials on a bounded interval like [-8, 8].
  • Max Pooling → Scaled Mean or Polynomial Softmax: The non-differentiable max operation is replaced by a smooth approximation like the LogSumExp function, which itself is built from exponentials and logarithms, each requiring polynomial approximation.
  • Division → Reciprocal Approximation: For operations like batch normalization, division is implemented by approximating 1/x with a polynomial and multiplying.
06

Precision and Application Suitability

The inherent approximation error must be evaluated against the application's tolerance for numerical imprecision.

  • CKKS and Approximate Arithmetic: The CKKS scheme is designed for approximate fixed-point arithmetic, making it the natural pairing for polynomial approximation. It treats least-significant-bit errors as noise, aligning with the approximation error.
  • Inference vs. Training: Encrypted inference is highly practical with polynomial approximations, as a pre-trained model's weights are fixed and the approximation error can be validated offline. Encrypted training is significantly harder because gradients must also be approximated, compounding errors.
  • Accuracy Validation: The final encrypted model's accuracy must be benchmarked against the original plaintext model on a held-out test set to ensure the approximation error does not degrade predictive performance below acceptable thresholds.
POLYNOMIAL APPROXIMATION

Frequently Asked Questions

Clear answers to common questions about replacing non-linear functions with polynomials for homomorphic encryption.

Polynomial approximation is the mathematical technique of replacing non-linear functions—such as the sigmoid, ReLU, or softmax—with low-degree polynomials, enabling their evaluation within homomorphic encryption (HE) schemes that natively support only addition and multiplication. Since HE ciphertexts cannot directly compute division, comparison, or transcendental operations, a function like max(0, x) must be approximated by a polynomial P(x) that closely mimics its behavior over a defined input interval. The approximation is typically derived using methods like minimax approximation, Chebyshev interpolation, or Taylor series expansion, with the goal of minimizing the maximum absolute error while keeping the polynomial degree as low as possible to manage the noise budget and computational latency.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.