Kitonum

21525 Reputation

26 Badges

17 years, 75 days

MaplePrimes Activity


These are answers submitted by Kitonum

Use the tgonometric form of complex numbers:

z1 := cos(alpha)+I*sin(alpha): 
z2 := cos(beta)+I*sin(beta):
is((z1^2+2*z1*z2+z2^2)/(z1+z2) = z1/z2+z2/z1);
is(z1/z2+z2/z1+2 = 2*(1+cos(alpha-beta)));

                                          false
                                           true

I simplified both of your procedures by making the following changes:
1. The parameter of the procedures is taken as a whole vector, and not its coordinates.
2. Used elementwise operators.
3. Used two-argument  arctan .

Now everything works as expected:
 

restart;
UV:=proc(V::Vector)
local r;
  r:=sqrt(add(V^~2));
  if r=0 then return <0,0,0> else V/r fi;
end proc:

PUV:=proc(V::Vector)
local r,inclination,azimuth;
  r:=sqrt(add(V^~2));
   if r = 0 then return <0,0,0> else
      inclination:=arccos(V[3]/r); azimuth:=arctan(V[2],V[1]);
      inclination:=inclination-(Pi/2);
      <sin(inclination)*cos(azimuth),sin(inclination)*sin(azimuth),
      cos(inclination)>
   fi;
end proc:
        

# Tests:

UV(<5,0,0>);
PUV(<5,0,0>);
PUV(<3,4,0>);
PUV(<2,2,1>);

Vector(3, {(1) = 1, (2) = 0, (3) = 0})

 

Vector(3, {(1) = 0, (2) = 0, (3) = 1})

 

Vector(3, {(1) = 0, (2) = 0, (3) = 1})

 

Vector[column](%id = 18446746539489454190)

(1)

plots:-fieldplot3d({PUV(<1, 0, 0>), UV(<1, 0, 0>)}, x = -1 .. 1, y = -1 .. 1, z = -1 .. 1, grid = [2, 2, 2], orientation = [160, 110, -100], arrows = `3-D`);
plots:-fieldplot3d(UV(<x, y, z>), x = -1 .. 1, y = -1 .. 1, z = -1 .. 1, grid = [4, 4, 4], orientation = [160, 110, -100], arrows = `3-D`);

 

 

plots:-fieldplot3d(PUV(<x, y, z>), x = -1 .. 1, y = -1 .. 1, z = -1 .. 1, grid = [4, 4, 4], orientation = [160, 110, -100], arrows = `3-D`);

 

 


 

Download PP.mw

According to Maple's help, in Maple there is no  Vector[col] , but there is  Vector[column]  (or Vector).
In Maple 2018.2, Vector[col] does not kill the session, but just an error message appears.

Apply the  simplify  command to this expression.

 It’s better to do all this programmatically:

g:=t->t*(cos(t)+I*sin(t));
D(g)(2*Pi);

                                    g := t -> t (cos(t) + I sin(t))
                                              1 + 2 I Pi

saw1.mw

restart;
f:=x->4*(x/2/Pi+1/2-floor(x/2/Pi+1/2)-1/2):
A:=plot(f(x), x=-3*Pi..3*Pi, scaling=constrained, color=red, size=[1000,300]);

   
 

a0:=1/Pi*int(f(x),x=-Pi..Pi);
a:=unapply(1/Pi*int(f(x)*cos(n*x),x=-Pi..Pi), n);
b:=unapply(1/Pi*int(f(x)*sin(n*x),x=-Pi..Pi),n);
g:=n->a0/2+add(a(k)*cos(k*x)+b(k)*sin(k*x), k=1..n);
F:=n->plots:-display(A,plot(g(n),x=-3*Pi..3*Pi, color=blue), plots:-textplot([1.2,2.5,N=n], font=[times,bold,18])):
plots:-display(A$5,seq(F(n)$5, n=1..5), seq(F(n), n=6..50), insequence, scaling=constrained, size=[1000,300], axes=none);

