text:
# How to color numbers in certain parts of a lstlisting

So, I'm a student and my teacher posted this kind of "how to make XML look cool in LaTeX". We were using it in class but I noticed some errors.

For example, when printing numbers inside the labels (as in <number> this is 25 </number>) the program won't print the number 25 the same color as the rest of the words.

A picture is worth a thousand words:

I'd like them printed in the same way that the rest of the text. I tried telling LaTeX to print all the numbers red, but that works too for the XML declaration. Which is not nice.

There's any way to do what I'm asking for?

Thanks for the help, I'm a total noob :D

Sorry for the bad english <3

The actual code:

\documentclass[11.5pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
\usepackage{newtxtext}

\lstdefinelanguage{XML}{
basicstyle=\ttfamily\footnotesize,
morestring=[b]",
moredelim=[s][\bfseries\color{Maroon}]{<}{\ },
moredelim=[s][\bfseries\color{Maroon}]{</}{>},
moredelim=[l][\bfseries\color{Maroon}]{/>},
moredelim=[l][\bfseries\color{Maroon}]{>},
morecomment=[s]{<?}{?>},
numberstyle=\color{red}
morecomment=[s]{<!--}{-->},
stringstyle=\color{blue},
identifierstyle=\color{red},
extendedchars=true,
literate=
{á}{{\textcolor{red}{\'a}}}{1}
{é}{{\textcolor{red}{\'e}}}{1}
{í}{{\textcolor{red}{\'i}}}{1}
{ó}{{\textcolor{red}{\'o}}}{1}
{ú}{{\textcolor{red}{\'u}}}{1}
{ñ}{{\textcolor{red}{\"n}}}{1},
}

\begin{document}
\lstset{language=XML}
\begin{lstlisting}
<number> This is 25</number>
\end{lstlisting}
\end{document}

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Reinstate Monica - M. Schröder Nov 30 '15 at 21:29


text:
## unimatix one year ago Integral (3x+1)/(x^2-3x+2) dx

1. unimatix

|dw:1441664655453:dw|

2. anonymous

did you try partial fractions?

3. unimatix

No hold I'll try that.

4. unimatix

Not sure how to do that in this case.

5. unimatix

Maybe like a 1/3 x?

6. anonymous

factor the denominator to $$(x-1)(x-2)$$ Then the original fraction can be written as $\frac{ A }{ x-1 }+\frac{ B }{ x-2 }$

7. anonymous

$\frac{ 3x+1 }{ (x-1)(x-2) }=\frac{ A }{ x-1 }+\frac{ B }{ x-2 }$

8. unimatix

Okay I got that.

9. unimatix

I'm watching a video on partial fractions because it's been so long since I've seen them.

10. Jhannybean

$\frac{3x+1}{x^2-3x+2} = \frac{3x+1}{(x-2)(x-1)}$$\frac{3x+1}{(x-2)(x-1)} = \frac{A}{(x-2)}+\frac{B}{(x-1)}$$3x+1=A(x-1)+B(x-2)$Yu could use a system of equations or the "zero" method to solve for the x's

11. anonymous

add on the right then set thh denominators equal. $A(x-1)+B(x-2)=3x+1$ Equate the coefficients and solve the system $A+B=3$ $-A-2B=1$

12. anonymous

And then once you have A and B the integral becomes $\int\limits \left( \frac{ A }{ x-1 }+\frac{ B }{ x-2 } \right)dx$

13. Jhannybean

Let's say we took $$x=1$$, then $3(1)+1=A(1-1)+B(1-2)$$4=0-B$$B=-4$$3x+1=A(x-1)+B(x-2)$$3(2)+1=A(2-1)+0$$7=A$

14. amistre64

not sure if partials are needed, what is the derivative of the bottom to start with? can we modify the top?

15. Jhannybean

Basically trying to find what makes A and B = 0... etc.

16. Jhannybean

$\int \left(\frac{7}{x-1}-\frac{4}{x-2}\right)dx$... Trying to refresh my memory on Partial Fraction Decomposition as well. I found PFD easier because the polynomial at the bottom could be factored, and factoring leads me to partial fractions.. etc.

17. amistre64

2x-3: 3x+1+(-x+4+x-4) 2x-3: 2x-3+(x+4) meh, would still need it for part of it i spose ...

18. Jhannybean

$7\int \left(\frac{1}{x-1}\right)dx -4\int \left(\frac{1}{x-2}\right)dx$ Im guessing?

19. Jhannybean

@unimatix Are you capable of continuing from here?

20. unimatix

I think so! Thanks for all your help everyone!

21. Jhannybean

And can you show me how you would integrate this? Just want to make sure you do it right.

format: plain


text:
# Return mantissa and exponent as a pair of a given tuple in Numpy

NumpyServer Side ProgrammingProgramming

To return mantissa and exponent as a pair of a given tuple, use the numpy.frexp() method in Python Numpy. The out is a location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned. A tuple (possible only as a keyword argument) must have length equal to the number of outputs.

NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.

## Steps

At first, import the required library −

import numpy as np

Create a tuple −

myTuple = (37.2, 39.2, 166.8, -14.8, 78,6, -19.8)

Display the array −

print("Tuple...\n", myTuple)

Length of the tuple −

print("\nTuple length...\n", len(myTuple))

Type of the tuple −

print("\nTuple type...\n", type(myTuple))

To return mantissa and exponent as a pair of a given tuple, use the numpy.frexp() method in Python Numpy −

print("\nResult...\n",np.frexp(myTuple))

## Example

import numpy as np

# Create a tuple
myTuple = (37.2, 39.2, 166.8, -14.8, 78,6, -19.8)

# Display the tuple
print("Tuple...\n", myTuple)

# Length of the tuple
print("\nTuple length...\n", len(myTuple))

# Type of the tuple
print("\nTuple type...\n", type(myTuple))

# To return mantissa and exponent as a pair of a given tuple, use the numpy.frexp() method in Python Numpy
print("\nResult...\n",np.frexp(myTuple))

## Output

Tuple...
(37.2, 39.2, 166.8, -14.8, 78, 6, -19.8)

Tuple length...
7

Tuple type...
<class 'tuple'>

Result...
(array([ 0.58125 , 0.6125 , 0.6515625, -0.925 , 0.609375 , 0.75 , -0.61875 ]), array([6, 6, 8, 4, 7, 3, 5], dtype=int32))
Updated on 08-Feb-2022 07:08:11


text:
TheInfoList

A packing density or packing fraction of a packing in some space is the fraction of the space filled by the figures making up the packing. In packing problems, the objective is usually to obtain a packing of the greatest possible density.

## In compact spaces

If K1,…,Kn are measurable subsets of a compact measure space X and their interiors pairwise do not intersect, then the collection {Ki} is a packing in X and its packing density is

${\displaystyle \eta ={\frac {\sum _{i=1}^{n}\mu (K_{i})}{\mu (X)}}}$.

## In Euclidean space

If the space being packed is infinite in measure, such as Euclidean space, it is customary to define the density as the limit of densities exhibited in balls of larger and larger radii. If Bt is the ball of radius t centered at the origin, then the density of a packing {Ki : i∈ℕ} is


text:
# Uniform kernel estimator

For practice, I'm trying to provide an estimation for a nonparametric model on dataset BMACS from library (npmlda). I'm having trouble to set up a kernel estimator with Uniform(-1/2,1/2) kernel and bandwidth h = 0.5.

The outcome I'm interested in is CD4 over time, which I believe the initial set up should be:

fit.linear.1 <- loess(CD4 ~ Time , span =0.5 , degree=1, data=BMACS)

plot(CD4 ~ Time, data=BMACS,  xlab = "Time since infection (years)", ylab =
"CD4 percentage", ylim=c(0,65), cex=0.7, col='gray50', main="Local linear:
span=0.5")

lines(Time.int, predict(fit.linear.1 , data.frame(Time  = Time.int)),col=1,
lwd=2) mtext("A.", cex=1.3, side=3, line=0.7, font=2, at=-0.9)

I'm not very clear on what type of limit is represented by (-1/2, 1/2). If it is the limit for Time, then the smoothed curve will be too short to have any purpose for this analysis? If it is the range for the uniform kernel what function should I use for the setup that allows me to define a bandwidth?

Could anyone suggest a possible setup in R for the problem?

• i am quite confuse what is your issue, because you have not used the limit (-1/2, 1/2) in your code? – Angel Nov 3 '18 at 5:38
• If you want to use kernel by your own choice then other function allows this but not loess() – Angel Nov 3 '18 at 5:45
• @Angel I added xlim = c(-1/2,1/2) to my plot, but my question is actually not certain what (-1/2, 1/2) indicates. I want to have some confirmation that Uniform(-1/2, 1/2) is, in fact, referring to the x limit being (-1/2,1/2). – lydias Nov 3 '18 at 5:45
• @Angel what do you mean by my own choice? Can I express Uniform(-1/2, 1/2) in another way? Other than fitting with loess()? – lydias Nov 3 '18 at 5:47
• Uniform(-1/2, 1/2) tells the range of your variable and on the side xlim = c(-1/2,1/2) set the x-axis. Both are not same. – Angel Nov 3 '18 at 5:48

library(npmlda)
local_polynomial <- locpoly(y = readdata$$CD4, x = readdata$$Time, degree = 3, bandwidth = 0.5,        kernel = "Uniform")
plot(readdata$$CD4 ~ readdata$$Time, data= readdata,  xlab = "Time since infection (years)", ylab ="CD4 percentage",  xlim = c(-1/2,1/2), ylim=c(0,65), cex=0.7, col='gray50', main="Local linear: span=0.1")


text:
# QOF News

### Calculating prevalence

For ease of comparison all of the prevalences on this site are based on the whole practice registered list, not just those in the correct age group - this applies to areas such as diabetes or epilepsy. This is largely because countries other than England do not list the specific number of patients on the practice list over, say, seventeen years old. It is also the prevalence that is used for adjustment of point value.
I was asked this week why the whole list is used for prevalence adjustment rather than the age adjusted subgroup. Is this unfair on practices? Well the answer is no, it is actually more fair the way it is, but for some quite complicated reasons. We have to look at some maths.
$\begin{array}{c}\mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{PracPrev}}{\mathrm{AvgPrev}}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\left(\frac{\mathrm{Register}}{\mathrm{PracList}}\right)}{\left(\frac{\mathrm{AvgReg}}{\mathrm{AvgList}}\right)}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{Register}}{\overline{)\mathrm{PracList}}}×\frac{\overline{)\mathrm{AvgList}}}{\mathrm{AvgReg}}×\frac{\overline{)\mathrm{PracList}}}{\overline{)\mathrm{AvgList}}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{Register}}{\mathrm{AvgReg}}\end{array}$

We have started from saying that the point value is modified by the practice prevalence relative to the average practice prevalence. Then the point value is modified by the relative size of the practice list overall. The second line expands this a bit by using the register size and the list size against the averages. It is true that this is not exactly how the average prevalence is calculated but it is pretty close.

After simplifying the formula there is a lot we can cancel from the top and bottom until we get to the final formula which basically says that the practice gets a set amount per person on the register but that this drops as the national average register size rises. Nothing else matters.

We can try again using an 'Eligible' denominator for the register.

$\begin{array}{c}\mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{PracPrev}}{\mathrm{AvgPrev}}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\left(\frac{\mathrm{Register}}{\mathrm{Eligible}}\right)}{\left(\frac{\mathrm{AvgReg}}{\mathrm{AvgEgble}}\right)}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{Register}}{\mathrm{Eligible}}×\frac{\mathrm{AvgEgble}}{\mathrm{AvgReg}}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\\ \\ \mathrm{Point}\mathrm{value}=\mathrm{£}160×\frac{\mathrm{AvgEgble}}{\mathrm{Eligible}}×\frac{\mathrm{Register}}{\mathrm{AvgReg}}×\frac{\mathrm{PracList}}{\mathrm{AvgList}}\end{array}$

There is much the same process here but there is a lot less to cancel out. That is not necessarily a bad thing but we can see how this formula behaves. If we assume a practice of average list size then the last term will be one. If it has an average register size for diabetes then the middle term will be one as well. Interestingly in this case the point value would vary with the proportion of over 17 year olds on the practice list (i.e. Eligible would change without changing the overall list size). This is not what we want to see at all as the practice list makeup would alter income without any change to the actual number of patients treated.

So that is why the overall list size is used to calculate prevalence.


text:
# Equation relating Points of Parallelogram in Complex Plane/Mistake

## Source Work

Chapter $2$: Geometrical Representations
Exercise $7$

This mistake can be seen in the $1960$ edition as published by Routledge & Kegan Paul.

## Mistake

The vertices parallelogram $ABVU$ are represented by the complex numbers $a, b, v, u$ respectively. The angle $UAB$ is equal to $\alpha$ and $\cmod {UA} = \lambda \cmod {AB}$. Prove that $u = \paren {1 - q} a + q b$ and $v = -q a + \paren {1 + q} b$, where $q = \lambda e^{i \alpha}$.

The configuration as described is:

However, because of the sense of $UAB$, this leads to:

$u = \paren {1 - q} a + q b$ and $v = -q a + \paren {1 + q} b$, where $q = \lambda e^{-i \alpha}$.

The question as it was intended to be stated should contain:

The angle $BAU$ is equal to $\alpha$ ...

See Equation relating Points of Parallelogram in Complex Plane for a solution to the correctly-stated exercise.


text:
# In what context can enriched category theory be done?

There are many possible situations one can do enriched category theory. See https://ncatlab.org/nlab/show/category+of+V-enriched+categories#possible_contexts for a list.

My question is what characterizes this list?

Is there a general structure on a bicategory $B$ that we can develop a theory of $\mathcal{V}$-enriched category, for $\mathcal{V}\in ob B$ (along with base change functors) that "behave well"?

For example, if we take skew-closed categories as the enriching context, there is no yoneda lemma unless the enriching category is left normal. Therefore there should be some restrictions on the bicategory.

My motivation is that I work in one of these contexts (closed categories), and it seems the only property I really need in order to do 2-categorial constructions is the enriched yoneda lemma (the yoneda structure of $V$-categories). The details of the enriching context are not relevent to the construction, and can be removed, if we only assumed a bicategory where one can do enriched category theory.

EDIT: The definition be something as follows (I'm not being precise about what notion of $3$-categories we work in as I don't know what it should be):

There is a $3$-category called $Context$ (whose objects are bicategories of enrichment contexes, with $MonCat$ being the prime example) along with a $3$-functor $(-)Cat: Context \to 3Cat$ that satisfies a bunch of axioms that make it look like the theory of enrichment along with base change.

Then there should be a sub-$3$-category of contexes whose "enrichement theory functor $(-)Cat$" gives rise to $3$-categories equipped with a yoneda structure that is compatible along base change (and other structure?).

Aside: If this sub-$3$-category exists, there can be a "completeness functor" (left adjoint to the inclusion). And in this functor for example, the completeness of $MonCat$ would probably be $SymClosedCat$ if that makes sense. For $SkewClosedCat$ the closure should be the $ClosedCat$ If we have such a completeness functor, and if the subcategory contains an initial object (which I believe exists) then we can have a very thorough description of "what is enrichment" and when two bicategories give the same information when enriching over them.

Following the comment: if we manage to define this situation, then enrichement in $n$-categories can be described using descent of $(-)Cat$ along all the forgetful functors from $nCat$ to $(n-1)Cat$

• Is "${\cal V}\in Bicat$" a sufficient request? You can do quite a lot of category theory in bicategory-enriched categories. For example, you can re-do universal algebra and Gabriel-Ulmer duality. – Fosco Loregian Aug 27 '18 at 19:47
• The point of this question is "what are the minimal assumptions on the enriching context" to develop a well behaved theory of "enriched categories". Now we can do a lot of category theory indeed in $Bicat$-enriched categories, but it seems overly strict. If we only try to develop the $2$-categorial tools for the $2$-category of $V$-categories, all we really need is the yoneda structure. This is a closer goal (as we stay in the realm of $2$-categories, well at least until we introduce base-change). – Omer Rosler Aug 27 '18 at 20:26
• You may find Garner and Shulman's work interesting. They develop a theory of bicategories enriched in a tricategory, and show that for a certain monoidal bicategory they call $\mathcal F_\infty$, the passage from a locally cocomplete proarrow equipment to its proarrow equipment of enriched categories is a free cocompletion under a certain type of $\mathcal F_\infty$-enriched colimit called a "tight collage". I think if I were looking for a general context to talk about enrichment I would look for a similar "free cocompletion" type statement. – Tim Campion Aug 27 '18 at 22:46
• Mike Shulman’s paper Enriched indexed categories lays out a quite general setting for enriched cats, which might be relevant, though I haven’t time now to check through whether it covers all your examples. Martin Lundfall’s masters thesis Models of Linear Dependent Type Theory presents of a slightly less general but still quite general setup, in terms of linear logic. – Peter LeFanu Lumsdaine Aug 28 '18 at 6:46
• Tom Leinster's Generalized Enrichment for Categories and Multicategories argues that the most general context in which one can enrich a $T$-multicategory is a $T'$-multicategory, where $T'$ is the monad whose algebras are $T$-multicategories. This leads to the conclusion that the most general thing in which to enrich a category is a virtual double category (which Leinster calls an "fc-multicategory"). – Mike Shulman Sep 5 '18 at 17:38


text:
# Products of infinitely many measure spaces. Applications?

• What are some typical applications of the theory for measures on infinite product spaces?
• Are there any applications that you think are particularly interesting - that make the study of this worthwhile beyond finite products, Fubini-Tonelli.
• Are there theorems that require, or are equivalent to, certain choice principles (AC, PIT, etc)? (similar to Tychonoff in topology)

Sorry for being so vague, I am just trying to get a feel for this new area before diving head-first into the technical details.

-
Infinite products of measure spaces are used very frequently in probability. Probabilists are frequently interested in what happens asymptotically as a random process continues indefinitely. The Strong Law of Large Numbers, for example, tells us that if $\{X_i\}_i$ is a sequence of independent, identically distributed random variables with finite mean $\mu$ then the sum $\frac{1}{n}\sum_{i=1}^n X_i$ converges almost surely to $\mu$. But how do we find infinitely many independent random variables to which we can apply this theorem? The most common way to produce these variables is with the infinite product. For example, say we want to flip a coin infinitely many times. A way to model this would be to let $\Omega$ be the probability space $\{-1,1\}$ where $P(1) = P(-1) = \frac{1}{2}$. Then we consider the probability space $\prod_{i=1}^\infty \Omega$, and let $X_i$ be the $i$th component. Then the $X_i$ are independent identically distributed variables.


text:
# Calculating a Parachute Descent

1. Jun 4, 2010

### Lunar_Lander

Hello,

I'm still working on my balloning project and now I have arrived at the problem of getting a accurate idea of a descent velocity/time. I am sure that the formula to get the velocity is:

$$\sqrt{m*g/0.5*\rho*A}$$

Now density changes with altitude, causing a higher velocity at high altitude and a decreasing velocity while closing in on Earth. In the formula, m is the mass of the payload and A is the cross-sectional area of the parachute.

Question: How can I implement $$\rho(h)$$, that is the density as a function of altitude, into the formula above? Integration over $$\rho$$?

My previous approach was to get myself the atmospheric densities for 4000 m-levels out of the 1976 U.S. Standard Atmosphere, to calculate the velocity by putting in each of the densities in turn, and finally to average the velocities. I don't know if this is also OK, but I can imagine that it is less accurate than a analytical solution I am looking for here.


text:
What work can be done to study the solutions of $\varphi\left(x^{\sigma(x)}\sigma(x)^x\right)=2^{x-1} x^{3x-1}\varphi(x)$?

For integers $$n\geq 1$$ I denote the Euler's totient function as $$\varphi(n)$$ and the divisor function $$\sum_{1\leq d\mid n}d$$ as $$\sigma(n)$$, that are two well-known mulitplicative functions. We assume also the theory of odd perfect numbers, see if you want the corresponding section of the Wikipedia with title Perfect number.

It is easy to prove the following statement, on assumption that there exists an odd perfect number $$x$$.

Fact. If $$x$$ is an odd perfect number then $$\varphi\left(x^{\sigma(x)}\sigma(x)^x\right)=2^{x-1} x^{3x-1}\varphi(x)\tag{1}$$ holds.

Computational fact. For integers $$1\leq n\leq 5000$$, the only solution of $$(1)$$ is $$n=1$$. To see it, after some seconds, choose GP as language and evaluate next code (it is just a line written in Pari/GP) in the web page Sage Cell Server

for (x = 1, 5*10^3,if (eulerphi(x^(sigma(x))*(sigma(x))^x)==2^(x-1)*x^(3*x-1)*eulerphi(x), print(x)))

I believe that the following conjecture holds.

Conjecture. The only solution of our equation $$(1)$$ is the integer $$1$$.

Motivation for the post. My belief is that an interesting way (but my attempts were failed) to study the unsolved problem related to odd perfect numbers (that is if there exist any of them) should be to create intrincated/artificious equations similar than $$(1)$$ involving the sum of divisors functions and the Euler's totient function with the purpose to invoke inequalitites, asymptotics, heuristics or conjectures for these arithmetic functions (my belief is that the problem of odd perfect numbers is related to the distribution of prime numbers, thus maybe in the equations similar than $$(1)$$ that previously I've evoked should be required also that arise functions as the radical of an integer $$\operatorname{rad}(x)$$ or even the prime-counting function $$\pi(x)$$, both specialized for odd perfect numbers $$x$$).

Question. What work can be done to prove of refute previous conjecture, that the only solution of $$\varphi\left(n^{\sigma(n)}\sigma(n)^n\right)=2^{n-1} n^{3n-1}\varphi(n)$$ should be $$n=1$$? It is welcome unconditionally statements or heuristics, but also feel free to invoke conjectures if you can get some advanced statement. Many thanks.

Thus, as how it is perceived in the title of the post, previous Question is also an invitation to add remarkable statements about the nature of the solutions of $$(1)$$, if we are in the situation that the Question can not be solved.

Last remarks to to emphasize my ideas. What is saying myself thus previous Motivation and Question? That of couse I understand that the equation/characterization for odd perfect nubmers by means the equation $$\sigma(x)=2x$$ for odd integers $$x\geq 1$$ is easiest (to understand and study it) than others involving more arithmetic functions, but in my belief is that there exists a chance to get some statement for odd perfect numbers by the method to create more intrincated/artificious equations.

I think that my question is interesting, and I think that arises in a natural way when one tries to drop solutions like $$2^{2^{\lambda-1}-1}$$, that is the sequence A058891 from the On-Line Encyclopedia of Integer Sequences, for equations like this $$\varphi(x^x\sigma(x))=x^x\varphi(x).$$ See if you want the code

for (x = 1, 10^4,if (eulerphi((x^x)*sigma(x))==(x^x)*eulerphi(x), print(x)))

I would like to refer that certain characterizations of primes are feasibles from answers of next posts (the problem [2] remains as unsolved), these posts are not directly related to this my post in MathOverflow, but maybe can be inspiring for some user of MathOverflow since are similar problems. Thus I justify this last paragraph as a compilation of similar equations for constellations of primes: thanks to the excellence of the user who provides the answer of [1] we've the characterization of Sophie Germain primes and similarly for twin primes; thanks to the excellence of the user who provides the answers of problems [2] and [3] we've a characterization of Mersenne exponents, Fermat primes and near-square primes.

[1] From the equation $$\sigma(x^{\varphi(y)})=\frac{1}{\varphi(x)}(x^y-1)$$ involving arithmetic functions to a characterization of Sophie Germain primes, question 3578715 from Mathematics Stack Exchange (Mar 12 '20).

[2] From the equation $$\sigma(x^{\sigma(y)-1})=\frac{1}{\varphi(x)}(x^{y+1}-1)$$ involving arithmetic functions to a characterization of Mersenne exponents, question 3587159 from Mathematics Stack Exchange (Mar 19 '20).

[3] On characterizations for near-square primes and Fermat primes in terms of equations involving arithmetic functions, question 3588192 from Mathematics Stack Exchange (Mar 20 '20).

• Many thanks for the upvote. Jul 19, 2019 at 13:40
• As aside comment is that I believe that similar discussions are feasible in terms of the Dedekind psi function $\psi(n)$, in particular one should to have the following claim: Each odd perfect number $n$ satisfies $$\psi(n^{\sigma(n)}\sigma(n)^n )=3\cdot 2^{n-1}n^{3n-1}\psi(n).$$ And I cann't find any integer satisfying this equation over the segment $1\leq n\leq 1000$. A reformulation is using the equation $\psi(n^{\sigma(n)}\sigma(n)^n )=3\cdot 2^{n-1}n^{3n}\cdot\frac{\sigma(\text{rad}(n))}{\text{rad}(n)}$. For the definiton $\text{rad}(n)$ see the Wikipedia Radical of an integer. Oct 30, 2019 at 12:56
• I'm trying equations that satisfy odd perfect numbers $x$ (with $y=\sigma(x)$) and that harmonize with the references of MSE that I've added $$2^{\sigma(x)-x-1}x^{\sigma(x)+x-1}=\frac{1}{\varphi(y-x)}\cdot\varphi(x^y y^x)\tag{2}$$ also for integral variables (and satisfied for odd perfect numbers choosing $y=\sigma(x)=2x$ as below). The corresponding code written in Pari/GP is for(x=1, 1000, for(y=1, 1000, if(x<y&&(2^(sigma(x)-x-1))*(x^(x+y-1))*eulerphi(y-x)==eulerphi((x^y)*(y^x)),print(x," ",y)))) it seems that the code for eulerphi() is due to the Pari/GP group of Université Bordeaux I. May 11, 2020 at 18:29
• I'm sorry for the typo, and previous deleted comments. The right code corresponding to the equation $(2)$ in previous comment is for(x=1, 1000, for(y=1, 1000, if(x<y&&(2^(sigma(x)-x-1))*(x^(sigma(x)+x-1))*eulerphi(y-x)==eulerphi((x^y)*(y^x)),print(x," ",y)))) where all solutions that are showed as outputs have the form $(x,y)=(1,\text{even})$. May 11, 2020 at 18:38
• Other form to state the equation $(1)$ in our Conjecture is to rewrite it as $$y^{y-x}(y-x)^y=\frac{\sigma(x)}{\varphi(y-x)}\cdot\varphi(x^y y^x),$$ or as $$y^{y-x}(y-x)^y=\frac{\sigma(y-x)}{\varphi(y-x)}\cdot\varphi(x^y y^x)$$ for $x$ denoting an odd perfect number and $y=\sigma(x)=2x$. See if you want the related post on Mathematics Stack Exchange with title On a symmetric equation over the integer lattice that involves the Euler's totient function (asked today), with 3679325 as identificator. May 17, 2020 at 17:23

Here is a proof that if an odd integer $$x>1$$ satisfies (1), then $$x$$ is a perfect number.

First, by using the property that $$\varphi(nm)=n\varphi(m)$$ whenever $$\mathrm{rad}(n)\mid\mathrm{rad}(m)$$, we can rewrite (1) as $$\big(\frac{\sigma(x)}2\big)^{x-1}\cdot \frac{\varphi(x\sigma(x))}{\varphi(x)} = x^{3x-\sigma(x)}.$$ Since the fractions in the l.h.s. are integer, the r.h.s. is also integer and odd, and thus $$\sigma(x)=2y$$ for some odd $$y$$ such that $$\mathrm{rad}(y)\mid \mathrm{rad}(x)$$. Then we further simplify the above equation to $$y^x = x^{3x-2y}.$$ In other words, $$\big(\frac{y}x\big)^x = x^{2(x-y)}.$$

Now, if $$x>y$$, then lhs < 1 while rhs > 1. Vice versa, if $$x, then lhs > 1 while rhs < 1.

Hence, $$x=y$$, meaning that $$\sigma(x)=2x$$. QED

• Many thanks when I can I read the answer, now I'm in a call center. My intention with this kind of formulas and inequalities (see my rcent post/bounty) is try to evoke some relationship between odd perfect numbers and the growth/size of some number theoretic functions that encode Rieamnn hypothesis (while I knw that my atetmps are vague) Dec 25, 2021 at 13:01

In general, problems involving the composition of multiplicative functions are very hard to analyze. I don't see any specific way to approach this problem, and I'm skeptical that this is likely to be a fruitful direction.

That said, I don't have any strong intuition of whether there will be non-odd perfect numbers satisfying this equation (aside from x=1). My guess is that there will not be, because if x is not an OPN, then $$x^{\sigma(x)}$$ will have primes raised to very different powers then $$\sigma(x)^x$$ will, and numbers where $$x$$ and $$\sigma(x)$$ have the same set of distinct prime factors are rare. Turning this idea into a proof may be difficult.

• Many thanks for your answer. I've persuaded to myself (it is not a scientific procedure) that the problem of odd perfect numbers is related to Riemann hypothesis. My attempt thus is to create artificious equations with the intention to invoke some equivalence to the RH with the hope to get some useful information (in my imagination it is just transfer information from the odd perfect number problem to the RH problem). I think that due to the bound given by Ochem and Rao the problem of odd perfect numbers is inaccessible for the human mind, and that behind this problem there a physical meaning. Jul 21, 2019 at 20:42
• What connection are you seeing between odd perfect numbers and the Riemann Hypothesis, @user142929? Are you referring to the elementary criterion (i.e. an inequality) by Lagarias? Jul 30, 2019 at 22:41
• I am persuaded myself that there is some relationship (and this, the persuasion, is outside the scientific field) @JoseArnaldoBebita-Dris There are in the literature more equivalences/issues related to the Riemann hypothesis similar than Lagarias theorem, because the formulations are using number theoretic functions or special sequences: highly composite numbers, Nicolas criterion, Robin's theorem. In my imagination, from my human size, my ignorance, and as a non-professional mathematicianIn, I ear that these are like a purring/murmur about the OPN. Jul 31, 2019 at 8:44
• I've updated the post adding references for similar problems that I've asked in Mathematics Stack Exchange. The purpose of those posts was try to get characterizations of certain constellations of primes. Maybe these references that I've added in the last paragraph of my post can be inspiring for some user, and we can to continue the discussion of this post of MathOverflow. Many thanks again for your excellent answer. May 10, 2020 at 18:23


text:
How to convert expression to String, but keep it looking similar to input form?

I have lots of differential equations, that I save to file (along with output and other things), as "strings", to process later in Latex and make a document of them.

I save each input differential equation, by first converting it from expression to String, then write it to the file (using WriteString command).

The problem is that when converting say eq = y'[x] == 1/y[x] to String, using ToString it becomes

Which ofcource does not work, when saved to file, since it messes up the lines in the text file. So I use InputForm like this ToString[eq,InputForm] and now it works, the string is flat and on one line:

The above is a string, and I can use that with no problem.

What I like however is to have the string look like the original expression, since it is easier to read (these will later show as verbatim in Latex), i.e. I need to convert expression to

   y'[x] == 1/y[x]

to same as above, but as string

   "y'[x] == 1/y[x]"

I do not use 2D math at all in my input. All my original Mathematica expressions are flat, read from plain text file, read them, and process them, then need to save them back as strings with other things for post-processing.

But I'd like to keep the same looking expression used, but as string.

Question: How to to convert y'[x] == 1/y[x] to string "y'[x] == 1/y[x]" ?

For example of one Latex output, here is a link to help explain what I mean.

Mathematica 11.0.1.

Update:

To answer comments, I have the ODE's in a list. Then I use a loop to process them. Here is a MWE, a very simplified version. The process is completely non-interactive.

SetDirectory[NotebookDirectory[]];
lst = {{y'[x] == a*f[x]}, {y'[x] == x + Sin[x] + y[x]}, {y'[x] ==
x^2 + 3*Cosh[x] + 2*y[x]}};
fileName = "result.txt";
file = OpenWrite[fileName, PageWidth -> Infinity];
Do[
s = ToString[First@lst[[n]], InputForm];
WriteString[file, s];
WriteString[file, "\n"]
, {n, 1, Length@lst}
];
Close[file]

The text file where these are saved to now looks like

• In what form do you have the equations? In a list in an input cell? E.g.: Cases[#, BoxData[b_] :> StringJoin @@ Flatten[b /. RowBox -> List], -1] &@ Cell[BoxData[ RowBox[{RowBox[{RowBox[{"y", "'"}], "[", "x", "]"}], "\[Equal]", RowBox[{"1", "/", RowBox[{"y", "[", "x", "]"}]}]}]], "Input"] – Rolf Mertig Dec 26 '16 at 23:09
• returns {"y'[x]==1/y[x]"} . You could extend this to a button a script to get all input cells in a certain notebook and you are done. – Rolf Mertig Dec 26 '16 at 23:15
• If you have (*In[100]=*) y'[x] == 1/y[x], then ToString[DisplayForm[ToExpression[InString[100]]]] returns : "y '[x] == 1/y[x]" (with a blank between y and ') . – andre314 Dec 26 '16 at 23:45
• @RolfMertig thanks. I added an MWE. These are in a list. I do not know what each ODE looks like, there are 1,000's of them in the list. So I can't hardcode things. I just showed one example. – Nasser Dec 27 '16 at 0:06
• @andre thanks. Can I use your method if the equations are in a list? as in the MWE I showed? – Nasser Dec 27 '16 at 0:10

My approach for this sort of thing is to define conditioned Format rules for the problematic symbols, and then to Block the condition true when using ToString. In addition, I like to use SequenceForm as a substitute for HoldForm. In your example, I would do:

Format[Derivative[n_?Positive][f_], InputForm] /; $Nasser := SequenceForm[f, OutputForm@StringJoin[ConstantArray["'", n]]]  Then, I would define a special tostring function: SetAttributes[tostring, HoldFirst] tostring[expr_] := InternalInheritedBlock[{$Nasser = True, SequenceForm},
SetAttributes[SequenceForm, HoldFirst];
ToString[SequenceForm[expr], InputForm]
]

A couple examples:

tostring[y'[x] == a/y[x]] // InputForm
(* "y'[x] == a/y[x]" *)

tostring[x''[t] + c0 x'[t]^2 + c1 x[t]] // InputForm
(* "x''[t] + c0*x'[t]^2 + c1*x[t]" *)

• How does SequenceForm work in this case? There isn't a lot of detail in the wolfram documentation. When I tried replacing SequenceForm with Row, Text, or Print -- things I assume are alternatives -- it no longer worked. – 1110101001 Jun 11 '17 at 0:05
• @1110101001 SequenceForm is a very special function that disappears when displayed using InputForm. You can think of it as the InputForm analog of HoldForm, except that SequenceForm doesn't hold any arguments. This is why SequenceForm is so useful when creating custom formats in InputForm. – Carl Woll Jun 11 '17 at 4:39

This is pure string hackery and I don't know how robust it is, but it works on your test case and one other that I tried.

helper[l_, d_] := l <> StringJoin @@ ConstantArray["'", ToExpression[d]]

SetAttributes[toPrimedForm, HoldFirst]
toPrimedForm[expr_] :=
Module[{str},
str[1] = ToString[HoldForm[expr], FormatType -> InputForm];
str[2] = StringReplace[str[1], {"HoldForm[" -> "", "]" ~~ EndOfString -> ""}];
StringReplace[
str[2],
"Derivative[" ~~ d : DigitCharacter ~~ "][" ~~ l : LetterCharacter ~~ "]" :>
helper[l, d]]]

toPrimedForm[y'[x] == 1/y[x]]

"y'[x] == 1/y[x]"

toPrimedForm[x''[t] + c0 x'[t]^2 + c1 x[t]]

"x''[t] + c0*x'[t]^2 + c1*x[t]"

Certainly it needs more testing and probably more work, but I'm short on time at the moment. Perhaps it will give you something you can develop further.

Update

Here is version written to work when passed an argument that is an ODE expression or a variables holding such an expression.

helper[l_, d_] := l <> StringJoin @@ ConstantArray["'", ToExpression[d]]

SetAttributes[toPrimedForm, HoldFirst]
toPrimedForm[expr_Symbol] :=
Module[{str},
str[1] = ToString[HoldForm[Evaluate@expr], FormatType -> InputForm];
str[2] = StringReplace[str[1], {"HoldForm[" -> "", "]" ~~ EndOfString -> ""}];
StringReplace[
str[2],
"Derivative[" ~~ d : DigitCharacter ~~ "][" ~~ l : LetterCharacter ~~ "]" :>
helper[l, d]]]
toPrimedForm[expr_] := Module[{xpr = expr}, toPrimedForm[xpr]]

expr = y'[x] == a/f[x];
toPrimedForm[expr]

"y'[x] == a/f[x]"

toPrimedForm[y'[x] == a/f[x]]

"y'[x] == a/f[x]"

• @Nasser. I know it won't work if you have derivatives of order 10 or more or if you use multi-character dependent variable names. – m_goldberg Dec 27 '16 at 0:50
• it works on one example, when I removed the SetAttributes[toPrimedForm,HoldFirst]. But need to test it more. This is good so far.... – Nasser Dec 27 '16 at 0:58
• @Nasser. I use the HoldFirst to preserve forms like 1/y. If you evaluate expression like expr = y'[x] == a/f[x], the front-end is going to mess up that expression before my function gets it. Could you live with expr = HoldForm[y'[x] == a/f[x]]? Then the HoldFirst could be dropped. – m_goldberg Dec 27 '16 at 1:02
• Will it show like HoldForm[y'[x] == a/f[x]] in the file you mean? Then no, since this can't be copied pasted from the web page. I'd like it to be just "y'[x] == a/f[x]" but I am trying your code now, without the Hold on it, else it does not work, since I need to pass expressions in variable. Not literally, since these are in a long list. As I have in MWE. Testing more now... thanks – Nasser Dec 27 '16 at 1:10
• @Nasser. No, it would strip the HoldForm off. It already does this now after it converts the expression to a string. The only change needed would be for it not to add HoldForm` in its 1st step. – m_goldberg Dec 27 '16 at 1:18


text:
Time Limit : sec, Memory Limit : KB

# Koch Curve

Write a program which reads an integer n and draws a Koch curve based on recursive calles of depth n.

The Koch curve is well known as a kind of fractals.

You can draw a Koch curve in the following algorithm:

• Divide a given segment (p1, p2) into three equal segments.
• Replace the middle segment by the two sides of an equilateral triangle (s, u, t) of the same length as the segment.
• Repeat this procedure recursively for new segments (p1, s), (s, u), (u, t), (t, p2).

You should start (0, 0), (100, 0) as the first segment.

## Input

An integer n is given.

## Output

Print each point (x, y) of the Koch curve. Print a point in a line. You should start the point(0, 0), which is the endpoint of the first segment and end with the point (100, 0), the other endpoint so that you can draw the Koch curve as an unbroken line. Each solution should be given as a decimal with an arbitrary number of fractional digits, and with an absolute error of at most 10-4.

• 0 ≤ n ≤ 6

## Sample Input 1

1

## Sample Output 1

0.00000000 0.00000000
33.33333333 0.00000000
50.00000000 28.86751346
66.66666667 0.00000000
100.00000000 0.00000000

## Sample Input 2

2

## Sample Output 2

0.00000000 0.00000000
11.11111111 0.00000000
16.66666667 9.62250449
22.22222222 0.00000000
33.33333333 0.00000000
38.88888889 9.62250449
33.33333333 19.24500897
44.44444444 19.24500897
50.00000000 28.86751346
55.55555556 19.24500897
66.66666667 19.24500897
61.11111111 9.62250449
66.66666667 0.00000000
77.77777778 0.00000000
83.33333333 9.62250449
88.88888889 0.00000000
100.00000000 0.00000000


text:
# The Exim4 Cheat Sheet

Here are some useful things to know for managing an Exim 4 server. This assumes a prior working knowledge of SMTP, MTAs, and a UNIX shell prompt.

### Message-IDs and spool files

The message-IDs that Exim uses to refer to messages in its queue are mixed-case alpha-numeric, and take the form of: XXXXXX-YYYYYY-ZZ. Most commands related to managing the queue and logging use these message-ids.

There are three -- count 'em, THREE -- files for each message in the spool directory. If you're dealing with these files by hand, instead of using the appropriate exim commands as detailed below, make sure you get them all, and don't leave Exim with remnants of messages in the queue. I used to mess directly with these files when I first started running Exim machines, but thanks to the utilities described below, I haven't needed to do that in many months.

Files in /var/spool/exim/msglog contain logging information for each message and are named the same as the message-id.

Files in /var/spool/exim/input are named after the message-id, plus a suffix denoting whether it is the envelope header (-H) or message data (-D).

These directories may contain further hashed subdirectories to deal with larger mail queues, so don't expect everything to always appear directly in the top /var/spool/exim/input or /var/spool/exim/msglog directories; any searches or greps will need to be recursive. See if there is a proper way to do what you're doing before working directly on the spool files.

### Basic information

Print a count of the messages in the queue:

root@localhost# exim -bpc

Print a listing of the messages in the queue (time queued, size, message-id, sender, recipient):

root@localhost# exim -bp

Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals):

root@localhost# exim -bp | exiqsumm

Print what Exim is doing right now:

root@localhost# exiwhat

Test how exim will route a given address:

root@localhost# exim -bt alias@localdomain.com
user@thishost.com
<-- alias@localdomain.com
router = localuser, transport = local_delivery
root@localhost# exim -bt user@thishost.com
user@thishost.com
router = localuser, transport = local_delivery
root@localhost# exim -bt user@remotehost.com
router = lookuphost, transport = remote_smtp
host mail.remotehost.com [1.2.3.4] MX=0

Run a pretend SMTP transaction from the command line, as if it were coming from the given IP address. This will display Exim's checks, ACLs, and filters as they are applied. The message will NOT actually be delivered.

root@localhost# exim -bh 192.168.11.22

Display all of Exim's configuration settings:

root@localhost# exim -bP

### Searching the queue with exiqgrep

Exim includes a utility that is quite nice for grepping through the queue, called exiqgrep. Learn it. Know it. Live it. If you're not using this, and if you're not familiar with the various flags it uses, you're probably doing things the hard way, like piping exim -bp into awk, grep, cut, or wc -l. Don't make life harder than it already is.

First, various flags that control what messages are matched. These can be combined to come up with a very particular search.

Use -f to search the queue for messages from a specific sender:

root@localhost# exiqgrep -f [luser]@domain

Use -r to search the queue for messages for a specific recipient/domain:

root@localhost# exiqgrep -r [luser]@domain

Use -o to print messages older than the specified number of seconds. For example, messages older than 1 day:

root@localhost# exiqgrep -o 86400 [...]

Use -y to print messages that are younger than the specified number of seconds. For example, messages less than an hour old:

root@localhost# exiqgrep -y 3600 [...]

Use -s to match the size of a message with a regex. For example, 700-799 bytes:

root@localhost# exiqgrep -s '^7..$' [...]  Use -z to match only frozen messages, or -x to match only unfrozen messages. There are also a few flags that control the display of the output. Use -i to print just the message-id as a result of one of the above two searches: root@localhost# exiqgrep -i [ -r | -f ] ...  Use -c to print a count of messages matching one of the above searches: root@localhost# exiqgrep -c ...  Print just the message-id of the entire queue: root@localhost# exiqgrep -i  ### Managing the queue The main exim binary (/usr/sbin/exim) is used with various flags to make things happen to messages in the queue. Most of these require one or more message-IDs to be specified in the command line, which is where exiqgrep -i as described above really comes in handy. Start a queue run: root@localhost# exim -q -v  Start a queue run for just local deliveries: root@localhost# exim -ql -v  Remove a message from the queue: root@localhost# exim -Mrm <message-id> [ <message-id> ... ]  Freeze a message: root@localhost# exim -Mf <message-id> [ <message-id> ... ]  Thaw a message: root@localhost# exim -Mt <message-id> [ <message-id> ... ]  Deliver a message, whether it's frozen or not, whether the retry time has been reached or not: root@localhost# exim -M <message-id> [ <message-id> ... ]  Deliver a message, but only if the retry time has been reached: root@localhost# exim -Mc <message-id> [ <message-id> ... ]  Force a message to fail and bounce as "cancelled by administrator": root@localhost# exim -Mg <message-id> [ <message-id> ... ]  Remove all frozen messages: root@localhost# exiqgrep -z -i | xargs exim -Mrm  Remove all messages older than five days (86400 * 5 = 432000 seconds): root@localhost# exiqgrep -o 432000 -i | xargs exim -Mrm  Freeze all queued mail from a given sender: root@localhost# exiqgrep -i -f luser@example.tld | xargs exim -Mf  View a message's headers: root@localhost# exim -Mvh <message-id>  View a message's body: root@localhost# exim -Mvb <message-id>  View a message's logs: root@localhost# exim -Mvl <message-id>  Add a recipient to a message: root@localhost# exim -Mar <message-id> <address> [ <address> ... ]  Edit the sender of a message: root@localhost# exim -Mes <message-id> <address>  ### Access control Exim allows you to apply access control lists at various points of the SMTP transaction by specifying an ACL to use and defining its conditions in exim.conf. You could start with the HELO string. # Specify the ACL to use after HELO acl_smtp_helo = check_helo # Conditions for the check_helo ACL: check_helo: deny message = Gave HELO/EHLO as "friend" log_message = HELO/EHLO friend condition =${if eq {$sender_helo_name}{friend} {yes}{no}} deny message = Gave HELO/EHLO as our IP address log_message = HELO/EHLO our IP address condition =${if eq {$sender_helo_name}{$interface_address} {yes}{no}}

accept

NOTE: Pursue HELO checking at your own peril. The HELO is fairly unimportant in the grand scheme of SMTP these days, so don't put too much faith in whatever it contains. Some spam might seem to use a telltale HELO string, but you might be surprised at how many legitimate messages start off with a questionable HELO as well. Anyway, it's just as easy for a spammer to send a proper HELO than it is to send HELO im.a.spammer, so consider yourself lucky if you're able to stop much spam this way.

Next, you can perform a check on the sender address or remote host. This shows how to do that after the RCPT TO command; if you reject here, as opposed to rejecting after the MAIL FROM, you'll have better data to log, such as who the message was intended for.

# Specify the ACL to use after RCPT TO
acl_smtp_rcpt = check_recipient

# Conditions for the check_recipient ACL
check_recipient:

# [...]

drop hosts = /etc/exim_reject_hosts
drop senders = /etc/exim_reject_senders

# [ Probably a whole lot more... ]

This example uses two plain text files as blacklists. Add appropriate entries to these files - hostnames/IP addresses to /etc/exim_reject_hosts, addresses to /etc/exim_reject_senders, one entry per line.

It is also possible to perform content scanning using a regex against the body of a message, though obviously this can cause Exim to use more CPU than it otherwise would need to, especially on large messages.

# Specify the ACL to use after DATA
acl_smtp_data = check_message

# Conditions for the check_messages ACL
check_message:

deny message = "Sorry, Charlie: $regex_match_string" regex = ^Subject:: .*Lower your self-esteem by becoming a sysadmin accept  ### Fix SMTP-Auth for Pine If pine can't use SMTP authentication on an Exim host and just returns an "unable to authenticate" message without even asking for a password, add the following line to exim.conf:  begin authenticators fixed_plain: driver = plaintext public_name = PLAIN server_condition = "${perl{checkuserpass}{$1}{$2}{$3}}" server_set_id =$2
>  server_prompts = :

This was a problem on CPanel Exim builds awhile ago, but they seem to have added this line to their current stock configuration.

### Log the subject line

This is one of the most useful configuration tweaks I've ever found for Exim. Add this to exim.conf, and you can log the subject lines of messages that pass through your server. This is great for troubleshooting, and for getting a very rough idea of what messages may be spam.

log_selector = +subject

### Disable identd lookups

Frankly, I don't think identd has been useful for a long time, if ever. Identd relies on the connecting host to confirm the identity (system UID) of the remote user who owns the process that is making the network connection. This may be of some use in the world of shell accounts and IRC users, but it really has no place on a high-volume SMTP server, where the UID is often simply "mail" or whatever the remote MTA runs as, which is useless to know. It's overhead, and results in nothing but delays while the identd query is refused or times out. You can stop your Exim server from making these queries by setting the timeout to zero seconds in exim.conf:

rfc1413_query_timeout = 0s

### Disable Attachment Blocking

To disable the executable-attachment blocking that many Cpanel servers do by default but don't provide any controls for on a per-domain basis, add the following block to the beginning of the /etc/antivirus.exim file:

if $header_to: matches "example\.com|example2\.com" then finish endif  It is probably possible to use a separate file to list these domains, but I haven't had to do this enough times to warrant setting such a thing up. ### Searching the logs with exigrep The exigrep utility (not to be confused with exiqgrep) is used to search an exim log for a string or pattern. It will print all log entries with the same internal message-id as those that matched the pattern, which is very handy since any message will take up at least three lines in the log. exigrep will search the entire content of a log entry, not just particular fields. One can search for messages sent from a particular IP address: root@localhost# exigrep '<= .* $12.34.56.78$ ' /path/to/exim_log  Search for messages sent to a particular IP address: root@localhost# exigrep '=> .* $12.34.56.78$' /path/to/exim_log  This example searches for outgoing messages, which have the "=>" symbol, sent to "user@domain.tld". The pipe to grep for the "\<=" symbol will match only the lines with information on the sender - the From address, the sender's IP address, the message size, the message ID, and the subject line if you have enabled logging the subject. The purpose of doing such a search is that the desired information is not on the same log line as the string being searched for. root@localhost# exigrep '=> .*user@domain.tld' /path/to/exim_log | fgrep '<='  Generate and display Exim stats from a logfile: root@localhost# eximstats /path/to/exim_mainlog  Same as above, with less verbose output: root@localhost# eximstats -ne -nr -nt /path/to/exim_mainlog  Same as above, for one particular day: root@localhost# fgrep YYYY-MM-DD /path/to/exim_mainlog | eximstats  ### Bonus! To delete all queued messages containing a certain string in the body: root@localhost# grep -lr 'a certain string' /var/spool/exim/input/ | \ sed -e 's/^.*\/$$[a-zA-Z0-9-]*$$-[DH]$/\1/g' | xargs exim -Mrm

Note that the above only delves into /var/spool/exim in order to grep for queue files with the given string, and that's just because exiqgrep doesn't have a feature to grep the actual bodies of messages. If you are deleting these files directly, YOU ARE DOING IT WRONG! Use the appropriate exim command to properly deal with the queue.

If you have to feed many, many message-ids (such as the output of an exiqgrep -i command that returns a lot of matches) to an exim command, you may exhaust the limit of your shell's command line arguments. In that case, pipe the listing of message-ids into xargs to run only a limited number of them at once. For example, to remove thousands of messages sent from joe@example.com:

root@localhost# exiqgrep -i -f '<joe@example.com>' | xargs exim -Mrm

### Speaking of "DOING IT WRONG" -- Attention, CPanel forum readers

I get a number of hits to this page from a link in this post at the CPanel forums. The question is:

Due to spamming, spoofing from fields, etc., etc., etc., I am finding it necessary to spend more time to clear the exim queue from time to time. [...] what command would I use to delete the queue

The answer is: Just turn exim off, because your customers are better off knowing that email simply isn't running on your server, than having their queued messages deleted without notice.

Or, figure out what is happening. The examples given in that post pay no regard to the legitimacy of any message, they simply delete everything, making the presumption that if a message is in the queue, it's junk. That is total fallacy. There are a number of reasons legitimate mail can end up in the queue. Maybe your backups or CPanel's "upcp" process are running, and your load average is high -- exim goes into a queue-only mode at a certain threshold, where it stops trying to deliver messages as they come in and just queues them until the load goes back down. Or, maybe it's an outgoing message, and the DNS lookup failed, or the connection to the domain's MX failed, or maybe the remote MX is busy or greylisting you with a 4xx deferral. These are all temporary failures, not permanent ones, and the whole point of having temporary failures in SMTP and a mail queue in your MTA is to be able to try again after awhile.

Exim already purges messages from the queue after the period of time specified in exim.conf. If you have this value set appropriately, there is absolutely no point in removing everything from your queue every day with a cron job. You will lose legitimate mail, and the sender and recipient will never know if or why it happened. Do not do this!

If you regularly have a large number of messages in your queue, find out why they are there. If they are outbound messages, see who is sending them, where they're addressed to, and why they aren't getting there. If they are inbound messages, find out why they aren't getting delivered to your user's account. If you need to delete some, use exiqgrep to pick out just the ones that should be deleted.

After making changes to exim.conf, you need to give the main exim pid a SIGHUP to re-exec it and have the configuration re-read. Sure, you could stop and start the service, but that's overkill and causes a few seconds of unnecessary downtime. Just do this:

root@localhost# kill -HUP cat /var/spool/exim/exim-daemon.pid

You should then see something resembling the following in exim_mainlog:

pid 1079: SIGHUP received: re-exec daemon
exim 4.52 daemon started: pid=1079, -q1h, listening for SMTP on port 25 (IPv4)


text:
# Announcement: Seminar on Matroids in Algebra, Representation Theory and Topology

I was asked to share information about a Seminar on Matroids in Algebra, Representation Theory and Topology, to be held January 24-29 in Les Diablerets, Switzerland. The deadline for registration is October 4.

All information can be found on the website: http://www.combinatorialmethods.ch/sm-art/

# Matroids and graphs in Princeton

All the contributors to this blog have been in Princeton, New Jersey within the last few weeks for the 2014 International Workshop on Structure in Graphs and Matroids. This meeting is a descendant of three very successful workshops run by Bert Gerards in Sittard and Maastricht between 2008 and 2012. Although the location has shifted from the Netherlands to the US, a Dutch connection remains, since the 2014 workshop was organised by Rudi Pendavingh and Stefan van Zwam. They both deserve a vote of thanks, for doing a great job and for continuing the tradition; the biennial meeting has become one of the most important fixtures for people interested in the structural theory of matroids and graphs.

In this type of post, I would usually make note of talks that were relevant to the contents of this blog, as well as talks that I found particularly interesting or attractive. That rule is pretty much useless in this case. For obvious reasons, all the talks had connections to matroid theory, and a large number of talks were high-quality presentations about high-quality results. Judging by a number of conversations I have had over the years, there is a feeling that the matroid community (and its relatives) does a better-than-average job of mathematical communication. I don’t think you would have seen much to contradict that belief at this workshop.

It seems as though it has been a good couple of years for matroid and graph research, since a number of people spoke about important new developments, but one such development obviously stands out. Rota’s Conjecture was the outstanding open problem in matroid theory for decades, and its resolution by Jim Geelen, Bert Gerards, and Geoff Whittle is certainly the most significant accomplishment in the field. Geoff gave a talk on one important step in that project. In particular, he talked us through a sketch of the proof that an excluded minor for representability over a finite field must be $f$-connected. That is, if $\mathrm{GF}(q)$ is a finite field, then for every positive integer $k$, there is an integer $n_{q}(k)$ such that whenever $M$ is an excluded minor for $\mathrm{GF}(q)$-representability, and $(A,B)$ is a $k$-separation of $M$, then either $|A|\leq n_{q}(k)$ or $|B|\leq n_{q}(k)$.

Geoff’s talk is complemented by an article in the Notices of the American Mathematical Society. In addition, you can find the slides from many of the conference talks on this page.

Although singling out talks is essentially an impossible task, I will just mention one that I found particularly interesting. Reinhard Diestel reported on work with Sang-Il Oum that provides a meta-theorem about various width parameters. I’ll illustrate the theorem by talking about branch-width and tangles. A branch-decomposition of a matroid or graph is a tree where the non-leaf vertices have degree three, and the leaves are labeled with elements of the ground-set (edge-set). Now each edge of the tree represents a partition of the ground-set into two parts, in other words, a separation. The decomposition has low width if each of those separations has low order. If a matroid does not have low-width branch-decomposition, then we should be able to certify that this is the case. Tangles allow us to do so. A tangle is an orientation of each of the separations of low order. In particular, if we have a tangle, then we have designated a “small” side of each low-order separation. Certain constraints must be satisfied in order for this orientation to be sensible. The most important of these constraints is that three small sides should not cover the entire ground-set between them. Note that in a low-order decomposition, each internal vertex represents a partition of the ground-set into three “small” parts, so a decomposition is a certificate that there can be no tangle, and vice versa. The work by Diestel and Oum generalises these ideas. We choose families of separations, for example the families that might be represented by an internal vertex of a decomposition, and then the theorem guarantees that either there will be a labeled tree where the internal nodes represent members of our chosen families of separations, or else there is some consistent orientation of separations that avoids those families. More details can be found on the arxiv.

At the close of the conference, Stefan extended an invitation to those interested in contributing to this blog, which I will repeat here. If you have an idea for a post, then please get in touch with one of us to discuss it.

Much speculation surrounds the location of the next workshop, two years from now, and multiple suggestions have been made. Expect updates to follow.


text:
## Introduction

Saturn’s hexagon is a unique and persistent wave. It was first observed at the upper cloud level by the Voyager 1 and 2 during their flybys of the planet in 19811. Since 1991, it has been imaged using the Hubble Space Telescope (HST) and ground-based telescopes and, between 2006 and 2017, with the Cassini Imaging Science Subsystem (ISS) and Visual and Infrared Mapping Spectrometer (VIMS)2,3,4,5,6,7,8,9. The hexagon stands out at visible and adjacent wavelengths (0.2–1 microns) by reflecting sunlight at the upper clouds (pressure level 0.5–1 bar), and by transmission and opacity of the clouds at 5 microns (pressure level 2–3 bar)10. Within the hexagonal wave, winds blow in an intense and narrow jet with maximum speeds of 120 ms−11,5,6,7,8. The hexagon also manifests itself in the temperature field in the upper troposphere at 0.1 bar and in the stratosphere (5–0.5 mbar), more than ~300 km above the clouds11. To date, its recorded lifetime is >38 years, more than one Saturn’s year (29.4571 Earth years), showing that it has survived the strong seasonal insolation cycle at the top of the atmosphere9,10,11,12,13.

In June 2015, the Cassini spacecraft obtained images of the planet limb at a high spatial resolution of 1–2 km/pixel, covering a broad wavelength range from 225 to 950 nm that included methane absorption bands. These images revealed the existence of a system of at least six stacked haze layers located above the upper cloud deck, southward of the hexagon. The presence of those hazes, and the knowledge of their physical properties, can provide important new clues to the understanding of the atmosphere of Saturn, and in particular, the hexagonal wave and its coupling with upper layers of the atmosphere.

In this paper, we concentrate first on the characterization of the hazes. We find that the vertical thickness of the individual layers ranged from 7 to 18 km, and that they extended in altitude above the pressure level of 0.5 bar up to 0.01 bar (130 km in vertical extent), with a thin but extended aerosol layer above them, up to an altitude of 340 km (pressure 0.4 mbar). Radiative transfer modeling of the spectral reflectivity of the hazes, including nadir-viewing images with the Hubble Space Telescope, shows that their properties can be explained by particles in the size range of 0.07–1.4 μm and number densities in the range of 100–500 cm−3. Then, we analyze the possible origin of the hazes. Their nature is compatible with their formation by condensation of hydrocarbon ices, including acetylene and benzene at the higher altitudes, and we propose that their vertical distribution could be due to upward-propagating gravity waves generated by dynamical forcing by the hexagon and its associated eastward jet.

## Results

### Multilayer stacked hazes above the hexagon

Cassini ISS images of the limb of Saturn obtained with the Narrow Angle Camera (NAC)14 on June 16, 2015 (northern spring season, solar longitude Ls = 69°) at high resolution (maximum of 1.25 km/pixel) showed a system of multilayered hazes above cloud tops (Fig. 1). The haze layers stand out conspicuously at 890 nm, in backward reflection at a strong methane absorption band. Additional images were obtained with a large number of filters at wavelengths ranging from ultraviolet (258 nm) to near infrared (938 nm)14 (Supplementary Fig. 1, Supplementary Tables 1 and 2, and Methods). The limb images were taken in backward scattering under a Sun-atmosphere–spacecraft phase angle α = 29° (Supplementary Fig. 2). The planetographic latitude of limb in the images spans from 75.8°N to 77.1°N, just south of the eastward jet peak centered at 78.1°N that is embedded in the hexagon wave, thus on the anticyclonic side of the jet4,5,6,7.

In Fig. 2, we show the vertical profile of reflectivity (I/F) of the haze layers at the different wavelengths observed. A small uncertainty of a few tens of km in the relative navigation of different images was corrected by taking into consideration the similarity of the main haze-layer structure in all filters. We assume the reference altitude at z = 0 km (where the optical depth at the line-of-sight τLOS 1) and a pressure level of P = 0.5 bar, based on a previous radiative transfer analysis of Cassini ISS images15. We used a vertical temperature profile at limb retrieved at latitude 77°N from Cassini Composite Infrared Spectrometer (CIRS) data (see Methods) in the same epoch (June 2015) and the hydrostatic condition to relate altitude (z) and pressure (P) and to calculate the layer thicknesses $$\Delta z = H\ln \left( {\frac{{P_i}}{{P_{i + 1}}}} \right)$$ between two pressure levels (Pi, Pi+1). Here $$H = \frac{{R_g^ \ast < T > }}{g} \approx 38 - 63\,{\mathrm{km}}$$ is the range of atmospheric-scale heights for the different altitudes covered, where R*g = 3890 J kg−1 K−1, g = 9 ms−2, and 〈T 〉 is the temperature at the altitude of the middle point between pressure levels Pi and Pi+116.

We have used both the photometric scans and direct measurements on contrast-enhanced versions of the images to determine the altitude of the boundaries for each individual haze layer, retrieving their mean altitudes (top and bottom) and vertical thicknesses (Table 1). The red and methane band images show the highest contrast and sharper separation between the layers. We identify at least seven haze layers above the limb, the first six layers with a thickness in the range of ∆z 7–18 km (0.3 H). The uppermost layer extends above the 10-mbar pressure level and has a large vertical extent ∆z 3 H, suggesting a change in the atmospheric conditions at this altitude.

In order to survey the presence of hazes in other latitudes of the planet, we have performed a systematic search of images of the limb spanning the complete Cassini mission (December 2004–September 2017). We selected images with spatial resolution better than 15 km pixel−1, a limit we think reasonable to clearly capture hazes in reflected sunlight protruding at limb. We found images with these conditions obtained in a total of 120 days. These observations encompass 310 image series, each containing a sequence of images with a similar limb-viewing geometry but with different filters (1–15 filters, depending on the series). Only a limited part of these series contains all the filters used in our study (Supplementary Table 1). All latitudes were observed at some time, but the temporal sampling, latitude coverage, spatial resolution, and viewing geometry were very variable (Supplementary Figure 3). The survey shows that haze layers are present above cloud tops at all latitudes and at any time, being their number, vertical extent, and reflectivity very variable. We have found only one clear case with a similar haze system formed by 5–6 stacked layers regularly separated. It was imaged on 24 November 2015 (6 months after the one studied here) and extends from latitudes 66°N to 71.2°N (south of the hexagon region). It is likely that it forms part of the multilayer system studied here. Southward of 65°N and up to latitude 41°N, the number of haze layers decreases to 3–4 and their thicknesses varies from one to another. The survey also shows that along the North Polar Region, i.e., from the hexagon to the pole, there are hazes formed by 3–5 layers at the best available resolution of 6.5–7 km/pixel. We cannot rule out the existence of thinner layers that cannot be resolved at the resolutions available at these latitudes. At other latitudes, the layer multiplicity and regular vertical distribution is not present. For example, from midlatitudes to the equator, the number of layers reduces to 1–3 even at high resolution of 1–2 km pixel−1. A general study of the haze layers we have observed at Saturn’s limb along the whole Cassini mission will be presented elsewhere.

The properties of the aerosol and haze layers were studied using two datasets. A first analysis was performed on multiwavelength images taken on 29–30 June 2015 with the Hubble Space Telescope (HST), 15 days after the Cassini limb images. The HST images17 were obtained under a phase angle α = 3.9°, with a pixel scale of about 265 km and providing a nadir-integrated view of the hazes and upper cloud properties without resolving the limb. This nadir situation is analogous to that of our previous analysis of the region based on Cassini ISS images15 obtained in 2013 under phase angles ranging from 5.5° to 61.2°. An analysis of the HST nadir images explains the differences in brightness at different filters using a two-haze-layer model with (a) a thin layer in the stratosphere extending from 5 to 200 mbar with an optical depth τ (0.9 μm) = 0.02 and particles with a mean size a = 0.15 μm; (b) a dense tropospheric haze extending from 50 to 410 mbar with an optical depth τ (0.9 μm) = 12 and maximum particle number density Np 35 cm−3 (Supplementary Figs. 4 and 5). These results agree with Sanz-Requena et al.18, and may provide a better fit to 2013 observations than the models investigated in ref. 15, something that we are currently exploring and will be reported elsewhere. Because of the geometry of observations, the HST nadir analysis is unable to resolve each of the separate layers, and thus integrates into just two layers the properties of the entire multilayer system evident in the Cassini limb images.

A second analysis examines the wavelength-dependent reflectivity (I/F) of limb profiles obtained from Cassini (Fig. 2). We do this in two steps: first, estimating the particle density we expect for single scattering in the hazes, then, running a full multiple-scattering model. At wavelengths where the sensitivity to scattering and absorption by the gas is low, for optically thin layers with aerosol particles widely separated, the reflectivity is given by the single scattering of radiation19,20

$$\left( {\frac{I}{F}} \right)_{{\mathrm{particles}}} \approx \varpi _0\frac{{p(\theta )}}{4}\sigma _pN_p\sqrt {2\pi R_S\left\langle H \right\rangle }$$
(1)

Here RS = 66,100 km is the Saturn’s radius of curvature at the latitude of the hazes, which we approximated by the polar radius of curvature (RS ≈ RE2/RP, being RE and RP the Equatorial and Polar radius, respectively), and we take a typical scale height for particles 〈H〉 = 15–20 km (Table 1). From a previous study of Saturn’s stratospheric particles in this region15, we take a single-scattering albedo ϖ0 = 0.9 and a scattering phase function p(θ) = 0.05 at scattering angle θ = 150°15. The scattering cross section is $$\sigma _p = Q_s\pi a^2$$, with the scattering efficiency factor Qs 0.1, and the particle radius is taken to be a = 0.15 μm from HST analysis. At z = 100 km, Fig. 2 shows that (I/F)  0.05 at the wavelength of the continuum red filters sensitive to the particles, which yields a number density for the particles of the order of Np 220 cm−3.

The complete analysis of the properties of each layer observed at the limb was aimed to reproduce the measured spectral reflectivity, and uses a model that solves the radiative transfer problem under spherical geometry21. We selected four tangential altitudes for the spacecraft’s line of sight, namely z = 40, 90, 120, and 140 km. The first one probes the lower tropospheric haze (Fig. 2), and the other three probe the stratospheric hazes. Our model considers an exponential drop in the particles’ number density from the troposphere and stratosphere, with different optical properties at each of the two regions. We considered as free parameters the number density of particles at the troposphere (Np) and the corresponding scale height (Haerosol). In the stratosphere, we used a wavelength-dependent single-scattering albedo based on that for Titan’s hazes22 because the chemical composition of both hazes is consistent with hydrocarbons (see the next section and Methods). In Fig. 3 we show the best fits of the limb models to the reflectivity profiles. For the tropospheric haze at z = 40 km (Fig. 3d), we find Haerosol = 18 km, Np = 100 cm−3, and a = 1.45 μm (Qs 1). For the stratospheric hazes, we find Haerosol = 19–21 km, Np = 100–500 cm−3, and a = 0.07 μm (Qs 0.1) (see the Methods section). These particle number densities are consistent with the estimates using the single-scattering approach given above.

### Nature of the hazes

Given that the haze boundaries are sharp (Fig. 1), a likely scenario is that the haze particles form by a condensation process at the level where saturation of a given compound occurs. At the cold temperatures of the lower stratosphere of Saturn, hydrocarbons tend to condense out as ices10,23,24. High in the atmosphere (z > 300–350 km), the haze particles could be a mix of solid organics formed by methane photolysis and electron deposition25 or, alternatively, from a combination of auroral activity and ionospheric ion chemistry26. Saturn’s main auroral oval, associated with the boundary between open and closed magnetic field lines, occurs at an average latitude of 76.5°N27,28, corresponding to the location of the hazes studied here. Cassini CIRS observations showed haze signatures at only two locations in the polar area (latitudes 80°S29 and 77°N30), i.e., in the auroral oval region. One must consider therefore the possibility that the hazes above the hexagon are due to the energy deposition by the aurora8. However, the detection of multilayer hazes outside the aurora region, described above, points to different mechanisms. Perhaps, the highest (z > 140 km) and most extended vertical layer (L7 in Table 1) could have an auroral origin. We do not disregard that the hazes can also be formed by photochemical tholins and fractal aggregate particles as it has been proposed for similar hazes in Titan31,32. Since the hazes we report lay in the upper troposphere and lower stratosphere (z < 340 km), we explore their possible formation by ice condensation of photochemically produced hydrocarbons33.

We used vertical profiles of the temperature and hydrocarbons’ volume-mixing ratio retrieved from Cassini/CIRS thermal emission spectra obtained at the same epoch (June 16, 2015) and latitude (77°N) as in the haze images (see Methods). In Fig. 4 we show a set of hydrocarbon candidates with their vapor-pressure curves24 and condensation altitudes (Supplementary Fig. 6). The retrieved mole fractions for each compound are consistent with expectations from a photochemical model, except for benzene, which is underestimated in current photochemical models, at least at polar latitudes29. We find that C3H8 (propane), C2H2 (acetylene), CH3C2H (propyne), C4H2 (diacetylene), and C6H6 (benzene) are good candidates to form hazes from condensation at different stratospheric levels. This agrees with previous studies that also considered C5H12 (pentane) and C4H10 (butane) as condensates in the 5–50-mbar level25. It has been suggested that because of the proximity of the condensation altitude levels of these compounds and due to the gravitational settling of the particles, they could condense on one another forming layers of mixed composition25. Condensation of water ice could also occur at high altitudes in a thin layer above 0.1-mbar pressure level25. At deeper levels, in the upper troposphere, NH3 ice is a good candidate to form the lower haze34.

### Vertical propagation of gravity waves

The quasi-regular vertical distribution of the multiple haze layers suggests that they could be produced by the passage of vertically propagating waves, inducing vertical oscillations in the temperature profile, favoring the condensation of compounds at specific altitudes according to the saturation vapor-pressure curves of the compounds.

As indicated above, the haze layers we study here were observed between planetographic latitudes 75.8°N and 77.1°N, but these limits are imposed by the limited field of view of the limb by Cassini ISS at that time. The hazes most probably extended beyond these latitudes at least south of the hexagon wave and its embedded jet down to latitude 66°N, as shown by our survey of Cassini ISS images during the Cassini mission described above. Here we focus on the latitudes on which the multilayer system has been observed in more detail as shown in Table 1. At cloud level (0.5–1 bar), the eastward jet shows velocities increasing from u 5 ms−1 at 75.8°N to u 55 ms−1 at 77.1°N, in the anticyclonic side of the jet5,6,7,8. The hexagon and its meandering eastward jet have been proposed to be a trapped Rossby wave5,35. We explore the possibility that the hexagon and jet force gravity waves at the cloud level that, propagating vertically in the region of positive static stability12,36, generate the conditions for the stacked haze-layer formation. There are abundant descriptions in the literature of non-orographic gravity wave generation on Earth from jets and fronts37 that could be applicable to the Saturn hexagon and, at other latitudes, by Saturn’s zonal jet system. The vertical propagation of hydrostatic gravity waves requires that the angular frequency ω of the wave verifies

$$\left| f \right| \le \left| \omega \right| \le \left| N \right|$$
(2)

where $$f = 2\Omega \sin \varphi$$ = 3.17 × 10−4 s−1 is the Coriolis parameter at latitude φ = 76.5°N and N ≈ 0.012 s−1 the Brunt–Väisälä frequency13. We consider linear perturbations to the governing dynamic equations20,38,39,40, and search for plane-wave solutions of the form $$\psi {\prime}(x,y,z,t) = \psi _0\exp \left[ {\left( {z/2H} \right) + i(kx + \ell y + mz - \omega t)} \right]$$, where ω = (cxu)k is the intrinsic wave frequency, m = /Lz denotes the vertical wavenumber, with Lz being the vertical wavelength, and the horizontal wavenumbers are $$k = 2\pi /L_x,\;\ell = 2\pi /L_y$$, with Lx and Ly being the horizontal wavelengths. The waves obey the dispersion relationship20,38,39,40:

$$m^2 = \frac{{N^2 - \omega ^2}}{{\omega ^2 - f^2}}\,k^2\delta ^2 - \frac{1}{{4H^2}} + \left( {\frac{{\omega ^2 - \omega _a^2}}{{c_s^2}}} \right) + \frac{k}{\omega }\left( {\frac{1}{H}\frac{{du}}{{dz}} + \frac{{d^2u}}{{dz^2}}} \right)$$
(3)

where $$\delta ^2 = \left[ {1 + \left( {\left. {\ell /k} \right)^2} \right)} \right]$$. Using H = 40 km as the average gas-scale height, the speed of sound is $$c_s = \sqrt {\gamma R^ \ast T}$$ = 710 ms−1 (γ = 1.4, R* = 3890 J kg−1 K−1, T = 90 K) and the acoustic frequency$$\omega _a = c_s/2H$$ ≈ 0.01 s−1. We assume that the atmosphere is homogeneous since at the latitudes and epoch of the observations, the dependence of N and u with altitude is small above 0.2 bar (Fig. 10b, c in ref. 13), thus dropping the last term in Eq. (3).

The wave frequency ω is calculated using cx ≈ 0 ms−1 (hexagon-phase speed) and u = 120 ms−1 (value of the peak of the eastward jet)5,6. We take for the horizontal scale the Rossby deformation radius LD ≈ 1500 km because of the prevalence of geostrophic conditions at the hexagon5,6,36. Then $$k = \ell \approx$$ 4 × 10−6 m−1, δ = 1.41, and $$\omega = \left( {c_x - u} \right)k$$ ≈ 5 × 10−4 s−1, implying that $$\omega ^2 < < \omega _a^2$$. The acoustic term and the vertical damping scale have similar values in Eq. (3), i.e., $$\left| {\left( {\omega ^2 - \omega _a^2} \right)/c_s^2} \right| \sim 1/4H^2$$ ≈ 2 × 10−10 m−2 and therefore the first term dominates in Eq. (3). Then we have

$$m^2 \approx \frac{{N^2 - \omega ^2}}{{\omega ^2 - f^2}}\,k^2\delta ^2 \approx {\mathrm{3}} \times {\mathrm{1}}0^{ - {\mathrm{8}}}\,{\mathrm{m}}^{ - {\mathrm{2}}}$$
(4)

Figure 5 (upper panel) shows the dependence of the vertical wavelength Lz = 2π/m for gravity waves as a function of the frequency and for two values of the intrinsic velocity (cxu) according to Eq. (4). The frequency range is bounded by the Coriolis and Brunt–Väisälä frequencies from Eq. (2). The expected values for the vertical wavelength would be in the range of 20–60 km. Figure 5 (bottom panel) shows an idealization of the vertical structure of the amplitude of propagating internal waves with no dissipation (i.e., without damping by eddy and molecular viscosity). The amplitude grows upward exp(z/2 H) to make energy density constant with altitude38. For hazes produced by condensation, it can be expected that the vertical wavelength is Lz 2Δz with Δz the layer thickness. Taking Δz 8–18 km (the range of thicknesses for layers L0–L6 in Table 1) gives Lz 16–36 km, consistent with the above calculations. The maximum and minimum of the amplitude oscillation are partially in agreement with the observed pattern in some of the layers (L0–L2, L4, and L6), but differ from these idealized oscillations in others (L3 and L5). Obviously, this is to be expected, since in our analysis we neglect dissipation effects and changes in the scale height. In addition, compression and rarefaction due to the gravity wave passage could affect the particle number density and thickness of the haze layers19,20. However, the lack of data on both the mechanisms subjacent to the gravity wave generation and the initial upward velocity of the parcels in the wave, does not allow us to deepen the analysis.

## Discussion

We have analyzed in detail a system of at least seven detached haze layers in the upper troposphere and stratosphere above the hexagon’s clouds using Cassini ISS high-resolution limb images. The nature of these hazes is compatible with their formation by condensation of a number of hydrocarbons detected in Saturn’s atmosphere forming high in the atmosphere by photochemical reactions (e.g., C2H2, C4H2, C6H6, and CH3C2H). We cannot rule out the possibility that the hazes are formed by photochemical tholins and fractal aggregate particles from more complicated aerosol microphysics and chemistry as it has been proposed for similar hazes in Titan31,32. We suggest that the vertical distribution of the stacked system of haze layers could be produced by the upward propagation of internal gravity waves excited in the hexagon wave and its eastward jet area, perhaps in a similar way to what it occurs in Earth’s jets and fronts37. In fact, the lower value of the derived vertical wavelength, in the range of 20–60 km, is compatible with the retrieved aerosol-scale height and with the measured layer thicknesses if condensation is the mechanism behind haze formation.

Our survey of Saturn’s limb using Cassini ISS images along the whole mission (2004–2017) shows that haze layers exist in all latitudes above the upper cloud deck, but multilayer structures are only found at high northern latitudes, and the set described here has the best resolution and filter coverage. Ongoing studies will characterize and determine the properties of haze layers in Saturn according to their latitude and in relation to zonal jets. The generation of gravity waves by these jets will be explored by taking into account jet wind intensity and meridional distribution41, as well as their variations in altitude and over time in some latitudes42. Finally, the future research should also explore microphysical models, the growth, and destruction mechanisms of the observed aerosols, and look for changes in the haze properties in relation to the seasonal insolation cycle10.

## Methods

### Cassini images

The Cassini ISS images here analyzed are public data retrieved from the Atmospheres node of the Planetary Data System (PDS) NASA. Images are available from the following filters: UV1, UV2, UV3, BL1, RED, MT1, MT2, MT3, CB1, CB2, and CB3 (see details in ref. 14 and Supplementary Table 1). The maximum resolution achieved was in the range of 2–6 km/pixel, but images with ultraviolet filters were binned (UV1 ×4, UV2–UV3 ×2). During the observations, the phase angle varied from 29.1° to 30.5° (corresponding to a scattering angle θ 150°, see Supplementary Fig. 2). The images were calibrated with the CISSCAL software43 and navigated to determine the limb location and obtain reflectivity scans across the limb using the software PLIA44.

### HST images

Images used in this work are the same as in ref. 17, where all relevant information is detailed. The following filters were available: F225W, F336W, F410M, F502N, F547M, F689M, FQ727N, FQ750N, FQ889N, and FQ937N (details given in Supplementary Table 1). All HST images were calibrated in absolute reflectivity as explained in ref. 45. Image navigation and reflectivity scans were obtained using the software LAIA46. Reflectivity was evaluated at 35 points at the latitude of interest from −80° to +80° from the central meridian, providing coverage of all the available illumination and viewing geometries within a plane-parallel approximation.

The radiative transfer analysis used two different codes: one for the spherical geometry case21 and the other, the NEMESIS code, for nadir case47. For the interpretation of the limb-viewing observations, we used a Monte Carlo model21 that solves the multiple-scattering problem in a spherical-shell atmosphere. The setup of the model is similar to that described in a previous work48, and takes as input the geometry of the observations and the optical properties of the atmosphere. We adopted a background gas atmosphere specified by the profiles of the Rayleigh scattering coefficient and methane absorption, and based on ref. 15. On top of the gas optical properties, we specified an exponential profile for the number density of the particles. The profile is described as Np(z) = Np exp(−z/Haerosol), where Np and Haerosol are considered to be tunable parameters, and z is measured from the tropopause.

The radiative transfer solution depends on the scattering-phase function, the single-scattering albedo, and the extinction cross section of the particles. We have conducted a sensitivity analysis with the spectral distribution measured at z = 140 km to demonstrate the impact of some of the corresponding choices:

• Perturbation of the extinction cross section. Because in the radiative transfer problem the extinction cross section of the particles always appears multiplied by the number density of the particles, both factors are inversely related, which affects directly our inferred Np. Smaller cross sections will result in larger Np values, and vice versa.

• Perturbation of the scattering-phase function. Alternatively, to our standard choice for the scattering-phase function, we have implemented the scattering-phase function corresponding to Titan’s stratospheric haze at a wavelength of 350 nm. For Np = 500 cm−3 and Haerosol = 19 km, a good fit is still obtained, but the model appears too reflective at the shorter wavelengths.

• Perturbation of the single-scattering albedo. We have modified our standard choice for the single-scattering albedo by scaling it by a 0.9× factor at all wavelengths. For Np = 500 cm−3 and Haerosol = 19 km, the fit actually improves, which suggests that Saturn’s stratospheric haze may be darker than that in our models.

In the troposphere (z < 0), we assumed the same scattering cross sections as for the nadir analysis. In the stratosphere (z > 0), we parameterized the cross section as $$\sigma _p(\lambda ) = \sigma _{\mathrm{Titan}}(939\,{\mathrm{nm}}) \cdot \left( {939\,{\mathrm{nm}}/\lambda ({\mathrm{nm}})} \right)^4$$, with σTitan(939 nm) = 1.28 × 10−11 cm−2 23. For the scattering properties, we adopted for all wavelengths the scattering-phase function proposed for Titan’s stratospheric particles at 650 nm22, which is in the mid of the range of wavelengths explored here. We kept the single-scattering albedo of the particles as an additional degree of freedom for the final fine-tuning of the model-observation comparison. The models presented in the paper adopt for the stratospheric particles a single-scattering albedo that is 0.5 for λ ≤ 450 nm, and 0.9× the single-scattering albedos proposed for Titan’s stratospheric particles for λ > 450 nm22. Other choices in how the haze optical properties are described in the radiative transfer model will have an impact on the inferred number densities. We consider our estimated values to be valid first-order descriptions that could eventually be refined by, for instance, combining observations at other phase angles.

The NEMESIS code uses an optimal estimator scheme to find the most likely values of atmospheric parameters starting from a priori assumption. Our a priori assumption for this work was inherited from previous studies at neighboring latitudes49, where all the details in the initialization of the model atmosphere can be found. Further details on the goodness of fit and retrieved parameters from the nadir observations can be found in the companion Supplementary Table 2 and Supplementary Figs. 3 and 4.

### Temperature and hydrocarbon vertical profiles

Vertical profiles of the temperature and volume-mixing ratio of six hydrocarbons were obtained from the analysis of thermal emission spectra recorded by Cassini/CIRS using a radiative transfer model coupled to a retrieval algorithm. CIRS was a Fourier-transform spectrometer onboard the Cassini Spacecraft, covering the spectral range of 600–1400 cm−1 (7–17 µm). We focus here on spectra recorded in limb-viewing geometry at planetographic latitude 77°N on 16 June, 2015, at a spectral resolution of 1.5 cm−1. We first exploited emission features from the ν4 band of CH4 (centered at 1304 cm−1) and of the emission induced by collisions by H2–H2 and H2–He (range 600–660 cm−1) to constrain the temperature vertical profile, following the methodology described in ref. 50. As thermal emission depends on both the temperature and the abundance of these molecules, we assume a methane vertical profile taken from a photochemical model and scaled to match a deep mixing ratio of 4.5 × 10−3 51 and a He mixing ratio of 0.135552. By combining typically 10 spectra acquired at different tangent altitudes, we constrain the temperature between ~20 mbar and 3 µbar with a vertical resolution of one atmospheric-scale height (~50 km). Once the temperature is set, we then analyzed emission bands from ethane (centered at 822 cm−1), acetylene (730 cm−1), propane (748 cm−1), diacetylene (628 cm−1), methyl acetylene (634 cm−1), and benzene (673 cm−1) to derive their volume-mixing ratio vertical profile29,51,53. Vertical sensitivity extends from 3 mbar to 3 µbar, except for propane (only constrained between 3 and 0.3 mbar) and benzene (retrieved between 0.1 mbar and 3 µbar).