Questions tagged [derivative]

In calculus, a derivative is a measure of a function's rate of change as its input changes.

Loosely speaking, a derivative can be thought of as how much one quantity is changing in response to changes in some other quantity; for example, the derivative of the position of a moving object with respect to time is the object's instantaneous velocity.

The derivative of a function at a chosen input value describes the best linear approximation of the function near that input value. For a real-valued function of a single real variable, the derivative at a point equals the slope of the tangent line to the graph of the function at that point. In higher dimensions, the derivative of a function at a point is a linear transformation called the linearization.1 A closely related notion is the differential of a function.

The process of finding a derivative is called differentiation. The reverse process is called antidifferentiation. The fundamental theorem of calculus states that antidifferentiation is the same as integration. Differentiation and integration constitute the two fundamental operations in single-variable calculus.

enter image description here

845 questions
7
votes
2 answers

Can SymPy recognize the derivative of a product?

In the program below, SymPy does not seem to understand that the integrand is the derivative of a product. Is there a way to make it return u*v? import sympy x = sympy.symbols('x', real=True) u = sympy.Function('u') v =…
Rastapopoulos
  • 487
  • 2
  • 18
7
votes
2 answers

How can I get derivative value in R?

I want to get the derivative value from the function below when x = 2. Is there way to keep the form of the function and also get derivative value with out any additional package? f <- function(x) return(x^3) For example, I have tried below but…
user8878064
  • 71
  • 1
  • 1
  • 3
7
votes
1 answer

How is the gradient and hessian of logarithmic loss computed in the custom objective function example script in xgboost's github repository?

I would like to understand how the gradient and hessian of the logloss function are computed in an xgboost sample script. I've simplified the function to take numpy arrays, and generated y_hat and y_true which are a sample of the values used in the…
Greg
  • 8,175
  • 16
  • 72
  • 125
6
votes
4 answers

Get the derivative of a function_handle in MATLAB

Is it possible to get the derivative of a function_handle as a other function_handle? Like: fun1 = @(x) x^2; % do that ... disp(fun2); @(x) x*2 I know how to find the derivative of a symbolic function but I can't convert a function_handle…
user839791
  • 671
  • 1
  • 6
  • 5
6
votes
1 answer

PyTorch gradient differs from manually calculated gradient

I'm trying to compute the gradient of 1/x without using Pytorch's autograd. I use the formula grad(1/x, x) = -1/x**2. When I compare my result with this formula to the gradient given by Pytorch's autograd, they're different. Here is my code: a =…
6
votes
1 answer

non-uniform spacing with numpy.gradient

I'm not sure how to specify non-uniform spacing when using numpy.gradient. Here's some example code for y = x**2. import numpy as np import matplotlib.pyplot as plt x = [0.0, 2.0, 4.0, 8.0, 16.0] y = [0.0, 4.0, 16.0, 64.0, 256.0] dydx = [0.0, 4.0,…
Aaron
  • 85
  • 2
  • 7
6
votes
1 answer

Numerical calculation of curvature

I would like to calculate local curvature i.e at each point. I have a set of data points that a equally spaced in x. Below is the code for generating curvature. data=np.loadtxt('newsorted.txt') #data with uniform spacing x=data[:,0] y=data[:,1] dx…
newstudent
  • 402
  • 6
  • 19
6
votes
3 answers

Nullability (Regular Expressions)

In Brzozowski's "Derivatives of Regular Expressions" and elsewhere, the function δ(R) returning λ if a R is nullable, and ∅ otherwise, includes clauses such as the following: δ(R1 + R2) = δ(R1) + δ(R2) δ(R1 · R2) = δ(R1) ∧ δ(R2) Clearly, if both R1…
emi
  • 5,380
  • 1
  • 27
  • 45
6
votes
1 answer

Number density distribution of an 1D-array - 2 different attempts

I have an large array of elements that I call RelDist (In which dimensionally, is a unit of distance) in a simulated volume. I am attempting to determine the distribution for the "number of values per unit volume" which is also number density. It…
iron2man
  • 1,787
  • 5
  • 27
  • 39
6
votes
3 answers

How do you evaluate a derivative in python?

I'm a beginner in python. I've recently learned about Sympy and its symbolic manipulation capabilities, in particular, differentiation. I am trying to do the following in the easiest way possible: Define f(x,y) = x^2 + xy^2. Differentiate f with…
user3843183
6
votes
1 answer

Why does my Sympy code calculate the first order Taylor series approximation incorrectly?

I have an expression like this which is entered into Sympy like this (for the sake of a reproducible example in this question) from sympy import * expression = Add(Mul(Integer(-1), Float('0.9926375361451395', prec=2),…
Michael A
  • 4,391
  • 8
  • 34
  • 61
6
votes
3 answers

Function for polynomials of arbitrary order (symbolic method preferred)

I've found polynomial coefficients from my data: R <- c(0.256,0.512,0.768,1.024,1.28,1.437,1.594,1.72,1.846,1.972,2.098,2.4029) Ic <- c(1.78,1.71,1.57,1.44,1.25,1.02,0.87,0.68,0.54,0.38,0.26,0.17) NN <- 3 ft <- lm(Ic ~ poly(R, NN, raw = TRUE)) pc <-…
user4489658
6
votes
4 answers

Calculating a 3D gradient with unevenly spaced points

I currently have a volume spanned by a few million every unevenly spaced particles and each particle has an attribute (potential, for those who are curious) that I want to calculate the local force (acceleration) for. np.gradient only works with…
brokenseas
  • 310
  • 1
  • 12
6
votes
1 answer

How do I get the derivative of the function?

How do I get the derivative of the following function? g <- expression(x^2) derivg <- D(g, 'x') derivg # 2 * x g1 <- derivg(2) # Error: could not find function "derivg" I want to find the derivative at x = 2.
6
votes
2 answers

Why are dFdx/ddx and dFdy/ddy 2 dimension variables when quering a 2d texture?

I cannot seem to understand this, shouldn't the derivative/change along the U or V coordinate in a 2d texture/array be single dimension variable as we are checking it only along ddx (U coordinate) or ddy (V coordinate)?
Nims
  • 477
  • 1
  • 5
  • 12
1 2
3
56 57