Edit.

Use the following procedure to generate all the primitive Pythagorean triples (see  https://en.wikipedia.org/wiki/Tree_of_primitive_Pythagorean_triples ). It is very fast.

NextTriple:=proc(L)
local i;
[seq(op([[L[i,1]-2*L[i,2]+2*L[i,3], 2*L[i,1]-L[i,2]+2*L[i,3], 2*L[i,1]-2*L[i,2]+3*L[i,3]], [L[i,1]+2*L[i,2]+2*L[i,3], 2*L[i,1]+L[i,2]+2*L[i,3], 2*L[i,1]+2*L[i,2]+3*L[i,3]],
[-L[i,1]+2*L[i,2]+2*L[i,3], -2*L[i,1]+L[i,2]+2*L[i,3], -2*L[i,1]+2*L[i,2]+3*L[i,3]]]), i=1..nops(L))];
end proc:


Examples of use:

seq((NextTriple@@n)([[3,4,5]])[], n=1..5);
CodeTools:-Usage(seq((NextTriple@@n)([[3,4,5]])[], n=1..10)):
nops([%]);

  

[5, 12, 13], [21, 20, 29], [15, 8, 17], [7, 24, 25], 

  [55, 48, 73], [45, 28, 53], [39, 80, 89], [119, 120, 169], 

  [77, 36, 85], [33, 56, 65], [65, 72, 97], [35, 12, 37], 

  [9, 40, 41], [105, 88, 137], [91, 60, 109], [105, 208, 233], 

  [297, 304, 425], [187, 84, 205], [95, 168, 193], 

  [207, 224, 305], [117, 44, 125], [57, 176, 185], 

  [377, 336, 505], [299, 180, 349], [217, 456, 505], 

  [697, 696, 985], [459, 220, 509], [175, 288, 337], 

  [319, 360, 481], [165, 52, 173], [51, 140, 149], 

  [275, 252, 373], [209, 120, 241], [115, 252, 277], 

  [403, 396, 565], [273, 136, 305], [85, 132, 157], 

  [133, 156, 205], [63, 16, 65]

memory used=37.52MiB, alloc change=0 bytes, cpu time=578.00ms, real time=629.00ms, gc time=0ns
                             88572
 

First, we turn the graph into directed, and then remove the unnecessary directions.

An example:


 

restart;
with(GraphTheory):
G:= SpecialGraphs:-PetersenGraph();
G1:=MakeDirected(G);
DrawGraph(G1);
Edges(G1);
DeleteArc(G1,remove(e->e[1]>e[2],Edges(G1)));
DrawGraph(G1);
 

GRAPHLN(undirected, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Array(%id = 18446746876727067342), `GRAPHLN/table/1`, 0)

 

GRAPHLN(directed, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Array(%id = 18446746876727067342), `GRAPHLN/table/2`, 0)

 

 

{[1, 2], [1, 5], [1, 6], [2, 1], [2, 3], [2, 9], [3, 2], [3, 4], [3, 7], [4, 3], [4, 5], [4, 10], [5, 1], [5, 4], [5, 8], [6, 1], [6, 7], [6, 10], [7, 3], [7, 6], [7, 8], [8, 5], [8, 7], [8, 9], [9, 2], [9, 8], [9, 10], [10, 4], [10, 6], [10, 9]}

 

GRAPHLN(directed, unweighted, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], Array(%id = 18446746876727067342), `GRAPHLN/table/2`, 0)

 

 

 


 

Download DirectedPeterson.mw


 

 

Why not immediately give numerical values to the parameters, and only then do all the calculations?
 

restart

Digits := 100

assign(alpha = 3.093676148361444, beta = 1.136458914000455*10^2, C1[1, 1] = 1.000000000000000, C1[1, 2] = 0, C1[1, 3] = -0.22069165109e-4, C1[1, 4] = 0, C1[2, 1] = .764799945371359, C1[2, 2] = 0.36674613077895e-1, C1[2, 3] = .95132568684786, C1[2, 4] = -.95132568684786);

