Kitonum

21695 Reputation

26 Badges

17 years, 186 days

MaplePrimes Activity


These are replies submitted by Kitonum

Your example has no solutions, because we have inconsistent system:

restart;

sol:=rhs(dsolve(diff(y(x),x,x)+sin(x)=0));

{eval(diff(sol,x$3),x=0)+eval(diff(sol,x$2), x=0)=-0.1, eval(diff(sol,x$4), x=0)=0.1};

                                               sol := sin(x)+_C1*x+_C2

                                                   {-1 = -.1, 0 = .1}

@toandhsp   Here are the solutions with  Composition1  procedure:

N1:=0:

for n from 4 to 296 by 2 do

N1:=N1+nops(select(t->nops(t)=nops(convert(t,set)), Composition1(n,3, {$ 1..100})))/3!;

od:

N1;   # Solution of the problem 1

 

N2:=0:

for n from 6 to 15 do

N2:=N2+nops(select(t->nops(t)=nops(convert(t,set)) and irem(`+`(op(t)),3)=0, Composition1(n,3, {$ 1..6})));

od:

N2;   # Solution of the problem 2

                                                                   

 

Of course, these examples are easier and faster to solve in another way:

binomial(50,3)+50*binomial(50,2);   # Solution of the problem 1

select(t->irem(`+`(op(t)),3)=0, combinat[permute](6,3)); 

nops(%);   # Solution of the problem 2

 

@Carl Love  I meant to set up an appropriate graphical structure (plot or plots[implicitplot]) with options like grid  or  numpoints  so  that independent variable were passing with predefined step, for example,  t=-0.05, -0.049, -0.048, ... .

@Carl Love  When we extract the data from a graphical structure, can we make so that they were passing with predefined step, for example,  t=-0.05, -0.049, -0.048, ... ?

@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.

First 99 100 101 102 103 104 105 Last Page 101 of 133