Learn R Programming

FindAllRoots (version 1.0)

f: function returning one function value, or a vector of function values.

Description

function returning one function value, or a vector of function values.

Usage

f(x, a, b)

Arguments

x
either one value or a vector containing the x-value(s)
a
vector of coefficients of the equation
b
vector of exponention of the equation,One one corresponding with a mentioned above

Value

the value(s) of the function equation,one function value, or a vector of function values.

Details

the function f that estimates the function values will be called as f(x, ...). If x is a vector, then the first argument passed to f should also be a vector.

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.
a=c(2,-1,-13,-1,-5)
b=c(4:0)
x=c(1:3)
f(x,a,b)

## The function is currently defined as
function (x, a, b) 
{
    z = 0
    for (i in 1:length(b)) z = z + a[i] * x^(b[i])
    z
  }

Run the code above in your browser using DataLab