y1 := C1[1, 1]*sin(alpha*x)+C1[1, 2]*cos(alpha*x)+C1[1, 3]*sinh(beta*x)+C1[1, 4]*cosh(beta*x)

1.000000000000000*sin(3.093676148361444*x)-0.22069165109e-4*sinh(113.645891400045500*x)

(1)

y2 := C1[2, 1]*sin(alpha*x)+C1[2, 2]*cos(alpha*x)+C1[2, 3]*sinh(beta*x)+C1[2, 4]*cosh(beta*x)

.764799945371359*sin(3.093676148361444*x)+0.36674613077895e-1*cos(3.093676148361444*x)+.95132568684786*sinh(113.645891400045500*x)-.95132568684786*cosh(113.645891400045500*x)

(2)

fun1 := int(y1^4, x = 0 .. 0.5e-1)+int(y2^4, x = 0.5e-1 .. 1)

.1308832003494291657430777664602299881224552490777598299889111954482828996588502290591220342036629305

(3)

``


 

Download question_(2)_new.mw

To find all the real roots in the specific interval using the  Student:-Calculus1:-Roots  command:

Student:-Calculus1:-Roots(0.6*10*35000^a+0.4*10*15000^a=1*10*26000^a, a=-10..10)[];

                             0.,  0.5008768259

Try using splines for this (CurveFitting:-Spline).

You can also use CurveFitting:-PolynomialInterpolation  command.  But  if you want your plot to look like the plot in the picture ((in particular, the part of the graph below Ox-axis does not have inflection points), then you need to reduce the values of your function at the points  x=3  and  x=4 .

An example:

restart;
XY:=[[-4,3],[-3.5,1.8],[-3,1],[-2,1],[-1,1],[0,0],[1,-1],[2,-1.62],[3,-2],[4,-2],[5,1]]:
f:=unapply(CurveFitting:-PolynomialInterpolation(XY, x), x);
plot(f(x), x = -4 .. 5.2, thickness=2, gridlines, size=[600,500]);

                   

Edit.

In a for-loop:

for i from 11 to 20 do
i^2;
od;


Directly (elementwise):

[$11..20]^~2;

 

If you want to create a matrix consisting of matrices, then here is an example of how to do it:


 

A:=<1,2; 3,4>;
B:=<5,6; 7,8>;
C:=<0,0; 0,0>;
L:=[[A,C],[C,B]];
Matrix(2,2, (i,j)->[[A,C],[C,B]][i,j]);
# Compare with
convert(L, Matrix);

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4})

 

Matrix(2, 2, {(1, 1) = 5, (1, 2) = 6, (2, 1) = 7, (2, 2) = 8})

 

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

 

[[Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4}), Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0})], [Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), Matrix(2, 2, {(1, 1) = 5, (1, 2) = 6, (2, 1) = 7, (2, 2) = 8})]]

 

Matrix(2, 2, {(1, 1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4}), (1, 2) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 1) = Matrix(2, 2, {(1, 1) = 0, (1, 2) = 0, (2, 1) = 0, (2, 2) = 0}), (2, 2) = Matrix(2, 2, {(1, 1) = 5, (1, 2) = 6, (2, 1) = 7, (2, 2) = 8})})

 

Matrix(%id = 18446746250364056870)

(1)

 


 

Download matrix_of_matrices.mw


 

restart;
f:=-x^4-2*y^4+14*x^2*y^2/5:
plot3d(f, x=-5..5,y=-5..5,
   axes     = boxed,
   axesfont = [Times,default,10],
   axis[1]  = [tickmarks=[3,subticks=5],thickness=0,color=red],
   axis[2]  = [tickmarks=[3,subticks=5],thickness=0,color=blue],
   axis[3]  = [tickmarks=[3,subticks=5],thickness=0,color=green],
   labeldirections = [horizontal, horizontal, horizontal],        
   labels   = ['x', 'y', 'z'],
   scaling  = unconstrained, view=[-5.2..5.2,-5.2..5.2,-1300..40]);

 

 


