Kitonum

21530 Reputation

26 Badges

17 years, 85 days

MaplePrimes Activity


These are answers submitted by Kitonum

cat(2*x-5, ` > `, 3*x-6);

                                    

 

or even simplier:

 `2*x-5 > 3*x-6`;

                                    

For further changes, you can use  parse  command:

`2*x-5 > 3*x-6`;

parse(%);

solve(%);

                       

Edited.

m := -t*(-1+t)^3/(t^3+2):

map(t->`if`(type(t,`^`) and op(2,t)>1, `$`(op(t)), t), [op(m)]);

                                   [-1, t, -1+t, -1+t, -1+t, 1/(t^3+2)]

 

Edited.

 

 

If the problem should be solved not a single time then the solution is useful to write down as a procedure. The parameter  P  is a set or a list of any number of polynomials. The procedure returns the list whose first element is the number of common terms of these polynomials, and the second one is the set of common terms.

CommonTerms:=proc(P::{set(polynom),list(polynom)})

local S;

S:=`intersect`(op(map(t->{op(t)},P)));

[nops(S), S];

end proc:

 

Example of use:

CommonTerms({x^2*y+x+y, x^3+x^2*y+y, y^2+x^2*y+y});

                                                [2, {y, x^2*y}]

 

In the code replace  Iteration  by  iteration  (or  iteration  by   Iteration). Maple distinguishes between lower and upper case.

Very strange bug! Use  Optimization[Maximize]  command as a workaround:

Optimization[Maximize](x^2+4, x = -1 .. 2);

                                            [8., [x = 2.]]

Carl showed how to find the general solution of a linear system. But if you want to modify a solution to the desired form, a special procedure is necessary. Here is my attempt :

LSSF:=proc(A::Matrix)

local Sol, Ind, n, N, Sol0, i, V;

uses LinearAlgebra;

Sol:=LinearSolve(A);

Ind:=indets(Sol);

n:=nops(Ind);

N:=op(A)[2]-1;

if n=0 then return Sol else

Sol0:=eval(Sol,Ind=~0);

for i from 1 to n do

V[i]:=eval(Sol-Sol0,{Ind[i]=1,op(Ind minus {Ind[i]})=~0});

od; fi;

print(x=Vector([seq(x[i],i=1..N)]),v[0]=Sol0,seq(v[k]=V[k], k=1..n));

x=v[0]+``(`+`(seq(C[k]*v[k],k=1..n)));

end proc:

 

Solution of the initial example:

R := Matrix([[1, -2, 2, 6, -6], [2, -3, 4, 9, -8]]);

LSSF(R);  # C[1] and C[2] are arbitrary parameters

                           

 

 The procedure works for the arbitrary linear system which is given by an augmented matrix.

 

The absolutely exact (symbolic) value of  DthetaZero   can be gotten from the equation  Eq3  in my solution above:

DthetaZero:=eval((1/10)*sqrt(100*sin(theta(t))^2+1962*cos(theta(t))+1962), theta(t)=2*Pi/3);

evalf[20](%);

                                             

 

 

First we reduce the order of the equation. Using the conditions  theta(t)=Pi and diff(theta(t),t)=0  we find _C1 and then  DthetaZero . At this value there is instability when the pendulum reaches the top position. If the value  DthetaZero  is slightly less (DthetaZero1), the pendulum comes back, and if a little more (DthetaZero2), then the angle  theta  continues to increase (Plot1 and Plot 2):

restart;

Eq1:=sin(theta(t))*cos(theta(t))-9.8100*sin(theta(t))-(diff(theta(t), t, t)) = 0:

# The change diff(theta(t),t)=p. We get diff(theta(t), t, t)=p*diff(p(theta),theta)

Eq2:=p(theta)*diff(p(theta),theta)=1/2*sin(2*theta)-9.81*sin(theta);

sol0:=dsolve(Eq2)[2];

_C1:=solve(eval(sol0,[theta=Pi,p(theta)=0]));

Eq3:=eval(sol0,[p(theta)=diff(theta(t),t),theta=theta(t)]);

sol:=dsolve({Eq3,theta(0)=2*Pi/3},numeric):

DthetaZero1:=evalf[5](eval(rhs(Eq3),theta(t)=eval(theta(t),sol(0))));

DthetaZero2:=evalf[5](eval(rhs(Eq3),theta(t)=eval(theta(t),sol(0)))-10^(-7)+10^(-4));

Sol1:=dsolve({Eq1, theta(0) = 2*Pi*(1/3), D(theta)(0) = DthetaZero1}, numeric):

Sol2:=dsolve({Eq1, theta(0) = 2*Pi*(1/3), D(theta)(0) = DthetaZero2}, numeric):

plots[odeplot](Sol1,[[t,theta(t)-Pi],[t,diff(theta(t),t)]],t=0..14, color=[red,blue], axes=normal); # Plot 1

plots[odeplot](Sol2,[[t,theta(t)-Pi],[t,diff(theta(t),t)]],t=0..14, color=[red,blue], axes=normal); # Plot 2

                                

                                    

 

 

 

 

For single use we can simply write

a:=0:  b:=1:  n:=4:

evalf[2]([seq(a+(b-a)/n*k, k=0..n)]);

                                                   [0., 0.25, 0.50, 0.75, 1.]

 

This also works for complex and symbolic cases.

restart;

[seq(a+(b-a)/4*k, k=0..4)];

                            [a, (3/4)*a+(1/4)*b, (1/2)*a+(1/2)*b, (1/4)*a+(3/4)*b, b]

 

a:=0: b:=1+I: n:=4:

evalf[2]([seq(a+(b-a)/n*k, k=0..n)]);

                                  [0., 0.25+0.25*I, 0.50+0.50*I, 0.75+0.75*I, 1.+1.*I]

If you can live with the extra parentheses, you can do so:

A:=<1/3,1/3; 1/3,1/3>;

1/3*``(A/~(1/3));

                                       

a := n->(1/2)*(1/n-(-1)^n/n-1/n^2-(-1)^n/n^2);

 

Examples of use:

a(3), a(4), a(11), a(14), a(100);

                                             1/3, -1/16, 1/11, -1/196, -1/10000

1. A system better at once to write in curly (or square) brackets.

2. If you still want to insert a label (instead of a name) then first use  Ctrl+L (the same you can do from  Insert  menu).

 

 

 

To prevent the automatic change of the argument in the sin, you can use the empty symbol `` .  If any substitutions and other transformations, the expression inside  the extra parentheses retained. To remove these extra parentheses expand command should be applied to the argument:

b:=sin(``(x+y+z-Phi));

c:=eval(%, x=1);

applyop(t->t/2, 1, c);

applyop(expand, 1, c);

                                 

 

 

 

First we plot this body:

plots[implicitplot3d](sqrt(x^2+y^2)=5*sin(z)*exp(-(Pi-z)/(1.5)),x=-2.3..2.3,y=-2.3..2.3, z=0..3.7, style=surface, numpoints=1000000,color=khaki, axes=normal, scaling=constrained);

                               

 

Below the problem is reduced to the calculation of the surface integral over this surface (assuming the surface density equal to 1). Unfortunately Maple cannot symbolically compute the double integral (calculated only one of two successive integrals). The remaining integral is computed numerically:

f:=unapply(5*sin(z)*exp(-2*(Pi-z)/3), z):

F:=unapply(sqrt(f(z)^2-x^2), x,z);

MI_z:=4*int(sqrt(1+diff(F(x,z),x)^2+diff(F(x,z),z)^2)*f(z)^2,[x=0..f(z),z=0..Pi]);

 

evalf(MI_z);

evalf[20](MI_z);

                         

 

So the final result   105.1187800

toandhsp, you wrote "How can I add this code into Perpendicularity Criterion?"  You can write your own code (to simplify the equation of the line a*x+b*y+c=0) in the form of a  procedure, and then use this procedure when you want. 

P:=proc(d::equation)

local a, b, k;

a := coeff(lhs(d), x):

b := coeff(lhs(d), y):

k := igcd(a, b):

if a <> 0 then sign(a)*sort(d)/k else sign(b)*sort(d)/k fi;

end proc:

 

Examples of use:

P(-6*x+2*y+8 = 0);

map(t->[P(t[1]),P(t[2]),t[3]], [[-4*x-3*y-44 = 0, -4*x+3*y-14 = 0, [x = -29/4, y = -5]], [-4*x-3*y-44 = 0, -3*x-4*y-48 = 0, [x = -32/7, y = -60/7]], [-4*x-3*y-44 = 0, 3*x+4*y-2 = 0, [x = -26, y = 20]]]);

                                                                    3 x - y - 4 = 0

[[4*x+3*y+44 = 0, 4*x-3*y+14 = 0, [x = -29/4, y = -5]], [4*x+3*y+44 = 0, 3*x+4*y+48 = 0, [x = -32/7, y = -60/7]], [4*x+3*y+44 = 0, 3*x+4*y-2 = 0, [x = -26, y = 20]]]

First 181 182 183 184 185 186 187 Last Page 183 of 290