Functions Index :: P :: PowSeries

[<< up one level]


numeric :: powseries


PowSeries(float x, string coef_func, string power_func, int start_index, int end_index, int "increment", string "coef_args", string "power_args")


Returns an arbitrary power series of x.

The power series is generated by summing the terms coef_func(index, coef_args) * Pow(x, power_func(index, power_args)) for all indexes in the range [start_index .. end_index), ie end_index is NOT included.

coef_func and power_func user-functions must accept an integer (the index of the series term) as their first argument. Optionally, they can accept other arguments, which can be passed as strings (containing the intermediate commas) with the "coef_args" and "power_args" arguments.


x: The value of which the power series will be calculated.

coef_func: The name of the function that produces the coefficients of the series. coef_args argument.

power_func: The name of the function that produces the powers of the series.

start_index: The index of the first term of the series.

end_index: The first index after the end of the series (that is, no term will be generated for that index).

"increment" (Optional, defaults to 1): The increment between successive indexes of the series.

"coef_args" (Optional, defaults to ""): Additional arguments to pass to the coef_func function.

"power_args" (Optional, defaults to ""):

Notes and conditions on arguments relations:

1] start_index must be <= end_index. In the special case where these two are equal the function returns zero.

2] If coef_args or power_args contain string arguments, the later must be surrounded with double quotes before entering them into the arguments. Use StrQuote for this purpose.

3] Since coef_func and power_func are the first constituents of the constructed string for Eval() you can perform simple operations with constants and globals inside those strings, such as multiplication and addition (eg. set coef_func to "2 + funcname").


# Calculate the power series (2n/n!)*x(2n+1)

# for n=0 to 19 and value of x = 1.4

function mycoef(int i) { return Pow(2, i) / Factorial(i) }

function mypow(int i) { return 2 * i + 1 }

f1 = PowSeries(1.4, "mycoef", "mypow", 0, 20)

# Calculate the power series (2/n!)*x2n for n=4 to 16,

# with step 2 and value of x = 0.5

f2 = PowSeries(0.5, "2 / Factorial", "2 * Self", 4, 18, 2)

# Calculate the power series [Sin(n*pi()*x/a)/(2n)]*x(2n+1)/b

# for n=-10 to 10 (included) and value of

# x = 0.75 with a = 10 and b = Pi()

function mycoef(int i, float x, float a) {

return Sin(i*Pi()*x/a) / Pow(2, i)


function mypow(int i, float b) { return (2 * i + 1)/b }

f3 = PowSeries(0.75, "mycoef", "mypow", -10, 11, 1, "0.75, 10", "Pi()")


[<< top]