Kitonum

21525 Reputation

26 Badges

17 years, 75 days

MaplePrimes Activity


These are answers submitted by Kitonum

Or use the  map  command, which causes Maple to sequentially calculate the integral of each summand:

map(int, g, theta = 0 .. Pi)  assuming r>0;

                      


Axel's approach does not work in Maple 2018.

Edit. Of course, as acer showed in his comment, the  IntegrationTools:-Expand  command solves the problem.

I think this task is not too simple for a beginner, since there are many different objects in it. Here is a solution using  eval  and  diff  commands (the differentiation operator  D  does not seem to work for vector functions for Maple <=2018). A detailed commentary is provided for each line of code so that the beginner understands what it is doing. I gave different names for the parameters of the original curve  and the tangent line  s  (they are often confused but they are not related to each other). Ranges  t=0..1.4  and  s=-0.3..0.4  are chosen so that everything looks beautiful and informative.

restart;
f:=[t,t^2,t^3]; # The parametric equations of the original curve
t0:=1; # The value of the parameter at the tangency point
P:=eval(f,t=t0); # The coordinates of the tangency point  
df:=eval(diff(f,t), t=t0); # The coordinates of the tangent vector at t=t0
with(plots):
A:=spacecurve(f, t=0..1.4, color=red, thickness=2,labels=[x,y,z]): # The plot of the original curve
T:=map(p->s*p,df)+P; # The parametric equations of the tangent line 
B:=spacecurve(T, s=-0.3..0.4, color=blue, thickness=3): # The plot of the tangent line 
C:=pointplot3d(P,color=red,symbol=solidsphere,symbolsize=10): # The plot of the tangency point  
display(A,B,C, axes=normal, orientation=[-35,75], scaling=constrained); # All at once

          

 

 

Download ABC.mw

I significantly reduced the  stepsize  option, slightly increased  the ranges for  x  and  y , and removed unused lines of code.
 

with(DEtools)

with(plots)

with(LinearAlgebra)

p1 := phaseportrait([diff(x(t), t) = x(t)*(1-x(t)^2-y(t)^2)+y(t)*(y(t)^2+(x(t)^2-1)^2), diff(y(t), t) = y(t)*(1-x(t)^2-y(t)^2)-x(t)*(y(t)^2+(x(t)^2-1)^2)], [x(t), y(t)], t = 0 .. 50, [[x(0) = -3, y(0) = .5], [x(0) = 4, y(0) = 2]], x = -5 .. 5, y = -5 .. 5, dirgrid = [13, 13], stepsize = 0.1e-2, axes = BOXED); p1

 

p2 := pointplot([[1, 0], [-1, 0], [0, 0]], symbolsize = 20, symbol = solidcircle, color = black)

 

 

display(p1, p2, size = [500, 500])

 

solve({x*(-x^2-y^2+1)+y*(y^2+(x^2-1)^2), y*(-x^2-y^2+1)-x*(y^2+(x^2-1)^2)}, {x, y})

{x = 0, y = 0}, {x = RootOf(_Z^8-6*_Z^6+11*_Z^4-6*_Z^2+2), y = RootOf(_Z^8-6*_Z^6+11*_Z^4-6*_Z^2+2)^5-3*RootOf(_Z^8-6*_Z^6+11*_Z^4-6*_Z^2+2)^3+RootOf(_Z^8-6*_Z^6+11*_Z^4-6*_Z^2+2)}, {x = 1, y = 0}, {x = -1, y = 0}, {x = RootOf(_Z^2-2), y = RootOf(_Z^2+1)}

(1)

subs({x = .5, y = -.5}, x*(-x^2-y^2+1)+y*(y^2+(x^2-1)^2))

-.15625

(2)

sys := [x*(-x^2-y^2+1)+y*(y^2+(x^2-1)^2), y*(-x^2-y^2+1)-x*(y^2+(x^2-1)^2)]

[x*(-x^2-y^2+1)+y*(y^2+(x^2-1)^2), y*(-x^2-y^2+1)-x*(y^2+(x^2-1)^2)]