In Maple everything look a little better.
 

Download plot3d.mw


 

NULL

restart

g := proc (m, n) options operator, arrow; sum(sum(h(m-k, n-l)*f(k, l), l = 1 .. N), k = 1 .. N) end proc

proc (m, n) options operator, arrow; sum(sum(h(m-k, n-l)*f(k, l), l = 1 .. N), k = 1 .. N) end proc

(1)

NULL

Example; N := 7; g(4, 5)

h(0, 2)*f(4, 3)+h(0, 1)*f(4, 4)+h(0, 0)*f(4, 5)+h(0, -1)*f(4, 6)+h(0, -2)*f(4, 7)+h(-1, 4)*f(5, 1)+h(-1, 3)*f(5, 2)+h(-1, 2)*f(5, 3)+h(-1, 1)*f(5, 4)+h(-1, 0)*f(5, 5)+h(-1, -1)*f(5, 6)+h(-1, -2)*f(5, 7)+h(-2, 4)*f(6, 1)+h(-2, 3)*f(6, 2)+h(-2, 2)*f(6, 3)+h(-2, 1)*f(6, 4)+h(-2, 0)*f(6, 5)+h(-2, -1)*f(6, 6)+h(-2, -2)*f(6, 7)+h(-3, 4)*f(7, 1)+h(-3, 3)*f(7, 2)+h(-3, 2)*f(7, 3)+h(-3, 1)*f(7, 4)+h(-3, 0)*f(7, 5)+h(-3, -1)*f(7, 6)+h(-3, -2)*f(7, 7)+h(3, 4)*f(1, 1)+h(3, 3)*f(1, 2)+h(3, 2)*f(1, 3)+h(3, 1)*f(1, 4)+h(3, 0)*f(1, 5)+h(3, -1)*f(1, 6)+h(3, -2)*f(1, 7)+h(2, 4)*f(2, 1)+h(2, 3)*f(2, 2)+h(2, 2)*f(2, 3)+h(2, 1)*f(2, 4)+h(2, 0)*f(2, 5)+h(2, -1)*f(2, 6)+h(2, -2)*f(2, 7)+h(1, 4)*f(3, 1)+h(1, 3)*f(3, 2)+h(1, 2)*f(3, 3)+h(1, 1)*f(3, 4)+h(1, 0)*f(3, 5)+h(1, -1)*f(3, 6)+h(1, -2)*f(3, 7)+h(0, 4)*f(4, 1)+h(0, 3)*f(4, 2)

(2)

NULL


 

Download convolution_new.mw

We use polar coordinates for this. One focus of the conic is at the origin. The eccentricity   varies from 0 to   in increments of  0.02. When e = 1 we get a parabola. Different types of conics are made in different colors:

 

restart;
A:=plots:-animate(plot,[1/(1-e*cos(phi)), phi=0..2*Pi, color=blue, thickness=2, coords=polar, caption="Ellipse", captionfont=[times,bold,20]],e=0..0.98, frames=50):
B:=plots:-animate(plot,[1/(1-e*cos(phi)), phi=0..2*Pi, color=red,thickness=2,coords=polar, caption="Parabola", captionfont=[times,bold,20]],e=1..1, frames=15):
C:=plots:-animate(plot,[1/(1-e*cos(phi)), phi=0..2*Pi, color=green,thickness=2,coords=polar, discont, caption="Hyperbole", captionfont=[times,bold,20]],e=1.02..2, frames=50):
plots:-display([A,B,C], insequence=true, scaling=constrained, view=[-7..20,-7..7], size=[1000,450]);

 

 


 

Download conics_animation.mw

First 59 60 61 62 63 64 65 Last Page 61 of 290