New answers tagged

2

As suggested by @cvgmt (assuming here that a>0) res=Integrate[(x^2 + (a/y^2))^(-1/2), {x, 0, 1}, {y, 0, 1}, Assumptions -> a > 0] And a quick check: NIntegrate[(x^2 + (a/y^2))^(-1/2) /. a -> 2, {x, 0, 1}, {y, 0, 1}] 0.3406417035798416` res/. a-> 2. 0.3406417035798416`


2

primeVectors[max_, tries_] := Catch[Module[ {a, b, done = False, tt = 0, u, v, egcd}, While[! done && tt < tries, tt++; {a, b} = RandomInteger[{2, max}, 2]; egcd = ExtendedGCD[a, b]; If[egcd[[1]] =!= 1, Continue[]]; {u, v} = {1, -1}*egcd[[2]]; If[u < 0, {u, v} = {u, v} + {b, -a}; If[u < 0, Continue[]]]; ...


6

Try n = 20; M = Table[If[i == j, -(1 + 2/h^2), If[Abs[i - j] == 1, 1/h^2 + x1/(2 h), 0]], {i, 1, n}, {j, 1, n}] or also M = SparseArray[{Band[{1, 1}] -> -(1 + 2/h^2), Band[{2, 1}] -> 1/h^2 + x1/(2 h), Band[{1, 2}] -> 1/h^2 + x1/(2 h)}, {n, n}] NOTE Now for $x_k, k=1,\cdots, n$ we can use M = SparseArray[{{i_, i_} -> -(1 + 2/h^2), {n, n - 1} -&...


1

Convert your code that processes one element of the list into a function and map that function over the list. Maybe something like decode[x_] := Module[{q, r, msg}, q = x; msg = {}; While[q ≠ 0, {q, r} = QuotientRemainder[q, 256]; msg = Join[msg, {r}]]; msg] decode /@ mFromAlice Couldn't test it because you posted an image not ...


Top 50 recent answers are included