## 12760 Reputation

8 years, 299 days

## MaplePrimes Activity

### These are answers submitted by vv

Replace sum with add in the definition of S.

## Careful with log branches...

 > ode := diff(y(x), x) - 2*(2*y(x) - x)/(x + y(x)) = 0; ic:=y(0)=2;
 (1)
 > sol:=dsolve(ode,'implicit');
 (2)
 > eq:=exp(lhs(sol))=1;
 (3)
 > EQ:=simplify(eq,exp);
 (4)
 > #plugin in y=2 at x=0 eval(%,[y(x)=2,x=0]);
 (5)
 > solve(%,_C1)
 (6)
 > EQ0:=eval(EQ, _C1=%);
 (7)
 > ysols:=solve(EQ0,y(x));
 (8)
 > simplify(limit~([ysols], x=0));
 (9)
 > ysol:=ysols[1];
 (10)
 > plot(ysol,x=-1..1);
 > odetest(y(x)=ysol,[ode,ic]);
 (11)
 >

## input, output...

Yes, an error or at least a warning would be better. input and output work with polynomials of any degree.

Note that when n >= p^k,  input(n) produces a polynomial (zpoly) of degree >= k.
The reduction modulo the extension polynomial is not performed.
It is however performed by the arithmetic operations in G except G:-`+`, G:-`-`
(here G := GF(p,k)).

## Trigonometry!...

This is a nice example where the correct use of trigonometry is essential.
It seems to be too subtle for a CAS!

By solving the ode by hand one obtains  the solution:

Y:= piecewise(x < 0, -2*arctan((x+2)/x), x>0, -2*arctan((x+2)/x)+2*Pi, Pi)

It is easy to check that it satisfies the ODE for ANY real x.
Your solution, 2*Pi-2*arccos(x/(2*x^2+4*x+4)^(1/2)),  is valid only for x>-2.

Edit.
It can be shown that  Y = 2*arctan(x + 1) + Pi/2
(it is enough to compute int(diff(Y,x), x) + C).

## Not strange...

Everything is correct. Note that

{ sqrt(y/x), - sqrt(y/x) } = { sqrt(y) / sqrt(x), - sqrt(y) / sqrt(x) } = { sqrt(x*y) / x, - sqrt(x*y) / x}

for any complex x,y;  (x <> 0, of course).

 >
 > restart;
 > SYS := [cos(x)*cos(y)*cos(x + y) - 2*(sin(x)*sin(y) - 1)*2*(sin(x)*sin(x + y) - 1)*2*(sin(y)*sin(x + y) - 1),        (cos(x + y) - (cos(x) + cos(y)) + 1)**2 + 2*cos(x)*cos(y)*cos(x + y)]:
 > eval(expand~(SYS), [cos(x)=a, sin(x)=b, cos(y)=c, sin(y)=d]):
 > sys:=[%[], a^2+b^2-1, c^2+d^2-1];
 (1)
 > S:=[solve](sys, explicit):
 > Sr:=evala(select(u -> is( Im~(eval([a,b,c,d], u))=[0,0,0,0]), S));
 (2)
 > XY:= u -> [x=arctan(eval(b,u),eval(a,u)), y=arctan(eval(d,u),eval(c,u))]:
 > select(u -> is(eval(x,u)+eval(y,u) >=0), XY~(Sr));
 (3)
 >

## Change IC...

Only if you provide another initial condition beyond the singularity.

Like in the next simple example.

 > dsolve({diff(y(x),x)=y(x)^2, y(0)=1});
 (1)

 > sol1:=dsolve({diff(y(x),x)=y(x)^2, y(0)=1}, numeric);
 (2)
 > plots:-odeplot(sol1, [x, y(x)], x= 0..3);
 > sol2:=dsolve({diff(y(x),x)=y(x)^2, y(2)=-1}, numeric); # Choose an IC at x=2 (after the previous singularity at 1)
 (3)
 > plots:-odeplot(sol2, [x,y(x)], x=1.1 .. 5);
 >

## eval...

```simplify( eval(rel(n), n=3 + 1/(2*t)) ) assuming t>0;
# 0 = 0```

## keyword params...

In maple there are many kinds of parameters. I don't think such a new class is really needed.
For your example, it is easy to use a keyword parameter; Eivenvectors uses for instance
output=['vectors', 'values']  or  output=['values']  etc.

## Just a bug...

More simple,

```is(w^2 = abs(w)^2);     # Maple 2023
true    ```

In Maple 2020 .. 2022 it is OK (i.e. false).
Same for:  is(w = conjugate(w))

## export mpl...

Export the document as Maple code (.mpl).
Then open the .mpl. In Maple 2023, it will appear in a new Code Edit window.
Edit the code, i.e. replace `&ndash;` with -

There are not other errors (see the Diagnostics tab), so you can copy & paste the code in the worksheet and execute.

P.S. I use 2D input strictly for presentation purposes (and almost never the Document mode).

## degree...

ex:=x*y*z^2*w^3:
degree(ex);
#                              7
factors(ex)[2];
#               [[y, 1], [z, 2], [w, 3], [x, 1]]

## Procedure for an enhanced version...

