On 12 Feb 2018. 1- for each of you signals (a) and (c) there is a built-in fucntion in matlab to generate them: see th function swatooth for (c), for (a) it is a simple rectangular function, look for it. 2- for calculating the exponential Fourier series look for fourier transform in the help browser of Matlab.
- Write A Program To Compute Exponential Series Pdf
- Write A Program To Compute Exponential Series 2
- Write A Python Program To Compute The Exponential Series
Active6 years, 11 months ago
- Table of Content. C Program to print table of n and square of n using pow() C Program to find Factorial of Number without using function. C Program to find exponent Power Series!! C Program to Compute sum of the array elements using pointers! C Program to find exponent Power Series!!
- Exponential Series: Exponential Series is a series which is used to find the value of e x. The formula used to express the e x as Exponential Series is. Expanding the above notation, the formula of Exponential Series is. For example, Let the value of x be 3. So, the value of e 3 is 20.0855. Program code for Exponential Series in C.
- C Program Write a Program For Sine Series; C Program Calculate Factorial of a Number using Recursion. C Program Write a Program to Find the Exponential Power; C Program For Replace a String. C Program Write Program to Calculate the Quadric Equation; Write Program to Read in an INT and then Print in out DEC, OCT and HEX.
I want to write a function that takes a single floating-point parameter x andreturns the value of the function e(to the power of x) . Using the Taylor series expansionto compute the return value, using a loop that terminates when the partial sum SN+1 of Eq. (2) is equal to SN.
Dont know how to make to the power of so i'm putting in a link to the Wikipedia article for the Taylor Series.
Mat171k3030 gold badges331331 silver badges349349 bronze badges
Wynand KoenWynand Koen
closed as not a real question by Mat, Eitan T, j0k, pad, JunuxxSep 23 '12 at 12:51
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.
3 Answers
Imho there is no need to implement what is already there.
but if you insist, there is the
pow
function also:Write A Program To Compute Exponential Series Pdf
ConstantiniusConstantinius25.4k66 gold badges5555 silver badges8080 bronze badges
Constantinius has a good answer, but I thought I would add that the python shortcut for exponentiation is **.
E.g.
Note however that e**x is handled differently than math.exp(x):
blackfedorablackfedora
the taylor series developed at 0 is:
f(x) = exp(0) + exp(0)/1*x + exp(0)/(1*2)*x^2 + exp(0)/(1*2*3)*x^3 + exp(0)/(1*2*3*4)*x^4 + ..
= 1 + x + 1/2*x^2 + 1/6*x^3 + 1/24*x^4 +..
user1535814user1535814
Not the answer you're looking for? Browse other questions tagged python or ask your own question.
Active2 years, 9 months ago
$begingroup$The original question is to write a Fortran program to compute the sum of the first 20 terms in the exponential equation (for x=1,2,3,4,5):$$sum_{n=0}^infty frac{x^n}{n!} = 1 + frac{x^1}{1!} + frac{x^2}{2!} + frac{x^3}{3!} + frac{x^4}{4!} + frac{x^5}{5!} + ldots$$
My original approach was:
The code could run, but only displayed results up to x=3:
Then, I tried another approach:
and it gave the right results:
I wonder if the second solution is the only correct solution to this question?Is there a way to rectify the first approach to avoid the arithmetic overflow problen in Fortran?
200_success136k2121 gold badges173173 silver badges443443 bronze badges
user3036719user3036719
$endgroup$1 Answer
$begingroup$Well the exponential function is map from reals to reals (usually denoted f:R→R), so I would have expected the use of
real
s for all variables (i.e., x
and n
). However, I'll base my answer using integer
s, as that is what you've used.Using larger integers
Write A Program To Compute Exponential Series 2
Fortran's basic integer precision has a largest integer value of 2147483647, which is exceeded for
4**16=4294967296
. However, you certainly can specify a larger integer type (see the link) and easily fit 4**19=274877906944. This would be as easy as specifying the kind:would become
And you easily get the values you desire.
Alternative implementation
Instead of specifying larger precision, you could express the Taylor-expansion of the exponential as$$e^x = 1 + xcdot left(1 + frac{x}{2}cdotleft(1 + frac{x}{3}cdot left(cdotsright) right) right)$$and write your function as,
(here
n
is your number of terms you want). Fortran will implicitly cast i
and x
as reals (since they are multiplying/dividing a real in f
), so you don't need to worry about larger precision in your integers. This version could also fit easily into a function where you can have the user specify the n
and x
values:which is small enough that a simple
contains
will be fine for your program (i.e., using a module
isn't needed).Other odds-and-ends
Modern Fortran (well, since Fortran 90) does not require the use of capitals for keywords, so you don't need to have your program yell at you that it is printing something or that you're going to specify the
type
s of all variables (i.e., you can use implicit none
, real
and integer
). Most IDEs I know have support for Fortran syntax, so you'll know when you're using keywords.While initializing
f=1.0
in the main will do what you expect, you may want to break the habit of doing so now because you may (accidentally) carry it over to functions where it will have different behaviour.Write A Python Program To Compute The Exponential Series
Community♦
Kyle KanosKyle Kanos
$endgroup$