# MultiResidue.jl (A new package to calculate the multi-variable residue)

**URL:** <https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028>\
**Category:** Package Announcements\
**Tags:** math, integral, symbolics, complex-numbers\
**Created:** [June 1, 2022, 4:04am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028 "2022-06-01T04:04:13Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 1, 2022, 4:04am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/1 "2022-06-01T04:04:13Z")

</div>

I am announce a new package on[MultiResidue.jl](https://github.com/AmplitudeGravity/MultiDimResidue), which is used to calculate the multi-variable residue over a zero-dimensional point in multi-variable complex space. The method and Mathematica code have beed included in [MultiResidue.nb](https://github.com/AmplitudeGravity/Multi-variable-Residue). This package is using the CAS in Julia [SymEngine](https://github.com/symengine/SymEngine.jl).

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 1, 2022, 4:08am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/2 "2022-06-01T04:08:58Z")

</div>

solve for linear equation is added

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 2, 2022, 4:11pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/3 "2022-06-02T16:11:28Z")

</div>

New version v1.5.0 [MultiResidue.jl](https://github.com/AmplitudeGravity/MultiDimResidue)

Using the efficient and proper birddet( @stevengj ) for the determinant of symbolic matrix.

Still missing efficient solve or inverse function for linear symbolic equations.  
It will better to simplify function for the final output, so we still need efficient simplify function in SymEngine.jl @isuruf

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 3, 2022, 11:05am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/4 "2022-06-03T11:05:11Z")

</div>

new version, v1.3.0  
Extend to the equations with symbolic coefficients

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 4, 2022, 8:56pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/5 "2022-06-04T20:56:06Z")

</div>

Next step, add the residue for inhomogeneous equations.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [June 4, 2022, 10:05pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/6 "2022-06-04T22:05:57Z")

</div>

> [@gangchern](#):
>
> This package is using the CAS in Julia [SymEngine](https://github.com/symengine/SymEngine.jl).

Is there a reason you are using SymEngine and not Symbolics.jl?

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 5, 2022, 4:12am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/7 "2022-06-05T04:12:32Z")

</div>

No. I am just more familiar with SymEngine.  
Symbolics looks better on performance and of more functions. I need spend more time on learning it. I plan to use Symbolics in further versions.

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 5, 2022, 6:04am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/8 "2022-06-05T06:04:45Z")

</div>

Some plan in future on this package:

1. using Symbolics. Symbolics have solve function and simplify function now. Just need two optimization: One is on the degree function in Symbolics. Now it does not support for a given multivariable list.

```julia
degree(a*b+b*x^2,[a,b]) 
0

```

Another tiny drawback is the int numbers in equation sometimes convert to float type in the output. Look forward they can fix this (@ChrisRackauckas @YingboMa @shashi )

```julia
sols=Symbolics.solve_for([a+x*b+y*c+d~(big(0)),a+big(5)x*b+y*c+d~big(2),a+x*b+y*c+big(3)d~2,big(4)a+x*b+y*c+d~big(2)],[a,b,c,d])
sols[1] 
(-(6.0 / -4.0 - 5.0)) / 3.0 - (3//2)

```

1. extending to non-homogeneous ideals
2. extending to non-zero dimensional intersections
3. adding Exterior algebra on the differential form and parameter transformation(local transformation will improve the performance greatly)
4. adding the new integral reduction method by Multi variable residue.

---

<div class="post-metadata">

