# Using Symbolics and Flux

Let’s say I have something along the lines of

using Symbolics, Flux
@variables x,y
function f()
[x^2y^3 ; x+y^2]
end

The following error comes:

ERROR: Sym x^(4(y^3)) + (x + y^2)^2 is not callable. Use @syms x^(4(y^3)) + (x + y^2)^2(var1, var2,…) to create it as a callable.

However it isn’t clear how I use “Use @syms x^(4(y^3)) + (x + y^2)^2(var1, var2,…)”. That is I am not sure where I include this or the syntactical formatting necessary.

https://docs.juliahub.com/Symbolics/eABRO/3.4.0/tutorials/symbolic_functions/#Syms-and-callable-Syms-1

method I always get a zero vector returned. Namely, it returns

2-element Vector{Num}:
0
0

I am afraid Symbolics and Flux are not compatible.

This is false given I just managed to get the following to work:

using Symbolics, Flux
@variables x,y,z
function ff(x,y,z)
x^2+y^2*z
end

the output is:

(2x, 2y*z, y^2)

I found a fix, consider the following MWE

using Symbolics, Flux

@variables x, y
function f(x,y)
A = transpose([x;y])*[x;y]
return A
end
display(f(x,y))

This returns

x^2 + y^2

Note that Flux reexports `gradient` from Zygote.jl, so unless you need the NN functionality I’d recommend using that instead.