sursumCorda

1239 Reputation

15 Badges

2 years, 232 days

MaplePrimes Activity


These are replies submitted by sursumCorda

@nm Actually, one can obtain (almost) the same results in Mma: 

Series solutions from MatLab's ode::series (just for comparison): 

@Carl Love & @mmcdara Thanks. 

In my opinion, Mathematica's Apply is technically not identical with Maple's apply. Compare:

(* Mma *)
Construct[f, a, b, c];
(* Maple *)
apply(f, a, b, c):

 and 

(* Mma *)
Apply[f, {a, b, c}];
(* Maple *)
`?()`(f, [a, b, c]):

@Carl Love Well, maybe the better term is "ordered pair" rather than "rule" (let alone "function"). (A bijection is dispensable.)
Here is the result from Mathematica: 

@Christian Wolinski@mmcdara, and @Carl Love 
Thanks. But if we add a new rule fg (which gives an additional cycle), the results will go wrong.

@lcz 

eval(reduce(uneval(SubstituteAll), [s, seq(uneval(L1[k], L2[k]), k = 1 .. length['shortname'](L1))]));
 = 
  "{ {0, 1}, {1, 2}, {1, 10}, {2, 3}, {3, 4}, {4, 5},

    {4, 9}, {5, 6}, {6, 7}, {7, 8},{8, 9}, {10, 11}, {11, 12},

    {11, 16}, {12, 13}, {13, 14}, {14, 15}, {15, 16}}"



@Carl Love Actually, as I mentioned before, sometimes such a list does perform a permutation, but in my opinion, we do not need to regard it as a permutation. 
Here we convert one cycles into (another) rules

cycles := [[g, d, c], [e, a], [f, d, c], [b]]:
use ListTools in rules := (combinat['randperm']@MakeUnique@curry(`?()`,`=`)~@FlattenOnce)([seq(Transpose([k,Rotate(k,1)]),k  in  cycles),[[a,b](*,[f,g]*)]]) end use: # a = b obfuscates the rules here.

Yet I have no idea how to reconvert rules back into cycles
Comparison: 
 

restart;

RandomTools:-Generate(listlist(variable(alpha), 20, 23))

[[y, K, N, h, c, G, K, m, x, Y, Y, T, x, R, A, P, Y, L, R, k, y, z, m], [i, K, L, E, f, L, m, m, f, F, A, y, d, h, n, l, f, m, M, J, o, Y, Q], [s, F, l, W, d, U, d, E, h, I, G, Q, n, s, A, H, u, T, p, Q, a, C, T], [h, a, u, r, Q, t, A, s, G, h, Z, p, F, Y, s, l, v, t, P, n, W, s, h], [K, R, S, c, A, M, f, i, A, V, l, T, a, Q, v, v, A, J, m, j, A, U, T], [t, o, L, J, W, w, L, Y, I, T, j, G, e, y, u, s, Z, M, O, b, B, I, x], [d, o, c, a, d, C, S, k, g, z, Z, N, Y, N, B, w, o, R, A, A, F, m, d], [e, Y, x, c, c, V, M, u, c, y, O, p, V, M, o, f, O, z, H, M, g, x, C], [R, W, a, q, D, p, R, H, n, s, V, r, B, m, u, Q, h, Y, z, h, v, d, F], [s, h, I, r, O, L, q, S, M, g, h, b, X, l, f, X, B, I, W, n, q, h, C], [i, B, H, F, c, W, g, B, l, q, N, J, H, M, p, L, x, Y, d, R, s, T, f], [a, D, r, k, P, d, m, U, j, R, g, M, D, F, D, r, G, B, V, t, q, B, i], [X, I, w, a, c, W, z, E, g, f, x, f, w, A, k, M, T, o, l, B, C, t, Z], [h, h, R, j, z, g, B, M, n, B, R, J, s, o, u, g, s, M, K, I, c, y, V], [P, D, b, U, X, V, E, O, a, u, M, M, t, o, m, r, k, x, r, W, N, l, N], [d, M, R, P, a, z, G, c, w, p, P, g, A, Y, W, w, b, h, u, i, c, H, Z], [H, z, U, F, M, z, x, n, r, g, E, s, p, P, H, o, y, O, f, N, b, C, n], [D, u, P, R, G, t, Z, p, Y, S, r, O, B, h, K, s, T, C, O, S, d, u, Y], [S, n, K, Q, t, b, k, l, H, X, J, C, K, M, O, y, z, D, A, b, d, n, z], [X, X, H, u, w, i, x, u, u, D, m, i, u, I, f, c, n, g, i, j, f, L, e]]

