Kitonum

21435 Reputation

26 Badges

17 years, 25 days

MaplePrimes Activity


These are answers submitted by Kitonum

This can be done in many ways. Here is a solution using a procedure that I wrote many years ago. All comments in the procedure are written in Russian. The full text of the procedure itself can be found in the attached file, and here its application to your example:

   

L:=-185173378616457/6178315520000*x+86813215770519/24713262080000*(y^2)+126906272070543/24713262080000*(x^2)+256107247454961/6178315520000+(2514994832007/950510080000*x)*y-9123740375967/6178315520000*y = 0 :  
QuadricCurveAnalysis(L, detail);

`Уравнение заданной кривой в координатах (x, y):`

 

-(185173378616457/6178315520000)*x+(86813215770519/24713262080000)*y^2+(126906272070543/24713262080000)*x^2+256107247454961/6178315520000+(2514994832007/950510080000)*x*y-(9123740375967/6178315520000)*y = 0

 

`Собственные векторы соответствующей квадратичной формы:`

 

v[1] = (array( 1 .. 2, [( 1 ) = (84/137+(5/137)*1033^(1/2)), ( 2 ) = (1)  ] )), v[2] = (array( 1 .. 2, [( 1 ) = (84/137-(5/137)*1033^(1/2)), ( 2 ) = (1)  ] ))

 

`Соответствующие собственные числа:`

 

lambda[1] = 106859743920531/24713262080000+(18357626511/380204032000)*1033^(1/2), lambda[2] = 106859743920531/24713262080000-(18357626511/380204032000)*1033^(1/2)

 

`Тип кривой:  эллипс`

 

`Каноническое уравнение:`

 

`x' `^2/((1/64)*(5821+65*1033^(1/2))^(1/2))^`2`+`y' `^2/((1/64)*(5821-65*1033^(1/2))^(1/2))^`2` = 1

 

`Фокусное расстояние:`

 

c = (1/64)*130^(1/2)*1033^(1/4)

 

`Эксцентриситет эллипса:`

 

epsilon = 130^(1/2)*1033^(1/4)/(5821+65*1033^(1/2))^(1/2)

 

`Координаты фокусов в старой системе координат (x,y):`

 

F[1]((1/64)*(84-5*1033^(1/2))*130^(1/2)*1033^(1/4)/(51650-840*1033^(1/2))^(1/2)+203/64, (137/64)*130^(1/2)*1033^(1/4)/(51650-840*1033^(1/2))^(1/2)-63/64), F[2](-(1/64)*(84-5*1033^(1/2))*130^(1/2)*1033^(1/4)/(51650-840*1033^(1/2))^(1/2)+203/64, -(137/64)*130^(1/2)*1033^(1/4)/(51650-840*1033^(1/2))^(1/2)-63/64)

 

`Уравнения директрис в старой системе координат (x,y):`

 

-84*x/(51650-840*1033^(1/2))^(1/2)+5*1033^(1/2)*x/(51650-840*1033^(1/2))^(1/2)-137*y/(51650-840*1033^(1/2))^(1/2)+(8421/64)/(51650-840*1033^(1/2))^(1/2)-(1015/64)*1033^(1/2)/(51650-840*1033^(1/2))^(1/2)+(1/128)*130^(1/2)*1033^(1/4)+(5821/8594560)*130^(1/2)*1033^(3/4) = 0, -84*x/(51650-840*1033^(1/2))^(1/2)+5*1033^(1/2)*x/(51650-840*1033^(1/2))^(1/2)-137*y/(51650-840*1033^(1/2))^(1/2)+(8421/64)/(51650-840*1033^(1/2))^(1/2)-(1015/64)*1033^(1/2)/(51650-840*1033^(1/2))^(1/2)-(1/128)*130^(1/2)*1033^(1/4)-(5821/8594560)*130^(1/2)*1033^(3/4) = 0

 

`Уравнения большой и малой осей эллипса:`

 

-137*x/(51650-840*1033^(1/2))^(1/2)+84*y/(51650-840*1033^(1/2))^(1/2)-5*1033^(1/2)*y/(51650-840*1033^(1/2))^(1/2)+(33103/64)/(51650-840*1033^(1/2))^(1/2)-(315/64)*1033^(1/2)/(51650-840*1033^(1/2))^(1/2) = 0, 137*x/(51650+840*1033^(1/2))^(1/2)-84*y/(51650+840*1033^(1/2))^(1/2)-5*1033^(1/2)*y/(51650+840*1033^(1/2))^(1/2)-(33103/64)/(51650+840*1033^(1/2))^(1/2)-(315/64)*1033^(1/2)/(51650+840*1033^(1/2))^(1/2) = 0

 

`Связь старых и новых координат:`

 

x = -(84-5*1033^(1/2))*`x'`/(51650-840*1033^(1/2))^(1/2)+(84+5*1033^(1/2))*`y'`/(51650+840*1033^(1/2))^(1/2)+203/64

 

y = -137*`x'`/(51650-840*1033^(1/2))^(1/2)+137*`y'`/(51650+840*1033^(1/2))^(1/2)-63/64

 

`Угол поворота новой системы координат относительно старой:`

 

alpha = (1/2)*arctan(137/84)-(1/2)*Pi

 

`График кривой в системах координат (x,y) и (x',y'):`

 

 

 


 

Download QuadricCurveAnalysis.mw

This is a known bug in  RealDomain  package when it does not take into account the domain of the equation. Here is a simple workaround:

restart;
RealDomain:-solve({(x-1)*sqrt(x^2-4) = 0, x^2-4>=0}, x);

                                     {x = -2}, {x = 2}

restart;
f:=t->piecewise(t<1 and t>=-1,t/2+1/2,t>=1 and t<2,-t+2);
F:=t->f(t-floor((t+1)/3)*3); #  F  is a periodic extension of  f  to the whole real axis
F(4.5);
plot(F(t), t=-4..5, scaling=constrained, size=[1200,150]);

Use the  LinearAlgebra:-GenerateMatrix  command for this (3 steps):
 

Download MatrixForm.mw

If you do not like the order of the elements in the set, then you can convert it into the list, and then sort this list according to the desired order:

E:={{1,2,3,4,5,6},{4,5,6,7,8,9,10,11},{10,11,12,13,14}};
        E := {{10, 11, 12, 13, 14}, {1, 2, 3, 4, 5, 6}, {4, 5, 6, 7, 8, 9, 10, 11}}
E1:=convert(E, list);
       E1 := [{10, 11, 12, 13, 14}, {1, 2, 3, 4, 5, 6}, {4, 5, 6, 7, 8, 9, 10, 11}]
sort(E1, (x,y)->x[1]<y[1]);
       [{1, 2, 3, 4, 5, 6}, {4, 5, 6, 7, 8, 9, 10, 11}, {10, 11, 12, 13, 14}]


Of course, to avoid this hassle, you should immediately specify E as a list and not as a set.

See help on the  diff  command.

The code for your example:

w:=exp(-beta*t-mu*x)*u(x,t);
diff(w, t);

 

Eq:=v1(t) - R1*(-i3(t)/n13 - i2(t)/n12) - L1*diff(-i3(t)/n13 - i2(t)/n12, t) = n12*(v2(t) - R2*i2(t) - L2*diff(i2(t), t));
Eq1:=expand((lhs-rhs)(Eq));
Terms:=[op(Eq1)];
DTerms:=select(has, Terms, diff);
Lhs:=add(DTerms);
collect(Lhs, diff)=collect(-(Eq1-Lhs), R1);  # The final result

 

You must specify the integration range, but you cannot use the symbol to as a name because it is a reserved word. I replaced it with  a :

a:=3:
evalf(int(exp((5+I*6)*x)*sin(1+erf(x)),x=-a..a));
evalf(int(exp((5+I*6)*x)*cos(1+erf(x)),x=-a..a));

 

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.

First 84 85 86 87 88 89 90 Last Page 86 of 289