Kitonum

21455 Reputation

26 Badges

17 years, 47 days

MaplePrimes Activity


These are answers submitted by Kitonum

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

Example with 4 points:

r:=[12, 56, 29, 78]:

v:=[15, 45, 75, 102]:

map(t->[t[1]*cos(t[2]),t[1]*sin(t[2])], zip((x,y)->[x,y],r,v));

     [[12*cos(15), 12*sin(15)], [56*cos(45), 56*sin(45)], [29*cos(75), 29*sin(75)], [78*cos(102), 78*sin(102)]]

y  is a complex expression, so you can plot only  Re(y)  and  Im(y)  separately or  together as parametric function:

restart;

y := A*(1/x+x*exp(-2*sqrt(-1)*b))+4*sin(h)^2*(2*exp(-sqrt(-1)*b)-3*sin(h)^2*x^(-sin(h))*exp(sqrt(-1)*b*(-sin(h)-1))+3*x^(-sin(h))*exp(sqrt(-1)*b*(-sin(h)-1)))/(3*(1-r))-exp(-2*sqrt(-1)*b)/x-x:

A := (1+r)/(1-r):  r := (1/3)*sin(h)^2:  b := m*Pi*h:  m := 1:  h := 0.05:

plot([Re(y), Im(y)], x=0..3, -1..2, color=[red,blue], thickness=2);

plots[complexplot](y, x=0..3, view=[-1..1,-1..1], thickness=2);

                           

 

 

The second plot shows that Rе(y)  and Im(y)  probably  are linearly related.

 

eq := (4*a^3*b)^(1/2)/(-(a/(4*b))^(1/2))+(4*a^3*b*(4*b/a))^(1/2) = 0:

simplify(eq)  assuming a::positive, b::positive;

simplify(eq)  assuming a::negative, b::negative;

                                   

 

Unfortunately Maple cannot itself find restrictions under which the identity is true.

 

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