```Miny:=proc(eqs::list, m::list(posint), R:=1000)
description "minimize y, for integers  x,y  satisfying 0<x<y, eqs[1] = 0 mod m[1], ...";
local p,q,X,Y,u,k, ir, Xmin,Ymin,pmin,qmin;
if nops(eqs)<>nops(m) then error "Lists must have same size" fi;
if nops(indets(eqs)) <> 2 then error "Must have 2 variables" fi;
eval( isolve({(eqs =~ m*~[seq(u[k],k=1..nops(m))])[]}), [_Z1=p,_Z2=q] ):
(X,Y):= (eval([indets(eqs)[]],%)[]);
ir:=IntegerRelations:-LLL([[coeff(X,p),coeff(Y,p)], [coeff(X,q),coeff(Y,q)]]):
(X,Y):= (ir[1,1]*p+ir[2,1]*q, ir[1,2]*p+ir[2,2]*q);
(Xmin,Ymin,pmin,qmin):=(infinity\$4):
for p from -R to R do
for q from -R to R do
if eval(X<1 or X >= Y) then next fi;
if eval(Y<Ymin) then (Xmin,Ymin,pmin,qmin):=eval([X,Y,p,q])[] fi
od od:
['X','Y','p','q'] =~ eval([Xmin,Ymin,pmin,qmin]);
end proc:
```

eqs := [154*x+69*y, 13*x+716*y, 23*x+3059*y]:
m := [7^3, 13^3, 23^3]:
Miny(eqs,m);

[X = 15893, Y = 18837, p = 0, q = 1]

eqs := [154*x+69*y, 13*x+716*y, 23*x+3059*y, 2295*x + 4522*y, 6479*x + 5396*y]:
m := [7^3, 13^3, 23^3, 17^3,  29^3]:
Miny(eqs,m);

[X = 186957261, Y = 190687133, p = -12, q = -1]

## Solution...

 > restart

Minimize   y   for integers  x,y  satisfying:
0 < x < y,  154*x+69*y =0 mod  7^3 , 13*x+716*y =0 mod 13^3  , 23*x+3059*y =0 mod  23^3.

 >
 > restart;
 > eqs := 154*x+69*y, 13*x+716*y, 23*x+3059*y; m := 7^3, 13^3, 23^3;
 (1)

For an "ideal Maple" it should work:

 > # Optimization:-Minimize(y, {1<=x, x<=y, eqs =~ m*~(u,v,w)}, assume = integer, depthlimit=100000);
 > # But the problem it too large!
 > #################################################################################################
 > Eqs := 154*x+69*y, 13*x+716*y, x+133*y; M := 7^3, 13^3, 23^2;
 (2)
 > sys:=y =-154 * 1/69*x mod M[1] + M[1]*u,  y = -13/716*x mod M[2] + M[2]*v, y = -1/133*x mod M[3] + M[3]*w;
 (3)
 > isolve(sys[1]-sys[2]);
 (4)
 > eval(%, [_Z1=a,_Z2=b]);
 (5)
 > e1:=eliminate(%, {u,v});
 (6)
 > isolve(sys[1]-sys[3]);
 (7)
 > eval(%, [_Z1=c,_Z2=d]);
 (8)
 > e2:=eliminate(%, {u,w});
 (9)
 > ee:=e1[1] union e2[1], e1[2] union e2[2];
 (10)
 > EE:=eval(ee, [a=u, c=u]);
 (11)
 > X, X1 := solve~(EE[2],x)[];
 (12)
 > s:=eval(isolve(X=X1),[_Z1=p,_Z2=q,_Z3=r]);
 (13)
 > X0:=eval(X, s);
 (14)
 > Y0:=rhs(eval(eval(sys[1], s), x=X0));
 (15)
 > Optimization:-Minimize(Y0, { X0<=Y0, 1<=X0}, assume=integer, depthlimit=1000 );
 (16)

Unfortunately Minimize uses hardware integers and it results an overflow!
(This is actually a bug!)

Let's minimize the reduced X0, Y0 problem by brute force:

 > p:='p':q:='q':
 > (Xmin,Ymin,pmin,qmin):=(infinity\$4): for p from -1000 to 1000 do for q from -1000 to 1000 do   if X0<1 or X0 >= Y0 then next fi;   if Y0
 (17)
 >

## ExtremePoints for piecewise...

ExtremePoints is not reliable for piecewice defined functions.

 > restart;
 > EP:=Student:-Calculus1:-ExtremePoints:
 > piecewise(-1 <= x and x <= 2, x^2, undefined);
 (1)
 > EP(%); #OK
 (2)
 > piecewise(-1 < x and x < 2, x^2, undefined);
 (3)
 > EP(%); #OK
 (4)
 > piecewise(-1 <= x and x <= 2, x, undefined);
 (5)
 > EP(%); # expected [1,2]
 (6)
 > piecewise(x<1, undefined, x<=2, x*sin(1/x), undefined);
 (7)
 > EP(%, 1..2); # expected [1,2]
 (8)
 > EP(x*sin(1/x), 1..2); # OK
 (9)
 > piecewise(x<0, undefined, x=0, 0,  x<=1, x*sin(1/x), undefined);
 (10)
 > EP(%); # expected [1]
 (11)
 > piecewise(x<-1, undefined, x<0, x*sin(1/x), x=0, 0, undefined);
 (12)
 > EP(%); # expected [-1]
 (13)
 >

 2 3 4 5 6 7 8 Last Page 4 of 113
﻿