Kitonum

21440 Reputation

26 Badges

17 years, 36 days

MaplePrimes Activity


These are answers submitted by Kitonum

Probably you are using an older version of the package,  which in fact does not have  DirectSearch:-SolveEquations  command. Here's a link to the new version  http://www.maplesoft.com/applications/view.aspx?SID=101333

The easiest way to solve your problem by using a special procedure. The procedure  RootsToTrig  is based on the formulas in your link. The construction  ``(...)  used to prevent premature cosine computation in some cases.

RootsToTrig:=proc(P::polynom)

local P1, A, B, C, Q, R, Discr, F, theta, x;

x:=op(indets(P));

P1:=P/coeff(P,x^3);

A:=coeff(P1,x^2); B:=coeff(P1,x); C:=coeff(P1,x,0);

Q:=simplify(3*B-A^2)/9; R:=simplify(9*A*B-27*C-2*A^3)/54; Discr:=Q^3+R^2;

if is(Discr>=0) then error "Should be discriminant<0" fi;

F:=simplify(R/sqrt(-Q^3));

theta:=arccos(F);

x[1]=2*sqrt(-Q)*cos(``(theta/3))-A/3, x[2]=2*sqrt(-Q)*cos(``(theta/3+2*Pi/3))-A/3, x[3]=2*sqrt(-Q)*cos(``(theta/3+4*Pi/3))-A/3;

end proc: 

 

Examples of uses (all angles are expressed in radians):

RootsToTrig(5*x^3-4*x+1);

RootsToTrig(5*x^3-4*x+2);

 

 Here is the version of the same procedure with degrees:

restart;

RootsToTrig1:=proc(P::polynom)

local P1, A, B, C, Q, R, Discr, F, theta, x;

x:=op(indets(P));

P1:=P/coeff(P,x^3);

A:=coeff(P1,x^2); B:=coeff(P1,x); C:=coeff(P1,x,0);

Q:=simplify(3*B-A^2)/9; R:=simplify(9*A*B-27*C-2*A^3)/54; Discr:=Q^3+R^2;

if is(Discr>=0) then error "Should be discriminant<0" fi;

F:=simplify(R/sqrt(-Q^3));

theta:=arccos(F);

x[1]=2*sqrt(-Q)*cos(theta/3*180*degrees/Pi)-A/3, x[2]=2*sqrt(-Q)*cos((theta/3+2*Pi/3)*180*degrees/Pi)-A/3, x[3]=2*sqrt(-Q)*cos((theta/3+4*Pi/3)*180*degrees/Pi)-A/3;

end proc: 

 

Example:

RootsToTrig1((x-1)*(x-2)*(x-3));

 

 

There is no  evaluate  command in Maple (there is  eval  command). Removal (or expansion) of parentheses in different meanings expand command carries out.

 

Examples:

restart;

L:=[x*(x+y), (x+y)^5, sin(3*x), cos(x+y), (x+y)/z, 2^(x-y), Int(f(x)+g(x),x)]:

for l in L do

expand(l);

od;

 

 

restart;

solve({x+y-3, x^2+y^2-5}, {x, y}):

a,b:= eval([x, y], %[1])[]:

a, b;

                    2, 1

Array( [seq(plot(p, x = -Pi .. Pi, -1.4 .. 1.4, scaling = constrained), p = [sin(x), cos(x)])]);
plots[display](%);

You can just copy and paste the sign (below I put this sign in this way)

         ▪

of the Word. In the Word menu  Insert->Symbols->Other Symbols . The number of the sign in Unicode is  25AA .

 

Addition:  long to not look for this sign, you can just type in the Word  25AA , select it and then  alt+x

 

 

  

 

This  is equivalent to the union of two plots  r=-sqrt(5-4*cos(theta))  and  r=sqrt(5-4*cos(theta)) :

 

plots[polarplot]([-sqrt(5-4*cos(theta)), sqrt(5-4*cos(theta))], theta = 0 .. 2*Pi, color = red, thickness = 2);

 

 

In this example, it is more convenient to use  surd  command.  surd(a,3)  means  the cubic root in the real domain. The results are displayed in a more compact form.

Compare:

restart;

de := diff(y(x), x) = 3*abs(y(x))^(2/3);

dsolve(de);

                         

 

and

 

restart;

de := diff(y(x), x) = 3*surd(y(x)^2, 3);

dsolve(de);

                                     

 

The latter result can be more simplified to  x - y(x)^(1/3) +_C1 = 0 ,  but Maple does not want to do this.

