I have a power series idea that is

A) a real-valued vector of length n that originates from another loop and may be quite long, but let's suppose it is simple, for example

a<-1:10

and

B) a genuine facility, such as

c<-3

I want to explain the polynomial (in my example)

a+a*(x-3)+ a*(x-3)^2+ .... + a*(x-3)^9

as a result. Unfortunately

1) I am unable to use the function as.polynomial(a) since, as far as I can see, it only allows centre 0;

2) The list of coefficients can be too extensive to manually calculate.

3) In the future, I might require a multivariable version.

I'd prefer to define this "finite power series" using a loop, but I'm not sure how to achieve it. Jun 22 9 views

## 1 answer to this question.

this will work

```_polynomial = function(x) {
sum(sapply(seq_along(a), function(ii) a[ii] * (x - c) ^ (ii - 1L)))
}``` answered 6 days ago by
• 2,960 points

## How to remove all variables except functions in R?

One line that removes all objects except for functions: rm(list ...READ MORE

## How to evaluate expression given as a string in R?

The eval() function evaluates an expression, but "5+5" is a string, ...READ MORE

## What is the difference between library () and require () functions in R ?

library() require() Library () function gives an error message ...READ MORE

+1 vote

## Difference between factor and as.factor in R programming

Hey @Ali, as.factor is a wrapper for ...READ MORE

## Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

## Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

The below is the code to perform ...READ MORE