Kitonum

21500 Reputation

26 Badges

17 years, 59 days

MaplePrimes Activity


These are answers submitted by Kitonum

This system can be solved instantly (and we obtain all solutions) by  solve  command:

restart;

eq[1]:= 0.223569*c_1+2.35589*c_2*c_1^2+0.002356*c_1*c_2^2:

eq[2]:= 1.277899*c_1*c_3-2.350023*c_2*c_3^2+7.5856*c_3*c_2^2:

eq[3]:= 3.225989*c_1^2-2.35589*c_3*c_1^2-7.28356*c_3*c_2^3:

solve({eq[1], eq[2], eq[3]}, {c_1, c_2, c_3});

Your example can be easily generalized to any natural number, if you use the binary number system. In it  any number  S such that  1<= S <2^n  can be recorded as the sequence of no more than  n  of  "0"  and  "1" .

The first procedure for a given number  S  returns the list of the number of dollars in each bag that your condition is true. The second procedure returns the corresponding partition for any number.

 

MinBags:=proc(S)

[seq(2^n, n=0..ilog[2](S))];

end proc:

 

Parts:=proc(s)

local L;

L:=convert(s, base, 2);

convert(s,symbol)=convert([seq(`if`(L[i]<>0,convert(L[i]*2^(i-1),symbol),NULL), i=1..nops(L))], `+`);

end proc:

 

Examples.

Your example:

MinBags(15);

for n from 1 to 15 do

Parts(n);

od;

                       

 

Another example:

MinBags(137);

for n from 100 to 110 do

Parts(n);

od;

                  

 

 

You can easily solve the problem by converting the output into the list, and reversing it:

A:=<1,1,1,1; 1,2,3,4; 4,3,2,1>;

LinearAlgebra[NullSpace](A);

ListTools[Reverse](convert(%, list));

                    

 

 

L:={1,2,3,4,5,6,7,8}:

P:=combinat[choose](L, 3):

k:=0:

for p in P do

a:=p[1]; b:=p[2]; c:=p[3];

if a+b>c and a+c>b and b+c>a then k:=k+1 fi;

od:

k;

                        22

 

Addition:  faster code for large sets.

Example for  L:={$ 1..500}:

restart;

ts:=time():

k:=0:

for a from 1 to 498 do

for b from a+1 to 499 do

for c from b+1 to 500 do

if a+b>c and a+c>b and b+c>a then k:=k+1 fi;

od: od: od:

k;

time()-ts;

                                 10323125

                                    23.875

The first code fails in this example.

solves the problem for  specific parameters values.

Example:

Optimization[QPSolve](2*x+5*y+3*x^2+3*x*y+2*y^2-x*z+4*y*z+2*z^2, {x+y+z=1, 2*x-3*y+z=5});

         [-4.18080357142857, [x = 0.410714285714286, y = -0.897321428571428, z = 1.48660714285714]]

ben maths  You wrote about the mission to give a better code. Here is the shorter and faster code: 

Simp38:=proc(f,x0,xn,n)

local  h:=(xn-x0)/n,  x:=i->x0+i*h;

3*h/8*(f(x0)+f(xn)+3*add(f(x(i)),i=1..n-1,3)+3*add(f(x(i)),i=2..n-1,3)+2*add(f(x(i)),i=3..n-1,3));

end proc:

 

Test:

ts:=time():

simp38(x->x^5-5.15*x^2+8.55*x-4.05045,1,5,3000);

int(x^5-5.15*x^2+8.55*x-4.05045,x=1..5);  

time()-ts;

                         

  

ts:=time():

Simp38(x->x^5-5.15*x^2+8.55*x-4.05045,1,5,3000);

int(x^5-5.15*x^2+8.55*x-4.05045,x=1..5);

time()-ts; 

                            

 

 

plots[inequal](not (x>4 and y>4), x=-10..10, y=-10..10, color=yellow);

                        

 

 

In older versions of Maple (for example in Maple 12)  ListTools:-FindMaximalElement  command does not work. Workaround is   ListTools:-Search  or   ListTools:-SearchAll  commands:

L := [1,2,3,7,6,5,4]:

m:=max(L);

pos:=ListTools:-Search(m,L);

                        m := 7

                       pos := 4

limit(n^(1/n), n=infinity);

limit(exp(n)/n^4, n=infinity);

                               1

                           infinity

 

 

For visual purposes only.

Example:

restart;

applyrule(-cos(x::anything)=cos(x+pi), sin(t)-cos(t));

subs(pi=Pi, %);

%;

                           

 

 

For a correct perception  add the option  view=[-5..0, 0..1]  into Carl's code after  axes=boxed :

For  x>0  this equation is equivalent to the equation  add(ln(x+j), j=0..2015)=0 , so we have:

Digits:=20:

fsolve(add(ln(x+j), j=0..2015), x=0..infinity);

              0.86678004277349545751*10^(-5785)

 

It is obvious that this is the only positive root.

restart;

sys:=diff(fi1(t),t,t)=(m0-m)/5, diff(fi2(t),t,t)=m/50:

m0:=200:  m:=(fi1(t)-fi2(t))*32.2+(diff(fi1(t),t)-diff(fi2(t),t))*10:

dsol2:=dsolve({sys,fi1(0)=0,fi2(0)=0,D(fi1)(0)=0,D(fi2)(0)=0}):

fi1:=unapply(rhs(dsol2[1]), t): fi2:=unapply(rhs(dsol2[2]), t):

t1:=fsolve(D(fi1)(t)=10);  t2:=fsolve(D(fi2)(t)=10);

plot([piecewise(t>=0 and t<=t1, D(fi1)(t), 10), piecewise(t>=0 and t<=t2

, D(fi2)(t), 10)], t=0..10, color=[red,green], thickness=2); 

 

These are the very simple problems. See help on Maple commands:

1.  dsolve

2.  plots[fieldplot]   and   plots[fieldplot3d]

3.  plot3d  - 3rd variant in Calling Sequence

I recorded your data as 2 matrices consisting of lists simultaneously correcting several errors:

A:=<[0.55,0.67,0.78,0.89],[0.7,0.8,0.8,0.9],[0.767,0.867,0.93,0.967],[0.72,0.83,0.83,0.93];    

[0.67,0.78,0.89,0.97],[0.8,0.9,1,1],[0.73,0.83,0.867,0.93],[0.66,0.76,0.79,0.90];

[0.78,0.89,0.89,1],[0.8,0.9,1,1],[7.67,8.67,9.3,9.67],[0.55,0.66,0.69,0.79];

[0.78,0.89,0.89,1],[0.06,0.13,0.167,0.267],[0.8,0.9,1,1],[0.76,0.86,0.90,0.97];

[0.78,0.89,0.89,1],[0.8,0.9,1,1],[0.06,0.13,0.167,0.267],[0.76,0.86,0.90,0.97];

[0.74,0.85,0.93,1],[0.67,0.767,0.83,0.9],[0.73,0.83,0.867,0.93],[0.62,0.72,0.83,0.90];

[0.59,0.70,0.74,0.85],[0.567,0.667,0.73,0.83],[0.667,0.767,0.83,0.9],[0.69,0.79,0.86,0.93];

[0.74,0.85,0.93,1],[0.7,0.8,0.9,0.93],[0.567,0.667,0.73,0.83],[0.79,0.90,0.97,1];

[0.70,0.81,0.85,0.96],[0.7,0.8,0.9,0.93],[0.7,0.8,0.8,0.9],[0.59,69,0.76,0.86]>:

V:=<[0.7,0.8,0.8,0.9],[0.8,0.9,1,1],[0.767,0.867,0.93,0.967],[0.43,0.53,0.567,0.667],

[0.73,0.83,0.867,0.93],[0.8,0.9,1,1],[0.067,0.1,0.2,0.3],[0.73,0.83,0.867,0.93],[0.53,0.63,0.667,0.767]>:

 

Matrix(9,4, (i,j)->zip((a,v)->a*v, A[i,j], V[i,1]));  # Final answer

First 213 214 215 216 217 218 219 Last Page 215 of 290