# Symbolics.jl with Linear Algebra+derivative

**URL:** <https://discourse.julialang.org/t/symbolics-jl-with-linear-algebra-derivative/118807>\
**Category:** General Usage\
**Tags:** question, package, linearalgebra, symbolics\
**Created:** [August 30, 2024, 12:53pm UTC](https://discourse.julialang.org/t/symbolics-jl-with-linear-algebra-derivative/118807 "2024-08-30T12:53:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnerob](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/arnerob/32/49522_2.png) [@arnerob](https://discourse.julialang.org/u/arnerob)\
**Post date:** [August 30, 2024, 12:53pm UTC](https://discourse.julialang.org/t/symbolics-jl-with-linear-algebra-derivative/118807/1 "2024-08-30T12:53:26Z")

</div>

I am trying to use Symbolics.derivative and Linear Algebra. I am confused with how things work and I am stuck with a specific problem that I have reduced to a MWE.

```julia
using Symbolics
@variables x A[1:3,1:3]
v=[1,x,x^2]
Symbolics.derivative(A[1:3,1:3]*v,x) # This outputs [0,0,0]
Symbolics.derivative(collect(A[1:3,1:3]*v),x) # This works as I want
Symbolics.derivative(transpose(hcat(v))*A[1:3,1:3]) # This does not work and gives an error

```

The reason why I also want to multiply a transposed vector in front is that I want to work with [quadrics](https://en.wikipedia.org/wiki/Quadric).  
However I can’t seem to make it work even with combinations of collect. (They also give an error.)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 30, 2024, 1:13pm UTC](https://discourse.julialang.org/t/symbolics-jl-with-linear-algebra-derivative/118807/2 "2024-08-30T13:13:17Z")

</div>

It works if you scalarize. If you don’t scalarize it gives you an error saying that it cannot currently do array derivatives and tells you to scalarize. The comments you have here are consistent with that.

The easiest thing is probably just to `Symbolics.scalarize(A)`.

We are of course going to work on adding matrix derivatives but until that feature exists this error will be there.
