annuity
Compute the present value interest factor of an annuity. The input parameter is a real number.
Interface Definition
C interface:
float annuityf(float x, float y);
double annuity(double x, double y);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- If x is greater than –1 and y ∈ (–∞, +∞), the computing result is returned.
- If x is any value and y is ±0, the return value is 0.
- If x is NaN and y is any value, the return value is NaN.
- If x is any value and y is NaN, the return value is NaN.
- If x is +∞ and y is –1, the return value is –1. If y < –1, the return value is –∞. If y ∈ (–1, 0), the return value is –0.
- If x = 0 and y != 0, the return value is y.
- If x is –1 and y < 0, the return value is –1. If y > 0, the return value is +∞.
- If x < –1 and y != 0, the return value is NaN.
- If y is –∞ and x ∈ (–1, 0), the return value is 1.0/x. If x > 0, the return value is –∞.
- If y is +∞ and x ∈ (–1, 0), the return value is +∞. If x > 0, the return value is 1.0/x.
Dependency
C: "km.h"
Example
C interface:
// print result
printf("annuity(1.0, 10.0) = %.15f\n", annuity(1.0, 10.0));
printf("annuity(0.5, -3.0) = %.15f\n", annuity(0.5, -3.0));
printf("annuity(0.3, -10.0) = %.15f\n", annuity(1.0, 10.0));
printf("annuity(4, 2.0) = %.15f\n", annuity(0.5, -3.0));
printf("annuity(INFINITY, 0) = %.15f\n", annuity(INFINITY, 0));
printf("annuity(INFINITY, 0) = %.15f\n", annuity(INFINITY, 0));
printf("annuity(1.0, NAN) = %.15f\n", annuity(1.0, NAN));
printf("annuity(NAN, 1.0) = %.15f\n", annuity(NAN, 1.0));
printf("annuity(INFINITY, -1.0) = %.15f\n", annuity(INFINITY, -1.0));
printf("annuity(INFINITY, -10.0) = %.15f\n", annuity(INFINITY, -10.0));
printf("annuity(INFINITY, 10.0) = %.15f\n", annuity(INFINITY, 10.0));
printf("annuity(0, 1.0) = %.15f\n", annuity(0, 1.0));
printf("annuity(-1.0, -1.0) = %.15f\n", annuity(-1.0, -1.0));
printf("annuity(-1.0, 1.0) = %.15f\n", annuity(-1.0, 1.0));
printf("annuity(-10.0, 1.0) = %.15f\n", annuity(-10.0, 1.0));
printf("annuity(-0.5, -INFINITY) = %.15f\n", annuity(-0.5, -INFINITY));
printf("annuity(0.5, -INFINITY) = %.15f\n", annuity(0.5, -INFINITY));
printf("annuity(-0.5, INFINITY) = %.15f\n", annuity(-0.5, INFINITY));
printf("annuity(0.5, INFINITY) = %.15f\n", annuity(0.5, INFINITY));
/*
* annuity(1.0, 10.0) = 0.999023437500000
* annuity(0.5, -3.0) = -4.750000000000000
* annuity(0.3, -10.0) = 0.999023437500000
* annuity(4, 2.0) = -4.750000000000000
* annuity(INFINITY, 0) = 0.000000000000000
* annuity(INFINITY, 0) = 0.000000000000000
* annuity(1.0, NAN) = nan
* annuity(NAN, 1.0) = nan
* annuity(INFINITY, -1.0) = -1.000000000000000
* annuity(INFINITY, -10.0) = -inf
* annuity(INFINITY, 10.0) = 0.000000000000000
* annuity(0, 1.0) = 1.000000000000000
* annuity(-1.0, -1.0) = -1.000000000000000
* annuity(-1.0, 1.0) = inf
* annuity(-10.0, 1.0) = nan
* annuity(-0.5, -INFINITY) = -2.000000000000000
* annuity(0.5, -INFINITY) = -inf
* annuity(-0.5, INFINITY) = inf
* annuity(0.5, INFINITY) = 2.000000000000000
*
* */
Parent topic: Special Functions