Post Reply 
Trapezoidal Rule or Simpsons Rule?
07-05-2015, 10:49 PM
Post: #1
Trapezoidal Rule or Simpsons Rule?
I'm trying to gather ideas to implement a function such as the Trapezoidal Rule, Simpsons Rule (or something similar) on the Prime.

How to supply an input function, then using values from a list, is central to this problem. Specifically, I want to be able to (programmatically) input functions, values for the lower and upper range, and the number of intervals needed, for solving them. A program might begin something like this:

Code:

EXPORT Trap(f,a,b,n)
BEGIN
  local h=(b-a)/n, x; 
  L1:=MAKELIST(X,X,a,b,1/n);  // To create a linear range of function values from a to b. 

//  The following is the objective, but I haven't been able to tweak it for the Prime:

//  I1=(h/2)*(2*sum(f(x))-f(x(1))- f(x(n+1)));  // where x is from the list, L1 

END;

The input variables are the function (f), lower range (a), upper range (b), and the number of intervals (n).

If you can help, thanks!

-Dale-
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Trapezoidal Rule or Simpsons Rule? - DrD - 07-05-2015 10:49 PM



User(s) browsing this thread: 1 Guest(s)