**Author:** ![greatpet](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Post date:** [June 5, 2022, 10:25am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/9 "2022-06-05T10:25:42Z")

</div>

When I load your package, I got a warning:

```julia
julia> using MultiResidue
[Info: Precompiling MultiResidue [15ac1977-6a35-4422-b111-63c1dba6b911]
┌ Warning: Package MultiResidue does not have Combinatorics in its dependencies:
│ - If you have MultiResidue checked out for development and have
│ added Combinatorics as a dependency but haven't updated your primary
│ environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with MultiResidue
└ Loading Combinatorics into MultiResidue from project dependency, future warnings for MultiResidue are suppressed.

```

Maybe you should include `Combinatorics` in your `Project.toml`?

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [June 5, 2022, 10:31am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/10 "2022-06-05T10:31:29Z")

</div>

You could also consider supporting multiple symbolic packages at once, e.g., SymEngine.jl, Symbolics.jl, and SymPy.jl. That’s what I do in [BSeries.jl](https://github.com/ranocha/BSeries.jl). This allows comparing the efficiency of different packages for the same task. For the tasks I need in BSeries.jl, SymEngine.jl is the fastest option at the moment, see [Benchmarks · BSeries.jl](https://ranocha.de/BSeries.jl/stable/benchmarks/)

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 5, 2022, 11:03am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/11 "2022-06-05T11:03:38Z")

</div>

Thanks for pointing this out. Fixed it.

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 6, 2022, 4:35am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/12 "2022-06-06T04:35:32Z")

</div>

That makes sense! Nowadays, SymEngine is the fastest one and easy to understand the inner structures. I can defined my own abstract algebra operator or function conveniently. It is usually my plan A. Symbolics is very active recently. Look forward they can be the fastest one in near future. SymPy.jl looks very slow. I usually can not get the result for complex symbolic system.

> [@ranocha](#):
>
> SymEngine.jl is the fastest option at the moment, see [Benchmarks · BSeries.jl](https://ranocha.de/BSeries.jl/stable/benchmarks/)

---

<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:** [June 6, 2022, 3:42pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/13 "2022-06-06T15:42:34Z")

</div>

@shashi could this be a good benchmark for the new Unityper stuff?

@gangchern there’s a breaking change on SymbolicUtils.jl master which should change the performance quite dramatically. It would be interesting to test that.

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [June 6, 2022, 5:23pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/14 "2022-06-06T17:23:28Z")

</div>

Does this include the performance of differentiating and substituting variables for concrete numbers? I coud test this in BSeries.jl.

---

<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:** [June 6, 2022, 5:25pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/15 "2022-06-06T17:25:27Z")

</div>

It definitely does. Unityper makes a composite type from what was many subtypes.

> **[GitHub - YingboMa/Unityper.jl](https://github.com/YingboMa/Unityper.jl)**
>
> Contribute to YingboMa/Unityper.jl development by creating an account on GitHub.

Now instead of `Add`, `Mul`, etc. as the basic types, there’s just a `Symbolic` that acts like the union of these types. It changes every symbolic operation from fundamentally type-unstable to fundamentally type-stable, which is (hopefully) very significant!

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [June 6, 2022, 5:26pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/16 "2022-06-06T17:26:27Z")

</div>

Which branches of which packages do I need to check out to test it?

---

<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:** [June 6, 2022, 5:27pm UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/17 "2022-06-06T17:27:46Z")

</div>

SymbolicUtils master already has this, which is why it’s a breaking v0.20.0-dev. I’m not sure what in Symbolics.jl is required to test it, but @shashi is working on this as I speak so connecting with him to make a real performance test case would be good.

---

<div class="post-metadata">

**Author:** ![gangchern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gangchern/32/13298_2.png) [@gangchern](https://discourse.julialang.org/u/gangchern)\
**Post date:** [June 7, 2022, 5:36am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/18 "2022-06-07T05:36:25Z")

</div>

Sounds great! I would like to test it.

---

<div class="post-metadata">

**Author:** ![ranocha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ranocha/32/35588_2.png) [@ranocha](https://discourse.julialang.org/u/ranocha)\
**Post date:** [June 7, 2022, 5:54am UTC](https://discourse.julialang.org/t/multiresidue-jl-a-new-package-to-calculate-the-multi-variable-residue/82028/19 "2022-06-07T05:54:28Z")

</div>

@shashi If you want to test something, just let me know how (or run the benchmarks from BSeries.jl I linked above yourself).
