Kitonum

21500 Reputation

26 Badges

17 years, 59 days

MaplePrimes Activity


These are answers submitted by Kitonum

Examples.

Code in 1d math:
A:=<1,2; -1,5>;
LinearAlgebra:-Determinant(A);


Code in 2d math:
A:=<1,2; -1,5>;
|A|;

You probably have 2d math by default. Therefore, use the second example.


Edit. If you are not allowed to use a Maple procedure, here is a user-defined recursive procedure that evaluates the determinant of a matrix:

MyDet:=proc(A::Matrix)
local m,n;
m,n:=op(1,A);
if m<>n then error "The Matrix should be square" fi;
if m=1 then return A[1,1] else
add(A[1,k]*(-1)^(1+k)*MyDet(A[2..m,[seq(`if`(j<>k,j,NULL), j=1..n)]]),k=1..n) fi;
end proc:

Example of use:
A:=<1,2,3;4,5,6;7,8,10>;
MyDet(A);

 

You can calculate this integral numerically using a simple procedure as follows:

Int1 := (b,k,r,R)->evalf(Int(exp(-z*(R^2*k^2 - b^2*z)/(R*b))/(z*HeunB(0, k^2*R^2/(b*sqrt(R*b)), R^3*k^4/(4*b^3), 0, -sqrt(R*b)*z/R)^2), z = R .. r));


Example of use:

Int1(0.5, 1, 2, 0.9);
                                             
  1.462594758

 


 

restart;
with(geom3d): with(plots):
cA:=[1,2,3]:
point(A,cA):
v:=[1,2,2]:
cC:=[10,11,12]:
point(C,cC):
point(E,v+cA):
line(AB,[A,E]):
projection(B,C,AB):
cB:=coordinates(B); # Coordinates of B. The angle ABC=90 degrees
Curve:=plottools:-curve([cA,cB,cC], color=red,thickness=3):
T:=textplot3d([[cA[],"A"],[cB[],"B"],[cC[],"C"]], font=[times,18], align=right):
display(Curve,T, axes=normal, labels=[x,y,z], view=[0..14,0..14,0..15], orientation=[-45,75]);

[6, 12, 13]

 

 

 

 

Addition. Below I made an animation of this travel (continuation of the above code). The first frame shows the initially given points  A  and  C  and a green vector that determines the direction of movement:

Back:=display(textplot3d([cA[],"A"], font=[times,18], align=right),textplot3d([cC[],"C"], font=[times,18], align=right),arrow([1,2,4],v,color=green),pointplot3d([cA,cC],symbol=solidsphere,color=red,symbolsize=17)):
Anim1:=animate((display@plottools:-line),[cA,cA+~t*~(cB-cA), color=red,thickness=3],t=0..1,background=Back,paraminfo=false):
Anim2:=animate(display,[textplot3d([cB[],"B"], font=[times,18], align=right)],a=0..1,frames=5,background=display(Back,pointplot3d(cB,symbol=solidsphere,color=red,symbolsize=17)),paraminfo=false):
Anim3:=animate((display@plottools:-line),[cB,cB+~t*~(cC-cB), color=red,thickness=3],t=0..1,background=display(Back,pointplot3d(cB,symbol=solidsphere,color=red,symbolsize=17)),paraminfo=false):
display([Anim1, display(op([1,-1,1],Anim1),Anim2), display(op([1,-1,1],Anim1),op([1,-1,1],Anim2),Anim3)], insequence, axes=normal, labels=[x,y,z], view=[0..14,0..14,0..15], orientation=[-45,75]);

                      

Edit.

Download travel.mw

Below is an example of solving your problem for a set of 10 random vectors:


 

restart;
with(LinearAlgebra):
n := 10:
v:={seq(RandomVector(n),k=1..n)};
for i to n do
for j to n do
r[i,j] := DotProduct(v[i], v[j]);
end do:
end do:
A:=Matrix(n, (i,j)->r[i,j]);
b:={seq(<seq(`if`(i=j,1,0),i=1..n)>,j=1..n)};
for k from 1 to n do
LinearSolve(A,b[k]);
od;

