# \#finitediff

**URL:** https://discourse.julialang.org/tag/finitediff/455.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [How does ForwardDiff.jl and FiniteDiff.jl handle edge-hitting cases?](https://discourse.julialang.org/t/how-does-forwarddiff-jl-and-finitediff-jl-handle-edge-hitting-cases/137828)

<div class="topic-metadata">

**Author:** [@Xu\_Shan](https://discourse.julialang.org/u/Xu_Shan)\
**Replies:** 3\
**Last updated:** [June 27, 2026, 11:18pm UTC](https://discourse.julialang.org/t/how-does-forwarddiff-jl-and-finitediff-jl-handle-edge-hitting-cases/137828 "2026-06-27T23:18:02Z")

</div>

Hi guys, I am using ForwardDiff.jl to calculate the parameter uncertainty in my model (see below about the more detailed information…). I am wondering, how does ForwardDiff.jl and FiniteDiff.jl handle the edge-hitting p…

---

## [ElasticWave2D.jl - 2D seismic wave simulation on your laptop](https://discourse.julialang.org/t/elasticwave2d-jl-2d-seismic-wave-simulation-on-your-laptop/135349)

<div class="topic-metadata">

**Author:** [@Wuheng10086](https://discourse.julialang.org/u/Wuheng10086)\
**Replies:** 0\
**Last updated:** [January 30, 2026, 2:32pm UTC](https://discourse.julialang.org/t/elasticwave2d-jl-2d-seismic-wave-simulation-on-your-laptop/135349 "2026-01-30T14:32:30Z")

</div>

Hi, everyone! I made ElasticWave2D.jl — GPU-accelerated 2D elastic wave simulation in Julia. I wanted to explore Julia’s potential for seismic simulation — easy install, GPU support, and readable code. Features: C…

---

## [Package to compute Hessian matrix numerically](https://discourse.julialang.org/t/package-to-compute-hessian-matrix-numerically/123151)

<div class="topic-metadata">

**Author:** [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Replies:** 2\
**Last updated:** [November 27, 2024, 1:23pm UTC](https://discourse.julialang.org/t/package-to-compute-hessian-matrix-numerically/123151 "2024-11-27T13:23:55Z")

</div>

Given numerical zᵢⱼ values defined over a regular 2D grid (xᵢⱼ, yᵢⱼ), is there a package to compute the Hessian matrix at each grid point?

---

## [Solving a nonlinear equation using NonlinearSolve.jl with AutoFiniteDiff() yields errors about dual number](https://discourse.julialang.org/t/solving-a-nonlinear-equation-using-nonlinearsolve-jl-with-autofinitediff-yields-errors-about-dual-number/112988)

<div class="topic-metadata">

**Author:** [@LINGXIAO\_QIN](https://discourse.julialang.org/u/LINGXIAO_QIN)\
**Replies:** 2\
**Last updated:** [April 16, 2024, 12:13pm UTC](https://discourse.julialang.org/t/solving-a-nonlinear-equation-using-nonlinearsolve-jl-with-autofinitediff-yields-errors-about-dual-number/112988 "2024-04-16T12:13:18Z")

</div>

I am trying to solve a nonlinear equation, which is constructed using the thermophysical properties of fluids (via CoolProp package). An MWE is shown below. using NonlinearSolve, CoolProp function myfun\_P\_MWE(p, (T, i…

---

## [Implementing Laplacian operator acting on a 2D array](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615)

<div class="topic-metadata">

**Author:** [@matt1](https://discourse.julialang.org/u/matt1)\
**Replies:** 6\
**Last updated:** [March 18, 2024, 5:41pm UTC](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615 "2024-03-18T17:41:03Z")

</div>

Hello, I’m interested in implementing the laplacian operator \\nabla^2=\\partial\_x^2+\\partial\_y^2, such that I can apply it to a matrix A\_{ij} and obtain the corresponding matrix: B\_{ij}=(\\nabla^2A)\_{i,j}. For example, th…

---

## [MATLAB outperforms Julia (20 times faster) running this nested loop](https://discourse.julialang.org/t/matlab-outperforms-julia-20-times-faster-running-this-nested-loop/92691)

<div class="topic-metadata">

**Author:** [@SantiagoOrtiz](https://discourse.julialang.org/u/SantiagoOrtiz)\
**Replies:** 20\
**Last updated:** [January 10, 2023, 2:03am UTC](https://discourse.julialang.org/t/matlab-outperforms-julia-20-times-faster-running-this-nested-loop/92691 "2023-01-10T02:03:30Z")

</div>

Hello Fellas, I am relatively new to Julia Programming. So far, Julia’s high performance has caught my attention. However, it was disappointing to see that MATLAB performs 20 times faster in executing the following prog…

---

## [Solving 2D poisson equation in polar coordinates (finite differences)](https://discourse.julialang.org/t/solving-2d-poisson-equation-in-polar-coordinates-finite-differences/74280)

<div class="topic-metadata">

**Author:** [@Aran](https://discourse.julialang.org/u/Aran)\
**Replies:** 19\
**Last updated:** [June 7, 2022, 1:47am UTC](https://discourse.julialang.org/t/solving-2d-poisson-equation-in-polar-coordinates-finite-differences/74280 "2022-06-07T01:47:03Z")

</div>

Hello all, I am looking to solve the following poisson equation \\nabla^2 \\psi = -\\omega \\quad \\text{and} \\quad \\nabla^2 = \\frac{\\partial ^2}{{\\partial \\rho^2 }} + \\frac{1}{\\rho }\\frac{\\partial}{\\partial \\rho} + \\frac{…

---

## [High order approximation of a multi-country trade model](https://discourse.julialang.org/t/high-order-approximation-of-a-multi-country-trade-model/83225)

<div class="topic-metadata">

**Author:** [@daisukeadachi](https://discourse.julialang.org/u/daisukeadachi)\
**Replies:** 22\
**Last updated:** [July 6, 2022, 2:38pm UTC](https://discourse.julialang.org/t/high-order-approximation-of-a-multi-country-trade-model/83225 "2022-07-06T14:38:32Z")

</div>

Hi, I hope this finds you well. I recently moved over from Matlab in search of better computational performance. I am doing this post to get best practices on higher-order approximations for large problems such as the o…

---

## [2d finite differences implementation for a Numerical Analysis lecture](https://discourse.julialang.org/t/2d-finite-differences-implementation-for-a-numerical-analysis-lecture/70222)

<div class="topic-metadata">

**Author:** [@vicdolean](https://discourse.julialang.org/u/vicdolean)\
**Replies:** 4\
**Last updated:** [June 23, 2022, 12:22am UTC](https://discourse.julialang.org/t/2d-finite-differences-implementation-for-a-numerical-analysis-lecture/70222 "2022-06-23T00:22:31Z")

</div>

Hi! I’m new to Julia world and would need some help in the transition from Matlab. I am teaching a numerical analysis class where I use finite differences on a two dimensional (cartesian but not necessarily square) doma…

---

## [Calculating Jacobian from two matrices](https://discourse.julialang.org/t/calculating-jacobian-from-two-matrices/78966)

<div class="topic-metadata">

**Author:** [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Replies:** 4\
**Last updated:** [April 5, 2022, 10:48am UTC](https://discourse.julialang.org/t/calculating-jacobian-from-two-matrices/78966 "2022-04-05T10:48:09Z")

</div>

Hi everyone, I would like to compute a Jacobian for one of my problem for a PDE, but I don’t have a function linking the unknown to my function. So I only have 2 matrices, 1 with the values of the function and 1 with th…

---

## [Numerical differentiation with bump size](https://discourse.julialang.org/t/numerical-differentiation-with-bump-size/78254)

<div class="topic-metadata">

**Author:** [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Replies:** 2\
**Last updated:** [March 22, 2022, 9:30am UTC](https://discourse.julialang.org/t/numerical-differentiation-with-bump-size/78254 "2022-03-22T09:30:16Z")

</div>

Is there a numerical differentiation package that allows you to specify the size of the bump ? I’d like to do f(x + d) - f(x) and specify the d (e.g. 0.001) FiniteDifferences seems to focus on approxim…

---

## [How to force Flux to use FiniteDiff](https://discourse.julialang.org/t/how-to-force-flux-to-use-finitediff/76324)

<div class="topic-metadata">

**Author:** [@BMval](https://discourse.julialang.org/u/BMval)\
**Replies:** 16\
**Last updated:** [February 16, 2022, 10:48pm UTC](https://discourse.julialang.org/t/how-to-force-flux-to-use-finitediff/76324 "2022-02-16T22:48:47Z")

</div>

I have loss() function. FiniteDiff.finite\_difference\_derivative - works great with the this loss() ForwardDiff.derivative - doesn’t work at all. As result Flux.train!(loss,Flux.params(NNODE),data,ADAM(0.001)) doesn’t …

---

## [Coupled non-linear PDEs using DifferentialEquations.jl and the MOL](https://discourse.julialang.org/t/coupled-non-linear-pdes-using-differentialequations-jl-and-the-mol/74139)

<div class="topic-metadata">

**Author:** [@Iddingsite](https://discourse.julialang.org/u/Iddingsite)\
**Replies:** 10\
**Last updated:** [January 8, 2022, 1:58pm UTC](https://discourse.julialang.org/t/coupled-non-linear-pdes-using-differentialequations-jl-and-the-mol/74139 "2022-01-08T13:58:39Z")

</div>

Hi everyone, I am trying to solve 2 coupled non-linear PDEs using the MOL with DifferentialEquations.jl and Finite differences first in 1D and I am stuck somewhere. My two equations describe the evolution of a porosity…

---

## [Why is this FiniteDiff derivative wrong?](https://discourse.julialang.org/t/why-is-this-finitediff-derivative-wrong/67616)

<div class="topic-metadata">

**Author:** [@amrods](https://discourse.julialang.org/u/amrods)\
**Replies:** 3\
**Last updated:** [September 4, 2021, 9:13am UTC](https://discourse.julialang.org/t/why-is-this-finitediff-derivative-wrong/67616 "2021-09-04T09:13:47Z")

</div>

What is going on here? using FiniteDiff randmat = rand(10, 2) sto = similar(randmat) function claytonsample!(sto, τ; randmat=randmat) sto .= randmat τ == 0 && return sto n = size(sto, 1) for i in 1:n …

---

## [High-order derivatives of sampled data](https://discourse.julialang.org/t/high-order-derivatives-of-sampled-data/67045)

<div class="topic-metadata">

**Author:** [@DanielIngraham](https://discourse.julialang.org/u/DanielIngraham)\
**Replies:** 9\
**Last updated:** [September 1, 2021, 5:38pm UTC](https://discourse.julialang.org/t/high-order-derivatives-of-sampled-data/67045 "2021-09-01T17:38:53Z")

</div>

Hi, I have discrete data sampled at a constant rate. I need the first, second, and third derivatives with respect to time. Is there a Julia package that could help me do that? Things that I’ve considered so far: Use f…

---

## [Is there any good way to check gradient calculated by Zygote.jl](https://discourse.julialang.org/t/is-there-any-good-way-to-check-gradient-calculated-by-zygote-jl/59782)

<div class="topic-metadata">

**Author:** [@Richard-Li](https://discourse.julialang.org/u/Richard-Li)\
**Replies:** 8\
**Last updated:** [August 30, 2021, 8:58am UTC](https://discourse.julialang.org/t/is-there-any-good-way-to-check-gradient-calculated-by-zygote-jl/59782 "2021-08-30T08:58:07Z")

</div>

Hi there, I’d like to know is there any good way to check the gradient of custom matrix functions calculated by Zygote.jl. like this one: function my\_custom\_matrix\_func(m) return sum(m \* m') end I know FiniteDif…

---

## [Simple numerical differentiation](https://discourse.julialang.org/t/simple-numerical-differentiation/52254)

<div class="topic-metadata">

**Author:** [@ishihama](https://discourse.julialang.org/u/ishihama)\
**Replies:** 5\
**Last updated:** [December 23, 2020, 10:26am UTC](https://discourse.julialang.org/t/simple-numerical-differentiation/52254 "2020-12-23T10:26:10Z")

</div>

Hello there, I am wondering how to implement numerical differentiation in Julia simply. My MWE looks like, using ForwardDiff p = \[1, 2, 3\] f(x::Vector) = p\[1\] .+ p\[2\] .\* x .+ p\[3\] .\* x .^ 2 x=1:10 g = x -\> ForwardDiff.g…

---

## [Implementing finite difference with periodic B.C](https://discourse.julialang.org/t/implementing-finite-difference-with-periodic-b-c/50975)

<div class="topic-metadata">

**Author:** [@yhchang](https://discourse.julialang.org/u/yhchang)\
**Replies:** 9\
**Last updated:** [November 30, 2020, 9:09pm UTC](https://discourse.julialang.org/t/implementing-finite-difference-with-periodic-b-c/50975 "2020-11-30T21:09:39Z")

</div>

I am pretty new to Julia and ultimately I want to transfer my python code for solving a nonlinear PDE into Julia (and see whether I can get the speedup I hope). The PDE I want to solve is similar to a nonlinear heat equ…

---

## [Simultaneous Jacobian and Hessian computations](https://discourse.julialang.org/t/simultaneous-jacobian-and-hessian-computations/44884)

<div class="topic-metadata">

**Author:** [@mleprovost](https://discourse.julialang.org/u/mleprovost)\
**Replies:** 7\
**Last updated:** [August 13, 2020, 10:15pm UTC](https://discourse.julialang.org/t/simultaneous-jacobian-and-hessian-computations/44884 "2020-08-13T22:15:42Z")

</div>

Hello, I would like to compute the Jacobian and the Hessian of a function f: \\mathbb{R}^n \\xrightarrow{} \\mathbb{R}^m with n,m \\sim60. This function involves multiple Fourier transforms and nonlinear transformations tha…
