octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #63950] trapz inconsistent results and error m


From: Chad Oldfield
Subject: [Octave-bug-tracker] [bug #63950] trapz inconsistent results and error messages with empty inputs
Date: Wed, 22 Mar 2023 12:57:25 -0400 (EDT)

Follow-up Comment #8, bug #63950 (project octave):

As I think more on this, it seems that the context matters.

In one example,

x = a:dx:(a + b);
y = trapz(x, f(x))

When repeated with b approaching zero, the integration range decreases, as
does the number of elements in x.  Then y would approach 0, unless there's an
asymptote in f at a.  This might explain the choice by Mathworks to return 0
in some cases.

In another example,

x = linspace(a, a + b, n);
y = trapz(x, f(x))

When repeated with n approaching 0, the numerical integration becomes
progressively more erroneous until it becomes 0 when n = 1, and quite
undefined when n = 0.  This is even though in theory one might instead choose
to reduce the trapezoidal technique to just b * f(x+b/2) when n = 1 (but
Octave cannot because trapz no longer has the integration bounds with n = 1).


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?63950>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]