{Vector(10, {(1) = -4, (2) = 27, (3) = 8, (4) = 69, (5) = 99, (6) = 29, (7) = 44, (8) = 92, (9) = -31, (10) = 67}), Vector(10, {(1) = -98, (2) = -77, (3) = 57, (4) = 27, (5) = -93, (6) = -76, (7) = -72, (8) = -2, (9) = -32, (10) = -74}), Vector(10, {(1) = -16, (2) = -9, (3) = -50, (4) = -22, (5) = 45, (6) = -81, (7) = -38, (8) = -18, (9) = 87, (10) = 33}), Vector(10, {(1) = 31, (2) = -50, (3) = -80, (4) = 43, (5) = 25, (6) = 94, (7) = 12, (8) = -2, (9) = 50, (10) = 10}), Vector(10, {(1) = 76, (2) = -44, (3) = 24, (4) = 65, (5) = 86, (6) = 20, (7) = -61, (8) = -48, (9) = 77, (10) = 9}), Vector(10, {(1) = 22, (2) = 14, (3) = 16, (4) = 9, (5) = 99, (6) = 60, (7) = -95, (8) = -20, (9) = -25, (10) = 51}), Vector(10, {(1) = 82, (2) = 72, (3) = 42, (4) = 18, (5) = -59, (6) = 12, (7) = -62, (8) = -33, (9) = -68, (10) = -67}), Vector(10, {(1) = -82, (2) = -70, (3) = 41, (4) = 91, (5) = 29, (6) = 70, (7) = -32, (8) = -1, (9) = 52, (10) = -13}), Vector(10, {(1) = 12, (2) = 45, (3) = -14, (4) = 60, (5) = -35, (6) = 21, (7) = 90, (8) = 80, (9) = 19, (10) = 88}), Vector(10, {(1) = -38, (2) = 91, (3) = -1, (4) = 63, (5) = -23, (6) = -63, (7) = -26, (8) = 30, (9) = 10, (10) = 22})}

 

Matrix(10, 10, {(1, 1) = 32062, (1, 2) = -18097, (1, 3) = -3805, (1, 4) = 5518, (1, 5) = 3395, (1, 6) = 10752, (1, 7) = -10444, (1, 8) = 5963, (1, 9) = 18966, (1, 10) = 5624, (2, 1) = -18097, (2, 2) = 45624, (2, 3) = -1666, (2, 4) = -15256, (2, 5) = -9097, (2, 6) = -11940, (2, 7) = 5539, (2, 8) = 11807, (2, 9) = -15920, (2, 10) = 5152, (3, 1) = -3805, (3, 2) = -1666, (3, 3) = 22333, (3, 4) = 779, (3, 5) = 8978, (3, 6) = 1597, (3, 7) = -13260, (3, 8) = -1146, (3, 9) = -4796, (3, 10) = 4565, (4, 1) = 5518, (4, 2) = -15256, (4, 3) = 779, (4, 4) = 23919, (4, 5) = 12765, (4, 6) = 5364, (4, 7) = -8739, (4, 8) = 10984, (4, 9) = 5671, (4, 10) = -9088, (5, 1) = 3395, (5, 2) = -9097, (5, 3) = 8978, (5, 4) = 12765, (5, 5) = 32344, (5, 6) = 17028, (5, 7) = -65, (5, 8) = 13528, (5, 9) = -7169, (5, 10) = -4945, (6, 1) = 10752, (6, 2) = -11940, (6, 3) = 1597, (6, 4) = 5364, (6, 5) = 17028, (6, 6) = 27069, (6, 7) = 3358, (6, 8) = 6859, (6, 9) = -7132, (6, 10) = -2326, (7, 1) = -10444, (7, 2) = 5539, (7, 3) = -13260, (7, 4) = -8739, (7, 5) = -65, (7, 6) = 3358, (7, 7) = 31667, (7, 8) = -9923, (7, 9) = -8375, (7, 10) = 3597, (8, 1) = 5963, (8, 2) = 11807, (8, 3) = -1146, (8, 4) = 10984, (8, 5) = 13528, (8, 6) = 6859, (8, 7) = -9923, (8, 8) = 31225, (8, 9) = -1909, (8, 10) = -1603, (9, 1) = 18966, (9, 2) = -15920, (9, 3) = -4796, (9, 4) = 5671, (9, 5) = -7169, (9, 6) = -7132, (9, 7) = -8375, (9, 8) = -1909, (9, 9) = 30236, (9, 10) = 9101, (10, 1) = 5624, (10, 2) = 5152, (10, 3) = 4565, (10, 4) = -9088, (10, 5) = -4945, (10, 6) = -2326, (10, 7) = 3597, (10, 8) = -1603, (10, 9) = 9101, (10, 10) = 20353})

 

{Vector(10, {(1) = 0, (2) = 1, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 1, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 1, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 1, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 1, (7) = 0, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 1, (8) = 0, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 1, (9) = 0, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 1, (10) = 0}), Vector(10, {(1) = 0, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 1}), Vector(10, {(1) = 1, (2) = 0, (3) = 0, (4) = 0, (5) = 0, (6) = 0, (7) = 0, (8) = 0, (9) = 0, (10) = 0})}

 

