# Peculiar performance variance with small arrays

C

#### Canleskis

##### Guest
Canleskis Asks: Peculiar performance variance with small arrays
as part of a larger project (of N-body simulations) I started working with arrays using const generics to represent algebraic vectors. Those vectors can then be of any size, but I'm especially interested in the ones of length 2 and 3.

I noticed that performance with arrays of length 2 was worse (a lot worse!) compared to similarly sized arrays (length 1 or 3 for example) in a certain scenario I need for my project.

This is the scenario, or rather a shortened version of it:

Code:
fn fold<const N: usize>(v: Vec<Array<N>>) -> Vec<Array<N>> {
let result = v.iter().map(|a1| {
v.iter().fold(Array::default(), |acc, a2| {
let d = *a2 - *a1;

acc + d
})
});

result.collect()
}

The arrays are wrapped in a newtype called Array implementing operators for simplicity, but the results are the same without that wrapper.

Using criterion with Vecs lengthed from 10 to 500 of random arrays, I benched this function and generated the following graph for differently sized arrays:

As you can see performance is a lot worse for arrays of length 2 compared to the rest. I'm unable to understand why this specific scenario leads to such performance variance, so I'm hoping someone can help me figure this out because this has slowed down my progress significantly.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.

Dick Grayson Asks: Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.
The Problem: Suppose $G=\left\langle x, y, t|x^7=y^7=t^3=1, txt^{-1}=x^2, tyt^{-1}=y\right\rangle$. Show that $y\in Z(G)$.

My Attempt: Clearly $y$ commutes with $t$, so $y$ commutes with $t^2$ as well. Thus to show $y\in Z(G)$, it suffices to show that $y$ commutes with $x$. But I struggle to prove that $xy=yx$. It seems a rather silly place to get stuck-any HINT would be greatly appreciated.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### Inner and Outer Radius of a Set in Isotropic Position

user6952886 Asks: Inner and Outer Radius of a Set in Isotropic Position
For a compact convex set $C\in \mathbb{R}^d$ in isotropic position, a classical result in convex geometry says that there exists $r,R>0$ such that $B_2^d(r)\subseteq C \subseteq B_2^d(R)$ and $R/r \leq O(d)$.

Does the same remain true when the $\ell_2$ balls are replaced by $\ell_{\infty}$ balls? That is, does there exist $r,R>0$ such that $B_\infty^d(r)\subseteq C \subseteq B_\infty^d(R)$ and $R/r \leq O(d)$?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### Prove $e$ is irrational.

Julian Neira Asks: Prove $e$ is irrational.
I'm stucked in this problem: For every $n\in\mathbb{N}$, show that

$$0<e-\left(1+\frac{1}{1!}+\frac{1}{2!}+...+\frac{1}{n!}\right)<\frac{1}{n!n}$$ From this, prove $e$ is irrational.

I don't know how to prove $e-\left(1+\frac{1}{1!}+\frac{1}{2!}+...+\frac{1}{n!}\right)<\frac{1}{n!n}$. I already used induction, but it didn't work. Thanks for your help.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### What are the total number of state combinations for this dice game?

RTT Asks: What are the total number of state combinations for this dice game?
Lets say we have the dice game explained below. What are the total number of game states? In other words, how many numerical combinations of lives, totalScore, and scratchScore exist?

Initial State:

lives = 5, totalScore = 0, scratchScore = 0

The Rules:

Each turn you roll a 6-sided dice. If the roll is [1-5] then you add that score to your scratchScore. If you roll a 6, then your scratchScore is reset to 0 and you lose 1 life.

Before each roll, you may decided to yell "BANK" at which point you add your scratchScore to your totalScore and reset the scratchScore to 0. Everytime you yell "BANK" though you will lose 1 life.

If lives=0 you lose. Otherwise youc an win by achieving a totalScore that is >= 40. The idea is to only yell "BANK" when your scratchScore is somewhat large.

Here is an example game:

1. lives = 5; total score = 0; scratch score = 0. You roll a 2 and do not yell ”bank.”
2. lives = 5; total score = 0; scratch score = 2. You roll a 3 and do not yell ”bank.”
3. lives = 5; total score = 0; scratch score = 5. You roll a 4 and yell ”bank.”
4. lives = 4; total score = 9; scratch score = 0. You roll a 2 and do not yell ”bank.”
5. lives = 4; total score = 9; scratch score = 2. You roll a 6.
6. lives = 3; total score = 9; scratch score = 0
7. ... repeat untill lives=0 or totalScore >= 40

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### Indefinite Integral of ${\tan(x)}^{p/q}$

Mailbox Asks: Indefinite Integral of ${\tan(x)}^{p/q}$
I have seen a lot of videos in which people integrate functions like $\sqrt{\tan(x)}$, $\sqrt[3]{\tan^2(x)}$, etc. I was wondering if there was a closed-form expression for $$\int (\tan{x})^{\frac{p}{q}} dx$$

Where $p,q$ are integers, and $q \neq 0$. Eventually, I would like to generalize the result to an integrand ${\tan(x)}^r$, for $r \in \mathbb{R}$, but for now we can stay with the rationals.

My attempt at solving this:

Let $u = \tan(x) \implies x = \arctan(u), dx = \frac{du}{1+u^2}$. This yields $$\int \frac{u^{\frac{p}{q}}}{1+u^2}du$$

But I'm not sure where to go from here. My first thought was long division, but that can't work here. I also considered treating $\frac{1}{1+u^2}$ like a geometric series, but that has a finite radius of convergence.

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### How does a Phantom Rogue's Ghost Walk ability movement work?

• Rykara
• Social
• Replies: 0
Rykara Asks: How does a Phantom Rogue's Ghost Walk ability movement work?
At level 13, the Phantom Rogue gets the ghost walk ability which grants (in part):

As a bonus action, you assume a spectral form. While in this form, you have a flying speed of 10 feet, you can hover [...]

Does this mean that the phantom rogue has (only) 10 feet of flying movement (and no other movement)?

Or does the phantom rogue gain 10ft of flying movement (in addition to their normal movement)?

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.

#### What do the spear and watermelon jokes in "Airplane!" mean?

• freeling10
• Social
• Replies: 0
freeling10 Asks: What do the spear and watermelon jokes in "Airplane!" mean?
In the awesome 1980 comedy Airplane!, there are two jokes that make no sense and I've never been able to find an adequate explanation for them. Is anyone able to shed some light?

Near the end of the film, Rex Kramer (Robert Stack) arrives at the control tower to help Ted Striker (Robert Hays) land Trans-American Airlines' endangered flight 209. Kramer confers with Steve McCroskey (Lloyd Bridges) and, while they're discussing the situation, they have the following exchange:

McCroskey: Right now, things aren't so good.

Kramer: Let me tell you something, Steve. Ted Striker was a top notch squadron leader. A long time ago.

At that moment, a spear whizzes across the room and into a nearby bulletin board. Without referencing the projectile, the conversation continues:

McCroskey: I want you to get on the horn and talk that guy down. Now you're going to have to let him get the feel of that airplane on the way and you'll have to talk him onto the approach. So help me, you'll have to talk him right down to the ground.

At this point, a watermelon drops from above and smashes onto the corner of a desk in the background. It is not acknowledged by either character.

Everything else in the movie is crystal clear, but these two gags have always confounded me. Surely somebody must know!

SolveForum.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your thoughts here to help others.