Questions tagged [calculus]

Calculus is the study of change of one or more variables with respect to another variable. Calculus has two main operators: differentiation and integration. Differentiation can be used to study the change of one variable with respect to another. Integration can be used to find the area bounded by a function.

Calculus plays an important role in computer science, for example, in the comparison of the performance of various algorithms and the complexity of various problems. These are often expressed using big O notation, which relies on the idea of the limits of ratios of functions as a variable tends to infinity.

On the practical programming side, there are several fields that will require calculus to a greater or lesser extent:

  • Numerical analysis and computation.
  • Signal processing (Image, video, audio, etc).
  • Data analysis and prediction for business applications.
  • Modeling of dynamical systems.
  • Machine learning.
  • Physics engines for video games.
580 questions
238
votes
1 answer

Minimizing NExpectation for a custom distribution in Mathematica

This relates to an earlier question from back in June: Calculating expectation for a custom distribution in Mathematica I have a custom mixed distribution defined using a second custom distribution following along the lines discussed by @Sasha in a…
Jagra
  • 3,149
  • 1
  • 18
  • 19
28
votes
4 answers

Derivative of sigmoid

I'm creating a neural network using the backpropagation technique for learning. I understand we need to find the derivative of the activation function used. I'm using the standard sigmoid function f(x) = 1 / (1 + e^(-x)) and I've seen that its…
14
votes
2 answers

how is backpropagation the same (or not) as reverse automatic differentiation?

The Wikipedia page for backpropagation has this claim: The backpropagation algorithm for calculating a gradient has been rediscovered a number of times, and is a special case of a more general technique called automatic differentiation in the…
13
votes
2 answers

Python partial derivatives easy

I'm interested in computing partial derivatives in Python. I've seen functions which compute derivatives for single variable functions, but not others. It would be great to find something that did the following f(x,y,z) = 4xy + xsin(z)+ x^3 +…
cnrk
  • 185
  • 1
  • 2
  • 10
11
votes
2 answers

Derivative of a softmax function explanation

I am trying to compute the derivative of the activation function for softmax. I found this : https://math.stackexchange.com/questions/945871/derivative-of-softmax-loss-function nobody seems to give the proper derivation for how we would get the…
Roshini
  • 703
  • 2
  • 8
  • 21
11
votes
4 answers

Math.Pow() vs Math.Exp() C# .Net

Can anyone provide an explanation of the difference between using Math.Pow() and Math.Exp() in C# and .net ? Is Exp()just taking a number to the Power using itself as the Exponent?
CraigJSte
  • 912
  • 6
  • 17
  • 33
11
votes
3 answers

Tricky interview puzzle

You have this code in Javascript (even though language choice does not matter): var arr = new Array(101); for (skip = 1; skip <= 100; skip++) { for (i = 0; i <= 100; i+= skip) { arr[i] = !arr[i]; } } Obviously, after this code is…
Evgeny
  • 6,261
  • 8
  • 35
  • 43
10
votes
5 answers

Derivative function in swift?

I wanted to make a function that returns the derivative of a function at a point for part of my app. Obviously, this is the formal definition of a limit. But what kind of a function would be able return the derivative of a function at a point in…
modesitt
  • 7,052
  • 2
  • 34
  • 64
10
votes
5 answers

Integration (math) in C++

I'm looking for a library to find the integral of a given set of random data (rather than a function) in C++ (or C, but preferably C++). There is another question asking about integration in C but the answers discuss more how to integrate a…
Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
10
votes
1 answer

MATLAB: How do I pass a parameter to a function?

I have the following function: function ypdiff = ypdiff(t,y) a = 0.01; b = 0.1; ypdiff(1) = -a*y(1)*y(2); ypdiff(2) = b*y(1)*y(2)-b*y(2); ypdiff(3) = b*y(2); ypdiff = [ypdiff(1) ypdiff(2) ypdiff(3)]'; If I want to solve…
Legend
  • 113,822
  • 119
  • 272
  • 400
9
votes
1 answer

implementation of the calculus functions i.e f(x), in programming

I want to write a program that calculates a given math function (by the user) with specific set of values. The user is asked to type a function, say he typed f(x)= (x^2)+3x+1 then through the program I should show the outputs of [ f(3), f(6) and…
Fahd
  • 353
  • 6
  • 17
9
votes
3 answers

PyTorch most efficient Jacobian/Hessian calculation

I am looking for the most efficient way to get the Jacobian of a function through Pytorch and have so far come up with the following solutions: # Setup def func(X): return torch.stack((X.pow(2).sum(1), X.pow(3).sum(1), …
Alejandro
  • 879
  • 11
  • 27
9
votes
4 answers

Predictive "blood glucose" algorithm?

I'm writing an app that lets a diabetic user enter his/her "blood glucose" readings, and then charts them on a graph over time from left to right. Since the blood readings will be done only several times a day, an algorithm would be handy to: a)…
username
  • 18,800
  • 11
  • 41
  • 45
9
votes
2 answers

Calculus Limits with Java

I wish to calculate limits (calculus) with Java. I have the following class Limit that can calculate limits: package calculus; public final class Limit { private Limit() { } public static final double limit(Function function, double…
hyper-neutrino
  • 5,272
  • 2
  • 29
  • 50
8
votes
2 answers

Partial Derivatives in Haskell

A while back a friend wanted help with a program that could solve for the roots of functions using Newton's method, and naturally for that I needed some way to calculate the derivative of a function numerically, and this is what I came up with:…
Ben DalFavero
  • 161
  • 1
  • 7
1
2 3
38 39