## How to compute eigenvalues of linear function (not matrix)?

How to compute eigenvalues of a known linear function? In Julia, there is a package https://jutho.github.io/LinearMaps.jl/dev/ to compute the matrix representation of given function, then we can compute eigenvalues of the final matrix.

And in MATLAB, function eigs can also directly compute eigenvalues of a linear function.

     d = eigs(Afun,n,___) specifies a function handle Afun instead of a matrix. The second input n gives the size of matrix A used in Afun. You can optionally specify B, k, sigma, opts, or name-value pairs as additional input arguments.

So how to realize them in Mma? This is my approach:

LinearMapMatrix[map_Association, dimension_] :=   Module[{vectorin, linearfunction, transformmatrix},    vectorin = Normal[map][[1, 1]]; linearfunction = map[vectorin];    transformmatrix =     Transpose[ParallelMap[linearfunction, IdentityMatrix[dimension]]]   ] 

But it costs a lot of Ram. If I want a matrix representation with huge dimension, this function would burn down the running notebook. Are there some better methods?

I’m hoping to learn what my options are for sharing the outputs of simple unlit shaders with compute shaders that will operate on the data.

Is my only course of action to use a render texture with the unlit shader, and Graphics.Blit to render the shader to a texture2D that can be set on the Compute Shader? I was hoping something like a ComputeBuffer or GraphicsBuffer might be made accessible and writable in the unlit shader and then could just be used in the Compute shader also.

## How to compute the max/min surface area of a donut-shape solid generated by a revolved 2D circle, as the volume of the solid doesn’t change?

A donut shape solid is generated by revolving a circle $$(x-a)^2+y^2=b^2$$ around the y-axis. $$a$$ is the distance from the center of the hole of the donut to the center of the circle revolved, and $$b$$ is the radius of the circle revolved. I’m trying to compute the minimized surface area and the maximized surface area (if the solid has) with the value of $$a$$ and $$b$$, while the volume of the solid doesn’t change (which is $$90\pi^2$$). Thanks a lot if someone can help me 🙂

## An alternative command to compute a logarithmic integral

I am trying to see if Mathematica can calculate: $$\int_0^1\frac{\ln(x)\ln(1-x)\ln(1+x)}{x}dx,$$ which has a well-known closed form. So I tried Integrate[Log[x]Log[1-x]Log[1+x]/x,{x,0,1}] but I waited for about 20 mins and it didn’t show any result, so I stopped the calculations. Is there a command that helps Mathematica calculate the meant integral within few mins?

## Floodfilling a texture in HLSL Compute shader

I have a very large texture which I want to fill with values representing "distance in units from a river tile". The texture is already seeded with these origin river points (meaning distance/value = 0 in them).

From these points I want to floodfill outwards, incrementing the value with each step from these origin points.

Doing this on the CPU is no problem using a stack or similiar structure but ideally I want to do this in the middle of a Compute shader execution which runs over the entire texture.

I have read this which sound similiar to what I want to do but it mentions there might be a smarter way to do this with Compute shaders – which is what I am using.

Any ideas on how to solve this on compute shaders?

## How to compute matrices in Einstein notation:

I would like to compute $$r_{ii’}=\sum_{kk’}A_{ii’}^{kk’}r_{kk’}$$ where all indices vary from 0 to 1 to yield a vector / matrix.

## Evaluate the limit of a subsequence: Compute the limit $\lim_{n\to\infty} \cos\left( \pi \sqrt{4n^2 + 5n + 1} \right)$ Integer $n$ on Mathematica

I want to compute the limit $$\lim \limits_{n\to\infty} \cos\left( \pi \sqrt{4n^2 + 5n + 1} \right)$$for integer $$n$$. By completing the square, we can determine that this limit is equal to $$– \tfrac1{\sqrt2} \approx -0.7071$$.

But if we don’t restrict $$n$$ to an integer, then the limit is indeterminate / does not exist. And can be easily found by typing it on WolframAlpha. Or in Mathematica:

However, I do not know how to compute the limit (on Mathematica) with the original constraint that $$n$$ must be an integer.

I know that we can plot a graph on Mathematica:

The graph suggests that the limit is equal to $$-\tfrac1{\sqrt2}$$. However, this doesn’t look like a convincing result because we can’t know that the limit is exactly equal to $$-\tfrac1{\sqrt2}$$.

Question: Is there a way to compute this limit in Mathematica where it spits out a single numerical value (of $$-1/{\sqrt2}$$)?