P:=Matrix([[ 0 , .5 , .5 , 0 , 0 , 0 ], [ 1/3 , 0 , 0 , 1/3 , 1/3 , 0 ], [ 1/3 , 0 , 0 , 0 , 1/3 , 1/3 ], [ 0 , 1 , 0 , 0 , 0 , 0 ], [ 0 , .5 , .5 , 0 , 0 , 0 ], [ 0 , 0 , 1 , 0 , 0 , 0 ]]):

pii:=Vector[row]([ a , b , c , d , e , f ]):

solve({seq(pii.P[i]=pii[i], i=1..6)});

                               {a = f, b = f, c = f, d = f, e = f, f = f}

If I understand the problem, the rotation around the vertical axis.

The plotting of the curve:

plot(1-cos(theta), theta = 0 .. 2*Pi, coords = polar);

 

 

The plotting of the body (for clarity, cutted a piece of the outer surface):

r := 1-cos(theta):

plot3d([r*cos(theta)*cos(phi), r*cos(theta)*sin(phi), r*sin(theta)], theta =0  .. 2*Pi, phi = Pi/2 .. 2*Pi, scaling = constrained,  axes=normal, view=[-2.7..2.7,-2.7..2.7,-1.4..1.4], orientation=[-160,-75,180]);

 

 

The calculations  the volumes of the bodies bounded by the outer and inner surfaces:

int(Pi*(r*cos(theta))^2, theta = (1/2)*Pi .. 3*Pi*(1/2));

int(Pi*(r*cos(theta))^2, theta = -(1/2)*Pi .. (1/2)*Pi);

                              

 

This problem was solved only with the help of  plots[textplot]  command in standard worksheet. The numerator and denominator of the fraction  r  should not be too large (less than 10^9):

 

MixedNumber := proc (r::{integer, fraction})

local a, b, d1, d2;

if r::integer or abs(numer(r)) < denom(r) then

return plots:-textplot([0, .9, r], view = [-1 .. 1, -1 .. 1], font = [TIMES, ROMAN, 18], color = blue, axes = none) else

a := trunc(r); b := `if`(0 < r, r-trunc(r), trunc(r)-r); d1 := `if`(0 < a, length(a), length(a)+1); d2 := max(length(numer(b)), length(denom(b)));

plots:-textplot([[-0.034*(d1-1), 0.9, a], [0.1+0.034*(d2-1), 0.9, b]], view = [-1 .. 1, -1 .. 1], font = [TIMES, ROMAN, 18], color = blue, axes = none) end if;

end proc:

 

Two examples of the work of the procedure:

MixedNumber(17/6);

                                              

MixedNumber(-100001/9971);

                                        

 

 

Vector  v  depends on 6 parameters  A, B, k, t, x, y . The simple procedure  VecPic  plots the vector  v  for specified values of these parameters.

VecPic := proc (A, B, k, t, x, y)

local a, b, c, d;

uses plots;

a := -A*y*exp(-k*t)/(x^2+y^2);

b := A*x*exp(-k*t)/(x^2+y^2);

c := B*t;

d := max(abs(a), abs(b), abs(c));

arrow(<a, b, c>, view = [-d .. d, -d .. d, -d .. d], color = red, scaling = constrained, axes = normal)

end proc:

 

Your example for  t=0, A=1 (I took the the remaining parameters arbitrarily):

VecPic(1, 1, 1, 0, 4, -3);

 

 

If I understand correctly, only zero elements are on the diagonal, and the remaining elements are equal to  0  or   in any combination.

Here is the procedure that builds all such symmetric  n  by  n  matrices:

LM:=proc(n)

local L;

uses combinat; 

L:=permute([1$(n*(n-1)/2), 0$(n*(n-1)/2)], n*(n-1)/2);

[seq(Matrix(n,{seq(seq((i+1,j)=L[k][(i-1)*i/2+j], j=1..i), i=1..n-1)}, shape=symmetric), k=1..nops(L))];

end proc:

 

Example (the first 12 matrices of  2^10  the all ones for  n=5 ):

LM(5)[1..12][];

 

 

 

Example:

with(LinearAlgebra):

A := Matrix(3,4, [[1,2,3,4],[5,6,7,8],[9,0,1,2]]);

SubMatrix(A, [1,2], [2,4]);

 

 

Max:=proc()

local S;

S:=select(t->not type(t, numeric), {args});

if nops(S)=0 then return max(args) else

'procname'(op(S),max({args} minus S)) fi;

end proc:

 

Example:

Max(3, 1, x, 4);

                       Max(x, 4)

 

First 222 223 224 225 226 227 228 Last Page 224 of 289