(1)

CyclestoRules := proc (C::(list(list))) options operator, arrow; map(proc (c) options operator, arrow; `~`[`=`](c, c[[2 .. -1, 1]])[] end proc, C) end proc

RulesfromCycles := proc (cycles::listlist) options operator, arrow; (`@`(`~`[curry(`?()`, `=`)], ListTools:-FlattenOnce))([seq(ListTools:-Transpose([k, ListTools:-Rotate(k, 1)]), `in`(k, cycles))]) end proc

Warning, (in RulesfromCycles) `k` is implicitly declared local

 

pairs1 := CodeTools:-Usage(CyclestoRules([[y, K, N, h, c, G, K, m, x, Y, Y, T, x, R, A, P, Y, L, R, k, y, z, m], [i, K, L, E, f, L, m, m, f, F, A, y, d, h, n, l, f, m, M, J, o, Y, Q], [s, F, l, W, d, U, d, E, h, I, G, Q, n, s, A, H, u, T, p, Q, a, C, T], [h, a, u, r, Q, t, A, s, G, h, Z, p, F, Y, s, l, v, t, P, n, W, s, h], [K, R, S, c, A, M, f, i, A, V, l, T, a, Q, v, v, A, J, m, j, A, U, T], [t, o, L, J, W, w, L, Y, I, T, j, G, e, y, u, s, Z, M, O, b, B, I, x], [d, o, c, a, d, C, S, k, g, z, Z, N, Y, N, B, w, o, R, A, A, F, m, d], [e, Y, x, c, c, V, M, u, c, y, O, p, V, M, o, f, O, z, H, M, g, x, C], [R, W, a, q, D, p, R, H, n, s, V, r, B, m, u, Q, h, Y, z, h, v, d, F], [s, h, I, r, O, L, q, S, M, g, h, b, X, l, f, X, B, I, W, n, q, h, C], [i, B, H, F, c, W, g, B, l, q, N, J, H, M, p, L, x, Y, d, R, s, T, f], [a, D, r, k, P, d, m, U, j, R, g, M, D, F, D, r, G, B, V, t, q, B, i], [X, I, w, a, c, W, z, E, g, f, x, f, w, A, k, M, T, o, l, B, C, t, Z], [h, h, R, j, z, g, B, M, n, B, R, J, s, o, u, g, s, M, K, I, c, y, V], [P, D, b, U, X, V, E, O, a, u, M, M, t, o, m, r, k, x, r, W, N, l, N], [d, M, R, P, a, z, G, c, w, p, P, g, A, Y, W, w, b, h, u, i, c, H, Z], [H, z, U, F, M, z, x, n, r, g, E, s, p, P, H, o, y, O, f, N, b, C, n], [D, u, P, R, G, t, Z, p, Y, S, r, O, B, h, K, s, T, C, O, S, d, u, Y], [S, n, K, Q, t, b, k, l, H, X, J, C, K, M, O, y, z, D, A, b, d, n, z], [X, X, H, u, w, i, x, u, u, D, m, i, u, I, f, c, n, g, i, j, f, L, e]]))

memory used=46.48KiB, alloc change=0 bytes, cpu time=0ns, real time=1000.00us, gc time=0ns

 