Vector(10, {(1) = -169940627196643188173250621881657584/3333547558892792316326860475095188301281, (2) = 438026116953033673491749651259969398/3333547558892792316326860475095188301281, (3) = -255050655414275755117405748891870924/1111182519630930772108953491698396100427, (4) = 321932118691131726869875294618205828/3333547558892792316326860475095188301281, (5) = 1373007510492486338571703243596691381/10000642676678376948980581425285564903843, (6) = 747013636376063522651945674611425393/10000642676678376948980581425285564903843, (7) = -2060388964494020122812732971561496625/10000642676678376948980581425285564903843, (8) = -2173743860677148792959428210659703455/10000642676678376948980581425285564903843, (9) = -174471584431899531206175168402642992/10000642676678376948980581425285564903843, (10) = 1444242593438633980829648335458654119/10000642676678376948980581425285564903843})

 

Vector(10, {(1) = 1444596370393643795663657369223363565/1111182519630930772108953491698396100427, (2) = -255050655414275755117405748891870924/1111182519630930772108953491698396100427, (3) = 1534044373457897082633999211394432681/370394173210310257369651163899465366809, (4) = -728793562328856727163725938018453137/1111182519630930772108953491698396100427, (5) = -6560785066626605559730816310705979742/3333547558892792316326860475095188301281, (6) = -1307038354010666035621572964279006916/3333547558892792316326860475095188301281, (7) = 11432271112122380451150698256840671440/3333547558892792316326860475095188301281, (8) = 7240003439562011873115885649707241277/3333547558892792316326860475095188301281, (9) = 4307716103241319177019439520131116594/3333547558892792316326860475095188301281, (10) = -10196587190892403108667772162844874246/3333547558892792316326860475095188301281})

 

Vector(10, {(1) = -553747022398847550376914830165188765/3333547558892792316326860475095188301281, (2) = 321932118691131726869875294618205828/3333547558892792316326860475095188301281, (3) = -728793562328856727163725938018453137/1111182519630930772108953491698396100427, (4) = 807727579768600763538411253926322109/3333547558892792316326860475095188301281, (5) = 2955381534487965632821946669557887205/10000642676678376948980581425285564903843, (6) = 672137958930191555765459293274927729/10000642676678376948980581425285564903843, (7) = -5409031460679218311654077878548784116/10000642676678376948980581425285564903843, (8) = -4165921848281552032382236434807053084/10000642676678376948980581425285564903843, (9) = -2435428918851862032645110967726426638/10000642676678376948980581425285564903843, (10) = 5279433586732602863623081201297458950/10000642676678376948980581425285564903843})

 

Vector(10, {(1) = -6089424356846919618691889209584310022/10000642676678376948980581425285564903843, (2) = 1373007510492486338571703243596691381/10000642676678376948980581425285564903843, (3) = -6560785066626605559730816310705979742/3333547558892792316326860475095188301281, (4) = 2955381534487965632821946669557887205/10000642676678376948980581425285564903843, (5) = 30215827736203602261153919318064177033/30001928030035130846941744275856694711529, (6) = 5055588371266268897855032602292325788/30001928030035130846941744275856694711529, (7) = -49111297480496176786983838817155882853/30001928030035130846941744275856694711529, (8) = -32026399386511462313633880057613461970/30001928030035130846941744275856694711529, (9) = -17668095295597160944549473989045528977/30001928030035130846941744275856694711529, (10) = 43184486861802787480990070734696380223/30001928030035130846941744275856694711529})

 

Vector(10, {(1) = -1896635471332301415246266173554991447/10000642676678376948980581425285564903843, (2) = 747013636376063522651945674611425393/10000642676678376948980581425285564903843, (3) = -1307038354010666035621572964279006916/3333547558892792316326860475095188301281, (4) = 672137958930191555765459293274927729/10000642676678376948980581425285564903843, (5) = 5055588371266268897855032602292325788/30001928030035130846941744275856694711529, (6) = 5061965802144761655234083774167612976/30001928030035130846941744275856694711529, (7) = -10580692178203965570258155064558820282/30001928030035130846941744275856694711529, (8) = -7208570838193627200761366038417646429/30001928030035130846941744275856694711529, (9) = -914785146010439354612575644148944323/30001928030035130846941744275856694711529, (10) = 8061805054400226598119349381651835306/30001928030035130846941744275856694711529})

 

