Questions tagged [eulers-number]

Euler's number (usually denoted e in mathematics) is a transcendental constant approximately equal to 2.718281828. It is the base of natural logarithms.

The mathematical constant e (wikipedia) can be defined in various equivalent ways:

  • the unique positive real number such that the derivative of the function f(x) = ex is always equal to ex
  • the unique positive real number such that the derivative of the function loge x = 1 / x
  • the limit as n tends to infinity of (1 + 1/n) ^ n
  • the sum of the infinite series 1 / n! as n goes from zero to infinity

Ths first of these accounts for the frequency with which e crops up in models involving compounded growth.

64 questions
123
votes
3 answers

R programming: How do I get Euler's number?

For example, how would I go about entering the value e^2 in R?
tora0515
  • 2,479
  • 12
  • 33
  • 40
19
votes
3 answers

How to calculate Euler constant or Euler powered in C++?

I am trying to find the more 'natural' way to use the number e in C/C++. I am focused on calculating the function e^n. I think that 'cmath', by default, does not provide support for both (function and constant). However, it can be enabled to include…
Antonio
  • 851
  • 2
  • 8
  • 17
9
votes
2 answers

Calculating the e number using Raku

I'm trying to calculate the e constant (AKA Euler's Number) by calculating the formula In order to calculate the factorial and division in one shot, I wrote this: my @e = 1, { state $a=1; 1 / ($_ * $a++) } ... *; say reduce * + * , @e[^10]; But…
8
votes
3 answers

How do I convert a very long binary number to decimal?

I have a binary number represented as 11.1111111 (the . being analogous to a decimal point). There are 2 bits before the point, and 1024 bits after the point. It was an exercise in calculating e to a high level of precision, but now I am stuck as to…
MrPRambo
  • 125
  • 2
  • 6
3
votes
3 answers

Euler's number expansion

#include #include using namespace std; int a[8], e[8]; void term (int n) { a[0]=1; for (int i=0; i<8; i++) { if (i<7) { a[i+1]+=(a[i]%n)*100000; } /* else { …
t3h_lolz
  • 31
  • 3
3
votes
1 answer

Haskell/GHC - Is there a way around Haskell only returning 16 decimal places?

I am trying to write a program in Haskell that returns 'e' (Euler's number) to a given decimal place. Here is my code so far: factorial 0 = 1 factorial n = n * factorial (n - 1) calculateE a | a == 0 = 1 | otherwise = nextLevel where…
3
votes
3 answers

Calculating Euler's Number in C++

Write a program that calculates Euler’s number e. To do this, first write a function that takes a parameter n, and returns the result (1+1/n)n. The limit of this function approaches e as n approaches infinity. In your main program, write a loop that…
Sahat Yalkabov
  • 32,654
  • 43
  • 110
  • 175
2
votes
2 answers

Optimizing an algorithm that approximates the euler number (e) in C

For starters, I'm reinventing the wheel here. I know there is a constant in C for Euler's number. As I find it easier to create scientific programs than any other type of problem, I use these problems to practice and become a good developer. /*…
user8519643
2
votes
3 answers

Improve performance of parallel calculation of euler number

I am trying to calculate e=∑(3−4k^2/(2k+1)!); k=0..10000 However I got stuck and can't get a desired performance boost using multithreading. Given a number of threads, I tried to divide the whole sum to k / numberOfThreads chunks and submit futures…
2
votes
2 answers

My C++ program has trouble calculating this series for Euler's number

Here is the C++ program i wrote to solve the above series: #include #include #include using namespace std; int factorial(int a) { if (a > 1) return a * factorial(a - 1); else return 1; } float…
2
votes
2 answers

Calculating Eulers number using BigDecimal

I am trying to make a program to approximate e by summing the following number series: e = 1 + (1 / 1!) + (1 / 2!) + (1 / 3!) .... + (1 / i!) Currently, my code looks like this: public static void main(String[] args) { BigDecimal one = new…
Esben86
  • 483
  • 8
  • 21
1
vote
1 answer

Plotting imaginary numbers on a complex plane

I'm trying to plot the graph of Euler's formula (e^(ix)) on a complex plane (preferably with matplotlib) to achieve the circular graph (radius i). Is there a way I can do this? So far I've only managed to plot it on a real plane to get a graph in…
AG-88301
  • 127
  • 1
  • 10
1
vote
1 answer

(APL) About the power and circle functions

Why does *○0j1 outputs -1 but *(○0j1) doesn’t? (¯1j1e¯16) What is the difference between them? Expected *(○0j1) to output the same thing as *○0j1
d d
  • 13
  • 2
1
vote
2 answers

Calculating the Euler's Number gives a limited number of decimals on C#

I'm trying to calculate the Euler's number (e = 2.718281828459045235) by doing a factorial function and then calling it to calculate the constant with a while loop. The problem is that I declare an i variable to make the loop work under the…
dann
  • 37
  • 8
1
vote
2 answers

Euler function in C++

Can someone explain me, what is mean this Euler function: int phi (int n) { int result = n; for (int i=2; i*i<=n; ++i) if (n % i == 0) { while (n % i == 0) n /= i; result -= result / i; …
prostak
  • 139
  • 6
1
2 3 4 5