(3)

A := Jacobian(sys, [x, y])

Matrix(%id = 18446746360039790702)

(4)

latex(Matrix(2, 2, {(1, 1) = -2, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}))

 \left[ \begin {array}{cc} -2&0\\ \noalign{\medskip}0&0\end {array}
 \right]

 

A1 := subs([x = 1, y = 0], A)

Matrix(%id = 18446746360040191630)

(5)

A2 := subs([x = -1, y = 0], A)

Matrix(%id = 18446746360040194406)

(6)

A3 := subs([x = 0, y = 0], A)

Matrix(%id = 18446746360040197166)

(7)

r1, e1 := Eigenvectors(A1)

Vector[column](%id = 18446746360083677662), Matrix(%id = 18446746360083677782)

(8)

r2, e2 := Eigenvectors(A3)

Vector[column](%id = 18446746359967554606), Matrix(%id = 18446746359967554726)

(9)

NULL


 

Download as22a_new.mw

Here is the procedure that inserts a rational number with the lowest denominator (vv's assumption) between any 2 list items. If there are several such numbers, then the smallest number is inserted.

FindSamples:=proc(sourcesamples)
local N, P;
N:=nops(sourcesamples);
P:=proc(a,b)
local a1, b1, m1, n, m;
if a=b then error "Should be a<>b" fi;
a1,b1:=op(convert(sort([a,b],(x,y)->evalf(x)<evalf(y)),rational));
for n from 1 do
m1:=a1*n;
m:=`if`(type(m1,integer),m1+1,ceil(m1));
if is(m/n>a1) and is(m/n<b1) then return m/n fi;
od;
end proc:
[ceil(sourcesamples[1])-1, seq(op([sourcesamples[i],P(sourcesamples[i],sourcesamples[i+1])]), i=1..N-1),sourcesamples[N],floor(sourcesamples[N])+1];
end proc:

The usage for your example:
sourcesamples :=[evalf(-1-sqrt(7)), -2, 1, evalf(-1 + sqrt(7)), 2];
FindSamples(sourcesamples);
                    

The main role in this procedure is played by the subprocedure  P , which returns a rational number between   and   with the lowest denominator. Here is a specific example of the application of this procedure: Take 2 numbers 3.14 and 3.15 (these are approximations of the number  Pi  with 3 digits with a deficiency and an excess) and find the intermediate number with the lowest denominator:

P:=proc(a,b) 
local a1, b1, m1, n, m; 
if a=b then error "Should be a<>b" fi;
a1,b1:=op(convert(sort([a,b],(x,y)->evalf(x)<evalf(y)),rational)); 
for n from 1 do 
m1:=a1*n; 
m:=`if`(type(m1,integer),m1+1,ceil(m1)); 
if is(m/n>a1) and is(m/n<b1) then return m/n fi; 
od;
end proc:
P(3.14, 3.15);

                         
 
Edit. The procedure  P  has been improved. Now it works much faster.

First, we complete the squares to estimate the ranges for the loop variables.
There are 2 integer solutions:

restart;
Eq:=7*(x^2+y^2+z^2)+2*x+4*y-8*z-8;
Student:-Precalculus:-CompleteSquare(Eq, [x,y,z]);
Eq1:=%/7; k:=0: T:=table(): 
for x from -2 to 2 do
for y from -2 to 2 do
for z from -2 to 2 do
if Eq=0 then k:=k+1; T[k]:=[x,y,z] fi;
od: od: od:
T:=convert(T,list);

               

      

Two syntax errors:
1. N/2  should be a positive integer.
2. Should be  add  instead of  sum.

Your example:

N:=10:
A:=Array(1..N/2);
add(A);

 

Here is your example automatically. It works for an arbitrary list:

restart;
L:= [-1+sqrt(7), -1 - sqrt(7)]:

L1:=sort(L,(x,y)->evalf(x)<=evalf(y));
m:=floor(L1[1]);  M:=ceil(L1[-1]);
[$ m..M, op(L)];
samples:=sort(%, (x,y)->evalf(x)<=evalf(y));
evalf(samples);

                    

Edit. If you need to insert something between the list items, you can do so:

[seq(op([A,s]), s=samples), A];

    

 

solve(a*x^2 + b*x + c=0, x, parametric=true, real);

                         

 

Here is a simple procedure that allows you to beautifully plot graphs in 3D. Required parameters: Names - the list of  vertex names, Coords - the list of vertex coordinates, Edges - the set of edges. Opt  is an optional parameter that determines the graphic properties of objects (the color of the vertices, the size of the vertices (as a fraction of the average distance between the vertices), the color of the edges, the thickness of the edges).

 

restart;
DrawGraph3D:=proc(Names::list,Coords::list, Edges::set(set), Opt::list:=[gold,0.05,brown,3])
local n, Dist, f, h, V, L, T;
uses plottools, plots, ListTools;
n:=nops(Edges);
Dist:=(A,B)->sqrt((A[1]-B[1])^2+(A[2]-B[2])^2+(A[3]-B[3])^2);
f:=x->Coords[Search(x,Names)];
h:=add(map(x->Dist(f(x[1]),f(x[2])), convert(Edges,list)))/n;
V:=seq(sphere(c,Opt[2]*h,style=surface,color=Opt[1]), c=Coords);
L:=seq(line(f(c[1]),f(c[2]),color=Opt[3],thickness=Opt[4]), c=Edges);
T:=textplot3d([seq([f(c)[1],f(c)[2],f(c)[3]+0.05*h,c], c=Names)], font=[times,16],align={left,above});
display(V, L, T, scaling=constrained, axes=none);
end proc:


Examples of use

DrawGraph3D([a,b,c,d],[seq([cos(2*Pi*k/3),sin(2*Pi*k/3),0],k=0..2),[0,0,1]],{{a,b},{b,c},{c,a},{d,a},{d,b},{d,c}},[red,0.06,blue,2]);

DrawGraph3D([$ 1..7],[seq([cos(2*Pi*k/5),sin(2*Pi*k/5),0],k=0..4),[0,0,1],[0,0,-1]],{seq({i,i+1},i=1..4),{5,1},seq({6,i},i=1..5),seq({7,i},i=1..5)}); # Graphic options by default

 

 


 

Download DrawGraph3D_2.mw

Animation of this picture:

plots:-animate(plots:-display,[plottools:-rotate(%,phi,[[0,0,0],[0,0,1]])], phi=0..2*Pi, frames=60);

                   

 

 

Edit.

Use the  dimension=3  option.

Example:

with(GraphTheory):
H := CompleteGraph(4);
DrawGraph(H, style = spring, dimension = 3);

                         

 

plots:-animate(plot3d, [[x, (cos(x)+1)*cos(phi), (cos(x)+1)*sin(phi)], x = 0 .. 4*Pi, phi = (1/2)*Pi .. t, style = surface, color = khaki, labels = [x, y, z], lightmodel = light1], t = (1/2)*Pi .. (-3*Pi)*(1/2), frames = 60, axes = normal, view = [-1 .. 13.7, -2.4 .. 2.4, -2.4 .. 2.4])

                        

 

 

 

I guess that OP only meant to animate the process of painting one area (the curves themselves should not move):

restart; 
with(plots): 
animate(shadebetween, [sin(x), cos(x), x = (1/4)*Pi .. t, positiveonly], 
t = (1/4)*Pi .. 5*Pi*(1/4),background = plot([sin(x), cos(x)], x = 0 .. 2*Pi, 
gridlines = true, thickness = 3, labels = ["", ""]), scaling = constrained, size = [900, 300])

                     

The answer is obvious - the function  2*sqrt(xyz)  does not depend on  . xyz is just a symbol unrelated to x .
In Maple, this can be tested using the  depends  function:

depends(x^2,x);
depends(xyz,x);

                                     true
                                    false

In the usual sense, it is impossible to plot a function of three variables, since it requires 3 dimensions for the arguments and one dimension for the values of the function, that is, we need 4-dimensional space. I propose the following way to solve problem: we fix 1 variable, for example , and then plot the function of two variables  x  and  y . Using  Explore command we can trace how this plot changes as  z  changes.


 

restart;

varphi[3/4,2/3]:=(x,y,z)->1/60*GAMMA(7/4)/(sqrt(2*Pi)*GAMMA(5/4))*(((abs(x)^(1/3)+abs(y)^(1/3))^2-abs(z)^(2/3))*(abs(z)^(2/3)-(abs(x)^(1/3)-abs(y)^(1/3))^2))^(1/4)/abs(x*y*z)^(1/2)*(10+66*cos(phi)^3-36*cos(phi));

proc (x, y, z) options operator, arrow; (1/60)*GAMMA(7/4)*(((abs(x)^(1/3)+abs(y)^(1/3))^2-abs(z)^(2/3))*(abs(z)^(2/3)-(abs(x)^(1/3)-abs(y)^(1/3))^2))^(1/4)*(10+66*cos(phi)^3-36*cos(phi))/(sqrt(2*Pi)*GAMMA(5/4)*abs(x*y*z)^(1/2)) end proc

(1)

A:=eval(varphi[3/4,2/3](x,y,z),phi=Pi);

-(1/2)*GAMMA(3/4)^2*(((abs(x)^(1/3)+abs(y)^(1/3))^2-abs(z)^(2/3))*(abs(z)^(2/3)-(abs(x)^(1/3)-abs(y)^(1/3))^2))^(1/4)/(Pi^(3/2)*abs(x*y*z)^(1/2))

(2)

Explore(plot3d(A, x=0.01..5, y=0.01..5, grid=[100,100], axes=normal, view=-0.5..0.1), z=0.01..10.);

eval(A,[x=1,y=3,z=0.05]);

-.2318459778*GAMMA(3/4)^2*(((1+3^(1/3))^2-.1357208808)*(.1357208808-(1-3^(1/3))^2))^(1/4)

(3)

evalf(%);

-.1892078612-.1892078612*I

(4)

 


The last 2 lines of code show that for some values of arguments your function takes imaginary values. For such values, the plot is not built.

Download Explore_plot3d.mw

To solve your problem, I used the simplest formulas for numerical differentiation. Your expression  diff(u(y, t), y)+diff(diff(u(y, t), y), t)  is calculated for the 4 indicated values  b   by replacing the derivatives at the point  (y,t) = (0,1)  with the corresponding difference ratios with the step  h=0.001

 

restart;
a := 0.7: L := 8: HAA := [0, 2, 5, 10]: h:=0.001:

PDE1 := diff(u(y, t), t) = diff(u(y, t), y, y)+diff(diff(u(y, t), y, y), t)-b*u(y, t)+T(y, t):
PDE2 := diff(T(y, t), t) = (1+(1+(a-1)*T(y, t))^3)*(diff(T(y, t), y, y))+(a-1)*(1+(a-1)*T(y, t))^2*(diff(T(y, t), y))^2+T(y, t)*(diff(T(y, t), y, y))+(diff(T(y, t), y))^2:

ICandBC := {T(L, t) = 0, T(y, 0) = 0, u(0, t) = t, u(L, t) = 0, u(y, 0) = 0, (D[1](T))(0, t) = -1}:

for i from 1 to nops(HAA) do
b := HAA[i];

pds[i] := pdsolve({PDE1,PDE2}, ICandBC, numeric);

f:=(y0,t0)->rhs((pds[i]:-value(u(y,t),t=t0)(y0))[3]);

A[i]:=(f(h,1)-f(0,1))/h+(f(h,1+h)-f(0,1+h)-f(h,1)+f(0,1))/h^2;

end do:

seq(A[i], i=1..4);

HFloat(-0.363959490085608), HFloat(-1.4987065854407122), HFloat(-2.6087957499710823), HFloat(-3.79562660597188)

(1)

 


 

Download ND.mw

First 68 69 70 71 72 73 74 Last Page 70 of 290