## Integration of a vector function in spherical coordinates, where the unit vector cannot be represented as the standard radial unit vector?

While trying to find out the electric field due to a charged sphere without using Gauss Law, I encountered an integration $$iiintfrac{r^2sintheta drdtheta dphi}{left|vec{r}-vec{r’}right|^3}left(vec{r}-vec{r’}right)$$
Here, $$vec{r’}$$ is a constant, while $$vec{r}$$ is the radial vector.

The exact part which is troubling me the most is $$int_0^{r_o}frac{r^2left(vec{r}-vec{r’}right)}{left|vec{r}-vec{r’}right|^3}dr$$
or, $$int_0^{r_o}frac{r^2(widehat{vec{r}-vec{r’}})}{left|vec{r}-vec{r’}right|^2}dr$$
Here, the unit vector isn’t $$hat{r}$$, which can be written as $$costhetacosphihat{i}+costhetasinphihat{j}+sinthetahat{k}$$, as I saw in another answer Vector valued integral in spherical coordinates.
Rather, it is $$(widehat{vec{r}-vec{r’}})$$. This cannot be taken out of the integral as the unit vectors of Cartesian coordinates $$hat{i}, hat{j}$$ and $$hat{k}$$, since they are dependent on $$theta$$ and $$phi$$. So, how exactly should I proceed?

## integration – What is the value of the following integral of a quotient of sines?

I am familiar with the following integral for a quotient of squares of sines in terms of the Bessel function of the first kind $$J$$:
$$int_{0}^{pi}frac{sin^{2}left(frac{N}{2}cos(theta)right)}{sin^{2}left(frac{1}{2}cos(theta)right)}dtheta=pileft(N+2sum_{n=1}^{N-1}(N-n)J_{0}(n)right)$$
However, this is clearly only valid when $$N$$ is a positive integer. I am keen to work out the value of
$$int_{0}^{pi}frac{sin^{2}left(frac{L}{2}cos(theta)right)}{sin^{2}left(frac{1}{2}cos(theta)right)}dtheta$$
where $$L$$ can be any positive number. For context, the integral comes up in calculating the diffraction patterns of periodic structures.

Thanks in advance for any help.

## 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.

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.

## numerical integration – Solving Fredholm Equation with composite unknown function

I would like to numerically solve a Fredholm Equation where the unknown function is composite. For example, an equation like the one described in Solving Fredholm Equation of the second kind but having composite functions as unknowns.

Consider then the Fredholm Equation:
$$phileft(frac{x^2}{2}-1right) = 1 + frac12 int_{0}^{pi} text{cos}left(x-sright) , phileft(frac{s^2}{2}-1right) ,ds$$
for $$xin(0,pi)$$.

How could one use Mathematica to find a numerical solution?

## How do we perform the following integration?

How do we perform the following integration?

equation

## Multi Var Calc: I think this is Partial Integration? How would you solve this problem?

…………………………. ## complex geometry – Explicit integration of Kahler form to get volume

Consider a compact Kaehler manifold $$X$$ of dimension $$d=3$$. The K”ahler form in local coordinates $$z^i,bar{z}^i$$ is
$$omega = omega_{i bar{j}}dz^i wedge dbar{z}^j,$$
with $$omega_{i bar{j}} = frac{i}{2} g_{i bar{j}}$$, where $$g_{i bar{j}}$$ is Hermitian.

I want to explicitly show that the volume given by $$int_X omega^n$$ yields
$$A int_X sqrt{mathrm{det}(g_{ibar{j}}) } dz^1wedge dz^2 wedge dz^3 wedge dbar{z}^1 wedge dbar{z}^2 wedge dbar{z}^3,$$
where $$A$$ is some overall constant.

The closest I arrive at my intended result is:
$$int_X epsilon^{i k m} epsilon^{bar{j} bar{l} bar{n} } ~ omega_{i bar{j}} omega_{k bar{l}} omega_{m bar{n} } ~ dz^1wedge dz^2 wedge dz^3 wedge dbar{z}^1 wedge dbar{z}^2 wedge dbar{z}^3,$$
using the antisymmetry of the wedge product and the identity
$$dz^i wedge dz^k wedge dz^m = epsilon^{i k m} dz^1wedge dz^2 wedge dz^3$$

and its complex conjugate.

I’m almost convinced that I can identify
$$epsilon^{i k m} epsilon^{bar{j} bar{l} bar{n} } ~ omega_{i bar{j}}omega_{k bar{l}} omega_{m bar{n} } = mathrm{det} (omega_{i bar{j}})$$,
but not 100% sure.

(FWIW, I have seen a version of this where the $$dz^i , dbar{z}^j$$‘s are turned into real forms $$dx^i, dy^j$$, but I want to avoid going down that route for the moment and express the result in complex coordinates.)

