Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

derivative of a function

Tags:

r

derivative

I am using D to get derivatives of a function. However, R does not simplify the expression when returning the derivative. I need to figure out if a function has a derivative that can be expressed generically. Is there some way in R to simplify the expression?

> D(expression(sqrt(1 - x^2)), 'x')
-(0.5 * (2 * x * (1 - x^2)^-0.5))
> D(D(expression(sqrt(1 - x^2)), 'x'), 'x')
-(0.5 * (2 * (1 - x^2)^-0.5 - 2 * x * (-0.5 * (2 * x * (1 - x^2)^-1.5))))

Secondly, is there a way in R to do numerical integration?

like image 325
user236215 Avatar asked Jul 27 '10 04:07

user236215


People also ask

What is derivative of a function with example?

We use a variety of different notations to express the derivative of a function. In Example 3.2. 2 we showed that if f(x)=x2−2x, then f′(x)=2x−2. If we had expressed this function in the form y=x2−2x, we could have expressed the derivative as y′=2x−2 or dydx=2x−2.

What is a derivative of a function in calculus?

In very simple words, the derivative of a function f(x) represents its rate of change and is denoted by either f'(x) or df/dx. Let's first look at its definition and a pictorial illustration of the derivative. Illustration of the Definition of a Function Derivative.

What is the derivative formula?

A derivative helps us to know the changing relationship between two variables. Mathematically, the derivative formula is helpful to find the slope of a line, to find the slope of a curve, and to find the change in one measurement with respect to another measurement. The derivative formula is ddx. xn=n.


1 Answers

library(Ryacas)
x <- Sym("x")
Simplify(deriv(sqrt(1 - x^2),x,2))  # return the result simplified

gives

expression((x^2 - 1 - x^2)/root(1 - x^2, 2)^3)

You can also try

PrettyForm(Simplify(deriv(sqrt(1 - x^2),x,2)))

which gives

   2        2  
  x  - 1 - x   
---------------
              3
    /      2 \ 
Sqrt\ 1 - x  / 

As for numerical integration try giving this to see what is available

library(sos)
findFn('{numerical+integration}')
like image 138
George Dontas Avatar answered Oct 25 '22 02:10

George Dontas