calculus and analysis – Integration by parts

I know this question is already present in many variations, and it seems that for each one you have to define your own rules, and I am struggling to invent them in this case.

I want to integrate a big list of expressions of the form

``````\$\$
{ r^n y^{(p)} y^{(q)}},,qquad n,p,qin mathbb{Z}_{>0}
\$\$
``````

where $$y$$ is an unknown function. Namely, by taking integrals by parts, I want to bring the expressions to the form of sum where remaining integrals contain minimal power of $$r$$ inside.
For example,

$$int dr,, r^2 y’ y” = frac{1}{2} r^2 y’^2 – int dr,, r^2 y’y”-2int dr,,r y’^2$$

Of course, straightforward application of some naive rules and then using FixedPoint will yield nothing but an infinite loop.

Probably, this is already implemented either in some package, or in some Mathematica function. I would be glad if you could point it to me.

integration – Symmetric PDF up to a proportionality

I have a random variable $$X$$ that has a pdf up to a proportionality defined by:
$$f(x) propto e^frac{-(x-1)^2}{ 2}+e^frac{-(x-4)^2}{2} quad 0

Also is given that the $$E(X)=2.5$$.It seems like there are two normal distributions there but how can I find the constant $$c$$ in order to calculate the expected value.

integration – Calculate the derivative of \$F(t)=int_0^tdzint_0^zdyint_0^y(y-z)^2f(x)dx\$

The original problem in the book is finding a way to prove that $$F(t)=int_0^tdzint_0^zdyint_0^y(y-z)^2f(x)dx$$ has a derivative $$frac{dF}{dt}=frac{1}{3}int_0^t(t-x)^3f(x)$$.

I know how to get a $$F(t)$$ expressed without multi-integrals, which is, if I am right, $$F(t)=int_0^tfrac{1}{12}(x-t)^4dx,$$ but I don’t know how to proceed.

riemann integration – Prove that for any partition 𝑃 of [𝑎,𝑏], 𝐿(f𝑏,𝑃)=0.

Let 𝑎<𝑏 and consider the function F𝑏:(𝑎,𝑏)→ℝ given by

F𝑏(𝑥)=

``````   0  if 𝑎 ≤ 𝑥 <𝑏

1  if 𝑥 = 𝑏
``````

Prove that for any partition 𝑃 of (𝑎,𝑏), 𝐿(F𝑏,𝑃)=0.

Hello, can anyone help me with this question? Much help needed. Thank you!

continuous integration – Big static web site build system design

We are running a relatively large size static website, which serves over 200K static web pages. We use Next.js to generate these static pages and we host the generated HTML and asset files in AWS S3.

Currently, we are using a dedicated EC2 instance as our build machine for two reasons: 1. the build needs some powerful computation power to populate 200K pages; 2. once the HTML files are generated, the network transfer speed between EC2 to S3 is fast.

I’m looking for some advice about how to automate this build process, so that it can automatically do the following:

1. Turn on the build instance on-demand when I need to build the project.
2. Run custom build command with pre-defined configurations.
3. Automatically upload the generated HTML files and assets to S3 after the build is completed.
4. Automatically switch to serve the new directory of HTML files in S3 after it’s uploaded.

Ideally, this workflow can be started by a simple trigger or push of a button. Please advise if there’s any tool or framework that I can take a deeper look at.

Thanks!

numerical integration – NIntegrate results different when using 0 or 0.0

i was trying to compute a convolution numerically, but got unexpected results. In the end i was able to reduce it to the code below. As you can see, the results are different, depending on whether i write (0-x)^2, x^2 or (0.0-x)^2 (x is a real value). i have Mathematica 10.3.
can somebody explain that to me?
thank you very, very much for your help.
all my best wishes
esra

