Kitonum

21006 Reputation

26 Badges

16 years, 185 days

MaplePrimes Activity


These are answers submitted by Kitonum

Probably this can be done in different ways. Below is one way:


 

restart; Sys := {T__1 = m__1*a, a = R*alpha, -R*T__1+R*T__2 = I__s*a/R, g*m__2-T__2 = m__2*a}; Var := {T__1, T__2, a, alpha}; Params := `minus`(indets(Sys), Var); Sol := solve(Sys, Var); T__1, T__2, a, alpha := seq(unapply(rhs(t), Params[]), t = Sol)

proc (I__s, R, g, m__1, m__2) options operator, arrow; R^2*g*m__2*m__1/(R^2*m__1+R^2*m__2+I__s) end proc, proc (I__s, R, g, m__1, m__2) options operator, arrow; m__2*g*(R^2*m__1+I__s)/(R^2*m__1+R^2*m__2+I__s) end proc, proc (I__s, R, g, m__1, m__2) options operator, arrow; R^2*g*m__2/(R^2*m__1+R^2*m__2+I__s) end proc, proc (I__s, R, g, m__1, m__2) options operator, arrow; R*g*m__2/(R^2*m__1+R^2*m__2+I__s) end proc

(1)

NULL



Here is another way in which variables and parameters are specified not by sets, but by lists. This allows us to maintain their order in the way we want, and not as Maple chooses:
 

restart; Sys := {T__1 = m__1*a, a = R*alpha, -R*T__1+R*T__2 = I__s*a/R, g*m__2-T__2 = m__2*a}; Var := [T__1, T__2, a, alpha]; Params := [R, m__1, m__2, g, I__s]; Sol := solve(Sys, Var)[]; T__1, T__2, a, alpha := seq(unapply(eval(Var[i], Sol), Params[]), i = 1 .. nops(Var)); T__1(1, 2, 3, 4, 5)

12/5

(1)

NULL


 

Download solveEqs_new2.mw

Download solveEqs_new1.mw

I'm used to always ending the line, the result of which should be displayed, end with a semicolon:       

# Using the Expression palette:

cos(5.);

# Using the Expression palette:

sqrt(4);
                            
# Using Command Completion:  

sqrt(4);
                             

Download No_Error.mw

restart:
  with(geometry):
  with(plots):
  _EnvHorizontalName = 'x':
  _EnvVerticalName = 'y':
   R := 5:
   ang := [3/4*Pi, -(3*Pi)/4, -Pi/6,4*Pi/9]:
   seq
   ( point
     ( `||`(P, i),
       [ R*cos(ang[i]), R*sin(ang[i])]
     ),
     i = 1 .. 4
   ):
   seq
   ( dsegment
     ( `||`(seg, i),
       [ `||`(P, i),
         `||`(P, irem(i, 4) + 1)
       ]
     ),
     i = 1 .. 4
   ):
   triangle(Tr1,[P1,P2,P4]):
   EulerCircle(Elc1,Tr1,'centername'=o1):
   triangle(Tr2,[P1,P2,P3]):
   EulerCircle(Elc2,Tr2,'centername'=o2):
   triangle(Tr3,[P3,P2,P4]):
   EulerCircle(Elc3,Tr3,'centername'=o3):
   triangle(Tr4,[P1,P3,P4]):
   EulerCircle(Elc4,Tr4,'centername'=o4):
   circle(cir, [point(OO, [0, 0]), R]):
   ngon1 :=[P1,P2,P3,P4]:

   poly1:=polygonplot(coordinates~(ngon1),color=blue,filled=true):
   ngon2 :=[P1,P2,P3,P4]:
   poly2:=polygonplot(coordinates~(ngon2),color=yellow,filled=true):
   display
   (draw
       ( [P1(color = black, symbol = solidcircle, symbolsize = 12),
           P2(color = black, symbol = solidcircle, symbolsize = 12),
           P3(color = black, symbol = solidcircle, symbolsize = 12),
           P4(color = black, symbol = solidcircle, symbolsize = 12),
           o1(color = black, symbol = solidcircle, symbolsize = 12),
           o2(color = black, symbol = solidcircle, symbolsize = 12),
           o3(color = black, symbol = solidcircle, symbolsize = 12),
           o4(color = black, symbol = solidcircle, symbolsize = 12),
           seg1,
           seg2,
           seg3,
           seg4,
           Tr1(color=green),Tr2(color=green),Tr3(color=green),Tr4(color=green),
           Elc1,Elc2,Elc3,Elc4,
           cir(color = blue)]
         
       ),
       textplot
       ( [ seq
           ( [ coordinates(`||`(P, i))[],
               convert(`||`(P, i), string)
             ],
             i=1..4
           )
         ,
         seq
           ( [ coordinates(`||`(o, i))[],
               convert(`||`(o, i), string)
             ],
             i=1..4
           )]
         ,
            
         align=[above, right]
       )
     ,
     axes=none
   );

                                        

restart;
with(geometry):
with(plots):
_EnvHorizont:lName = 'x';
_EnvVerticalName = 'y';
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc;
R := 5;
ang := [3/4*Pi, -(3*Pi)/4, -Pi/6,4*Pi/9];
seq(point(`||`(P, i), [R*cos(ang[i]), R*sin(ang[i])]), i = 1 .. 4);
pts:=[seq(P || i,i=1..4)]:
seq(dsegment(`||`(seg, i), [`||`(P, i), `||`(P, irem(i, 4) + 1)]), i = 1 .. 4);
triangle(Tr1,[P1,P2,P4]);
EulerCircle(Elc1,Tr1,'centername'=o);
circle(cir, [point(OO, [0, 0]), R]);
dist := proc(M, N) sqrt(Vdot(M - N, M - N)); end proc;

display(draw([P1(color = black, symbol = solidcircle, symbolsize = 12), 
P2(color = black, symbol = solidcircle, symbolsize = 12), 
P3(color = black, symbol = solidcircle, symbolsize = 12), 
P4(color = black, symbol = solidcircle, symbolsize = 12),seg1,
seg2,seg3,seg4,Tr1,Elc1,
cir(color = blue)]), 
textplot([seq([coordinates(`||`(P, i))[], convert(`||`(P, i), string)],i=1..4)], align = [above, right]), axes = none);

 

I fixed some bugs in your code:

restart;
with(geometry):
with(plots):
_EnvHorizontalName = 'x':
_EnvVerticalName = 'y':
Vdot := proc(U, V) local i; add(U[i]*V[i], i = 1 .. 2); end proc:
R := 5:
ang := [2/3*Pi, -3*Pi*1/4, -Pi*1/6]:
seq(point(`||`(P, i), [R*cos(ang[i]), R*sin(ang[i])]), i = 1 .. 3):
seq(dsegment(`||`(seg, i), [`||`(P, i), `||`(P, irem(i, 3) + 1)]), i = 1 .. 3):
circle(cir, [point(OO, [0, 0]), R]):
dist := proc(M, N) sqrt(Vdot(M - N, M - N)); end proc:
display(draw([P1(color = black, symbol = solidcircle, symbolsize = 12), 
P2(color = black, symbol = solidcircle, symbolsize = 12), 
P3(color = black, symbol = solidcircle, symbolsize = 12), 
cir(color = blue)]), 
textplot([[coordinates(P1)[], "P1"], 
[coordinates(P2)[], "P2"], 
[coordinates(P3)[], "P3"]], align = [above, right]), axes = none);
                             

 

1. You are trying to plot a curve in space as the intersection of two implicitly defined surfaces. The plotting of such lines is based on sign changes. But in your example, these 2 surfaces only touch each other, i.e. no sign changes.
2. Lines in space are best plotted using the  plots:-spacecurve  command, in which the line is given by its parametic equations.

restart;
P1:=plots:-implicitplot3d( [x^2 + b*x + c=0 , b^2 - 4*c=0], b = -4..4, c = -4..4, x = -4..4, style=surface, color=["Green","Yellow"],grid=[50,50,50]):
P2:=plots:-spacecurve([b, b^2/4, -b/2], b = -4..4, color=red, thickness=5, view=[-4..4,-4..4,-4..4], labels=[b,c,x]):
plots:-display(P1, P2);

                                             

 

restart;
sol:=dsolve({diff(y(x),x,x)+2*diff(y(x),x)^2+8*y(x)=0, y(0)=0 , D(y)(0)=1}, numeric);
plots:-odeplot(sol,[x,y(x)], x=0..10);

                                      

 

restart;
for oo to 2 do
    M[oo] := InertForm:-Display(EI/L,inert=false)*(4*theta(oo) + 2*theta(oo + 1));
end do;

                                 

 

This problem can be solved in 2 ways. Using the rotation matrix around some axis, we can obtain a parametrization of this rotation surface, i.e. its explicit parametric equations. But this is a rather cumbersome method, although the construction quality will be the highest. An easier and faster way is to use the  plottools:-rotate command which is implemented below:

 

restart;
f := x -> x^2+2:
g := x -> 1/2*x+1:

P1:=proc(a)
local L, L1, L2, L3, L11, Line;
uses plots, plottools;
L:=spacecurve([[0,t,f(t)],[0,t,g(t)]], t=0..1,color=red,thickness=3);
L1:=spacecurve([0,0,t], t=1..2, color=pink, thickness=0);
L2:=spacecurve([[0,t,f(t)],[0,t,g(t)]], t=0..1, color=pink, thickness=0);
L3:=spacecurve([0,1,t], t=3/2..3, color=pink,thickness=0);
L11:=display(L1,L2,L3);
Line:=line([0,0,8],[0,3,-1], color=blue, thickness=2);
display(L, Line, seq(rotate(L11,k*a/60,[[0,0,8],[0,2,2]]), k=1..60),rotate(L,a,[[0,0,8],[0,2,2]]), scaling=constrained, axes=normal, view=[-3.5..3.5,-0.5..4.5,-1.5..5.5]);
end proc:

plots:-animate(P1, [a], a=0..2*Pi, frames=90, orientation=[-15,65], paraminfo=false);

                                 
Edit. I remembered that the construction of the rotation matrix is automated in the  Student:-LinearAlgebra  subpackage. Below is the solution to this problem using the rotation matrix:

restart;
f := x -> x^2+2:
g := x -> 1/2*x+1:
M:=Student:-LinearAlgebra:-RotationMatrix(phi,<0,2,-6>):

P:=proc(a)
local Opt, T1, T2, v1, v2, v3, v4, P1, P2, P3, P4, L, Line;
uses plots, plottools;
Opt:=phi=0..a, color=pink;
T1:=v -> <v[1],v[2],v[3]+8>: T2:=v -> <v[1],v[2],v[3]-8>:
v1:=<0,x,f(x)>: v2:=<0,x,g(x)>: v3:=<0,0,t>: v4:=<0,1,t>:
P1:=plot3d(convert(T1(M.T2(v1)),list), x=0..1, Opt):
P2:=plot3d(convert(T1(M.T2(v2)),list), x=0..1, Opt):
P3:=plot3d(convert(T1(M.T2(v3)),list), t=1..2, Opt):
P4:=plot3d(convert(T1(M.T2(v4)),list), t=3/2..3, Opt):
L:=spacecurve([[0,t,t^2+2],[0,t,t/2+1]], t=0..1,color=red,thickness=3):
Line:=line([0,0,8],[0,3,-1], color=blue, thickness=2);
display(P1,P2,P3,P4, L, Line, scaling=constrained, axes=normal, view=[-3.5..3.5,-0.5..4.5,-0.5..5.5]);
end proc:

plots:-animate(P, [a], a=0..2*Pi, frames=90,  orientation=[-15,65], paraminfo=false);

                                      

If you want to get a high-quality plot of a body of rotation, then it is better to use the  plot3d  command. I made an animation of getting this body (the scale along the axes is made the same scaling=constrained):

restart;
f := x -> x^2+2:
g := x -> 1/2*x+1:
V := int(f(x)^2 - g(x)^2,x=0..1)*Pi;

P:=proc(a)
local Opt, P1, P2, P3, P4, L;
uses plots;
Opt:=phi=Pi/2..a, color=pink;
P1:=plot3d([f(x)*cos(phi),x,f(x)*sin(phi)], x=0..1, Opt):
P2:=plot3d([g(x)*cos(phi),x,g(x)*sin(phi)], x=0..1, Opt):
P3:=plot3d([r*cos(phi),0, r*sin(phi)], r=1..2, Opt):
P4:=plot3d([r*cos(phi),1, r*sin(phi)], r=3/2..3, Opt):
L:=spacecurve([[0,t,t^2+2],[0,t,t/2+1]], t=0..1,color=red,thickness=3):
display(P1,P2,P3,P4,L, scaling=constrained, axes=normal, view=[-3.5..3.5,-0.5..3.5,-3.5..3.5]);
end proc:

plots:-animate(P, [a], a=Pi/2..2*Pi+Pi/2, frames=90, orientation=[40,75], paraminfo=false);




                                                  

 

 

Use the procedure form for the plotting:

restart;
h:=p->MapleTA:-Builtin:-inverf(p);
plot(h, -1..1);

 

Try the  parse  command for this.

Use the  PolyhedralSets  package.

restart;
L:=[[-1.5, -0.5, 0.], [-1.5, 0.5, 0.], [-1., -1., -0.7071067810], [-1., 1., -0.7071067810], [-0.5, -1.5, 0.], [-0.5, -0.5, -1.414213562], [-0.5, 0.5, -1.414213562], [-0.5, 1.5, 0.], [0.5, -1.5, 0.], [0.5, -0.5, -1.414213562], [0.5, 0.5, -1.414213562], [0.5, 1.5, 0.], [1., -1., -0.7071067810], [1., 1., -0.7071067810], [1.5, -0.5, 0.], [1.5, 0.5, 0.]]:
L1:=map(t->convert~(t,fraction), L);
with(PolyhedralSets):
P:=PolyhedralSet(L1):
Plot(P, scaling=constrained);

                                                 

or

Plot(P, style=line, scaling=constrained);

                                  

PS. I increased the number of digits when specifying the coordinates of some vertices (multiples of the root of 2). Otherwise, Maple finds that the vertices of the pentagons do not lie in the same plane and adds extra edges.


 

Maybe the following:

A:=<1,2;3,4>: B:=<6,7;8,9>:
A%.B=A.B;

                                   

Here is  a solution to the problem without the Iterator package (the package appeared for the first time in Maple 2016). This is important for those who have older versions of Maple. First, you must initialize the user procedure SumPartition. Below is the text of the procedure and 2 examples:
 

restart;
SumPartition:=proc(S::set)
local SetPartition, n, L, L1;
uses ListTools,combinat;
SetPartition:=proc(S::set, Q::list(posint))  # Procedure finds all partitions of the set  S  into subsets of the specific size given Q.
local L, P, T, S1, S2, n, i, j, m, k;
if `+`(op(Q))<>nops(S) then error "Should be `+`(op(Q))=nops(S)" fi;
L:=convert(Q,set);
T:=[seq([L[i],Occurrences(L[i],Q)], i=1..nops(L))];
P:=convert(T,set);
S1:=S;  S2:={{}}; n:=nops(P);
for i to n do
m:=P[i,1]; k:=P[i,2];
for j to k do
S2:={seq(seq({op(s),t}, t=choose(S1 minus `union`(op(s)),m)), s=S2)};
od; od;
S2;
end proc:
L:=partition(nops(S));
L1:=map(t->SetPartition(S,t)[], L);
map(t->convert~(t,`+`), L1);
end proc:


Examples:

SumPartition({a,b,c});
SumPartition({a,b,c,d});

                      [{a, b, c}, {a, b + c}, {b, a + c}, {c, a + b}, {a + b + c}]
[{a, b, c, d}, {a, b, c + d}, {a, c, b + d}, {a, d, b + c},   {b, c, a + d}, {b, d, a + c}, {c, d, a + b}, {a + b, c + d},  {a + c, b + d}, {a + d, b + c}, {a, b + c + d}, {b, a + c + d},   {c, a + b + d}, {d, a + b + c}, {a + b + c + d}]
 

First 12 13 14 15 16 17 18 Last Page 14 of 286