## How to compute a vector V when N points are given and V satisfies given properties

We are given N points P1,P2,…,PN in a 2D plane(All points are distinct and N is as large as 10^5). For each valid i, the coordinates of the point Pi are (xi,yi). Help me to find a vector V = (a, b) ( where |a|, |b| <= 1e9) such that the following holds:

For each i (1 ≤ i ≤ N), let Si= dot(V, G(Pi, Pi+1)). lets assume PN+1=P1. where G(v1, v2) = ((v2(x) – v1(x)), (v2(y) – v1(y)) and dot(V1, V2) denotes dot product of two vectors

How to choose V such that It is possible to find two integers l and r (1 ≤ l ≤ r ≤ N) such that:

Si < 0 if(i <= r and i >= l) and Si > 0 otherwise

(or)

Si > 0 if(i <= r and i >= l) and Si < 0 otherwise

I need to know if there is a way of choosing vector (a, b) to satisfy the above conditions(If the solution is possible)

## Compute duration of an event based on consecutive values in another column

I need to compute the sum of durations of multiple events based on consecutive values in another column.

             ts             | w ----------------------------+---  2020-07-27 15:40:04.045+00 | t  2020-07-27 15:41:04.045+00 | t  2020-07-27 15:41:14.045+00 | f  2020-07-27 15:42:14.045+00 | t  2020-07-27 15:43:14.045+00 | t 

The event is considered being active as long as the column w has a consecutive value of true.

The duration of the first event would be 60 seconds. '2020-07-27 15:41:04.045+00' - 2020-07-27 15:40:04.045+00. The second event has the same duration. The sum of both would be 120 seconds.

What would be the best/most performant approach to computing these values? The longest time range we’ll be looking at will probably be half a year involving about 30 million rows.

I wrote a custom aggregate function that computes the duration but it takes about 16 seconds for only 1.5 million rows.

 Aggregate  (cost=444090.03..444090.04 rows=1 width=4) (actual time=16290.826..16290.828 rows=1 loops=1)    ->  Seq Scan on discriminator0  (cost=0.00..57289.03 rows=1547203 width=9) (actual time=0.016..1723.178 rows=1547229 loops=1)  Planning Time: 0.196 ms  JIT:    Functions: 3    Options: Inlining false, Optimization false, Expressions true, Deforming true    Timing: Generation 0.889 ms, Inlining 0.000 ms, Optimization 0.508 ms, Emission 6.472 ms, Total 7.870 ms  Execution Time: 16291.836 ms 

I’m new to SQL and basically just got this working through trial and error, so I’m sure there is room for improvement. Maybe even a whole different approach. Here’s a fiddle with the aggregate function.

I’m not sure if i should include the code because it’s quite long

## Given $n$ unique items and an $m^{th}$ normalised value, compute $m^{th}$ permutation without factorial expansion

We know that the number of permutations possible for $$n$$ unique items is $$n!$$. We can uniquely label each permutation with a number from $$0$$ to $$(n!-1)$$.

Suppose if $$n=4$$, the possible permutations with their labels are,

0:  1234 1:  1243 2:  1324 3:  1342 4:  1432 5:  1423 6:  2134 7:  2143 8:  2314 9:  2341 10: 2431 11: 2413 12: 3214 13: 3241 14: 3124 15: 3142 16: 3412 17: 3421 18: 4231 19: 4213 20: 4321 21: 4312 22: 4132 23: 4123 

With any well defined labelling scheme, given a number $$m, 0 \leq m < n!$$, we can get back the permutation sequence. Further, these labels can be normalised to be between $$0$$ and $$1$$. The above labels can be transformed into,

0:       1234 0.0434:  1243 0.0869:  1324 0.1304:  1342 0.1739:  1432 0.2173:  1423 0.2608:  2134 0.3043:  2143 0.3478:  2314 0.3913:  2341 0.4347:  2431 0.4782:  2413 0.5217:  3214 0.5652:  3241 0.6086:  3124 0.6521:  3142 0.6956:  3412 0.7391:  3421 0.7826:  4231 0.8260:  4213 0.8695:  4321 0.9130:  4312 0.9565:  4132 1:       4123 

Now, given $$n$$ and $$m^{th}$$ normalised label, can we get the $$m^{th}$$ permutation while avoiding the expansion of $$n!$$ ? For example, in the above set of permutations, if we were given the $$m^{th}$$ normalised label to be $$0.9$$, is it possible to get the closest sequence 4312 as the answer without computing $$4!$$ ?