# Knowing what package a function is from?

**URL:** <https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258>\
**Category:** General Usage\
**Tags:** package\
**Created:** [October 29, 2020, 7:35pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258 "2020-10-29T19:35:26Z")\
**Posts on this page:** 20\
**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, 7:35pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/1 "2020-10-29T19:35:26Z")

</div>

Both Calculus.jl and SystmUtils.jl have a simplify funtction. If I have code like.

```julia
using Calculus
using SystemUtils

differentiate("x^2+65x^58+7-63")

simplify(ans)

```

how do in know which simplify it would use?

---

<div class="post-metadata">

**Author:** ![affans](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/affans/32/11911_2.png) [@affans](https://discourse.julialang.org/u/affans)\
**Post date:** [October 29, 2020, 7:45pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/2 "2020-10-29T19:45:00Z")

</div>

I am not an expert on this stuff, but I imagine it would depend on the argument type. The `Calculus` package make define `simplify(::T1)` while `SystemUtils` may define the method `simplify(::T2)` where `T1` and `T2` are types. So when you call `simplify(ans)` it depends on what the type is of `ans`.

Now if both packages define a method for the same type, that is type piracy and you’ll get ambiguity warnings (error?). To resolve the ambiguity, you can qualify the method by its module name, i.e.

```julia
Calculus.simplify(ans)
# or 
SystemUtils.simplify(ans)

```

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [October 29, 2020, 7:51pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/3 "2020-10-29T19:51:02Z")

</div>

Prefix the function name with the module name: `Calculus.simplify`.

---

<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, 7:54pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/4 "2020-10-29T19:54:11Z")

</div>

Perfect! then I can compare outputs! I didn’t like the results of Calculus.jl simplifications, and hope that SymbolicUtils will do a better job. I’m also interested in comparing Reduce.jl (but I can’t find how to simplify it the documentation), and Maxima.jl(Maxima simplifies nice, but I need a .bar file with Windows).

---

<div class="post-metadata">

**Author:** ![tikej](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@tikej](https://discourse.julialang.org/u/tikej)\
**Post date:** [October 29, 2020, 8:46pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/5 "2020-10-29T20:46:57Z")

</div>

SymPy.jl is also worth trying

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [October 29, 2020, 9:30pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/6 "2020-10-29T21:30:52Z")

</div>

Calculus.jl is ancient and should not be used

---

<div class="post-metadata">

**Author:** ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)\
**Post date:** [October 29, 2020, 9:34pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/7 "2020-10-29T21:34:50Z")

</div>

@Wikunia is actually working on a project that should help with this called Seahawk.jl (link: [https://github.com/Wikunia/Seahawk.jl](https://github.com/Wikunia/Seahawk.jl)). He could probably explain more about it than I could. 🙂

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [October 29, 2020, 9:38pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/8 "2020-10-29T21:38:46Z")

</div>

Going back to the question in the title, you could have used the `which` macro, which tells you where the method being called comes from:

```julia
julia> @which sum(rand(10))
sum(a::AbstractArray; dims) in Base at reducedim.jl:722

```

---

<div class="post-metadata">

**Author:** ![Wikunia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wikunia/32/2180_2.png) [@Wikunia](https://discourse.julialang.org/u/Wikunia)\
**Post date:** [October 29, 2020, 9:44pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/9 "2020-10-29T21:44:52Z")

</div>

Seahawk can be used if you don’t know the name of the function. In this case you want to use `@which`

---

<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:09pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/10 "2020-10-29T22:09:45Z")

</div>

Also worth considering.

---

<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:10pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/11 "2020-10-29T22:10:32Z")

</div>

Thank’s I’ll try to remember that.

---

<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:13pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/12 "2020-10-29T22:13:00Z")

</div>

It’ seems to work fine for me, but what would you recomend? I like Reduce.jl, but it won’t work in Markdown, and there’s some drama with the creator. Maxima.jl is probably good, but has .bar files to set up. So, I’m thinking of looking into SymPy, although I’m a bit worried that it will be slow, if it’s a frontend for python code.

---

