Skip to main content

Derivatives with R

  • Chapter
  • First Online:
Applied Calculus with R
  • 801 Accesses

Abstract

The Deriv  package in R has a function that performs symbolic differentiation. The first line in R Code box 15.1 loads the Deriv package with the library command (this assumes the packages has been installed on your computer with install.packages(“Deriv") as noted in Chapter 1). Recall that a package has to be loaded only once per session and so we won’t have library(Deriv) in the examples below after the first example. The second line defines the CO2 function. The third line sets CO2_p to the derivative of CO2 using the Deriv function. We use the convention of adding _p to denote the derivative of a function in R since we don’t have the option of using a prime. In other words, we use f_p for the derivative of f in R because we cannot use \(f'(x)\). The last line outputs the derivative function. Note that Deriv(CO2) by itself will produce this output but by assigning CO2_p to Deriv(CO2) we can use the CO2_p function. For example, R Code box 15.2 outputs the derivative of CO2 for 2017 with CO2_p(67), which we estimated in Chapter 4 and calculated in example 11.8.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 89.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Thomas J. Pfaff .

Rights and permissions

Reprints and permissions

Copyright information

© 2023 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Pfaff, T.J. (2023). Derivatives with R. In: Applied Calculus with R. Springer, Cham. https://doi.org/10.1007/978-3-031-28571-4_15

Download citation

Publish with us

Policies and ethics