I am trying to code a root finding algorithm in R that will solve an equation of the form:
integral from xinitial->x of f(x) = a
with inputs of xinitial, a and the form of function f(x).
Do I need to use vectorize to set up the integral values prior to running them through the root finding algorithm?
Example: y=x x1=1 a=2 I was trying to set up the root find to output the value of x2 at which the integral, ((x2^2)/2 )=a+(x1^2)/2.
Tried using
a<-1.5
ftn<-function(x)return(x)
f<-function(x)return(-a+integrate(ftn,1,x)$value +0)
uniroot( f, c(0, 4) )