``````In(77):= NIntegrate(
0.16076649110325864` E^(-9774.602659078126` Sqrt(    x^2)) (Erfc(-123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4)) -
E^(19549.20531815625` Sqrt(x^2))
Erfc(123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4))) ((
3 (0 - x)^2)/(0.000025` + (0 - x)^2)^(5/2) -
1/(0.000025` + (0 - x)^2)^(3/2)), {x, -Infinity, Infinity})

Out(77)= -410.318

In(84):= NIntegrate(
0.16076649110325864` E^(-9774.602659078126` Sqrt(    x^2)) (Erfc(-123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4)) -
E^(19549.20531815625` Sqrt(x^2))
Erfc(123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4))) ((
3 (0.0 - x)^2)/(0.000025` + (0.0 - x)^2)^(5/2) -
1/(0.000025` + (0.0 - x)^2)^(3/2)), {x, -Infinity, Infinity})

Out(84)= -205.159

In(78):= NIntegrate(
0.16076649110325864` E^(-9774.602659078126` Sqrt(    x^2)) (Erfc(-123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4)) -
E^(19549.20531815625` Sqrt(x^2))
Erfc(123.28828005937953` Sqrt(10^-4) +
10 Sqrt(110/7) Sqrt(x^2/10^-4))) ((3 x^2)/(0.000025` + x^2)^(
5/2) - 1/(0.000025` + x^2)^(3/2)), {x, -Infinity, Infinity})

Out(78)= -410.318
``````

numerics – How to use parallel computation in mathematica for numerical Integration

I have a multi dimensional integral and I need to integrate it numerically and than plot it over an extra variable for zeta = 0.5.

``````g(kx_, ky_, k1x_, k1y_, qx_, qy_, zeta_, zz_) := (1/((1 + Exp(-Sqrt(k1x^2 + k1y^2) + zeta*k1x*Cos(zz) +
zeta*k1y*Sin(zz)))*(1 +
Exp(-Sqrt(kx^2 + ky^2) + zeta*kx*Cos(zz) +
zeta*ky*Sin(zz)))*(1 +
Exp(Sqrt((kx + qx)^2 + (ky + qy)^2) + zeta*(kx + qx)*Cos(zz) +
zeta*(ky + qy)*Sin(zz))*(1 +
Exp(Sqrt((k1x - qx)^2 + (k1y - qy)^2) +
zeta*(k1x - qx)*Cos(zz) + zeta*(k1y - qy)*Sin(zz))))));
PolarPlot(NIntegrate(g(kx, ky, k1x, k1y, qx, qy, 0.5, zz), {kx, -1, 1}, {ky, -1,
1}, {k1x, -1, 1}, {k1y, -1, 1}, {qx, -1, 1}, {qy, -1, 1}), {zz,
0, 2 Pi})
``````

my problem is that, it take many hours (more than 10 hours) without answer. my solution was to calculate the integral for some discrete set of angles, and than plot it, but I am searching for more better way.
based on searching in site,

Parallelizing Numerical Integration in Mathematica

it may be possible to use parallel computation to plot it. my knowledge in Mathematica is limited and I couldn’t understand what the role of index “i” is in that link.
Would someone please tell me how can I use all cores to decrease the time of calculation.

thanks

continuous integration – Clarifying the steps in a CI/CD, but namely if if unit testing should be done building a Docker image or before

I’m building at a Build and Deployment pipeline and looking for clarification on a couple points. In addition, I’m trying to implement Trunk Based Development with short-lived branches.

The process I have thus far:

1. Local development is done on the `main` branch.

2. Developer, before pushing to remote, rebases on remote `main` branch.

3. Developer pushes to short-lived branch: `git push origin main:short_lived_branch`.

4. Developer opens PR to merge `short_lived_branch` into `main`.

5. When PR is submitted it triggers the `PR` pipeline that has the following stages:

1. Builds the microservice.
2. Unit tests the microservice.
3. If passing, builds the Docker image with a `test-latest` tag and push to container registry.
4. Integration testing with other microservices (still need to figure this out).
5. Cross-browser testing (still need to figure this out).
6. If the `PR` pipeline is successful, the PR is approved, commits are squashed, and merged to `main`.

7. The merge to `main` triggers the `Deployment` pipeline, which has the following stages:

1. Builds the microservice.
2. Unit tests the microservice.
3. If passing, builds the Docker image with a `release-<version>` tag and push to container registry.
4. Integration testing with other microservices (still need to figure this out).
5. Cross-browser testing (still need to figure this out).
6. If passing, deploy the images to Kubernetes cluster.

I still have a ton of research to do on the integration and cross-browser testing, as it isn’t quite clear to me how to implement it.

That being said, my questions thus far really have to do with the process overall, unit testing and building the Docker image:

1. Does this flow make sense or should it be changed in anyway?

2. Regarding unit testing and building the Docker image, I’ve read some articles that suggest doing the unit testing during the building of the Docker image. Basically eliminating the first two stages in my `PR` and `Deployment` pipelines. Some reasons given:

• You are testing the code and not the containerized code which is actually what will be run.
• Even if unit testing passes, the image could be broke and it will be even longer before you find out.
• Building on that, it increases the overall build and deployment time. From my experience, the first two stages in my pipelines for a specific service take about a minute and half. Then building and pushing the image takes another two and half minutes. Overall about four minutes. If the unit tests were incorporated into the Docker build, then it could possibly shave a minute or more off the first three stages in my pipeline.

Would this be a bad practice to eliminate the code build and unit testing stages, and just moving unit testing into the Docker build stage?

Thanks for weighing in on this while I’m sorting it out.

definite integrals – On counting the areas covered by holes in a function in integration

As far as I know, holes in a function at the endpoints of an interval aren’t usually given any importance while integrating over that interval. For example, while calculating the area under the fractional part function from 0 to 1;

You don’t really think of a hole as being an infinitesimally small width that contributes to the calculated area. And I’m fine with that- it makes sense.

But there’s this question that defines f(x) as 0 where x can be expressed as $$frac{n}{n+1}$$, where n’s an natural number, and as 1 everywhere else. And you’re supposed to find the integral of f(x) from 0 to 2. So you’ve got a line, y=1, with dots on it that grow closer and more numerous as you get closer to 2, nearing an infinite number.

Now the solution to the question just integrates the function from 0 to $$frac{1}{2}$$, $$frac{1}{2}$$ to $$frac{2}{3}$$, $$frac{2}{3}$$ to $$frac{3}{4}$$ and so on until 1 and then a normal integral from 1 to 2-essentially just integrating y=1 from 0 to 2.

This seems odd. Isn’t ‘infinitesimally small quantities summed in infinite numbers forming actual numbers’, the general idea of integration? Since there’re an infinite number of small widths here, shouldn’t they be considered as constituting some area and thereby affecting the calculation?

numerical integration – Solving Fredholm Equation with composite unknown function

This equation can be solved with Bernoulli polynomials. First we substitute $$y=x^2/2-1$$, $$t=s^2/2-1$$, then define colocation points, solution and system of equations as follows

``````nN = 12; L = Pi^2/2 - 1; xcol =
Table(-1 + Pi^2/2 (j + 1/2)/nN, {j, 0, nN - 1});
v(x_) := Table(BernoulliB( n, x/L), {n, 0, nN - 1}); A =
Array(a, {nN}); u(x_) = A . v(x);
eqs = Table(
u(xcol((i))) - 1 -
1/2 A . NIntegrate(
v(t ) Cos(Sqrt(2 (1 + xcol((i)))) - Sqrt(2 (1 + t)))/
Sqrt(2 (1 + t)), {t, -1, L}, AccuracyGoal -> 10), {i,
Length(xcol)});
``````

Numerical solution can be evaluated in two step

``````sol = NMinimize(Norm(eqs), A)

sol1 = FindRoot(Table(eqs((i)) == 0, {i, Length(eqs)}),
Table({a(i), a(i) /. sol((2))}, {i, Length(A)}))
``````

Finally we plot solution

``````Plot({u(x^2/2 - 1) /. sol1, u(x^2/2 - 1) /. sol((2))}, {x, 0, Pi},
PlotRange -> All, Frame -> True,
PlotLegends -> {"FindRoot", "NMinimize"},
FrameLabel -> {"x", "(Phi)"}, PlotLabel -> Row({"n = ", nN}))
``````