pairs2 := CodeTools:-Usage(RulesfromCycles([[y, K, N, h, c, G, K, m, x, Y, Y, T, x, R, A, P, Y, L, R, k, y, z, m], [i, K, L, E, f, L, m, m, f, F, A, y, d, h, n, l, f, m, M, J, o, Y, Q], [s, F, l, W, d, U, d, E, h, I, G, Q, n, s, A, H, u, T, p, Q, a, C, T], [h, a, u, r, Q, t, A, s, G, h, Z, p, F, Y, s, l, v, t, P, n, W, s, h], [K, R, S, c, A, M, f, i, A, V, l, T, a, Q, v, v, A, J, m, j, A, U, T], [t, o, L, J, W, w, L, Y, I, T, j, G, e, y, u, s, Z, M, O, b, B, I, x], [d, o, c, a, d, C, S, k, g, z, Z, N, Y, N, B, w, o, R, A, A, F, m, d], [e, Y, x, c, c, V, M, u, c, y, O, p, V, M, o, f, O, z, H, M, g, x, C], [R, W, a, q, D, p, R, H, n, s, V, r, B, m, u, Q, h, Y, z, h, v, d, F], [s, h, I, r, O, L, q, S, M, g, h, b, X, l, f, X, B, I, W, n, q, h, C], [i, B, H, F, c, W, g, B, l, q, N, J, H, M, p, L, x, Y, d, R, s, T, f], [a, D, r, k, P, d, m, U, j, R, g, M, D, F, D, r, G, B, V, t, q, B, i], [X, I, w, a, c, W, z, E, g, f, x, f, w, A, k, M, T, o, l, B, C, t, Z], [h, h, R, j, z, g, B, M, n, B, R, J, s, o, u, g, s, M, K, I, c, y, V], [P, D, b, U, X, V, E, O, a, u, M, M, t, o, m, r, k, x, r, W, N, l, N], [d, M, R, P, a, z, G, c, w, p, P, g, A, Y, W, w, b, h, u, i, c, H, Z], [H, z, U, F, M, z, x, n, r, g, E, s, p, P, H, o, y, O, f, N, b, C, n], [D, u, P, R, G, t, Z, p, Y, S, r, O, B, h, K, s, T, C, O, S, d, u, Y], [S, n, K, Q, t, b, k, l, H, X, J, C, K, M, O, y, z, D, A, b, d, n, z], [X, X, H, u, w, i, x, u, u, D, m, i, u, I, f, c, n, g, i, j, f, L, e]]))

memory used=171.22KiB, alloc change=0 bytes, cpu time=15.00ms, real time=16.00ms, gc time=0ns

 

is(pairs1 = pairs2) = trueNULL


 

Download trivial.mw

@Carl Love Sorry, I don't know if such algorithms exist. This instance is adapted from the last example of MMA's Apply (which is more or less similar to Maple's `?()`). Unfortunately, the original function that occured in the help page only has limited functionalities. (So it is incorrect in general.)

@Carl Love Since ab cannot become or form a cycle (∵ ba is missing or lacking), the output should exclude [a, b].

@Carl Love Surely need not necessarily be a permutation; They are just a list of "ordered pairs". (However, sometimes such a list does perform a permutation.)

Remark. Something like this: the rules (instead of equalities) gdcg, dc construct a cycle g→d→c→g, so the result includes [g, d, c] (and for the same reason, the result includes [f, d, c] as well).

@dharr & @acer Thanks. It appears that nothing returns when I just give simple bounds on variables: 
 

restart;

(*_local(gamma);
alias(alpha = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 1), beta = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 2), gamma = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3));*)

