Skip to content

Can diff work with arrays? diff([cos(x),sin(x),x] returns an error. #205

@johnalx

Description

@johnalx

I am trying to use SymEngine with arrays of expressions. See example below

using SymEngine
@vars x
diff( [cos(x), sin(x)], x)
ERROR: MethodError: no method matching diff(::Array{Basic,1}, ::Basic)

Even more important is to be able to generate a gradient matrix by differentiating each element of a vector expression with each symbolic variable.

@vars a b
expr = [ a^2+2*b^2, -a*b]
f = diff(expr, [a,b])
#  expected result 2×2 matrix: [ 2a -b; 4a -a]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions