Kitonum

21860 Reputation

26 Badges

17 years, 237 days

MaplePrimes Activity


These are replies submitted by Kitonum

@acer  Good idea!

Composition1  procedure improves the previous  Composition  procedure. Added option  S  - set, which includes elements of the composition. By default  S = {$ 0.. n} .  In this case  Composition1(n, k, res)  is equivalent to  Composition(n, k, res) .

Composition1 := proc (n::nonnegint, k::posint, res::{range, nonnegint} := 0, S::set:={$0..n})

local a, b, It, L0;

if res::nonnegint then a := res; b := n-(k-1)*a  else a := lhs(res); b := rhs(res) fi;

if b < a or b*k < n then return `No solutions` fi;

It := proc (L)

local m, j, P, R, i, N;

m := nops(L[1]); j := k-m; N := 0;

for i to nops(L) do

R := n-`+`(op(L[i]));

if R <= b*j and a*j <= R then N := N+1;

P[N] := [seq([op(L[i]), s], s = {$ max(a, R-b*(j-1)) .. min(R, b)} intersect S)] fi;

od;

[seq(op(P[s]), s = 1 .. N)];

end proc;

L0 := [[]];

(It@@k)(L0);

end proc:

 

Two examples:

Composition1(20,3, {seq(2*i, i=1..10)});  # Elements should be posint and even

[[2, 2, 16], [2, 4, 14], [2, 6, 12], [2, 8, 10], [2, 10, 8], [2, 12, 6], [2, 14, 4], [2, 16, 2], [4, 2, 14], [4, 4, 12], [4, 6, 10], [4, 8, 8], [4, 10, 6], [4, 12, 4], [4, 14, 2], [6, 2, 12], [6, 4, 10], [6, 6, 8], [6, 8, 6], [6, 10, 4], [6, 12, 2], [8, 2, 10], [8, 4, 8], [8, 6, 6], [8, 8, 4], [8, 10, 2], [10, 2, 8], [10, 4, 6], [10, 6, 4], [10, 8, 2], [12, 2, 6], [12, 4, 4], [12, 6, 2], [14, 2, 4], [14, 4, 2], [16, 2, 2]]

Composition1(30,4, select(isprime,{$3..30}));  # Elements should be prime greater 2

[[3, 3, 5, 19], [3, 3, 7, 17], [3, 3, 11, 13], [3, 3, 13, 11], [3, 3, 17, 7], [3, 3, 19, 5], [3, 5, 3, 19], [3, 5, 5, 17], [3, 5, 11, 11], [3, 5, 17, 5], [3, 5, 19, 3], [3, 7, 3, 17], [3, 7, 7, 13], [3, 7, 13, 7], [3, 7, 17, 3], [3, 11, 3, 13], [3, 11, 5, 11], [3, 11, 11, 5], [3, 11, 13, 3], [3, 13, 3, 11], [3, 13, 7, 7], [3, 13, 11, 3], [3, 17, 3, 7], [3, 17, 5, 5], [3, 17, 7, 3], [3, 19, 3, 5], [3, 19, 5, 3], [5, 3, 3, 19], [5, 3, 5, 17], [5, 3, 11, 11], [5, 3, 17, 5], [5, 3, 19, 3], [5, 5, 3, 17], [5, 5, 7, 13], [5, 5, 13, 7], [5, 5, 17, 3], [5, 7, 5, 13], [5, 7, 7, 11], [5, 7, 11, 7], [5, 7, 13, 5], [5, 11, 3, 11], [5, 11, 7, 7], [5, 11, 11, 3], [5, 13, 5, 7], [5, 13, 7, 5], [5, 17, 3, 5], [5, 17, 5, 3], [5, 19, 3, 3], [7, 3, 3, 17], [7, 3, 7, 13], [7, 3, 13, 7], [7, 3, 17, 3], [7, 5, 5, 13], [7, 5, 7, 11], [7, 5, 11, 7], [7, 5, 13, 5], [7, 7, 3, 13], [7, 7, 5, 11], [7, 7, 11, 5], [7, 7, 13, 3], [7, 11, 5, 7], [7, 11, 7, 5], [7, 13, 3, 7], [7, 13, 5, 5], [7, 13, 7, 3], [7, 17, 3, 3], [11, 3, 3, 13], [11, 3, 5, 11], [11, 3, 11, 5], [11, 3, 13, 3], [11, 5, 3, 11], [11, 5, 7, 7], [11, 5, 11, 3], [11, 7, 5, 7], [11, 7, 7, 5], [11, 11, 3, 5], [11, 11, 5, 3], [11, 13, 3, 3], [13, 3, 3, 11], [13, 3, 7, 7], [13, 3, 11, 3], [13, 5, 5, 7], [13, 5, 7, 5], [13, 7, 3, 7], [13, 7, 5, 5], [13, 7, 7, 3], [13, 11, 3, 3], [17, 3, 3, 7], [17, 3, 5, 5], [17, 3, 7, 3], [17, 5, 3, 5], [17, 5, 5, 3], [17, 7, 3, 3], [19, 3, 3, 5], [19, 3, 5, 3], [19, 5, 3, 3]]

 