## numerical integration – How to define a polygonal region in 2D to subsequently integrate over it?

Here is an example in 12.2.

``````poly = Polygon({{0, 0}, {1/2, Sqrt(3)/2}, {1, 1/Sqrt(3)}, {1, 0}});
NIntegrate(Log(x + y + 1), {x, y} (Element) poly)
``````

`0.366623`

Let us verify it by

``````Integrate(Log(x + y + 1), {x, y} (Element) poly)
``````

`-((36 - 12 Sqrt(3) + 12 Log(2) + 228 Sqrt(3) Log(2) + 138 Log(3) + 54 Sqrt(3) Log(3) + 9 Log(4) - 3 Sqrt(3) Log(4) + 48 Sqrt(3) Log(6) - 2 Log(8) - 2 Sqrt(3) Log(8) + 2 Sqrt(3) Log(9) - 48 Sqrt(3) Log(2 - 2/Sqrt(3)) + 90 Log(2 - Sqrt(3)) + 54 Sqrt(3) Log(2 - Sqrt(3)) - 90 Log(3 - Sqrt(3)) - 54 Sqrt(3) Log(3 - Sqrt(3)) - 180 Log(-1 + Sqrt(3)) - 108 Sqrt(3) Log(-1 + Sqrt(3)) + 72 Log(1 + Sqrt(3)) - 48 Sqrt(3) Log(1 + Sqrt(3)) - 36 Log(2 + Sqrt(3)) + 24 Sqrt(3) Log(2 + Sqrt(3)) - 18 Log(3 + Sqrt(3)) - 90 Sqrt(3) Log(3 + Sqrt(3)) - 48 Log(6 + Sqrt(3)) - 52 Sqrt(3) Log(6 + Sqrt(3)) - 72 Log(3 + 2 Sqrt(3)) + 48 Sqrt(3) Log(3 + 2 Sqrt(3)) + 36 Log(9 + 5 Sqrt(3)) - 24 Sqrt(3) Log(9 + 5 Sqrt(3)))/(8 Sqrt( 3) (19 + 11 Sqrt(3)) (-45 + 26 Sqrt(3))))`

``````N(%)
``````

`0.366623`

Addition. `NIntegrate` produces a different result if the vertices are taken couunter-clockwise as

``````poly1 = Polygon({{1, 1/Sqrt(3)}, {1/2, Sqrt(3)/2}, {0, 0}, {1, 0}});
NIntegrate(Log(x + y + 1), {x, y} (Element) poly1)
``````

`0.17812`

shows. `Integrate` produces the same:

``````Integrate(Log(x + y + 1), {x, y} (Element) poly1)
``````

`(-18 - 18 Sqrt(3) + 117 Log(2) + 88 Sqrt(3) Log(2) + 297 Log(3) + 141 Sqrt(3) Log(3) - 417 Log(4) - 209 Sqrt(3) Log(4) - 574 Log(8) - 287 Sqrt(3) Log(8) - 396 Log(27) - 228 Sqrt(3) Log(27) + Log(216) + Sqrt(3) Log(216) + 6 Log(1728) + 4 Sqrt(3) Log(1728) - 6 Log(46656) - 4 Sqrt(3) Log(46656) + 4 Log(452984832) + 2 Sqrt(3) Log(452984832) - 594 Log(18 - 8 Sqrt(3)) - 342 Sqrt(3) Log(18 - 8 Sqrt(3)) - 288 Log(11 - 5 Sqrt(3)) - 144 Sqrt(3) Log(11 - 5 Sqrt(3)) + 594 Log(9 - 3 Sqrt(3)) + 342 Sqrt(3) Log(9 - 3 Sqrt(3)) + 1188 Log(5 - Sqrt(3)) + 684 Sqrt(3) Log(5 - Sqrt(3)) + 288 Log(-8 (-2 + Sqrt(3))) + 144 Sqrt(3) Log(-8 (-2 + Sqrt(3))) - 591 Log(6 + Sqrt(3)) - 279 Sqrt(3) Log(6 + Sqrt(3)) + 1179 Log(7 + Sqrt(3)) + 567 Sqrt(3) Log(7 + Sqrt(3)) + 297 Log(15 + 8 Sqrt(3)) + 141 Sqrt(3) Log(15 + 8 Sqrt(3)) - 297 Log(17 + 9 Sqrt(3)) - 141 Sqrt(3) Log(17 + 9 Sqrt(3)))/(8 Sqrt( 3) (-3 + 2 Sqrt(3)) (9 + 5 Sqrt(3)))`

``````N(%)
``````

`0.17812`