Kitonum

21455 Reputation

26 Badges

17 years, 47 days

MaplePrimes Activity


These are answers submitted by Kitonum

Use  side relations  option in  simplify  command.

Example:

simplify((x^2+y^2+z^2+w^2)^10, {x^2+y^2+z^2+w^2=1});

                                                 1

Example:

Matrix([[x+y,x-y], [z,w]]):

eval(%, {x=-x, y=-y, z=-z, w=-w});

For plotting a single plot of multiple objects use  plots[display] .

Example:

with(DynamicSystems):

T:= Vector(20, t->0.1*(t)):

x1:= Vector(20, t->sin(0.1*t)):

x2:= Vector(20, t->cos(0.1*t)):

A:=DiscretePlot(T, x1, style=stair):

B:=DiscretePlot(T, x2, style=stair):

plots[display](A, B);

For fixed parameters  a, b, c, omega  when changing  t  the end of your variable vector  r(t) describes  a spiral:

a := 2: b := 1: c := 1: omega := 2:

r := t-><a*cos(omega*t), b*sin(omega*t), c*t>:

with(plots):

A := animate(arrow, [r(t), color = blue], t = 0 .. 2*Pi, frames = 100):

B := animate(spacecurve, [[a*cos(omega*s), b*sin(omega*s), c*s], s = 0 .. t, color = red, thickness = 3, linestyle = solid], t = 0 .. 2*Pi, frames = 100):

display(A, B, axes = normal, scaling = constrained);

                                            

 

Another way - the direct plotting of required objects without  plottools:-transform .

Here are 3 examples:

F:=(x,y)->(1/2*x^2-3/2*y^3,-1/2*x^3+1/3*y^2):  # Nonlinear mapping R^2->R^2

X:=t->(1/2*t+1,t-1):  # Mapping R->R^2 (for specification of a segment)

plot([[X(t),t=0..1],[F(X(t)), t=0..1]], color=[red,blue], thickness=3, scaling=constrained);  # The first example

plot([[X(t),t=0..1],[(F@@2)(X(t)), t=0..1]], color=[red,blue], thickness=3, scaling=constrained);  # The second example

X1:=t->(t,0): X2:=t->(0,t): X3:=t->(t,1): X4:=t->(1,t):  # Specifying edges of the unit square

plot([[X1(t),t=0..1], [X2(t),t=0..1], [X3(t),t=0..1], [X4(t),t=0..1], [F(X1(t)), t=0..1], [F(X2(t)), t=0..1], [F(X3(t)), t=0..1], [F(X4(t)), t=0..1]], color=[red$4,blue$4], thickness=3, scaling=constrained);   # The third example - the image of the unit square under the mapping  F

The simple procedure  ListOfTerms  solves the problem:

ListOfTerms:=proc(p)

if nops([coeffs(p)]) >1 then [op(p)] else [p]  fi;

end proc:

 

Examples:

ListOfTerms(x^2*y + x*y + x);

ListOfTerms(x^2);

               [x^2*y, x*y, x]

                     [x^2]

jheath4  Here is the procedure which finds all combinations of a binary list of any length  N

BinaryList:=proc(N::posint)

local OneStep;

OneStep:=proc(L::listlist)

local n;

n:=nops(L);

[seq(op([[op(L[i]),0],[op(L[i]),1]]), i=1..n)];

end proc;

(OneStep@@N)([[]]);

end proc:

 

Your example:

BinaryList(3);

          [[0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1], [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]

 

This procedure works a bit faster than  combinat:-permute :

ts:=time():

combinat:-permute( [0$15,1$15], 15):

time()-ts;

                            0.188

 

ts:=time():

BinaryList(15):

time()-ts;

                            0.109

 

 

Assuming that your function is smooth enough, you can interpolate the integrand by a spline (by default of 3 degree), and then integrate:

flist := [0.1, 0.2, 2, 3, 3.5, 6]:

xlist := [1, 2, 3, 4, 5, 6]:

glist := flist*~(xlist^~2-~1);  # The list of the integrand's values

F:=CurveFitting[Spline](xlist,glist, x);  

int(F, x=1..6);

 

 

By nested loop:

restart;

n:=0:

for i from 0 to 1 do

for j from 0 to 1 do

for k from 0 to 1 do

n:=n+1;  s[n]:=cat(i,j,k);

od: od: od:

convert(s,list)[];

 

By Carl's approach:

(cat@op)~(combinat:-permute([0$3,1$3], 3))[];

 

By nested seq:

seq(seq(seq(cat(i,j,k),k=0..1),j=0..1),i=0..1);

 

 First variant was edited.

Two circle may touch internal or external way. Therefore, we have 8 systems to find solutions. In this example there are four solutions:

restart;

P:=combinat[permute]([1$3,-1$3], 3);  # All variants of arrangements of signs in the systems

n:=0:

for p in P do

S:=[solve({x0^2+y0^2=(r+p[1]*5)^2, (x0-5)^2+(y0-4)^2=(r+p[2]*2)^2, (x0-13)^2+y0^2=(r+p[3]*3)^2}, explicit)];

for s in S do

if evalf(rhs(s[1]))>=0 and Im(rhs(s[2]))=0 and Im(rhs(s[3]))=0 then n:=n+1; L[n]:=s; fi;

od: od:

convert(L, list);  # All the solutions

M:=evalf(%); 

 

 The code is general in nature and it can easily be re-written as a procedure.

 

Visualization (original circles are green):

C1:=x^2+y^2=25: C2:=(x-5)^2+(y-4)^2=4: C3:=(x-13)^2+y^2=9:   # The equations of original circles

for k from 1 to 4 do

C[k]:=eval((x-x0)^2+(y-y0)^2=r^2, M[k]): # The equations of found circles.

od:

plots[implicitplot]([C1,C2,C3,seq(C[k],k=1..4)], x=-12..22, y=-12..10, thickness=[3$3,2$4], color=[green$3, red,blue,yellow,violet], scaling=constrained, gridrefine=3);

 

 

The simple procedure  CyclePerm  solves your problem:

restart;

CyclePerm:=proc(L::list)

local n;

n:=nops(L);

seq([op(L[i..n]), op(L[1..i-1])], i=1..n);

end proc:

 

Your example:

CyclePerm([1,2,3]);

[1,2,3], [2,3,1], [3,1,2]

 

or in the for cycle for yours or similar example:

L:=[1,2,3]:  n:=nops(L):

for i from 1 to n do

op(L[i..n]), op(L[1..i-1]);

od;

               1,2,3

               2,3,1

               3,1,2

See the main rules here

For greater accuracy, use a spline approximation. With an increase in the degree of the spline (default value  is 3) the accuracy increases. 

 

Examples:

y:=unapply(CurveFitting[Spline](<seq(x, x=0..1, 0.1)>,<seq(x^2, x=0..1, 0.1)>, x), x):

y1:=unapply(CurveFitting[Spline](<seq(x, x=0..1, 0.1)>,<seq(x^2, x=0..1, 0.1)>, x, degree=5), x):

int(y, 0..1);

int(y1, 0..1);

                                                                    0.3334295580

                                                                    0.3333333333

 

um_vue 10

a1 := Matrix(3, 4, [1, 2, 3, 4, 7, 8, 9, 10, 13, 14, 15, 16]):

a2 := Matrix(3, 2, [5, 6, 11, 12, 17, 18]):

a3 := Matrix(2, [19, 20, 25, 26]):

a4 := Matrix(2, 4, [21, 22, 23, 24, 27, 28, 29, 30]):

<<a1|a2>, <a3|a4>>;  # your matrix

                              

Or even shorter :

<a1,a2; a3,a4>;

 

You can download  OrthogonalExpansions  package  for Maple from here  This package includes commands for working with Fourier series.

First 204 205 206 207 208 209 210 Last Page 206 of 290