[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Numerical integration: Simpson and trapezoidal method
From: |
David Lucas |
Subject: |
Numerical integration: Simpson and trapezoidal method |
Date: |
Mon, 4 Oct 2010 14:27:43 +0200 |
Hello,
i've been looking for how to perform a numerical integration with the Simpson's Rule and i found it:
e.g.:
function y = f(x)
y = sqrt(sin(x))
endfunction
quadv("f", 1, pi/2)
It gives me the result of the integration of sqrt(sin(x)) from 1 to PI/2.
The problem is that i also want to set the number of sub-intervals.
In Maple i would do it like this(4 sub-intervals/partitions):
ApproximateInt(sqrt(sin(x)), x = 1 .. 3.141592654*(1/2), method = simpson, partition = 4)
What about trapezoidal method? Does trapz have the same syntax as quadv?
Also, is there any way to plot something like Maple does with the following sentence?:
ApproximateInt(sqrt(sin(x)), x = 1 .. 3.141592654*(1/2), method = simpson, partition = 4, output = plot)
Thank you.
- Numerical integration: Simpson and trapezoidal method,
David Lucas <=