<p>I work in gravitational lensing, so maybe I can give you an idea.</p>
<p>In those JWST you have a massive galaxy cluster that is bending the light behind and acting as a true lens. If you have a temptative model of the mass distribution, including the dark matter halo of the cluster and the cluster galaxies, you can find the best mass distribution model by fitting the model to some observables. These observables are objects with multiple images.</p>
<p>Some objects with multiple images are obvious, just take a detailed look at the images of the cluster yourself. Once you identify these multiple images, you can use them to find the best mass model that reproduces those images. Then you can use this model to predict new images, and see if you find something that you previously missed, so you can improve the lens model again. It is an iterative process. The key here is that if you have an object with multiple images, you know it is the same object, so if the galaxy cluster were not there, you would only see one source, and the lens model MUST map multiple images to the same source behind the lens.</p>
<p>Once you have a precise enough model, you basically know how the mass distribution of the cluster bends the light. Take any light-ray coming to you through the cluster and you can know very precisely where it came from behind the lens. A &quot;distorted&quot; source looks distorted just because different regions of this source are in slightly different positions, and pass through different regions in the &quot;lens&quot;, but you now know the mass distribution, so you can use it to &quot;undistort&quot; the source and see how it really is behind the cluster.</p>
<p>Gravitational lensing in galaxy clusters works almost exactly in the same way as conventional optics, that's why is relatively easy to make lens models and . If you have more questions, I am happy to answer them.</p>
<p>Edit added from comments</p>
<p>Both papers use a parametric approach (using physical models for the mass distributions) and the same software (LENSTOOL). Now talking about multiple images, this is first done just (believe it or not) by eye. Then you iteratively use the lens model to find new images (complemented with spectroscopy if available). But basically, both papers just do the same, they just use the new JWST data to find new multiple images systems and improve the lens models. (More multiple images-&gt;better model). The ability to find new systems depends just on eye shaperness at the moment.</p>

