[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: average of a function
From: |
Ted Harding |
Subject: |
RE: average of a function |
Date: |
Tue, 09 Nov 2004 10:10:21 -0000 (GMT) |
On 09-Nov-04 Fred J. wrote:
> Hello
>
> debian 2.6.8 i686-pc-GNU/Linux
> GNU Octave, version 2.1.60
>
> I just started with octave, and appreciate some help
> with this simple
> task, could not get much help from reading the FAQs
> and the manual.
>
> OK,
> I need to determine the average value of this function
> which I expect
> it to be -1.620993 but I am getting a different ans
> and not sure if I am
> using octave correctly.
>
> octave> function y=x(t), y = t^2 - 5*t + 6*cos(pi*t);
> end;
> octave> quad('x', -1, 5/2)
> ans = -5.6735
If I've understood correctly, your code returns the numerical *integral*
of x(t) over the range (-1,2.5). The length of this range is 3.5.
The *average* of the function is the integral divided by the length
of the range. With your numerical answer I get
(-5.6735)/3.5 = -1.621
which is very close to the value (-1.620993) that you expected to get.
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <address@hidden>
Fax-to-email: +44 (0)870 094 0861 [NB: New number!]
Date: 09-Nov-04 Time: 10:10:21
------------------------------ XFMail ------------------------------
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------