# Using SymEngine. Functions not defined

**URL:** <https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270>\
**Category:** General Usage\
**Created:** [October 29, 2020, 10:30pm UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270 "2020-10-29T22:30:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 29, 2020, 10:30pm UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270/1 "2020-10-29T22:30:43Z")

</div>

```julia
using SymEngine

julia> expand(a + 2(b+2)^2 + 2a + 3(a+1))

```

when I try to do this, I get error, expand not defined.

I think that means it’s not fiding SymEngine.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 29, 2020, 11:06pm UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270/2 "2020-10-29T23:06:05Z")

</div>

Need to define first the symbolic variables: `a=symbols(:a); b=symbols(:b); `

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 29, 2020, 11:13pm UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270/3 "2020-10-29T23:13:27Z")

</div>

I tried that

```julia
using SyEngine

x=symbols(:x);
# get x as a result
expand((4x^2+3)(2x+5))

```

---

<div class="post-metadata">

**Author:** ![brett\_knoss](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/brett_knoss/32/13050_2.png) [@brett\_knoss](https://discourse.julialang.org/u/brett_knoss)\
**Post date:** [October 30, 2020, 1:55am UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270/4 "2020-10-30T01:55:09Z")

</div>

That fixed the differential function, doesn’t seem to help with expand. The other issue I have, is I’m not sure if there is a way to plot the output of diff(), other symbolic packages allow this with Gnuplots, but I don’t know of any that allow it with Plots.jl

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [October 30, 2020, 7:18am UTC](https://discourse.julialang.org/t/using-symengine-functions-not-defined/49270/5 "2020-10-30T07:18:28Z")

</div>

This works perfectly fine:

```julia
julia> using SymEngine

julia> x = symbols(:x)
x

julia> expand((4x^2+3)(2x+5))
103 + 80*x + 16*x^2

```

Your post has a typo (`using SyEngine` instead of `using SymEngine` [note the `m` in `Sym`]), so maybe this is why it didn’t work?

Alternatively, you might have had some other package loaded that exports sa function called `expaned` which would lead to a name clash and require qualification of the function call (e.g. `SymEngine.expand()`).

In either case, and as a more general piece of advice, when you post questions on here it would be useful if you

1. Start a completely fresh Julia REPL session
2. Execute your code line by line in the REPL
3. Post the full REPL session including all outputs (like I did above)

Assuming your problem here really was your typo, following this procedure would likely have lead you to discover the issue yourself, as your post would have looked like the following:

```julia
julia> using SyEngine
ERROR: ArgumentError: Package SyEngine not found in current path:
- Run `import Pkg; Pkg.add("SyEngine")` to install the SyEngine package.

Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:893

julia> x = symbols(:x)
ERROR: UndefVarError: symbols not defined
Stacktrace:
 [1] top-level scope at REPL[2]:1

julia> expand((4x^2+3)(2x+5))
ERROR: UndefVarError: x not defined
Stacktrace:
 [1] top-level scope at REPL[3]:1

```

i.e. you would have immediately seen that the problem was in the first line, with `SyEngine` not being found, rather than with your call to `expand`. Similarly, if your problem had been a name clash, you should have seen something like:

```julia
julia> expand(x) = "the expand function exists already in this namespace!"
expand (generic function with 1 method)

julia> using SymEngine
WARNING: using SymEngine.expand in module Main conflicts with an existing identifier.

```

which at a minimum would have meant someone on this forum could have explained the problem to you immediately.