CC BY-SA 4.0
2022-12-01T22:12:46.273Z
Certainly the ray-tracing calculations through a given model of mass distribution is not hard (something *a little bit* like [this](https://math.stackexchange.com/q/4181503/284619)) but so far all you've said is start with a guess based on what you are sure of, then refine it, which is how I learned to implement least-squares fitting in high school. Can you add to this a few specifics? Which objects were obvious at first? How did these two groups find such different ways to solve the same problem? Thanks, and *Welcome to Stack Exchange!*
uhoh
CC BY-SA 4.0
2022-12-05T14:44:53.870Z
They both use a parametric approach (using physical models for the mass distributions) and the same software (LENSTOOL). Now talking about multiple images, this is first done just (believe it or not) by eye. Then you iteratively use the lens model to find new images (complemented with spectroscopy if available). But basically, both papers just do the same, they just use the new JWST data to find new multiple images systems and improve the lens models. (More multiple images->better model). The ability to find new systems depends just on eye shaperness at the moment.
JOAQUÍN HERNÁNDEZ
CC BY-SA 4.0
2022-12-05T14:51:44.530Z
I can not explain all the details because it would be too many characters. But if you read the sections where they explain what they do with the lens models, you may find your answer. They say that they use the previous lens model (or add new mass component) and they just found new multiple images in JWST data. HOW multiple images are found is never fully explained. People just learn how to do it from other expert people and they almost never explicitly explain the procedures in the papers.
JOAQUÍN HERNÁNDEZ
CC BY-SA 4.0
2022-12-05T20:44:14.210Z
Okay I've got the picture (so to speak) *thanks!* You might consider moving this insight back into the answer post to ensure it remains a permanent part of the answer (some future readers will skip comments, and comments are considered temporary and subject to possible future deletion without warning). Certainly the bit about both using LENSTOOL and a link to it would be nice.
uhoh
CC BY-SA 4.0
2022-12-06T20:33:14.147Z
Sure I will. LENSTOOL is the code used to produce the lens models. You basically tell it where and what mass distributions to put in your model, and it optimizes the best parameters of these models using an MCMC algorithm. Once you have a model you are happy with, LENSTOOL allows you to produce "images" of the mass distributions, calculate the deflection angles produced by the lens, estimate light arrival times, calculate magnifications, and a lot of other things.

https://projets.lam.fr/projects/lenstool/wiki

This is the project's main page. It is not that good, but this is it.
JOAQUÍN HERNÁNDEZ
CC BY-SA 4.0
2022-12-01T18:11:01.687Z
2022-12-06T20:34:11.530Z
2022-12-06T20:34:11.530Z
JOAQUÍN HERNÁNDEZ
<p>Quanta Magazine's <a href="https://www.quantamagazine.org/two-weeks-in-the-webb-space-telescope-is-reshaping-astronomy-20220725/" rel="noreferrer">Two Weeks In, the Webb Space Telescope Is Reshaping Astronomy</a> highlights two submissions to arXiv soon after the first images were released: &quot;Three days later, just minutes before the daily deadline on arxiv.org...&quot; It certainly sounds exciting!</p>
<ul>
<li><a href="https://arxiv.org/abs/2207.07102" rel="noreferrer"><strong>Unscrambling</strong> the lensed galaxies in JWST images behind SMACS0723</a></li>
</ul>
<blockquote>
<p>The first deep field images from the James Webb Space Telescope (JWST) of the galaxy cluster SMACS~J0723.3-7327 reveal a wealth of new lensed images at uncharted infrared wavelengths, with unprecedented depth and resolution. Here we securely identify 14 new sets of multiply imaged galaxies totalling 42 images, adding to the five sets of bright and multiply-imaged galaxies already known from Hubble data. We find examples of arcs crossing critical curves with magnification factors of at least 150, allowing detailed community follow-up, including JWST spectroscopy for precise redshift determinations, chemical abundances and detailed internal gas dynamics of very distant, young galaxies. We also detect an Einstein cross candidate only visible thanks to JWST's superb resolution. Our parametric lens model is available at this https URL , and will be regularly updated using additional spectroscopic redshifts. The model reproduces very well the multiple images, and allows for accurate magnification estimates of high-redshift galaxies. This work represents a first taste of the enhanced power JWST will have for lensing-related science.</p>
</blockquote>
<ul>
<li><a href="https://arxiv.org/abs/2207.07101" rel="noreferrer"><strong>Precision modeling</strong> of JWST's first cluster lens SMACSJ0723.3-7327</a></li>
</ul>
<blockquote>
<p>Exploiting the fundamentally achromatic nature of gravitational lensing, we present a lens model for the massive galaxy cluster SMACSJ0723.3-7323 (SMACS J0723, z=0.388) that significantly improves upon earlier work. Building on strong-lensing constraints identified in prior Hubble Space Telescope (HST) observations, the mass model utilizes 21 multiple-image systems, 16 of which were newly discovered in Early Release Observation (ERO) data from the James Webb Space Telescope (JWST). The resulting lens model maps the cluster mass distribution to an RMS spatial precision of 1.08'' and is publicly available at this https URL . Consistent with previous analyses, our study shows SMACSJ0723.3-7323 to be well described by a single large-scale component centered on the location of the brightest cluster galaxy, however JWST data point to the need for two additional diffuse components west of the cluster, which in turn accounts for all the currently identified multiply imaged systems. A comparison of the galaxy distribution, the mass distribution, and gas distribution in the core of SMACS0723 based on HST, JWST, and Chandra data reveals a fairly concentrated regular elliptical profile along with tell-tale signs of recent merger activity, possibly proceeding aligned closely to our line of sight. The exquisite sensitivity of JWST's NIRCAM reveals in spectacular fashion both the extended intra-cluster-light distribution and numerous star-forming clumps in magnified background galaxies. The high-precision lens model derived here for SMACSJ0723-7323 demonstrates impressively the power of combining HST and JWST data for unprecedented studies of structure formation and evolution in the distant Universe.</p>
</blockquote>
<p>While the groups chose different algorithms for title selection (&quot;unscrambling&quot; vs &quot;precision modeling&quot;) I wonder if they used similar variations on the same technique?</p>
<p><strong>Question:</strong> How do they do this? How do astronomers <em>unscramble</em> or <em>precision-model</em> the undistorted image from an observed image gravitationally lensed by a complex (or at least lumpy) gravitational field. Is there an easy way to explain it as a straightforward algorithm, or is it more like solving a jigsaw puzzle - a long series of guesses and decisions and tests?</p>

CC BY-SA 4.0
2022-07-26T00:32:42.500Z
Maybe you could un-scramble an egg with a computer? :)
paul garrett
CC BY-SA 4.0
2022-07-26T04:14:15.440Z
Basically, when you scramble an egg, you also change its chemistry. The energy you have input into it by the whisking action, and the fact that parts were in contact which would not have been in contact normally, all that changes its nature. When light goes through a lens, gravitational or otherwise, its nature is not changed. It’s twisted, but it still remains light.
Pierre Paquette
CC BY-SA 4.0
2022-07-26T08:48:32.537Z
The short answer is that gravitational distorsions are non linear but not too strongly non linear, and with significant coherence, so it is in effect possible to reverse them to some extend. You could probably un scramble the egg if you had a snapshot an instant after it started breaking.
chris
CC BY-SA 4.0
2022-07-26T17:05:37.470Z
It's a bit of a chicken-and-egg situation. ;) The lensing mass distribution determines the distortion, but we measure that mass distribution from the distortion. So you start with approximate models of the masses and the undistorted field, ray-trace, and gradually refine the models, possibly using a process similar to a multidimensional version of the Remez algorithm.  https://en.wikipedia.org/wiki/Remez_algorithm Maybe some Fourier magic is used, too.
PM 2Ring
CC BY-SA 4.0
2022-07-26T18:24:55.593Z
It helps that the mass distribution of a cluster of galaxies is mostly from the intracluster medium (gas and dark matter between the galaxies), and its lensing effects are well approximated by a simple spheroid.  The individual galaxies are almost insignificant  perturbations to that unless the image lies right on a galaxy.  With this JWST data one can apparently make out some additional low mass subclumps of galaxies.
eshaya
CC BY-SA 4.0
2022-07-26T21:09:20.627Z
@PM2Ring Yes I think "refinement" is likely to be a key point. I'm hoping they started with a bunch of random distributions and used some kind of [simulated annealing](https://en.wikipedia.org/wiki/Simulated_annealing) algorithm for at least part of the refinement for nostalgic reasons. I learned to do that decades ago when making [computer generated holograms](https://en.wikipedia.org/wiki/Computer-generated_holography). I suppose the same technique could be used to calculate and optimize [transmission caustics](https://physics.stackexchange.com/a/637662/83380) (see first few links)
uhoh
CC BY-SA 4.0
2022-07-26T21:10:15.483Z
@chris a little bit like [Destin's depiction of laminar flow](https://youtu.be/j2_dJY_mIys?t=129)?
uhoh
CC BY-SA 4.0
2022-07-27T12:06:48.940Z
@paulgarrett  Agreed :-) , since at the atomic level you can rebuild the original molecules and compounds.  Not a simple task.  It's easier to feed the scrambled egg to a hen and get a new egg from the hen-engine.
Carl Witthoft
CC BY-SA 4.0
2022-07-27T17:10:14.597Z
@CarlWitthoft, and we could further muddle the rhetoric by some claim about the advantages of _quantum_ computers over classical ones in unscrambling eggs. :)
paul garrett
CC BY-SA 4.0
2022-08-06T20:39:23.963Z
We can't unscramble an egg, but 7 years ago someone figured out how to uncook egg whites.  https://chemistry-europe.onlinelibrary.wiley.com/doi/abs/10.1002/cbic.201402427
Camille Goudeseune
CC BY-SA 4.0
2022-08-06T21:49:01.207Z
@CamilleGoudeseune I'm going to think hard to try to find a way for that topic to somehow reappear in Cooking SE, and after I read it I'll see if I can get help in Chemistry SE to learn how to do that in my kitchen. In the mean time, on that page (for some reason) I found links to two other interesting papers [Eyebrows cue grandiose narcissism](https://onlinelibrary.wiley.com/doi/abs/10.1111/jopy.12396) and [Does pizza protect against cancer?](https://onlinelibrary.wiley.com/doi/full/10.1002/ijc.11382) hmm...
uhoh
CC BY-SA 4.0
2022-08-23T17:12:11.717Z
Here’s [some](https://royalsocietypublishing.org/doi/pdf/10.1098/rsta.2009.0209?download=true) [visuals](http://gravitationallensing.pbworks.com/w/page/15553257/strong%20lensing) that may not be a full answer but certainly gave me a lot of insight (the visual for the former link is the one on page 973)
Justin T
CC BY-SA 4.0
2022-08-24T22:32:36.257Z
@JustinT oh so cool; what a fun article to read, thanks!
uhoh
<observational-astronomy><data-analysis><gravitational-lensing><james-webb-space-telescope><image-processing>
If I can't unscramble an egg, how do Astronomers unscramble views gravitationally lensed by complex mass distributions?
uhoh
# If I can't unscramble an egg, how do Astronomers unscramble views gravitationally lensed by complex mass distributions?

(Asked by: username_0 on 2022-07-25)

Quanta Magazine's [Two Weeks In, the Webb Space Telescope Is Reshaping Astronomy](https://www.quantamagazine.org/two-weeks-in-the-webb-space-telescope-is-reshaping-astronomy-20220725/) highlights two submissions to arXiv soon after the first images were released: "Three days later, just minutes before the daily deadline on arxiv.org..." It certainly sounds exciting!

* [**Unscrambling** the lensed galaxies in JWST images behind SMACS0723](https://arxiv.org/abs/2207.07102)

> The first deep field images from the James Webb Space Telescope (JWST) of the galaxy cluster SMACS~J0723.3-7327 reveal a wealth of new lensed images at uncharted infrared wavelengths, with unprecedented depth and resolution. Here we securely identify 14 new sets of multiply imaged galaxies totalling 42 images, adding to the five sets of bright and multiply-imaged galaxies already known from Hubble data. We find examples of arcs crossing critical curves with magnification factors of at least 150, allowing detailed community follow-up, including JWST spectroscopy for precise redshift determinations, chemical abundances and detailed internal gas dynamics of very distant, young galaxies. We also detect an Einstein cross candidate only visible thanks to JWST's superb resolution. Our parametric lens model is available at this https URL , and will be regularly updated using additional spectroscopic redshifts. The model reproduces very well the multiple images, and allows for accurate magnification estimates of high-redshift galaxies. This work represents a first taste of the enhanced power JWST will have for lensing-related science.

* [**Precision modeling** of JWST's first cluster lens SMACSJ0723.3-7327](https://arxiv.org/abs/2207.07101)

> Exploiting the fundamentally achromatic nature of gravitational lensing, we present a lens model for the massive galaxy cluster SMACSJ0723.3-7323 (SMACS J0723, z=0.388) that significantly improves upon earlier work. Building on strong-lensing constraints identified in prior Hubble Space Telescope (HST) observations, the mass model utilizes 21 multiple-image systems, 16 of which were newly discovered in Early Release Observation (ERO) data from the James Webb Space Telescope (JWST). The resulting lens model maps the cluster mass distribution to an RMS spatial precision of 1.08'' and is publicly available at this https URL . Consistent with previous analyses, our study shows SMACSJ0723.3-7323 to be well described by a single large-scale component centered on the location of the brightest cluster galaxy, however JWST data point to the need for two additional diffuse components west of the cluster, which in turn accounts for all the currently identified multiply imaged systems. A comparison of the galaxy distribution, the mass distribution, and gas distribution in the core of SMACS0723 based on HST, JWST, and Chandra data reveals a fairly concentrated regular elliptical profile along with tell-tale signs of recent merger activity, possibly proceeding aligned closely to our line of sight. The exquisite sensitivity of JWST's NIRCAM reveals in spectacular fashion both the extended intra-cluster-light distribution and numerous star-forming clumps in magnified background galaxies. The high-precision lens model derived here for SMACSJ0723-7323 demonstrates impressively the power of combining HST and JWST data for unprecedented studies of structure formation and evolution in the distant Universe.

While the groups chose different algorithms for title selection ("unscrambling" vs "precision modeling") I wonder if they used similar variations on the same technique?

**Question:** How do they do this? How do astronomers *unscramble* or *precision-model* the undistorted image from an observed image gravitationally lensed by a complex (or at least lumpy) gravitational field. Is there an easy way to explain it as a straightforward algorithm, or is it more like solving a jigsaw puzzle - a long series of guesses and decisions and tests?

**Tags:** observational-astronomy, data-analysis, gravitational-lensing, james-webb-space-telescope, image-processing
> **Comments:**
> **username_1**: Maybe you could un-scramble an egg with a computer? :)  
> **username_2**: Basically, when you scramble an egg, you also change its chemistry. The energy you have input into it by the whisking action, and the fact that parts were in contact which would not have been in contact normally, all that changes its nature. When light goes through a lens, gravitational or otherwise, its nature is not changed. It’s twisted, but it still remains light.  
> **username_3**: The short answer is that gravitational distorsions are non linear but not too strongly non linear, and with significant coherence, so it is in effect possible to reverse them to some extend. You could probably un scramble the egg if you had a snapshot an instant after it started breaking.  
> **username_4**: It's a bit of a chicken-and-egg situation. ;) The lensing mass distribution determines the distortion, but we measure that mass distribution from the distortion. So you start with approximate models of the masses and the undistorted field, ray-trace, and gradually refine the models, possibly using a process similar to a multidimensional version of the Remez algorithm.  https://en.wikipedia.org/wiki/Remez_algorithm Maybe some Fourier magic is used, too.  
> **username_5**: It helps that the mass distribution of a cluster of galaxies is mostly from the intracluster medium (gas and dark matter between the galaxies), and its lensing effects are well approximated by a simple spheroid.  The individual galaxies are almost insignificant  perturbations to that unless the image lies right on a galaxy.  With this JWST data one can apparently make out some additional low mass subclumps of galaxies.  
> **username_0**: @PM2Ring Yes I think "refinement" is likely to be a key point. I'm hoping they started with a bunch of random distributions and used some kind of [simulated annealing](https://en.wikipedia.org/wiki/Simulated_annealing) algorithm for at least part of the refinement for nostalgic reasons. I learned to do that decades ago when making [computer generated holograms](https://en.wikipedia.org/wiki/Computer-generated_holography). I suppose the same technique could be used to calculate and optimize [transmission caustics](https://physics.stackexchange.com/a/637662/83380) (see first few links)  
> **username_0**: @chris a little bit like [Destin's depiction of laminar flow](https://youtu.be/j2_dJY_mIys?t=129)?  
> **username_6**: @paulgarrett  Agreed :-) , since at the atomic level you can rebuild the original molecules and compounds.  Not a simple task.  It's easier to feed the scrambled egg to a hen and get a new egg from the hen-engine.  
> **username_1**: @CarlWitthoft, and we could further muddle the rhetoric by some claim about the advantages of _quantum_ computers over classical ones in unscrambling eggs. :)  
> **username_7**: We can't unscramble an egg, but 7 years ago someone figured out how to uncook egg whites.  https://chemistry-europe.onlinelibrary.wiley.com/doi/abs/10.1002/cbic.201402427  
> **username_0**: @CamilleGoudeseune I'm going to think hard to try to find a way for that topic to somehow reappear in Cooking SE, and after I read it I'll see if I can get help in Chemistry SE to learn how to do that in my kitchen. In the mean time, on that page (for some reason) I found links to two other interesting papers [Eyebrows cue grandiose narcissism](https://onlinelibrary.wiley.com/doi/abs/10.1111/jopy.12396) and [Does pizza protect against cancer?](https://onlinelibrary.wiley.com/doi/full/10.1002/ijc.11382) hmm...  
> **username_8**: Here’s [some](https://royalsocietypublishing.org/doi/pdf/10.1098/rsta.2009.0209?download=true) [visuals](http://gravitationallensing.pbworks.com/w/page/15553257/strong%20lensing) that may not be a full answer but certainly gave me a lot of insight (the visual for the former link is the one on page 973)  
> **username_0**: @JustinT oh so cool; what a fun article to read, thanks!  

---

## 1 answers

### Answer by username_9 on 2022-12-01. Score: 9 | Accepted answer

I work in gravitational lensing, so maybe I can give you an idea.

In those JWST you have a massive galaxy cluster that is bending the light behind and acting as a true lens. If you have a temptative model of the mass distribution, including the dark matter halo of the cluster and the cluster galaxies, you can find the best mass distribution model by fitting the model to some observables. These observables are objects with multiple images.

Some objects with multiple images are obvious, just take a detailed look at the images of the cluster yourself. Once you identify these multiple images, you can use them to find the best mass model that reproduces those images. Then you can use this model to predict new images, and see if you find something that you previously missed, so you can improve the lens model again. It is an iterative process. The key here is that if you have an object with multiple images, you know it is the same object, so if the galaxy cluster were not there, you would only see one source, and the lens model MUST map multiple images to the same source behind the lens.

Once you have a precise enough model, you basically know how the mass distribution of the cluster bends the light. Take any light-ray coming to you through the cluster and you can know very precisely where it came from behind the lens. A "distorted" source looks distorted just because different regions of this source are in slightly different positions, and pass through different regions in the "lens", but you now know the mass distribution, so you can use it to "undistort" the source and see how it really is behind the cluster.

Gravitational lensing in galaxy clusters works almost exactly in the same way as conventional optics, that's why is relatively easy to make lens models and . If you have more questions, I am happy to answer them.

Edit added from comments

Both papers use a parametric approach (using physical models for the mass distributions) and the same software (LENSTOOL). Now talking about multiple images, this is first done just (believe it or not) by eye. Then you iteratively use the lens model to find new images (complemented with spectroscopy if available). But basically, both papers just do the same, they just use the new JWST data to find new multiple images systems and improve the lens models. (More multiple images->better model). The ability to find new systems depends just on eye shaperness at the moment.

> **Comments:**
> **username_0**: Certainly the ray-tracing calculations through a given model of mass distribution is not hard (something *a little bit* like [this](https://math.stackexchange.com/q/4181503/284619)) but so far all you've said is start with a guess based on what you are sure of, then refine it, which is how I learned to implement least-squares fitting in high school. Can you add to this a few specifics? Which objects were obvious at first? How did these two groups find such different ways to solve the same problem? Thanks, and *Welcome to Stack Exchange!*  
> **username_9**: They both use a parametric approach (using physical models for the mass distributions) and the same software (LENSTOOL). Now talking about multiple images, this is first done just (believe it or not) by eye. Then you iteratively use the lens model to find new images (complemented with spectroscopy if available). But basically, both papers just do the same, they just use the new JWST data to find new multiple images systems and improve the lens models. (More multiple images->better model). The ability to find new systems depends just on eye shaperness at the moment.  
> **username_9**: I can not explain all the details because it would be too many characters. But if you read the sections where they explain what they do with the lens models, you may find your answer. They say that they use the previous lens model (or add new mass component) and they just found new multiple images in JWST data. HOW multiple images are found is never fully explained. People just learn how to do it from other expert people and they almost never explicitly explain the procedures in the papers.  
> **username_0**: Okay I've got the picture (so to speak) *thanks!* You might consider moving this insight back into the answer post to ensure it remains a permanent part of the answer (some future readers will skip comments, and comments are considered temporary and subject to possible future deletion without warning). Certainly the bit about both using LENSTOOL and a link to it would be nice.  
> **username_9**: Sure I will. LENSTOOL is the code used to produce the lens models. You basically tell it where and what mass distributions to put in your model, and it optimizes the best parameters of these models using an MCMC algorithm. Once you have a model you are happy with, LENSTOOL allows you to produce "images" of the mass distributions, calculate the deflection angles produced by the lens, estimate light arrival times, calculate magnifications, and a lot of other things.  https://projets.lam.fr/projects/lenstool/wiki  This is the project's main page. It is not that good, but this is it.  

---