eqs := eval~(x^3*k[1] + x^2*y*k[2] + x^2*z*k[5] + x*y^2*k[3] + x*y*z*k[6] + x*z^2*k[8] + y^3*k[4] + y^2*z*k[7] + y*z^2*k[9] + z^3*k[10], {{x = 1, y = 1, z = 1}, {x = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 1), y = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 2), z = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3)}, {x = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 2), y = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3), z = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 1)}, {x = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3), y = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 1), z = RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 2)}}):

eqs2 := solve(evala(eqs));

{k[1] = -(1/6)*k[7]-(5/24)*k[8]+(5/12)*k[10]+(13/24)*k[4]-(7/24)*k[5]-(1/8)*k[6], k[2] = -(3/2)*k[7]-(13/8)*k[8]+(17/4)*k[10]+(37/8)*k[4]-(7/8)*k[5]-(11/8)*k[6], k[3] = (5/6)*k[7]+(7/24)*k[8]-(7/12)*k[10]-(143/24)*k[4]+(5/24)*k[5]+(3/8)*k[6], k[4] = k[4], k[5] = k[5], k[6] = k[6], k[7] = k[7], k[8] = k[8], k[9] = -(1/6)*k[7]+(13/24)*k[8]-(61/12)*k[10]-(5/24)*k[4]-(1/24)*k[5]+(1/8)*k[6], k[10] = k[10]}

(1)

isolve({eqs2[], `~`[`<=`](-1, `$`(k[i], `=`(i, 1 .. 10))), `~`[`<=`](`$`(k[i], `=`(i, 1 .. 10)), 2)})Warning, solutions may have been lostNULL

numelems(({isolve})({eqs2[], `~`[`<=`](-5, ` $`, k[1], k[2], k[3], k[4], k[5], k[6], k[7], k[8], k[9], k[10]), `~`[`<=`](k[1], k[2], k[3], k[4], k[5], k[6], k[7], k[8], k[9], k[10], ` $`, 5)}))

0

(2)

Yet the number of solutions should be 1407 (instead of 0).


 

Download anExplicitEnumeration.mw

@Kitonum I find that to obtain the Sol, this is enough: 

identify(solve(eqs =~ 0.));
 = 
 /         14                1        1        1        1        
{ k[1] = - -- k[10] - k[9] - - k[7] + - k[4] + - k[8] - - k[5], k
 \         3                 3        3        3        3        

          155                   10        7        13     
  [2] = - --- k[10] - 11 k[9] - -- k[7] + - k[4] + -- k[8]
           3                    3         3        3      

     4       
   - - k[5], 
     3       

         44                  4        16        4        1       
  k[3] = -- k[10] + 3 k[9] + - k[7] - -- k[4] - - k[8] + - k[5], 
         3                   3        3         3        3       

  k[4] = k[4], k[5] = k[5], 

         122                  4        5        13        1       
  k[6] = --- k[10] + 8 k[9] + - k[7] + - k[4] - -- k[8] + - k[5], 
          3                   3        3        3         3       

                                                      \ 
  k[7] = k[7], k[8] = k[8], k[9] = k[9], k[10] = k[10] }
                                                      / 


As @acer says, using a finite working precision may lead to less correct answers, but this way is feasible after all. Thanks.

@dharr Sorry for late reply. I think that the third form (i.e., c) is more suitable for representing the generic solutions. Many thanks.

@dharr @Axel Vogt Thanks. Is it possible to convert it into the following more ”symmetric“ form? 

[RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1, index = 3), -4/5*RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1, index = 3)^2 + 19/5*RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1, index = 3) + 3/5, 1]:
 = 
[RootOf(_Z^3 - 3*_Z^2 - 10*_Z - 1, index = 3), RootOf(_Z^3 + 10*_Z^2 + 3*_Z - 1, index = 3), 1]:
 = 
[RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 1)/RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3), RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 2)/RootOf(_Z^3 - 4*_Z^2 + _Z + 1, index = 3), 1]:

@C_R @dharr Thanks for your proposals.

First 17 18 19 20 21 22 23 Page 19 of 23