# Derivative silently returns 0 for an element of a registered array function when the variables are elements of an array variable

**URL:** <https://discourse.julialang.org/t/derivative-silently-returns-0-for-an-element-of-a-registered-array-function-when-the-variables-are-elements-of-an-array-variable/142981>\
**Category:** Modelling & Simulations\
**Tags:** modelingtoolkit, symbolics\
**Created:** [November 16, 2026, 4:30pm UTC](https://discourse.julialang.org/t/derivative-silently-returns-0-for-an-element-of-a-registered-array-function-when-the-variables-are-elements-of-an-array-variable/142981 "2026-11-16T16:30:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabien\_C](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fabien_c/32/225274_2.png) [@Fabien\_C](https://discourse.julialang.org/u/Fabien_C)\
**Post date:** [November 16, 2026, 4:30pm UTC](https://discourse.julialang.org/t/derivative-silently-returns-0-for-an-element-of-a-registered-array-function-when-the-variables-are-elements-of-an-array-variable/142981/1 "2026-11-16T16:30:54Z")

</div>

```julia
using Symbolics

g(a, b) = [a^2, a * b]
dg(a, b) = [2a 0; b a] 
@register_array_symbolic g(a, b) begin
    size = (2,)
    eltype = Real
end
@register_array_symbolic dg(a, b) begin
    size = (2, 2)
    eltype = Real
end
@register_derivative g(a, b) I dg(a, b)[:, I]

@variables a b v[1:2]
Symbolics.derivative(g(a, b)[2], a) # (dg(a, b))[2, 1] right
Symbolics.derivative(g(v[1], v[2])[2], v[1]) # 0 wrong, no error

```

The same function with the same derivative rule gives the right derivative with scalar  
variables, and 0 with the elements of an array variable.

Is it on purpose or should I submit a ticket ?

Symbolics 7.47.0, ModelingToolkit 11.45.5, Julia 1.12.6.
