c – Evaluation of π using Monte Carlo methods – Serial vs OMP

I wrote this simple code to evaluate the π using the Monte Carlo method. This is the serial version:

long double compute_pi_serial (long interval const) {

srand (time (NULL));

double x, y;
int i, circle = 0;

for (i = 0; i <interval; i ++) {
x = (double) (rand () / (double) RAND_MAX);
y = (double) (rand () / (double) RAND_MAX);

if (pow (x, 2) + pow (y, 2) <= 1.0) circle ++;
}

return (double long) circle / interval * 4.0;
}

Afterwards, I wrote a parallel version using OpenMP And this is the result:

long double compute_pi_omp (const long interval, const int threads) {



double x, y;
int i, circle = 0;

#pragma omp parallel private (x, y) num_threads (threads)
{

srand (SEED);

#pragma omp for reduction (+: circle)
for (i = 0; i <interval; i ++) {
x = (double) (rand () / (double) RAND_MAX);
y = (double) (rand () / (double) RAND_MAX);

if (pow (x, 2) + pow (y, 2) <= 1) circle ++;
}
}

return (double long) circle / interval * 4.0;
}

This is an efficient method or there is a more efficient version using always OpenMP?

real analysis – Is $ π: mathcal {C} ^ ∞ (M, N) → mathcal {C} ^ ∞ (S, N) $, $ π (f) = f | _S $ a quotient map in the $ mathcal {C} ^ 1 $ topology?

This question was previously published in MSE.

Leave $ M, N $ be connected smooth manifolds (without limit), where $ M $ It is a compact variety, so we can put a topology in space. $ mathcal C ^ infty (M, N) $ using $ mathcal {C} ^ 1 $ Topology of Whitney.

Now consider $ S subset M $ a compact submanifold of $ M $ with a limit such that $ text {dim} S = text {dim} M $, using the same process we can put a topology in $ mathcal C ^ infty (S, N) $ using the $ mathcal {C} ^ 1 $ Topology of Whitney. There is a natural continuous projection of $ mathcal C ^ infty (M, N) $ in $ mathcal C ^ infty (S, N) $Defined by

begin {align *}
pi: mathcal C ^ infty (M, N) and to mathcal C ^ infty (S, N) \
f & mapsto left.f right | _ {S}.
end {align *}

My question: Is $ pi $ An open map or at least a quotient map?


Some comments

$ mathcal {C} ^ 1 $-Whitney Topology is also called $ mathcal {C} ^ 1 $Strong topology

As noted by user Adam Chalumeau, the following exercise is found in the book "Differential Topology of Morris W. Hirsh"

[Exercise 16, page 41]: Leave $ M, N $ be $ mathcal {C} ^ r $ collectors. Leave $ V⊂M $ be an open set then

  • The restriction map $$ δ: mathcal {C} ^ r (M, N) → mathcal {C} ^ r (V, N) $$ $$ δ (f) = f | V $$ It is continuous for the weak topology, but not always for the strong one.

  • $ δ It is open for strong topologies, but not always for the weak. "

From our $ M $ It's weak compact topology = strong topology. However, I do not know how to solve this exercise, much less adapt that test to the case I want.

Does anyone know anything about this problem?

trigonometry: show that the arcosine (X) + arccos (y) = π / 2, Si and only if x = y

I was wondering about this identity:
arcosine (X) + arccos (X) = π / 2;
That a thought came to my mind that in general
arcsin (X) + arccos (Y) = π / 2, implied that X = Y.
I have a hunch that it's true and I've done a kind of self-test but it's illegal to use a test method, then I also tried to use graphics but I'm still stuck. I would be grateful if someone could help me please.

$ Π (x) ge log log x $ holds $ 2 le x e e {{e ^ 3} <5.3 times 10 ^ 8 $?

The book Theory of Numbers by G H Hardy, et al. test $ π (x) ge log log x $ for $ x> e ^ {e ^ 3} $. There is a way to try out that also goes for $ 2 le x e e ^ {e ^ 3} $ otherwise (in the worst case) some valuable source to verify this numerically?

calculation: How do I find x when θ = 1/4 π of dx / dθ = (x + 2) without ^ 2 2θ if x is 0 when θ is 0?

Some of your previous responses have not been well received and you are in danger of being blocked.

Please pay close attention to the following guide:

  • Please make sure answer the question. Provide details and share your research!

But avoid

  • Ask for help, clarifications or respond to other answers.
  • Make statements based on opinion; Support them with references or personal experience.

For more information, see our tips on how to write excellent answers.