# Nd level sets

**URL:** https://discourse.julialang.org/t/nd-level-sets/38532
**Category:** General Usage
**Tags:** question
**Created:** [May 1, 2020, 6:57am UTC](https://discourse.julialang.org/t/nd-level-sets/38532 "2020-05-01T06:57:23Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 1, 2020, 6:57am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/1 "2020-05-01T06:57:23Z")

</div>

Hi,

I want to compute the level sets of a Nd scalar function. Furthermore, I would like to be able to access the list of values on the level set. I am looking for suggestions.

I know of the following possibilities:

- `contour` in `Plots.jl`
- `contour` in `Makie.jl`
- `Contour.jl` but 2d
- `Meshing.jl` but 3d

At first, I thought it would be possible to make such method using `RegionTrees.jl `.

Thank you for your help,

Bests

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 1, 2020, 7:04am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/2 "2020-05-01T07:04:47Z")

</div>

In general this is, of course, hard problem.

Given an initial Nd box X, IntervalConstraintProgramming.jl can give you a set of small boxes that rigorously enclose the part of a level set lying inside X.

I believe this can also be solved by a version of the “parameterization method” used to find stable ame unstable manifolds, in which you stitch together pieces of Taylor polynomials. Cc @lbenet

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 1, 2020, 7:53am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/3 "2020-05-01T07:53:41Z")

</div>

Thank you for the pointers!  
Can you tell how to plot the box in 3d please, the semantic has changed?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 1, 2020, 1:59pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/4 "2020-05-01T13:59:47Z")

</div>

Oh good question, will have to check that.

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 4, 2020, 2:24pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/5 "2020-05-04T14:24:12Z")

</div>

I referenced your package in my [docs](https://rveltz.github.io/PseudoArcLengthContinuation.jl/dev/mittelmann/#Analysis-at-the-2d-branch-points-1). If you can do better than what is linked, I am all ears!

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 4, 2020, 3:27pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/6 "2020-05-04T15:27:33Z")

</div>

Those are some pretty amazing and beautiful figures!

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 4, 2020, 7:08pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/7 "2020-05-04T19:08:16Z")

</div>

What is the exact mathematical problem that you want to solve?

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 4, 2020, 7:22pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/8 "2020-05-04T19:22:17Z")

</div>

Intersect polynomial submanifolds. As of now, it just remains to adapt the 3d part of your docs/code to the new syntax of Makie .

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 4, 2020, 7:54pm UTC](https://discourse.julialang.org/t/nd-level-sets/38532/9 "2020-05-04T19:54:17Z")

</div>

Can you provide an explicit example?

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 5, 2020, 7:16am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/10 "2020-05-05T07:16:32Z")

</div>

Can you for example update one of [those](https://github.com/JuliaIntervals/IntervalConstraintProgrammingNotebooks/tree/master/3D) so the 3d plot works please?

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 6, 2020, 1:37am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/11 "2020-05-06T01:37:14Z")

</div>

Wow, those are super out of date – they were apparently made for Julia 0.5 or 0.6…

I’m trying to update them to use Makie, but it seems to be broken right now. Hopefully will be working soon!

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 7, 2020, 2:40am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/12 "2020-05-07T02:40:44Z")

</div>

Here is an updated example:

> <https://github.com/JuliaIntervals/IntervalConstraintProgramming.jl/blob/master/examples/sliced_solid_torus.jl>

 ![Screenshot 2020-05-06 at 23.09.11](https://global.discourse-cdn.com/julialang/original/3X/9/6/96a2a5cfbfa18d06615113f5c137a7c20697f26c.png)

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 7, 2020, 2:44am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/13 "2020-05-07T02:44:53Z")

</div>

Please do let me know if I can help more. I am interested in playing with difficult examples that you have.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [May 7, 2020, 3:18am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/14 "2020-05-07T03:18:42Z")

</div>

Here’s my attempt at drawing what I understand to be the set in your docs:

 ![Screenshot 2020-05-06 at 23.16.02](https://global.discourse-cdn.com/julialang/original/3X/f/2/f2e015057a2dc8969d4312d7e5f487c1353dbb42.png)

Unfortunately currently the mechanism for creating separators from functions is broken  
([Package is broken due to changes in ModelingToolkit · Issue #162 · JuliaIntervals/IntervalConstraintProgramming.jl · GitHub](https://github.com/JuliaIntervals/IntervalConstraintProgramming.jl/issues/162))

But actually I’m not sure this is the right tool for the job, since as far as I can see this is just a union of 1D curves (?). @Xing_Shi_Cai pointed me towards Cylindrical Algebraic Decomposition the other day. This can give you all the “pieces” of the solution.

---

<div class="post-metadata">

### Author: ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)
#### Post date: [May 7, 2020, 6:18am UTC](https://discourse.julialang.org/t/nd-level-sets/38532/15 "2020-05-07T06:18:11Z")

</div>

This is great !!
