Difference between revisions of "Area"

 
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
[[Category:Array-reducing functions]]
 
[[Category:Array-reducing functions]]
 +
[[Category:Integration (Quadrature) functions]]
 +
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
  
(this page is a stub -- it contains info of new-to-4.0, but needs to be updated/reorganized to be a general reference page)
+
== Area(y, x'', x1, x2, i'') ==
 +
Returns the area (sum of trapezoids) under the continuous curve described by the points (x_i, y_i), on the interval ''x1 &le; x &le; x2''. «x1» and «x2» are optional.  When «x» or «y» is an index, then it is safe to omit «i».  «x» and «y» should always have an index in common.
  
= Declaration =
+
In the simple usage, the second parameter, «x», is an index with increasing numeric values, and «y» is indexed by «x». You can visualize «y» as a function of «x», and [[Area]] returns the area under the curve obtained when «x» is plotted on the X-axis and «y» on the Y-axis.
  Area( R : Numeric[J] ; I : ascending Numeric[J] ; X1,X2 : opt numeric atomic ; J : opt hidden IndexType = I )
 
  
With J not specified, I can be an index with numeric ascending values, or it can be a self-indexed array with arbitrary index values but with numeric ascending values along Self.
+
== Using an array for «x» ==
 +
When your X-axis values are in an array, e.g., <code>x_val</code> and <code>y_val</code> are both arrays indexed by <code>In</code>, and you want the area from <code>lb &le; x_val &le; ub</code>, you can use:
 +
:<code>Area(y_val, x_val, lb, ub, In1)</code>
  
The J parameter also makes it possible to have an arbitrary X array:
+
Here the x-axis values are taken from the X-array rather than from the index ''i''.  If «x1» and «x2» are omitted, you can write
Area( Y, X, J: In1)
+
:<code>Area(y, x, i: In1)</code>
  
where X and Y are arrays indexed by J (X must be ascending along J).
+
or equivalently
 +
:<code>Area(y, x,,, In1)</code>
  
Some notes: J is hidden from the user, since the main concern was fixing several bugs with the function while maintaining backward compatibility.  However, as the above example shows, it can be useful.  The second parameter is named I for legacy reasons, but it would be better named X with the J parameter named I.  Consider this change when updating manuals.
+
When using an array of values for the X-axis, the index, «i», may contain arbitrary values, but X must always contain numeric (or [[Null]]) values.
  
Another difference relative to 3.1 is that X2 (upper bound) can be specified while not specifying X1 (lower bound).  So, for example, you could find the area up to a given point, e.g.:
+
== Discontinuities and treatment of null values ==
var dens := Pdf(Ch1);
+
When the same value of «x» occurs twice, this encodes a discontinuity in the function at that value.  The first occurrence provides the «y» value to the left, while the last occurrence provides the «y» value to the right.
Area( dens, dens.Step, X2:x )
+
 
 +
When «x» contains a [[Null]] value, that point is ignored and does not impact the final result.
 +
 
 +
When «y» contains a [[Null]] value, this is interpreted as a ''gap'' in the function, and the trapezoid extending form the previous «x» value to the next next «x» value is not included in the area. 
 +
 
 +
See the wiki page for [[Integrate]] for more details on both these points.
 +
 
 +
== History==
 +
To improve consistency with [[Integrate]] and [[Normalize]], and improve clarity, the names of the parameters to [[Area]] were changed in Analytica 4.2.  Previously the parameters were: [[Area]](r, i, x1, x2, j).  Models that utilized named parameters will thus encounter a syntax error when loaded into 4.2.  We believe this will occur extremely rarely.
 +
 
 +
Analytica 4.2 allows the points to be in any order, while earlier releases require points to increasing in «x».  Analytica 4.2 also allows [[Null]] values in the data.
 +
 
 +
Another difference relative to 3.1 is that «x2» (upper bound) can be specified while not specifying «x1» (lower bound).  So, for example, you could find the area up to a given point, e.g.:
 +
:<code>Var dens := Pdf(Ch1);</code>
 +
:<code>Area(dens, dens.Step, X2: x)</code>
 +
 
 +
== See Also ==
 +
* [[Integrate]]
 +
* [[Normalize]]
 +
* [[Gauss_Quadrature_Pts]] (for Gauss-Legendre Quadrature)
 +
* [[Array-reducing functions]]
 +
* [[:Category:Integration (Quadrature) functions]]

Latest revision as of 22:15, 3 July 2024


Area(y, x, x1, x2, i)

Returns the area (sum of trapezoids) under the continuous curve described by the points (x_i, y_i), on the interval x1 ≤ x ≤ x2. «x1» and «x2» are optional. When «x» or «y» is an index, then it is safe to omit «i». «x» and «y» should always have an index in common.

In the simple usage, the second parameter, «x», is an index with increasing numeric values, and «y» is indexed by «x». You can visualize «y» as a function of «x», and Area returns the area under the curve obtained when «x» is plotted on the X-axis and «y» on the Y-axis.

Using an array for «x»

When your X-axis values are in an array, e.g., x_val and y_val are both arrays indexed by In, and you want the area from lb ≤ x_val ≤ ub, you can use:

Area(y_val, x_val, lb, ub, In1)

Here the x-axis values are taken from the X-array rather than from the index i. If «x1» and «x2» are omitted, you can write

Area(y, x, i: In1)

or equivalently

Area(y, x,,, In1)

When using an array of values for the X-axis, the index, «i», may contain arbitrary values, but X must always contain numeric (or Null) values.

Discontinuities and treatment of null values

When the same value of «x» occurs twice, this encodes a discontinuity in the function at that value. The first occurrence provides the «y» value to the left, while the last occurrence provides the «y» value to the right.

When «x» contains a Null value, that point is ignored and does not impact the final result.

When «y» contains a Null value, this is interpreted as a gap in the function, and the trapezoid extending form the previous «x» value to the next next «x» value is not included in the area.

See the wiki page for Integrate for more details on both these points.

History

To improve consistency with Integrate and Normalize, and improve clarity, the names of the parameters to Area were changed in Analytica 4.2. Previously the parameters were: Area(r, i, x1, x2, j). Models that utilized named parameters will thus encounter a syntax error when loaded into 4.2. We believe this will occur extremely rarely.

Analytica 4.2 allows the points to be in any order, while earlier releases require points to increasing in «x». Analytica 4.2 also allows Null values in the data.

Another difference relative to 3.1 is that «x2» (upper bound) can be specified while not specifying «x1» (lower bound). So, for example, you could find the area up to a given point, e.g.:

Var dens := Pdf(Ch1);
Area(dens, dens.Step, X2: x)

See Also

Comments


You are not allowed to post comments.