Tag Info

New answers tagged

1

Questions 1 and 2: Solve[x == 3 y + e && Mod[y, 2] == 0 && 0 <= e <= 1, {x, y}, Integers] {{x -> ConditionalExpression[1 + 2 (3 C[1] - 3 C[2]), (C[1] | C[2]) ∈ Integers && C[1] >= 0 && C[2] >= 0 && e == 1], y -> ConditionalExpression[2 (C[1] - C[2]), (C[1] | C[2]) ∈ Integers ...


8

This is not a complete answer, but it's too long for a comment. It doesn't completely work, but perhaps it might inspire other answers. The idea is to use graph theory and flows. I shall just look at the 3x3 case. First we construct a graph of 9 source nodes and 9 sink nodes. The source nodes flow costlessly straight into the sink nodes, and the sink ...


7

Matlab is the fertile soil of bad Mathematica programming... try baseGenerator2[m_Integer, n_Integer] := Reverse@Sort[Join @@ Permutations /@ IntegerPartitions[n, {m}, Range[n, 0, -1]]] And for your own sanity, don't use uppercase initials on symbols - you may very well clash with built-ins and/or create debugging nightmares (e.g. N is a built-in, by ...


0

Here is a method that computes only the smallest eigenvalue and checks that it's greater or equal to zero. This can be done by using a shift as in this answer, or for large matrices by using the option Method -> {"Arnoldi", "Criteria" -> "RealPart"} for Eigenvalues: Clear@positiveSemiDefiniteQ positiveSemiDefiniteQ[mat_?MatrixQ] := ( ...


2

Here is a quick rewrite of your code. CipherSolve[modulus_, b_] := Module[{y = b, yList = {}, m = Ceiling[Sqrt[modulus]], pmod, modinv, z}, modinv = PowerMod[10^m, -1, modulus]; pmod = PowerMod[10, Range[0, m - 1], modulus]; While[FreeQ[pmod, y], yList = Append[yList, y]; y = Mod[y*modinv, modulus] ]; z = ...


0

This is not a package, just an idea how such a package might work. You could define a custom value type autoDiffValue that stores a value and it's first derivative (with respect to some variable), then define arithmetic operations for that type: Clear[autoDiffValue] autoDiffValue /: autoDiffValue[a_, adx_] + autoDiffValue[b_, bdx_] := autoDiffValue[a + b, ...


0

I have a very straightforward approach to implement the Bisection method.. Here, I used the procedural paradigm. Easy to read and understand. source: Numericstech



Top 50 recent answers are included