Vector(10, {(1) = 10978357018694769689586425142939989348/10000642676678376948980581425285564903843, (2) = -2060388964494020122812732971561496625/10000642676678376948980581425285564903843, (3) = 11432271112122380451150698256840671440/3333547558892792316326860475095188301281, (4) = -5409031460679218311654077878548784116/10000642676678376948980581425285564903843, (5) = -49111297480496176786983838817155882853/30001928030035130846941744275856694711529, (6) = -10580692178203965570258155064558820282/30001928030035130846941744275856694711529, (7) = 86705758406270899696398690745449316325/30001928030035130846941744275856694711529, (8) = 54714960637923616413173393748478553584/30001928030035130846941744275856694711529, (9) = 31716352822790087515476694661311719316/30001928030035130846941744275856694711529, (10) = -76196986898355930908122137844172835862/30001928030035130846941744275856694711529})

 

Vector(10, {(1) = 6501472839008909517373180105039964584/10000642676678376948980581425285564903843, (2) = -2173743860677148792959428210659703455/10000642676678376948980581425285564903843, (3) = 7240003439562011873115885649707241277/3333547558892792316326860475095188301281, (4) = -4165921848281552032382236434807053084/10000642676678376948980581425285564903843, (5) = -32026399386511462313633880057613461970/30001928030035130846941744275856694711529, (6) = -7208570838193627200761366038417646429/30001928030035130846941744275856694711529, (7) = 54714960637923616413173393748478553584/30001928030035130846941744275856694711529, (8) = 38076885517626475485820145391873957980/30001928030035130846941744275856694711529, (9) = 19735654892384487399815395178936984093/30001928030035130846941744275856694711529, (10) = -48034935442267507881933877976167951598/30001928030035130846941744275856694711529})

 

Vector(10, {(1) = 3243743941590239649499233081844476928/10000642676678376948980581425285564903843, (2) = -174471584431899531206175168402642992/10000642676678376948980581425285564903843, (3) = 4307716103241319177019439520131116594/3333547558892792316326860475095188301281, (4) = -2435428918851862032645110967726426638/10000642676678376948980581425285564903843, (5) = -17668095295597160944549473989045528977/30001928030035130846941744275856694711529, (6) = -914785146010439354612575644148944323/30001928030035130846941744275856694711529, (7) = 31716352822790087515476694661311719316/30001928030035130846941744275856694711529, (8) = 19735654892384487399815395178936984093/30001928030035130846941744275856694711529, (9) = 16952051890782578403396087337143058523/30001928030035130846941744275856694711529, (10) = -30542842685315282730217057837522272665/30001928030035130846941744275856694711529})

 

Vector(10, {(1) = -9556691286151430205379204226660264341/10000642676678376948980581425285564903843, (2) = 1444242593438633980829648335458654119/10000642676678376948980581425285564903843, (3) = -10196587190892403108667772162844874246/3333547558892792316326860475095188301281, (4) = 5279433586732602863623081201297458950/10000642676678376948980581425285564903843, (5) = 43184486861802787480990070734696380223/30001928030035130846941744275856694711529, (6) = 8061805054400226598119349381651835306/30001928030035130846941744275856694711529, (7) = -76196986898355930908122137844172835862/30001928030035130846941744275856694711529, (8) = -48034935442267507881933877976167951598/30001928030035130846941744275856694711529, (9) = -30542842685315282730217057837522272665/30001928030035130846941744275856694711529, (10) = 70708764784499688905224488367889438051/30001928030035130846941744275856694711529})

 

Vector[column](%id = 18446745359583314878)

(1)

 


 

Download GramMat_new1.mw

by the series command.

Example:

N:=10:
series(cos(x)^n, x=0, N);

        1-(1/2)*n*x^2+(-(1/12)*n+(1/8)*n^2)*x^4+(-(1/45)*n+(1/24)*n^2-  (1/48)*n^3)*x^6+(-17/2520*n+7/480*(n^2)-(1/96)*n^3+(1/384)*n^4)*x^8+O(x^10)

on a simple example from a help:

restart;
with(plots): 
A := Matrix([[2, 1, 0, 0, 3], [0, 2, 1, 0, 0], [0, 0, 2, 1, 0], [0, 0, 0, 2, 1], [0, 0, 0, 0, 2]]);
S := [([1, 2, 3, 4, 5]=~StringTools:-Char~(96+~[$1..5]))[]];
sparsematrixplot(A, matrixview, tickmarks = [S, map(t->-lhs(t) = rhs(t) , S)]);

                                     

As far as I know, Maple does not implement a step-by-step solution of differential equations. However, you can find out the type of your equation, for example:

DEtools:-odeadvisor(diff(y(x),x)=(x^2+1)*sin(y(x)), y(x));

 Output:                          [_separable]


For details see help on  ?dsolve,details

Try the following, where  Expr  is your expression to be simplified. If this does not help, then upload your worksheet here.

map(simplify, Expr);


The  map  command forces the application of the  simplify  command separately to each operand of the expression.


Edit.

We see that the sequence  f1(k)  is the sequence of even numbers, starting with 2. Therefore, the sum of the corresponding series is equal to infinity:

H := r->piecewise(r < 1, 1, 0);
f1 := k-> sum(2*(1-H(j)), j = 0 .. k);
seq(f1(k), k=1..10);
expand(sum(2*k, k=1..n));
sum(2*k, k=1..infinity);

                             

 

 

 

If you need to plot a graph of the dependence of the real roots of the equation on a parameter, then it is not necessary to solve this equation first (this is not always possible explicitly). The easiest way to use the  plots:-implicitplot  command for this.
Below your example is solved in two versions: first in the range a in  0 .. 1 , and then in a wider range  a in  -0.5 .. 2.5. For the range  0 .. 1, we see that there are 2 roots close to 0 and one positive root, significantly superior to the first two:

restart;

A:=plots:-implicitplot(x^3+(a-3)^3*x^2-x*a^2+a^3 = 0, a=0..1, x=-1..30, color=red, grid=[100,20000], axes=box):
B:=plots:-implicitplot(x^3+(a-3)^3*x^2-x*a^2+a^3 = 0, a=0..1, x=-1..1, color=red, thickness=2, gridrefine=4):
plots:-display(< A | B >);

C:=plots:-implicitplot(x^3+(a-3)^3*x^2-x*a^2+a^3 = 0, a=-0.5..2.5, x=-100..100, color=red, thickness=2, gridrefine=3, axes=box):

plots:-display(C, B, size=[800,400]);

          

                      

Addition. In your problem it is interesting to find values of the parameter a , at which the number of real roots changes. Visually, these are 0 and 1.8 (approximately). Next, we find the exact values using the discriminant:

d:=discrim(x^3+(a-3)^3*x^2-x*a^2+a^3, x);
solve(d);
select(type, {%}, realcons);
evalf(%);

 The final results:                  
                  {0, -(1/6)*(324+12*sqrt(741))^(1/3)+2/(324+12*sqrt(741))^(1/3)+3}
                                                   {0., 1.786588337}

Classic worksheet exists only in 32 bit Maple version.

If a polynomial has degree greater than 4, then its roots in the general case are not expressed in radicals. In this case, you can use the  solve  command with subsequent selection of the roots (by select command) or the  Student:-Calculus1:-Roots  command, which immediately returns the real roots:


 

restart;

solve(x^6-3*x-5);
evalf([%]);
select(r->Im(r)=0, %);

# Or
Student:-Calculus1:-Roots(x^6-3*x-5, numeric);

RootOf(_Z^6-3*_Z-5, index = 1), RootOf(_Z^6-3*_Z-5, index = 2), RootOf(_Z^6-3*_Z-5, index = 3), RootOf(_Z^6-3*_Z-5, index = 4), RootOf(_Z^6-3*_Z-5, index = 5), RootOf(_Z^6-3*_Z-5, index = 6)

 

[1.451571465, .5973639664+1.275126159*I, -.7760033304+.9926461157*I, -1.094292737, -.7760033304-.9926461157*I, .5973639664-1.275126159*I]

 

[1.451571465, -1.094292737]

 

[-1.094292737, 1.451571465]

(1)

 


 

Download real_roots.mw

Since your equation allows a symbolic (analytical) solution, we first obtain this solution, and then look for a maximum at a suitable interval. I think that with the same Digits, this approach gives a more accurate result:

restart;
Eq := {diff(y(t), t, t) + 2*diff(y(t), t) + 4*y(t) = 0.9*sin(9*t), y(0) = 0, D(y)(0) = 0}:
Sol:=dsolve(Eq);
plot(eval(y(t),Sol), t=0..10);
Optimization:-Maximize(eval(y(t),Sol), t=0..1);
Digits:=25:
Optimization:-Maximize(eval(y(t),Sol), t=0..1);

     

 

value(Diff(x,x));

sum(diff(x^k,x)/k! , k=1..infinity);


diff( m(x+ diff(...) ...) / diff ?  Write the full code for this!

I do not  know  Adomian decomposition method. You can just use the  pdsolve  command for this:

pdsolve(diff(U(x,t), x, t) = U(x,t));

 

First 74 75 76 77 78 79 80 Last Page 76 of 290