Design a site like this with WordPress.com
Get started

Euler’s Number e : A Dart (Flutter) Implementation

Introduction: Euler’s Number , also known as Euler’s Constant and denoted by ‘e’ is a constant value as well as an irrational number . Its approximate value is 2.718281828459045, or 2.71828 in short for quick calculation . Most modern programming languages include this value in their Math libraries, for example: C++’s exp() or Dart’s e displays the Euler’s Constant .

We shall write a Dart (Flutter) program to calculate the Euler’s Number, ‘e’ :

import ‘dart:math’;

// class to work with Euler’s value
class CalculateEuler{

// method to calculate ‘e’
void calculateEuler(){

// taking a specific constant named special_constant to calculate ‘e’
int special_constant = 99999991726;

// calculating ‘e’ without Math library’s assistance
num calculated_euler = pow((1 + (1/special_constant)),special_constant);

// displaying the calculated (approximate) ‘e’
print(“My Calculation: ” + calculated_euler.toString());
}
}

void main() {

// taking an instance of CalculateEuler class
CalculateEuler euler = CalculateEuler();

// calling the method on the instance
euler.calculateEuler();

// displaying the original value of ‘e’ from Dart’s Math library
print(“Actual e: ” + e.toString());
// print(exp(1)) displays the same value of ‘e’
}


The calculated value in this Dart (Flutter) program results in 2.7182818284464436 that is close to the actual value of ‘e’ (i.e. 2.718281828459045) that is showed as well .

Applications of Euler’s Number:

‘e’ is found to be used far and wide, including but not limited to:
1. Probability
2. Radioactivity
3. Pharmaceuticals
4. Bernoulli Trials
5. Standard Normal Distribution

Advertisement

Published by Farial Mahmod Tishan

Life-long learner. Developing Flutter apps on Parrot Linux OS .

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: