Kitonum

13367 Reputation

24 Badges

11 years, 71 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;
eqn1 := e1*i1 + e2*i2 + e3*i3 = 0;
A:=i1=expand(solve(eqn1, i1));
subs(e2=e1/n12, A);


Or more automatically:

restart;
eqn1 := e1*i1 + e2*i2 + e3*i3 = 0;
A:=i1=expand(solve(eqn1, i1));
eqn2 := n12 = e1/e2;
subs(e2=solve(eqn2, e2), A);


Or using the  applyop  command:

restart;
eqn1 := e1*i1 + e2*i2 + e3*i3 = 0;
A:=i1=expand(solve(eqn1, i1));
applyop(simplify, [2,1], A, {e1/e2=n12});


Edit.
 

Use  plots:-pointplot3d  and  plots:-display  commands for this.

An example:

pointplot3d.mw

You forgot to specify values for  xbas, tbas :


 

restart;
a:=-2:
b:=2:
alpha:=0.1:
beta:=1:
xbas:=2: tbas:=1:
pde:=diff(uu(x,t),t)=alpha*diff(uu(x,t),x,x)+beta*uu(x,t)*(1-uu(x,t));
IC:=uu(x,0)=(sech(10*x))^2;
BC:=uu(a,t)=0,uu(b,t)=0;  

s:=pdsolve(pde,{IC,BC},numeric ,timestep=1/100, spacestep=1/100);
s :- animate( uu(x,t) ,t=0..tbas, frames=40, labels=["x", "u(x,t)"], labelfont=[TIMES,ROMAN,14]);
plots:-animate(s:-plot3d,[uu(x,t), x=-xbas..xbas,t=0..aa, shading=zhue, axes=boxed, labels=["x","t","u(x,t)"], labelfont=[TIMES,ROMAN,16]], aa=0.005..tbas, frames=90);

diff(uu(x, t), t) = .1*(diff(diff(uu(x, t), x), x))+uu(x, t)*(1-uu(x, t))

 

uu(x, 0) = sech(10*x)^2

 

uu(-2, t) = 0, uu(2, t) = 0

 

_m2169187629056

 

 

 

 


 

Download anim_plot3d.mw
 

 

I rewrote your code as 2 procedures. The first one generates a full random polynomial of degree  N  with coefficients from the range  . The second finds all rational roots of a polynomial with integer coefficients:


 

FullRandomPolynom := proc (N::posint, R) local q; do q := randpoly(x, coeffs = rand(R), degree = N, dense); if nops(q) = N+1 then break end if; q end do end proc

FindingRationalRoots := proc (q::polynom) local S1, S2, s1, s2, x0, x1, k, RationalRoots; S1 := NumberTheory[Divisors](lcoeff(q, x)); S2 := NumberTheory[Divisors](tcoeff(q, x)); RationalRoots := table(); k := 0; for s1 in S1 do for s2 in S2 do x0 := s2/s1; x1 := -s2/s1; if eval(q, x = x0) = 0 then k := k+1; RationalRoots[k] := x0 end if; if eval(q, x = x1) = 0 then k := k+1; RationalRoots[k] := x1 end if end do end do; convert(RationalRoots, set) end proc

``

q := FullRandomPolynom(3, -9 .. 9); FindingRationalRoots(q)

{}

(1)

q := expand((x-1)*(x-2)*(x^2-9)); FindingRationalRoots(q)

{-3, 1, 2, 3}

(2)

 

NULL


 

Download rational_zeros_new.mw

We can easily solve this problem using the  seq  command with the  `if` - condition:

L:=[$ 1..50];
L1:=[seq(`if`(irem(i,2)=0,NULL, L[i]), i=1..nops(L))];
L2:=[seq(`if`(irem(i,3)=0,NULL, L1[i]), i=1..nops(L1))];

  


Edit. This method is about 2 times faster than using the  remove  command:

L:=[$ 1..1000000]:
CodeTools:-Usage([seq(`if`(irem(i,2)=0,NULL, L[i]), i=1..nops(L))]):
CodeTools:-Usage(RemoveEveryNth(L, 2)):

 

I have simplified your procedures somewhat by removing unused formal parameters and unnecessary local variables. Note also that the external call of  packages does not work in the procedures. Use  the  uses  command to call the package inside the procedure.


 

restart; Ff := proc (xx::Array) (sin(xx[1])+20)^2+(cos(xx[2])+5)^2 end proc

DP := proc (mx) VectorCalculus:-Gradient(mx, [x, y]) end proc

DP(Ff(Array([x,y])));

Vector(2, {(1) = (2*sin(x)+40)*cos(x), (2) = -(2*cos(y)+10)*sin(y)})

(1)

 


 

Download func_new.mw

1. First, you made a common syntax error: the exponent is encoded in Maple as  exp(x)  not  e^x  (in Maple  e  is only a symbol rather than the number  2.71828...).

2. Your integral contains 4 parameters (a, b, c, d), but their role is different. The most important is the parameter  b and we can easily get a solution (in many cases) depending on the value of  this parameter. The examples below show that the solution form depends heavily on the value of  b :

restart;
f:=b->d*exp(-b*x)/(((a*exp(-2*b*x)+c*exp(-4*x))));
F:=b->int(f(b),x);

 # Examples:
for b from 0 to 5 do
F(b);
od; 

 

Edit.

plots:-implicitplot((x-2)^2*(x-3)+epsilon^2=0, x=-1..6, epsilon=-5..5, gridrefine=4);
solve((x-2)^2*(x-3)+epsilon^2=0, x, parametric, real);


So we have 3 values for epsilon:  -2*sqrt(3)*(1/9),  0,  2*sqrt(3)*(1/9)

Use the  eliminate  command for this. The reverse representation is ambiguous and depends on the choice of parameters. For your example, if we take  x  and  y  as parameters, it is trivial:


 

restart;

F:=eliminate({x=s*cos(t),y=s*sin(t),z=s^2}, {s,t});

[{s = z^(1/2), t = arcsin(y/z^(1/2))}, {-x+z^(1/2)*(-(y^2-z)/z)^(1/2)}], [{s = -z^(1/2), t = -arcsin(y/z^(1/2))}, {x+z^(1/2)*(-(y^2-z)/z)^(1/2)}]

(1)

solve(F[1,2], z);
solve(F[2,2], z);

{z = x^2+y^2}

 

{z = x^2+y^2}

(2)

solve(z=x^2+y^2,{x,y,z});

{x = x, y = y, z = x^2+y^2}

(3)

 


 

Download elim.mw

A:=<1,2; 3,4>;
B:=<5,6; 7,8; 9,10; 11,12>;
<A[1], B[2], B[4]>;

                                       

 

 

An alternative to the  map  command would be the  seq  command:

restart;
L:=[[1,2,3],[7,8,9],[13,12,11]]:
[seq(l[3], l=L)];
L1:=[1, [2, 3], [4, [5, 6], 7], [8, 3], 9]:
[seq(`if`(l::list,l[1],l), l=L1)];

 


 

restart;

local D;
l:=0.5;a:=0.1; rho:=2700;h:=.0005;
E:=72.4*10^9;v:= 0.3;
n:=6;
m:=1;

AD:=10;
mu:=(2*a*2.35)/l;
nu:=sin(mu*l/(2*a))/sinh(mu*l/(2*a)); omega[m,n]:= 3067.173621;

.5

 

.1

 

2700

 

0.5e-3

 

0.7240000000e11

 

.3

 

6

 

1

 

10

 

.9400000000

 

.1369508410

 

3067.173621

(1)

 

E:=1:k[1,1]:=-5.660173062*10^10:k[1,2]:=-2.8552873062*10^10:k[1,3]:=-8.68528173062*10^10:k[1,4]:=-7.6788528173062*10^10:k[1,5]:=-1.52568528173062*10^10:k[2,1]:=-15.660173062*10^10:k[2,2]:=-21.8552873062*10^10:k[2,3]:=-18.68528173062*10^10:k[2,4]:=-71.6788528173062*10^10:k[2,5]:=-10.52568528173062*10^10:
k[3,1]:=-5.65257260173062*10^10:k[3,2]:=-27.8552552873062*10^10:k[3,3]:=-81.6854428173062*10^10:k[3,4]:=-9.67858528173062*10^10:k[3,5]:=-3.52568528173062*10^10:
k[4,1]:=-51.111660173062*10^10:k[4,2]:=-21.811552873062*10^10:k[4,3]:=-18.68528173062*10^10:k[4,4]:=-17.6788528173062*10^10:k[4,5]:=-11.52568528173062*10^10:
k[5,1]:=-6.660173062*10^10:k[5,2]:=-61.852873062*10^10:k[5,3]:=-82.68528173062*10^10:k[5,4]:=-72.6788528173062*10^10:k[5,5]:=-21.52568528173062*10^10

-0.2152568528e12

(2)

 

 

S:=(Matrix([[rho*h*omega[m,n]^2+k[1, 1],k[1,2],k[1,3],k[1,4]],[k[2,1],rho*h*omega[m,n]^2+k[2,2],k[2,3],k[2,4]],[k[3,1],k[3,2],k[3,3]+rho*h*omega[m,n]^2,k[3,4]],[k[4,1],k[4,2],k[4,3],k[4,4]+rho*h*omega[m,n]^2]])).(Vector(1..4,[[A],[B],[C],[D]]))=-E*(Vector(1..4,[k[1,5],k[2, 5],k[3,5],k[4,5]]));

(Vector(4, {(1) = -0.5658903042e11*A-0.2855287306e11*B-0.8685281731e11*C-0.7678852817e11*D, (2) = -0.1566017306e12*A-0.2185401729e12*B-0.1868528173e12*C-0.7167885282e12*D, (3) = -0.5652572602e11*A-0.2785525529e12*B-0.8168417280e12*C-0.9678585282e11*D, (4) = -0.5111166017e12*A-0.2181155287e12*B-0.1868528173e12*C-0.1767758280e12*D})) = (Vector(4, {(1) = 0.1525685282e11, (2) = 0.1052568528e12, (3) = 0.3525685282e11, (4) = 0.1152568528e12}))

(3)

solve(convert((lhs-rhs)(S), list))

{A = -.1373190087, B = -.1795797543, C = 0.3604957767e-1, D = -0.7148975043e-1}

(4)

 


Addition. You do not need to form a system of equations in any form. Using the  LinearAlgebra:-LinearSolve  command you can solve the system simply by specifying the matrix of coefficients in front of the unknowns and the vector of the right side:

M:=(Matrix([[rho*h*omega[m,n]^2+k[1, 1],k[1,2],k[1,3],k[1,4]],[k[2,1],rho*h*omega[m,n]^2+k[2,2],k[2,3],k[2,4]],[k[3,1],k[3,2],k[3,3]+rho*h*omega[m,n]^2,k[3,4]],[k[4,1],k[4,2],k[4,3],k[4,4]+rho*h*omega[m,n]^2]]));
V:=-E*(Vector(1..4,[k[1,5],k[2, 5],k[3,5],k[4,5]]));
LinearAlgebra:-LinearSolve(M, V);

Download solve_(1)_new.mw

The  AlmostCarmichaelNumbers  procedure finds all the numbers that meet your requirements for a number  k  and for a range  (which you specify when using) .

AlmostCarmichaelNumbers:=proc(k::posint,R::range)
local T, N, m, n, L;
T:=table(); N:=0; m:=lhs(R);
for n from `if`(m::odd,m,m+1) by 2 to rhs(R) do
L:=ifactors(n);
if nops(L[2])=k then if `and`(map(t->is(t[2]=1),L[2])[]) and `+`(seq(`if`(irem(n-1,t[1]-1)=0,1,0),t=L[2]))=k-1 then N:=N+1; T[N]:=n fi; fi;
od;
convert(T, list);
end proc:

Examples of use for k=3, 4, 5 :

AlmostCarmichaelNumbers(3,1..10000);
AlmostCarmichaelNumbers(4,1..10000);
AlmostCarmichaelNumbers(5,1..10000);
         
    

A:=(-108*q - 12*sqrt(12*p^3 + 81*q^2))^(1/3)/6;
B:=(A^3)^(1/3);
c:=op([1,2], B);
subsop([1,2]=-(c^2)^(1/2), B);


Addition. This method can be used in some cases when simplifying radicals, for example:

restart;
A:=sqrt(11-4*sqrt(6))+sqrt(21+6*sqrt(6));
sqrt(A^2);

 

The differential equation must be entered with explicit indication of the derivative (not differentials) using Maple syntax. For your example, you can do this:

restart;
de:=2*y*dx+3*x*dy=0;
subs([dy=diff(y(x),x)*dx,y=y(x)], de);
dsolve(%, y(x));

             

 

4 5 6 7 8 9 10 Last Page 6 of 209