Skip to content

Add Euler's number (E) as a mathematical constantΒ #8133

@ayushman1210

Description

@ayushman1210

πŸ“‚ Issue Category

  • Feature Request ✨

πŸ“ Issue Summary

Add Euler's number (E) as a new mathematical constant in p5.js

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build process
  • Unit testing
  • Internationalization
  • Friendly errors
  • Other (specify if possible)

Feature request details


πŸ”Ή Description

Euler's number (E, approximately 2.71828) is a fundamental mathematical constant representing the base of natural logarithms. It plays a crucial role in:

  • Exponential growth and decay models
  • Compound interest calculations
  • Probability distributions (e.g., Poisson, exponential)
  • Calculus and differential equations
  • Natural phenomena simulations

p5.js currently provides several mathematical constants (PI, TWO_PI, HALF_PI, TAU), but notably lacks E. Adding this constant would:

  • Complete the set of essential mathematical constants
  • Eliminate the need for users to define E manually or use Math.E
  • Maintain consistency with the library's existing constant naming conventions
  • Enhance p5.js's utility for mathematical visualizations and educational projects

πŸ”Ή Proposed Implementation

1. Add constant definition in src/core/constants.js:

/**
 * The mathematical constant Euler's number (e), the base of natural logarithms.
 * It is approximately equal to 2.71828.
 *
 * @property {Number} E
 * @final
 * @example
 * <div><code>
 * // Calculate exponential growth
 * let growth = E ** 2;
 * text('eΒ² = ' + growth.toFixed(4), 10, 50);
 * </code></div>
 */
export const E = Math.E;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions