Kitonum

13579 Reputation

24 Badges

11 years, 123 days

MaplePrimes Activity


These are answers submitted by Kitonum

You can use the commands  plots:-arrow, plots:-display, LinearAlgebra:-CrossProduct  to plot vectors, the results of operations on them, and animations of these. See examples below:


 

restart;
with(plots):
with(LinearAlgebra):

u, v, w:=<1, 2, 3>, <-1, 2, 3>, <-1, 2, -2>:
U:=arrow(u, color=blue):
V:=arrow(u, v, color=blue):
W:=arrow(u+v, w, color=blue):

r1:=u+v+w: r2:=u-v: r3:=CrossProduct(u,v):
R1:=arrow(r1, color=red):
R2:=arrow(v, r2, color=red):
R3:=arrow(CrossProduct(u,v), color=red):
display(U, V, W, R1, scaling=constrained);
V1:=arrow(v, color=blue):
display(U, V1, R2, scaling=constrained);
display(U, V1, R3, scaling=constrained);

 

 

 

display(plot3d([[0,0,0]])$5, display(U)$10, display([U,V])$10, display([U,V,W])$10, display([U,V,W,R1])$10, insequence, scaling=constrained);

 

 


 

Download Plotting_Vectors.mw

Try the  Explore  command for this:


 

restart;
f:=1+B*x-(1/12)*B*x^3+0.1666666667e-4*B^3*x^3-4.166666667*10^(-8)*B^4*x^4+(1/160)*B*x^5+8.333333333*10^(-11)*B^5*x^5-0.5000000000e-2*B^2*x^2+0.1666666667e-4*B*x^3*C^2-4.166666667*10^(-8)*B*x^4*C^3+8.333333333*10^(-11)*B*x^5*C^4-0.5000000000e-2*B*C*x^2+0.3333333333e-4*B^2*x^3*C-1.250000000*10^(-7)*B^3*x^4*C-1.250000000*10^(-7)*B^2*x^4*C^2+3.333333333*10^(-10)*B^4*x^5*C+5.000000000*10^(-10)*B^3*x^5*C^2+3.333333333*10^(-10)*B^2*x^5*C^3+0.7291666667e-3*B*x^4*C-0.3333333333e-5*B*x^5*C^2+0.6250000000e-3*B^2*x^4-0.2083333333e-5*B^3*x^5-0.5416666667e-5*B^2*x^5*C:
Explore(plot(f, x=-4..4, view=-10..10), B=-5...5., C=-5...5.);

 



It can be noted that changing the parameter  C  has very little effect on the graph

 

Download 2param.mw

Here is the corrected code:
 

restart:
with(PDEtools):
PDE :=  diff(y(x,t), t)-diff(y(x,t), x,x,t)-diff(y(x,t), x$2)+ diff(y(x,t), x)+y(x,t)*diff(y(x,t),x)=exp(-t)*(cos(x)-sin(x)+1/2*exp(-t)*sin(2*x));

diff(y(x, t), t)-(diff(diff(diff(y(x, t), t), x), x))-(diff(diff(y(x, t), x), x))+diff(y(x, t), x)+y(x, t)*(diff(y(x, t), x)) = exp(-t)*(cos(x)-sin(x)+(1/2)*exp(-t)*sin(2*x))

(1)

# Initial/boundary conditions
  BCs:=y(0,t) = 0, y(Pi,t)=0;
  ICs:=y(x,0) =sin(x) ;

y(0, t) = 0, y(Pi, t) = 0

 

y(x, 0) = sin(x)

(2)

pdsolve({PDE, BCs,ICs}, y(x,t));  # NULL. Maple does not find any exact solution

num_sol := pdsolve(PDE, {BCs,ICs}, numeric);
num_sol:-plot3d(x=0..1, t=0..1);

_m2208546638688

 

 

 

 
 exact_solution:=exp(-t)*sin(x);
Test1:=pdetest(y(x,t)=exact_solution,[PDE, BCs,ICs]);

exp(-t)*sin(x)

 

[0, 0, 0, 0]

(3)

 


 

Download BBM_new.mw

restart;
P:=proc(n)
option remember;
P(0):=0; P(1):=1;
if n>=2 and P(n-1)-1 in [seq(P(k),k=0..n-2)] then return 2*P(n-1) else P(n-1)-1 fi;
end proc:


Examples of use:

P(100);
seq('P(k)', k=0..50);             

                                                                121
0, 1, 2, 4, 3, 6, 5, 10, 9, 8, 7, 14, 13, 12, 11, 22, 21, 20, 19,  18, 17, 16, 15, 30, 29, 28, 27, 26, 25, 24, 23, 46, 45, 44, 43,   42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 62, 61, 60, 59
 

In the previous answer, the asymptote  y=-x  is omitted. To automatically find all asymptotes (inclined and vertical), use  Student:-Calculus1:-Asymptotes  command:

y:=sqrt(1+x^2):
Student:-Calculus1:-Asymptotes(y,x);
plot([y,x,-x], x=-5..5, -1..5, color=[red,black$2], thickness=[2,1$2], linestyle=[1,3$2], scaling=constrained); # The plotting for a visualization

                  

 

 

It seems that the natural parameterization and calculation of the arc length in this example can only be done numerically:

restart;
r:= t-><cos(2*t), sin(3*t), 4*t>:
L:=unapply(int(sqrt(add(diff(r(t),t)^~2)), t=0..t),t);
f:=s->fsolve(s=L(t),t=0..infinity);
f(1);  # Example
g:=s->r(f(s));
g(1);  # Example

L:=unapply(int(sqrt(add(diff(r(t),t)^~2)), t=t1..t2),t1,t2);
evalf(L(1,3));  # Example

                  

 

restart;
a:= plots:-display(plottools :- arrow( [1, -2], [4, -1], 0.001, 0.05, 0.1)):
b:= plots:-display(plottools :- arrow( [-1, 3], [2, 1], 0.001, 0.05, 0.1)):
c:= plots:-display(plottools :- arrow( [0, 2], [-3, 0], 0.001, 0.05, 0.1)):
plots:-display([plot([[0,0]])$5,a$10,plots:-display([a,b])$10,plots:-display([a,b,c])$10], insequence);

     

 

Replace the last line with
dsx := dsolve(sys_ode, numeric);

Example of use:
dsx(0.1);

See this help page  rtable_indexing

From Fig. 2 it is clearly seen that  f(0)=1  and  D(f)(0)<0 , which contradicts your initial conditions.

 Jayaprakash J   For movable boundary conditions you can use the  Explore  command.

 

Download BVP_new.mw

restart;
  rnge:=-1..1:
  fcns:=[[[0,0]]$5, x$10, [x,x^2]$10, [x,x^2,(1-x)]$10]:
  plots:-display( [ seq
                    ( plot
                      ( fcns[j], x=rnge),
                      j=1..35
                    )
                  ],
                  insequence=true, scaling=constrained
                );

               


Here is a more complicated option:

restart;
with(plots):
A:=animate(plot, [x, x=-1..a, color=red, thickness=2], a=-1..1):
B:=animate(plot, [x^2, x=-1..a, thickness=2, color=green], a=-1..1):
C:=animate(plot, [1-x, x=-1..a, color=blue, thickness=2], a=-1..1):
display([A, display(op([1,-1,1],A),B), display(op([1,-1,1],A),op([1,-1,1],B),C)], insequence, scaling=constrained);

                

See this post   https://mapleprimes.com/posts/207840-Combinations-Of-Multiple-Animations

Edit.

 


 

NULL

restart

n := 4; C := [seq(cos(2*Pi*K*l/n), l = 0 .. n-1)]; S := [seq(sin(2*Pi*K*l/n), l = 0 .. n-1)]

[1, cos((1/2)*Pi*K), cos(Pi*K), cos((3/2)*Pi*K)]

 

[0, sin((1/2)*Pi*K), sin(Pi*K), sin((3/2)*Pi*K)]

(1)

a := true; for c in C do for s in S do if int(c*s, K = -Pi .. Pi) <> 0 then a := false; break end if end do end do; a

true

(2)

NULL

NULL


 

Download orthogonal-new1.mw

 I think the easiest way to create the same animation is the using a procedure that creates an one frame, and then using the plots:-animate command:

restart;

OneFrame:=proc(a)
local f, Point, Points1, Points2, Curve;
uses plots;
f:=x->x^2-x+2;
Point:=plot([[2,f(2)]],style=point, color=black, symbol=solidcircle, symbolsize=30);
Points1:=plot([[2-a,f(2-a)],[2+a,f(2+a)]], x=-3..5, style=point, color=red, symbol=solidbox, symbolsize=30);
Points2:=plot([[2-a,0],[2+a,0],[0,f(2-a)],[0,f(2+a)]], x=-3..5, style=point, color=red, symbol=diamond, symbolsize=30);
Curve:=plot(f, -3..5, 0..8, color=blue, thickness=3);
display(Point,Points1,Points2,Curve, gridlines, scaling=constrained);
end proc:

plots:-animate(OneFrame, [a], a=1..0.05);

          

 

1 2 3 4 5 6 7 Last Page 3 of 212