<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:16pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/13 "2020-10-29T22:16:02Z")

</div>

Can symengine.jl do simplification? It’s a C library, that is supposedly faster.

---

<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:21pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/14 "2020-10-29T22:21:23Z")

</div>

I can make a new post on this, but here I suggested an alternate syntax for differentiation, if Calculus.jl could be rebuilt, to focus on differentiation, limits and integrals, without simplification, it would be a handy tool.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [October 29, 2020, 10:57pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/15 "2020-10-29T22:57:15Z")

</div>

SymEngine.jl can do simplification.  
I have used it for that before. it works.

I haven’t used it but I feel like ModellingToolkit is the future of practical symbolic calculus in julia  
Here is its docs on deriviatives [https://mtk.sciml.ai/stable/highlevel/#Differentiation-Functions-1](https://mtk.sciml.ai/stable/highlevel/#Differentiation-Functions-1)

It does simplication also, apparently via using SymbolicUtils.j  
[https://juliasymbolics.github.io/SymbolicUtils.jl/#simplification](https://juliasymbolics.github.io/SymbolicUtils.jl/#simplification)

* * *

> if Calculus.jl could be rebuilt, to focus on differentiation, limits and integrals, without simplification, it would be a handy tool.

When Calculus.jl says derivative at mostly means finite differencing.  
which has 2 problems:

1. Finite differencing is bad. We have excelling forward mode and reverse mode ADs so many of them. That are perfectly accurate. At least one could use ForwardDiff.jl
2. If one really wants finite differencing, then FiniteDiff.jl and FiniteDifferences.jl are state of the art finite differencing libraries that are much more accurate.

For 1 case it means symbolic differentiation. and ModelingToolkit does that has done for ages, and is much more actively worked on.

Calculus.jl doesn’t do limits or integrals.

---

<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:10pm UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/16 "2020-10-29T23:10:06Z")

</div>

Thanks, I think Reduce does the same finite differencing. I was going to say that SymEngine diff() works good and gives a simplified result:

but

```julia
using SymEngine

diff((4x^2+3)(2x+5),x)

```

gives  
16\*(5+2x)  
instead of 24x^2+40x+6

If I foil, it works fine though, so I can do a lot with that, until I have more time to learn up on ModellingToolkit.

---

<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, 2:10am UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/17 "2020-10-30T02:10:49Z")

</div>

I seem to be able to get SymEngine to work, the only thing, and it’s not important, but is there a way to plot the symbolic output without rewriting it? I know Maxima and Reduce both plot with Gnuplot, which would also work, but Plots.jl would be best.

---

<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:** [October 30, 2020, 5:33am UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/18 "2020-10-30T05:33:42Z")

</div>

> [@oxinabox](#):
>
> It does simplication also, apparently via using SymbolicUtils.j

Yes: ModelingToolkit is built with SymbolicUtils as its utility backend. But ModelingToolkit is a full complete CAS.

> [@brett\_knoss](#):
>
> I can make a new post on this, but here I suggested an alternate syntax for differentiation, if Calculus.jl could be rebuilt, to focus on differentiation, limits and integrals, without simplification, it would be a handy tool.

That’s already been done. FiniteDiff.jl, FiniteDifferences.jl, Quadratue.jl, and ModelingToolkit.jl. And this set greatly expands the functionality, makes it an order of magnitude faster, and makes it more robust/stable. Honestly, delete Calculus.jl: it’s been done for years now. I am still surprised it ever comes up in a conversation.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [October 30, 2020, 10:19am UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/19 "2020-10-30T10:19:34Z")

</div>

> [@ChrisRackauckas](#):
>
> But ModelingToolkit is a full complete CAS.

It might be nice to restructure to docs positioning it as a CAS first and foremost,  
with a particular set of nice things for working with differential equations.  
right now the docs are very DiffEq application centric.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [October 31, 2020, 10:25am UTC](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258/20 "2020-10-31T10:25:18Z")

</div>

Also, for a specific symbol, see `parentmodule`.

[Next page](https://discourse.julialang.org/t/knowing-what-package-a-function-is-from/49258.md?page=2)
