Breaking News

Microsoft Excel Exponential Integral Function

суббота 02 февраля admin 21
Integrals

Function Library. 168 functions are available in Petroleum Office Excel Addin. Function Category Description; 1 ModifiedHyperbolicDeclineRate: Decline. The exponential integral function - Ei(x) 139 ProximalInterpolate: Utilities. Download naruto sound effects.

In inputbox input x and n exponential function: e^x=1+ x/1! +.x^n/n!; n!=1*2*3.*n inside the function we can use t(n)=x^n/n!

And for recurrence formula t(n)=t(n-1)*x/n The partial sum to the n-th clause is expressed with s(n) which is; s(n)=s(n-1)+t(n) then e=1+s(n) the calculation will repeat until i=n and t(n) . Here's a solution that avoids using the ^ operator, there's not much point in doing that, cos you could hard code e as a constant and do e^n in code. Anyway, your keeping of a running total for the value seemed to be in error.

Dim n As Double Dim x As Double Dim i As Double Dim tn As Double Dim sn As Double Dim t1 As Double Dim e As Double x = CInt(InputBox('x?' )) n = CInt(InputBox('n?'

)) e = 0 tn = 1 e = e + tn 'now e is the first term in the taylor expansion (call this term 0) Do 'add on term 1, 2, 3 i = i + 1 tn = tn * x / i 'this gets the next term from the last e = e + tn 'If x = 0 Then Exit For - not needed, gives tn=0 when x = 0, so it ends below 'the end ing condition wasn't true Loop Until tn = 0 Or -tn. Thanks Kevin. I`d tried your solution and it is working!!!however i have to make the program by using the functions in the question.

Actually i found that i misunderstood the question.This is the question again; Exponential function: e^x=1+ x/1! +.x^n/n!; n!=1*2*3.*n Inside the function we can use t(n)=x^n/n!

And for recurrence formula t(n)=t(n-1)*x/n The partial sum to the n-th clause is expressed with s(n) which is; s(n)=s(n-1)+t(n) Then e=1+s(n) The calculation will repeat until n=100 and t(n) . Your calculation of the terms in the series is not right. The first term has to be calculated before you go into the loop, but that's always 1. Thanks deighton; I`d changed my program by referring your functions and it works. But how can i make that program to calculate until abs(tn). If you look at that, you have a for loop 'nested' in the Do loop, so you will always do 100 iterations, then you will break out of the second loop only if abs(tn) 100 or abs(tn).

I thought it might be nice to write a function in VBA that would evaluate a definite integral, given a string that represents y as a function of x and the lower and upper limit. Here's what I came up with: Function INTEG(exp As String, min As Double, max As Double) Dim t As Double Dim x As Integer Dim range As Double Dim exparray(5000) As Double Dim dx As Double range = max - min dx = range / 5000 t = min x = 0 Do Until x = 5000 exparray(x) = Evaluate(Replace(exp, 'x', CStr(t))) * dx + 0.5 * dx * Abs(Evaluate(Replace(exp, 'x', CStr(t + dx))) - Evaluate(Replace(exp, 'x', CStr(t)))) t = t + dx x = x + 1 Loop INTEG = WorksheetFunction.Sum(exparray) End Function It works pretty well so far - it uses the trapezoid rule so it's pretty accurate. And it works with most integrated excel functions. For example: =INTEG('x^2+3*x+ln(x)',1,9) in a cell gives a value of 3. I just thought I'd share that with anyone who might be able to use it. Also, one problem I'm having with it is that any cell or function in the expression string that has the character 'x' in it gives me an error.