## calculus and analysis – Symmetric part of a 4th rank tensor in mathematica

Let’s define a symbolic rank 4 tensor (of dimension 3):

``````MatrixForm(symbolicRank4=Array(Subscript(a,StringJoin(ToString/@{##}))&,{3,3,3,3}))
``````

We can symmetrize this manually using the permutations you suggest:

``````MatrixForm(manualSymmetrization=Simplify(Mean(TensorTranspose(symbolicRank4,#)&/@Permutations(Range(4)))))
``````

or using the built-in `Symmetrize`:

``````MatrixForm(builtInSymmetrization=Normal(Symmetrize(symbolicRank4,Symmetric(All))))
``````

These indeed agree, and get recognized by `TensorSymmetry`

``````In(54):= builtInSymmetrization == manualSymmetrization
TensorSymmetry(builtInSymmetrization)

Out(54)= True

Out(55)= Symmetric({1, 2, 3, 4})
``````

Finally, if you care for the independent tensor components, you can use `SymmetrizedArray` directly:

``````MatrixForm(SymmetrizedArray(pos_:>Subscript(a,StringJoin(ToString/@pos)),{3,3,3,3},Symmetric(All)))
``````

The particular examples given in the post can be symmetrized as:

``````MatrixForm(Symmetrize(TensorProduct(IdentityMatrix(3),IdentityMatrix(3)),Symmetric(All)))
MatrixForm(Symmetrize(TensorProduct(Array(a,{3,3}),Array(b,{3,3})),Symmetric(All)))
``````

## php – Tools cli script analysis

I work with MySQL based PHP scripts. I often encounter the problem of loading the application to the browsers. I use tools like → https://www.webpagetest.org. This gives me the overall picture, but I still can’t answer what’s happening on the host side when I have “wait”.

I am looking for tools to analyze the time of polled scripts in CLI (for only Linux).

## static analysis – Strategies for introducing or enforcing new linting or other code quality tooling rules

I’m in a situation where there is a code base that has TypeScript and ESlint but:

• There are a lot of type errors (code compiles despite errors using Babel)
• There are a lot of lint warnings.
• We may want to introduce some new lint rules to solve some particular problems we have (for example, cyclic dependencies really were causing a problem, so introducing the `import/no-cycle` rule to prevent it).

We’re now at a point where we are introducing a build pipeline so we can prevent people from committing code with errors – but the problem is the code is already not in a position to pass the CI quality check.

e.g. we can’t fail on type errors as it currently is, we’d need to fix all of the type errors first.

What’s the best strategy to move toward enforcing code quality, without preventing us from using the code in the meantime?

Here’s things I’ve tried or considered:

• Big shabang just clean up all of the errors now.

• This is a lot of work. Especially with sorting out type errors you might end up refactoring things, and then that breaks something.
• Also, it’s not like the ‘big shabang’ approach is something you ‘just need to do once’. For example, adding that no-cycles rule would require another big shabang clean up of fixing the imports.
• Use a tool like husky and lint-staged to enforce code quality on just the files you touched.

• The problem I ran into with this is having developers just push with `--no-verify` and then later when people are pulling master into their branch, they get all of the errors.
• Admittedly that was a problem of enforcing code style on the dev’s machine only – presumably there’s a tool that do the ‘enforce code quality on only the files you touched’ on CI servers.
• Maintain an ignore list – ie. put the rules in, but keep a list of ‘these are the files that are currently broken’ and slowly reduce it.

• This article here recommends coming up with your list of ideal lint rules, but turning them off until the codebase is ready.

• Essentially that’s a series of the ‘big shabang’ solution. I’m not sure how this would work for type errors.

Are there well tested strategies for solving this problem?

## real analysis – Periodical functions with \$f^{(n)} = f\$, but \$f^{(k)} neq f\$ for \$kin {1,ldots,n-1}\$

For any infinitely differentiable function $$f: mathbb{R}to mathbb{R}$$ and positive integer $$kinmathbb{N}$$, let $$f^{(k)}$$ denote the $$k$$-th derivative of $$f$$.

For which $$ninmathbb{N}$$, $$n>1$$, is there a periodical function $$f:mathbb{R}to mathbb{R}$$ with the property that $$f^{(n)} = f$$, but $$f^{(k)} neq f$$ for $$kin {1,ldots,n-1}$$?

## real analysis – Finiteness of a bilinear combination

For $$jinmathbb{N}$$, consider continuous functions $$f_j:(0,1)tomathbb{mathbb{R}^+}$$ such that
$$sup_{tin(0,1)}sum_jf_j(t)<+infty,$$
namely $$f_j(t)in L_t^{infty}((0,1),l_j^1(mathbb{N}))$$. I would like to understand whether the quantity
$$S_f:=sum_{j,kinmathbb{N}}int_0^1f_j(t)f_k(t)dt$$
is finite. Some observations:

• If for every $$j$$ the function $$f_j$$ is increasing in $$t$$, then $$S_f$$ is finite. Indeed,

$$S_fleq sum_{jinmathbb{N}}f_j(T)sum_{kinmathbb{N}}int_0^1 f_k(t)dtleq sum_{jinmathbb{N}}f_j(T)int_0^1sup_{tin(0,1)}sum_{jinmathbb{N}}f_k(t)dt<+infty$$

Similarly, if the functions $$f_j$$ attains their maxima on a finite set of points in $$(0,1)$$, then $$S_f$$ is finite.

• More generally, $$S_f$$ is finite if $$f_j(t)in L_j^1L_t^{infty}$$, but of course this is not always the case. For example, one can take (a smooth modification of) $$f_j(t):=delta_{t=j^{-1}}$$. Nevertheless, also in this case $$S_f$$ is finite.

• I tried to consider the case when the $$f_j$$ have plenty of oscillations, but I was unable to find a counterexample.

So my question is the following: is it true that $$S_f$$ is always finite?

In the context I’m interested, there is an additional (weak) control of the derivatives of $$f_j$$, of the form $$2^{-j}f_j’in L^1(0,1)$$, so one could also try to prove the finiteness of $$S_f$$ under this additional assumption.

Thank you for any suggestion.

## calculus and analysis – 1D Transient Heat Conduction Problem

I could really use some help with this problem regarding heat conduction through a steel bar

Solve the one-dimensional transient heat conduction problem as follows.
You insert a steel bar that had been sitting at room temperature at 72ºF into a
bed of hot coals at 800 ºF to a depth of 6 inches. The bar is 4 ft long and has a
diameter of 0.5 in. You keep the bar in the hot coals while you are holding on to
the end. How long before the temperature of the point where you are holding the
bar (5 inches from the end of the bar) reaches 130 ºF when you can no longer
hold on to the bar because it is too hot? Plot the temperature profile along the
length of the rod at that time. The bar is made of mild steel with the properties as follow:
`Thermal conductivity (k) in Btu/hr ft ºF = 26.0`
`Density (rho) in lbm/in3 = 0.284`
`Specific Heat (C) in Btu/lbm ºF = 0.122`

Any help with how to do this in Mathematica is appreciated, thanks!

## calculus and analysis – Remove complex part of a solution

I have a function `intSL(a,zl,zh)` where I want to compute its derivative with respect to `zl` given some values of `a` and `zh`. I also want to plot it wrt to `zl` with the range `0 < zl < 1`.

However, there are some `zl` where my function displays an error message and produces a complex value. When I compare results that are complex valued to the result that are not, it seems like their corresponding real parts has a trend and so I think I could just eliminate the imaginary part (I think???), but I do not know how to do it.

Here is my code,

``````d = 3;
torootL(a_?NumericQ, t_?NumericQ, zl_?NumericQ, zh_?NumericQ) := a - NIntegrate((zl y^d)/Sqrt((1 - (zl/zh)^(d + 1) y^(d + 1)) (1 + t^2 (1 - (zl/zh)^(d + 1))^-1 - y^(2 d))), {y, 0, 1})
tz(a_?NumericQ, zl_?NumericQ, zh_?NumericQ) := t /. FindRoot(torootL(a, t, zl, zh), {t, 1, -1000, 10000})
intSL(a_?NumericQ, zl_?NumericQ, zh_?NumericQ) := NIntegrate(With({b = zl/zh}, (((-1)/(d - 1)) (zl^(2 d) (1 + tz(a, zl, zh)^2 (1 - (zl/zh)^(d + 1))^(-1)))^(-1) zl^(2 d)) x^d ((1 - (b x)^(d + 1))/(1 - (zl^(2 d) (1 + tz(a, zl, zh)^2 (1 - (zl/zh)^(d + 1))^(-1)))^(-1) (zl x)^(2 d)))^(1/2) - ((b^(d + 1) (d + 1))/(2 (d - 1))) x ((1 - (zl^(2 d) (1 + tz(a, zl, zh)^2 (1 - (zl/zh)^(d + 1))^(-1)))^(-1) (zl x)^(2 d))/(1 - (b x)^(d + 1)))^(1/2) + (b^(d + 1)x)/((1 - (b x)^(d + 1)) (1 - (zl^(2 d) (1 + tz(a, zl, zh)^2 (1 - (zl/zh)^(d + 1))^(-1)))^(-1) (zl x)^(2 d)))^(1/2)), {x, 0, 0.98, 0.99, 1}, MaxRecursion -> 20, PrecisionGoal -> 6)
``````

Here is an example of the evaluation of the derivative,

``````intSLL(zl_) := Evaluate(D(intSL(0.01, zl, 1), zl))

In(58):= intSLL(0.3)

During evaluation of In(58):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-5.99038*10^-9}. Try perturbing the initial point(s).

During evaluation of In(58):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-5.99038*10^-9}. Try perturbing the initial point(s).

During evaluation of In(58):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-5.99038*10^-9}. Try perturbing the initial point(s).

During evaluation of In(58):= General::stop: Further output of FindRoot::jsing will be suppressed during this calculation.

During evaluation of In(58):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(58):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(58):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(58):= General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.

During evaluation of In(58):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(58):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(58):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(58):= General::stop: Further output of FindRoot::reged will be suppressed during this calculation.

Out(58)= 0.0149288

In(57):= intSLL(0.4)

During evaluation of In(57):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(57):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(57):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(57):= General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.

During evaluation of In(57):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-6.30218*10^-9}. Try perturbing the initial point(s).

During evaluation of In(57):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-6.30218*10^-9}. Try perturbing the initial point(s).

During evaluation of In(57):= FindRoot::jsing: Encountered a singular Jacobian at the point {t} = {-6.30218*10^-9}. Try perturbing the initial point(s).

During evaluation of In(57):= General::stop: Further output of FindRoot::jsing will be suppressed during this calculation.

During evaluation of In(57):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(57):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(57):= FindRoot::reged: The point {10000.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(57):= General::stop: Further output of FindRoot::reged will be suppressed during this calculation.

Out(57)= 0.00650273

In(55):= intSLL(0.5)

Out(55)= 0.00353467

In(56):= intSLL(0.6)

During evaluation of In(56):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(56):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(56):= FindRoot::lstol: The line search decreased the step size to within tolerance specified by AccuracyGoal and PrecisionGoal but was unable to find a sufficient decrease in the merit function. You may need more than MachinePrecision digits of working precision to meet these tolerances.

During evaluation of In(56):= General::stop: Further output of FindRoot::lstol will be suppressed during this calculation.

During evaluation of In(56):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.984824086012257}. NIntegrate obtained 0.0293841 -0.119444 I and 0.0017267736029825806` for the integral and error estimates.

During evaluation of In(56):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.984824086012257}. NIntegrate obtained 0.0293841 -0.119444 I and 0.0017267736029825806` for the integral and error estimates.

During evaluation of In(56):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.984824086012257}. NIntegrate obtained 0.0293841 -0.119444 I and 0.001726773577114529` for the integral and error estimates.

During evaluation of In(56):= General::stop: Further output of NIntegrate::ncvb will be suppressed during this calculation.

During evaluation of In(56):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(56):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(56):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(56):= General::stop: Further output of FindRoot::reged will be suppressed during this calculation.

During evaluation of In(56):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(56):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(56):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(56):= General::stop: Further output of NIntegrate::slwcon will be suppressed during this calculation.

Out(56)= 0.00225041 + 8.62966*10^-11 I

In(59):= intSLL(0.7)

During evaluation of In(59):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(59):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.99762205831973036103399454788132061366923153400421142578125000000}. NIntegrate obtained 0.00330503 -0.0437457 I and 0.0008224862881109875` for the integral and error estimates.

During evaluation of In(59):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(59):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.99762205831973036103399454788132061366923153400421142578125000000}. NIntegrate obtained 0.00330503 -0.0437457 I and 0.0008224862881109875` for the integral and error estimates.

During evaluation of In(59):= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

During evaluation of In(59):= General::stop: Further output of NIntegrate::slwcon will be suppressed during this calculation.

During evaluation of In(59):= NIntegrate::ncvb: NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in y near {y} = {0.99762205831973036103399454788132061366923153400421142578125000000}. NIntegrate obtained 0.00330503 -0.0437457 I and 0.0008224862758539473` for the integral and error estimates.

During evaluation of In(59):= General::stop: Further output of NIntegrate::ncvb will be suppressed during this calculation.

During evaluation of In(59):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(59):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(59):= FindRoot::reged: The point {1.} is at the edge of the search region {-1000.,10000.} in coordinate 1 and the computed search direction points outside the region.

During evaluation of In(59):= General::stop: Further output of FindRoot::reged will be suppressed during this calculation.

Out(59)= 0.0016139 + 2.5821*10^-6 I
``````

To summarize the sample result, `intSLL(zl)` produces the values for the corresponding `zl`

``````0.0149288                         zl=0.3   (with error)
0.00650273                        zl=0.4   (with error)
0.00353467                        zl=0.5
0.00225041 + 8.62966*10^-11 I     zl=0.6   (with error)
0.0016139 + 2.5821*10^-6 I        zl=0.7   (with error)
``````

You can see the trend of the values of the real part.

## real analysis – Homeomorphism between two metric spaces via identity

Suppose $$(X,d)$$ is a complete metric space with $$U_1,U_2,…$$ nonempty open subsets, with none equal to $$X.$$ Let $$U= bigcap_{n=1}^{infty } U_n neq emptyset$$ and define $$d_n$$ on
$$U_n$$ as $$d_{n}(x,y) =text{min} (D_{n} (x,y),1)$$ where $$D_{n}(x,y) =d(x,y)+lvert frac{1}{d(x,U_n^c) } – frac{1}{d(y,U_n^c)} rvert.$$ Define $$D(x,y)=sum_{n=1}^{infty } frac{1}{2^n} d_{n} (x,y).$$

If I want to show that $$(U,d)$$ is homeomorphic to $$(U,D)$$ by the identity function, then I can show that $$(U,d)$$ and $$(U,D)$$ have the same open sets.

$$implies$$
Let $$V$$ be an open set in $$(U,d)$$. Let $$x in V$$ and $$r<1.$$ If
$$d(x,y), then $$y in V.$$ $$f(x)=x$$ so $$x in f ^{-1} (V).$$ If
$$D(x,y) then $$f(y)=y in V$$ so $$y in f ^{-1} (V).$$ Thefore $$f ^{-1} (V)$$ is an open set.

$$impliedby$$
Let $$x in f ^{-1} (V)$$ open set. Let $$r<1.$$ $$D(x,y) $$f(x)=x in V.$$ If $$d(x,y) then $$y in f ^{-1} (V)$$
so $$f(y)=y in V.$$ Thus $$V$$ is an open set so $$(U,d)$$ is homeomorphic
to $$(U,D).$$

Is it correct to use a radius of less than 1? I did this because $$D(x,y)$$ is less than or equal to 1.

## calculus and analysis – Derivative of a set of equations

I am a new learner of Mathematica, I think this question should be simple, but I just can’t get the correct answer…

This is my equations:

``````p=x+y
q=2x+y
r=p+q
``````

And I want to get the derivation of r by x, so the answer should be 3 (r=(x+y)+(2x+y)=3x+y)

But the output I got is a+b ??!! Why?

## functional analysis – Norm of a linear form in a function space

I would appreciate some help with the following problem. Let $$u, u_n:C((0,1))tomathbb{R}$$ the linear forms defined by $$u(f)=int_0^1f(x)dxquad&quad u_n(f)=frac{1}{n}sum_{k=1}^nfleft(frac{k}{n}right).$$ I’m trying to prove that $$||u_n-u||=sup_{||f||_infty=1}|u_n(f)-u(f)|=2.$$

I already have that $$||u_n-u||leq2$$ and I’ve tried to show that the $$sup$$ is attained (I’m not sure that it is true) by using trigonometric functions but I haven’t been able to get anything. Could anyone give me a hint?