Kitonum

15369 Reputation

24 Badges

12 years, 105 days

MaplePrimes Activity


These are answers submitted by Kitonum

Your matrix equation  S*A*inverse(S)=A  is equivalent to  S*A-A*S=0  provided that  det(S)<>0 .
The solution is below:


 

restart;
A:=Matrix([[1,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]):
S:=Matrix([[a,b,c,d],[e,f,g,h],[i,j,k,l],[m,n,o,p]]):
S.A-A.S;

Matrix(4, 4, {(1, 1) = 0, (1, 2) = -b, (1, 3) = -c, (1, 4) = -d, (2, 1) = e, (2, 2) = 0, (2, 3) = 0, (2, 4) = 0, (3, 1) = i, (3, 2) = 0, (3, 3) = 0, (3, 4) = 0, (4, 1) = m, (4, 2) = 0, (4, 3) = 0, (4, 4) = 0})

(1)

S:=<a,0,0,0; 0,f,g,h; 0,j,k,l; 0,n,o,p>;
LinearAlgebra:-Determinant(S);

Matrix(4, 4, {(1, 1) = a, (1, 2) = 0, (1, 3) = 0, (1, 4) = 0, (2, 1) = 0, (2, 2) = f, (2, 3) = g, (2, 4) = h, (3, 1) = 0, (3, 2) = j, (3, 3) = k, (3, 4) = l, (4, 1) = 0, (4, 2) = n, (4, 3) = o, (4, 4) = p})

 

a*(f*k*p-f*l*o-g*j*p+g*l*n+h*j*o-h*k*n)

(2)

# Answer: S is any matrix above under the condition
%<>0;

a*(f*k*p-f*l*o-g*j*p+g*l*n+h*j*o-h*k*n) <> 0

(3)

S.A.S^(-1);  # Check

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

(4)

 


 

Download ME.mw

Let  k=theta/V  so  theta=k*V .

isolate(subs(theta = k*V, (1/3)*m*a^2*theta*s^2+(1/16)*m*g*a*sqrt(2)*(4+4*theta-Pi)+theta*B*s = (-K__m^2*s*theta+K__m*V)/(L*s+R)), k);
 ;

                 

In real domain use the  surd  function for this:

 

Example: Verifying Inverse Functions Graphically

 

NULL

"ex17f5(x):=2 x^(3)-1:"

"ex17g5(x):=surd((x+1)/(2),3):  plot([ex17f5(x),ex17g5(x)], x=-4..6, y=-4..6, scaling=constrained);"

 

NULL


The reason that the blue curve is not completely plotted in your document  is that Maple, for a negative number of the three possible values of the cubic root, returns the principal value of the cubic root (with the smallest argument). Compare:
 

simplify((-8)^(1/3)); 
surd(-8, 3)


Download inverseExample_new.mw

In fact, all your functions depend only on the variable  t . I made all the necessary simplifications and changes. In particular, I replaced  combine  with  simplify  with the option  size , because it turns out a more compact expression:

 

restartNULL

V__2six := proc (t) options operator, arrow; diff(x(t), t)-(l__1*sin(`&theta;__si`(t))-l__2c*sin(`&beta;__si`(t)+`&theta;__si`(t)))*cos(psi(t))*(diff(psi(t), t))-sin(psi(t))*(l__1*cos(`&theta;__si`(t))*(diff(`&theta;__si`(t), t))-`l__2&scy;`*cos(`&beta;__si`(t)+`&theta;__si`(t))*(diff(`&theta;__si`(t), t)+diff(`&beta;__si`(t), t))) end proc

proc (t) options operator, arrow; diff(x(t), t)-(l__1*sin(theta__si(t))-l__2c*sin(beta__si(t)+theta__si(t)))*cos(psi(t))*(diff(psi(t), t))-sin(psi(t))*(l__1*cos(theta__si(t))*(diff(theta__si(t), t))-`l__2с`*cos(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))) end proc

(1)

V__2siy := proc (t) options operator, arrow; -l__1*sin(`&theta;__si`(t))*(diff(`&theta;__si`(t), t))-`l__2&scy;`*sin(`&beta;__si`(t)+`&theta;__si`(t))*(diff(`&theta;__si`(t), t)+diff(`&beta;__si`(t), t)) end proc

proc (t) options operator, arrow; -l__1*sin(theta__si(t))*(diff(theta__si(t), t))-`l__2с`*sin(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t)) end proc

