Coder Social home page Coder Social logo

deriv's Introduction

Deriv

Symbolic differentiation

The original version of this software was written in R by Andrew Clausen (clausen at econ.upenn.edu) in 2007.

Mark Reid (mark.reid at anu.edu.au) sent a patch, applied 21/2/2009.

In 2014, Andrew has passed the maintenance to Serguei Sokol (sokol at insa-toulouse.fr). Since then, the software was deeply rewritten and completed.

Main new features include:

  • new derivative engine allowing simple syntaxe for differentiation rules;
  • many new functions are added to the rule table;
  • custom differentiation rules can be added by user;
  • automatic differentiation (AD) of a code with multiple assignement operators;
  • when taking derivative of a function Deriv() returns a function too. The later can be called with the same arguments as the original function;
  • can differentiate by variables stored in vectors or lists, e.g. param$theta or x[1], x[2] etc.
  • simplifications are extended to rational expressions and factorizations;
  • expression caching is enabled by default;
  • Deriv() is made the only entry point for all types of entries:
    • expression
    • language
    • function
    • right hand side of a formula
    • character string
    • plain unevaluated code
  • few unit tests were added to the package

Installation

> devtools::install_github("sgsokol/Deriv")

Usage

In R session do:

> library(Deriv)
> f <- function(x, n=2) x^n+sin(n*x)     # user defined function to diffierentiate
> (df <- Deriv(f))                       # -> c(x = n * x^(n - 1) + n * cos(n * x), n = log(x) * x^n + x * cos(n * x))
> df(2, 3)                               # ->         x         n
                                         # -> 14.880511  7.465518

> Deriv(expression(f(y, 3)), "y")        # -> expression(3 * y^2 + 3 * cos(3 * y))
> Deriv(~ f(y, 3), "y")                  # -> 3 * y^2 + 3 * cos(3 * y)
> y <- 2; eval(Deriv(~ f(y, 3), "y"))    # -> 14.88051

For more information and examples:

> ?Deriv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.