@brian bovril  I did not include the number  0  as a valid integer in heading of  the procedure  NumbersGame  because with this number sometimes problems arise (though very rarely). If you replace the heading of  the procedure with

NumbersGame:=proc(Result::{integer,fraction}, Numbers::list(nonnegint), Operators::list:=["+","-","*","/"], NumbersOrder::string:="strict order", Parentheses::symbol:=no)

then all your examples easy to solve even without changing the order of the numbers  in the list  [0,1,2,5] . Only the representation of the number 1 requires a change order:

for n from 1 to 10 do

NumbersGame(n, [0,1,2,5]);

od; ``;

[NumbersGame(1, [0,1,2,5], "arbitrary order")][-7];  # Representation of 1

 

 

@Carl Love  Your code is compact and elegant, so vote up. But, unfortunately, it does not work in older versions.

In Maple 12:

P:= (n::posint, m::posint)->

     (x-> (d-> `if`(d[1]=d[-1], x, ``))(convert(x, base, 10)))~

          (LinearAlgebra:-RandomMatrix(n,m, generator= rand(100..999))):

          Error, missing operator or `;

 

@smith_alpha   1) If you just need to solve a system of equations, I do not think there are any advantages of PolynomialSystem  command comparing with  solve  command. Here is a quote from help on  SolveTools  package 

"The SolveTools package is a collection of building blocks for solving systems of algebraic equations. The routines from this package are used at the heart of the Maple solve command. An expert user can take advantage of the SolveTools package in order to perform individual steps towards solving a system of algebraic equations, thus allowing more control over how a solution is found".

2)  %[1]  is the first solution of the system, ie,  {x = 2, y = 1}

     eval([x, y], %[1])  is the list  [2, 1]

     eval([x, y], %[1])[]   just removes the square brackets, ie, we obtain a sequence  2, 1 .  This is necessary

     for     multiple assignment    a, b := 2, 1

 

@Alejandro Jakubi  Your wonderful programmatic way  works, for example, in Standard Maple 12 on Windows 8.1:

 

cat(`&#`, convert("25AA", decimal, hex), `;`);

                                   

 

 

@Markiyan Hirnyk   Without a doubt, your plot out of competition!

@Rouben Rostamian   The parentheses are necessary.

Test the solution:

P:=Matrix([[ 0 , .5 , .5 , 0 , 0 , 0 ], [ 1/3 , 0 , 0 , 1/3 , 1/3 , 0 ], [ 1/3 , 0 , 0 , 0 , 1/3 , 1/3 ], [ 0 , 1 , 0 , 0 , 0 , 0 ], [ 0 , .5 , .5 , 0 , 0 , 0 ], [ 0 , 0 , 1 , 0 , 0 , 0 ]]):

pii:=Vector[row]([ a , b , c , d , e , f ]):

solve({seq((pii.P)[i]=pii[i], i=1..6)});

eval([seq((pii.P)[i]=pii[i], i=1..6)], %);

                                                       {a = 2.*f, b = 3.*f, c = 3.*f, d = f, e = 2.*f, f = f}

             [2.000000000*f = 2.*f, 3.0*f = 3.*f, 3.0*f = 3.*f, 1.000000000*f = f, 2.000000000*f = 2.*f, 1.000000000*f = f]

Statement of the problem is not clear. Your  beta  depends on  l  rather than on  n .  What does  beta[n]  mean?

 

Addition: The same question remains. The fact that in the equation  beta  is replaced by  beta[n] does not change anything. The roots of the equation does not depend on their designations.

@rit  If you have the matrix of the size   by  n , the number of its entries that lie below (or above) of the main diagonal equal to the sum of the arithmetic progression 1 + 2 + 3 + .. + (n-1) = n * (n-1) / 2.  If each element is   or  , the number of all possible ordered combinations of  n * (n-1) / 2  such elements obviously equal to the number of placements of  [1$(n*(n-1)/2), 0$(n*(n-1)/2)]  by  n*(n-1)/2 . This number equals  2^(n*(n-1)/2) .

For example, if  n=5  then we take of the set  {1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}  all possible ordered combinations of  10  numbers .  The total number of such combinations equals  2^10=1024

@acer   Thank you very much! A brilliant solution.

@one_man  Thank you for your suggestion! But I want the fractions to be displayed in 2D mode in beautiful style. Such output is important to me in one application.  See my solution in this thread.

@Carl Love  For example, should be  

                     

rather than

                    

or

                 

@beidouxing   The quote "So  x-y  is a solution for the  eqn1=0 , so the eqn1 can be divided by the  x-y".  This is true only for rational expressions.

For example,  eval(1 - exp(x-y), x=y) = 0 , but you can not divide  1 - exp(x-y)  by  x-y

You should submit a complete version of your problem, ie, all the equations of the system and etc,  rather than only one equation.

@Markiyan Hirnyk   Yes, you're right. A higher degree is needed.

 

V := <t, piecewise(t >= 0, t^5, 0), piecewise(t >= 0, 0, -t^5)>;

Student[VectorCalculus][Torsion](V, t);

Student[VectorCalculus][SpaceCurve](V, t = -1 .. 1);

 

 

 

First 100 101 102 103 104 105 106 Last Page 102 of 134