(2)

V__2siz := proc (t) options operator, arrow; diff(z(t), t)+(l__1*sin(`&theta;__si`(t))+l__2c*sin(`&beta;__si`(t)+`&theta;__si`(t)))*sin(psi(t))*(diff(psi(t), t))-cos(psi(t))*(l__1*cos(`&theta;__si`(t))*(diff(`&theta;__si`(t), t))+`l__2&scy;`*cos(`&beta;__si`(t)+`&theta;__si`(t))*(diff(`&theta;__si`(t), t)+diff(`&beta;__si`(t), t))) end proc

proc (t) options operator, arrow; diff(z(t), t)+(l__1*sin(theta__si(t))+l__2c*sin(beta__si(t)+theta__si(t)))*sin(psi(t))*(diff(psi(t), t))-cos(psi(t))*(l__1*cos(theta__si(t))*(diff(theta__si(t), t))+`l__2с`*cos(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))) end proc

(3)

V__2si := proc (t) options operator, arrow; simplify((V__2six^2+V__2siy^2+V__2siz^2)(t), size) end proc

proc (t) options operator, arrow; simplify((V__2six^2+V__2siy^2+V__2siz^2)(t), size) end proc

(4)

V__2si(t)

(-`l__2с`*sin(psi(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))*cos(beta__si(t)+theta__si(t))+l__1*cos(psi(t))*(diff(psi(t), t))*sin(theta__si(t))+l__1*sin(psi(t))*cos(theta__si(t))*(diff(theta__si(t), t))-l__2c*cos(psi(t))*(diff(psi(t), t))*sin(beta__si(t)+theta__si(t))-(diff(x(t), t)))^2+(`l__2с`*sin(beta__si(t)+theta__si(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))+l__1*sin(theta__si(t))*(diff(theta__si(t), t)))^2+(`l__2с`*cos(psi(t))*(diff(theta__si(t), t)+diff(beta__si(t), t))*cos(beta__si(t)+theta__si(t))+l__1*cos(psi(t))*cos(theta__si(t))*(diff(theta__si(t), t))-l__1*sin(psi(t))*(diff(psi(t), t))*sin(theta__si(t))-l__2c*sin(psi(t))*(diff(psi(t), t))*sin(beta__si(t)+theta__si(t))-(diff(z(t), t)))^2

(5)

``

``


 

Download equations_new.mw

You must specify a sequence step, for example:

f := unapply(3*x^2-2*x^3-1.080674649*x^2*(x-1)^2-.8118769171*x^2*(x-1)^3+.4147046974*x^2*(x-1)^4+.4585681954*x^2*(x-1)^5, x):
ma := seq(f(x), x = 0..1, 0.1);

             ma := 0., 0.02517819625, 0.09374594496, 0.1954298021, 0.3207056009, 0.4607261850, 0.6065902371, 0.7481833253, 0.8728222816, 0.9639340323, 1.000

restart;	
f:=(x,y)->sin(x)*cos(y):
g:=(x,y)->sin(y)*cos(x):
v:=(x,y)->combine(f(x,y)-g(x,y)):
v(x,y);

                                

alpha:=1: dT:=Th-Tc: n:=1:
plot([[Th-273,subs(Tc=400,n*alpha*dT/2),Th=300..700],[Th-273,subs(Tc=500,n*alpha*dT/2),Th=300..700]]);

 

Eq1.mw

restart;
V:=Vector[row]([x,y,z]):
M:=Matrix([seq(seq([`if`(y<>0,eval(solve(x*'y'+'z'=0,x),['y'=y,'z'=z]),undefined),y,z], y=-1..5),z=0..5)]):
interface(rtablesize=50):
<V; M>;

                                           


PS. "undefined" means that if  y=0  then there is no unique value  x  satisfying this equation. However, this case splits into 2 subcase: if  z = 0 , then  x  can be any number, and if  z<>0 , then this  x  does not exist. Below is a version of the code that takes these options into account:

restart;
V:=Vector[row]([x,y,z]):
M:=Matrix([seq(seq([`if`(y<>0,eval(solve(x*'y'+'z'=0,x),['y'=y,'z'=z]),`if`(z<>0,`not exist`,any)),y,z], y=-1..5),z=0..5)]):
interface(rtablesize=50):
<V; M>;

 

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


 

 
First 8 9 10 11 12 13 14 Last Page 10 of 239