# Packages to map 4-dimensional space with constraints on independent variables

**URL:** https://fortran-lang.discourse.group/t/packages-to-map-4-dimensional-space-with-constraints-on-independent-variables/4427
**Category:** Help
**Created:** [September 29, 2022, 2:56pm UTC](https://fortran-lang.discourse.group/t/packages-to-map-4-dimensional-space-with-constraints-on-independent-variables/4427 "2022-09-29T14:56:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![epagone](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/epagone/32/252_2.png) [@epagone](https://fortran-lang.discourse.group/u/epagone)
#### Post date: [September 29, 2022, 2:56pm UTC](https://fortran-lang.discourse.group/t/packages-to-map-4-dimensional-space-with-constraints-on-independent-variables/4427/1 "2022-09-29T14:56:08Z")

</div>

I hope this is not a trivial or insolvable problem and it’s not too much OT. In case it is, apologies in advance for my poor math skills and feel free to hide the question.

I have a complicated function f (continuous, differentiable) of 4 independent parameters, say f(x,y,z,t) all bounded between 0 and 1: x,y,z,t \in [0,1].

Are there packages able to map the 4-dimensional space to find n sets of \{\hat{x},\hat{y},\hat{z},\hat{t}\}\_n where the f(\hat{x}\_i,\hat{y}\_i,\hat{z}\_i,\hat{t}\_i) \geq 1? I am not sure if this problem can be recast into a constrained optimisation one as I’m interested in the condition f\geq 1 so I suspect that it might be a different type that I’m not aware of and I hope there might be a library able to help me with it.

## Update

After putting some more thought in it, I think that I can follow this high-level algorithm.

1. start with a “Monte Carlo”-like approach sampling the independent variables from uniform distributions
2. automatically select the closest points to f=1 to identify the frontier
3. use [NumDiff](https://github.com/jacobwilliams/NumDiff) to explore the numerical derivatives around the frontier to understand where the area f\geq 1 is located with respect to the independent variables.

It might work, although I feel that a more “educated” approach might be available.

---

<div class="post-metadata">

### Author: ![nshaffer](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/nshaffer/32/161_2.png) [@nshaffer](https://fortran-lang.discourse.group/u/nshaffer)
#### Post date: [September 30, 2022, 12:29am UTC](https://fortran-lang.discourse.group/t/packages-to-map-4-dimensional-space-with-constraints-on-independent-variables/4427/2 "2022-09-30T00:29:38Z")

</div>

Maybe for several time slices, you can do marching cubes to find the f(x,y,z,t\_i)=1 isosurface? I’m not an expert on computational geometry, but that was the first thing that came to mind. For this kind of question, maybe the computational science stackexchange ([scicomp.stackexchange.com](http://scicomp.stackexchange.com)) is another place to try searching/asking.

Edit

Apparently a marching hypercubes algorithm was published [earlier this year](https://doi.org/10.1016/j.cag.2021.10.023). Have not read it, but the discussion/references might be useful to you, even if the algorithm ends up not being what you want.

---

<div class="post-metadata">

### Author: ![OptimalDesigns](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/optimaldesigns/32/1772_2.png) [@OptimalDesigns](https://fortran-lang.discourse.group/u/OptimalDesigns)
#### Post date: [October 5, 2022, 3:18pm UTC](https://fortran-lang.discourse.group/t/packages-to-map-4-dimensional-space-with-constraints-on-independent-variables/4427/3 "2022-10-05T15:18:57Z")

</div>

“Monte Carlo” methods can be very slow. Are you trying to find an equal potential set of curves like a weather plot?
