Kitonum

21445 Reputation

26 Badges

17 years, 41 days

MaplePrimes Activity


These are answers submitted by Kitonum

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.

If given a curve in the plane by its parametric equations  L := [x(t), y(t), t=t1 .. t2]  then the following simple procedure  RotationAroundOy  helps you to plot the surface of rotation of  L  around Oy-axis.

Code of the procedure:

RotationAroundOy := proc(L)

plot3d([abs(L[1])*cos(phi), L[2], abs(L[1])*sin(phi)], L[3], phi = 0 .. 2*Pi);

end proc:

 

Example of use:

L1 := [t, t, t = 2 .. 4]:  # the line segment in 2D

L2 := [cos(t)+3, sin(t), t = 0 .. 2*Pi]:   # the circle in 2D

plots[display](RotationAroundOy~([L1, L2]), axes = normal, view = [-4.9 .. 4.9, -1.9 .. 4.9, -4.9 .. 4.9]);

                     

 

Instead of two objects  L1  and  L2  as in the example, you can specify any number of objects. 

plottools[getdata](plot(x^2-4, x=-3..3));

For plotting spacecurves in Maple 2015  linestyle=solid  option is required.

Comparison of 2 ways:

restart;

A:=plots[spacecurve]([cos(t), sin(t),t], t=1..5, linestyle=solid, axes=framed):

B:=Student[VectorCalculus][SpaceCurve](<cos(t),sin(t),t>,t=1..5, linestyle=solid, axes=framed):

plots[display](<A|B>);

I arbitrarily added the initial condition  g(0) = 0.5 :

sol := dsolve({diff(f(x), x,x)+6*x*(diff(f(x), x))+f(x), diff(g(x), x) = f(x)*g(x), f(0) = 0, g(0) = 0.5, D(f)(0) = 1}, type = numeric);

 

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