vv

13922 Reputation

20 Badges

10 years, 10 days

MaplePrimes Activity


These are answers submitted by vv


 

restart;

f:=w__1 * x__1 + w__2 * x__2; constr:=x__1^a * x__2^b - y=0;

w__1*x__1+w__2*x__2

 

x__1^a*x__2^b-y = 0

(1)

extrema(f, constr, {x__1, x__2}, 's'):

expand~(s[])  assuming positive;

{x__1 = a^(b/(a+b))*w__2^(b/(a+b))*y^(1/(a+b))/(w__1^(b/(a+b))*b^(b/(a+b))), x__2 = w__1^(a/(a+b))*b^(a/(a+b))*y^(1/(a+b))/(a^(a/(a+b))*w__2^(a/(a+b)))}

(2)

combine(%);

{x__1 = w__1^(-b/(a+b))*a^(b/(a+b))*b^(-b/(a+b))*w__2^(b/(a+b))*y^(1/(a+b)), x__2 = w__1^(a/(a+b))*a^(-a/(a+b))*b^(a/(a+b))*w__2^(-a/(a+b))*y^(1/(a+b))}

(3)

It is possible to combine the middle terms but I think that this should not matter (i.e. Maple should not be used as a typesetting machine).

Catalan1 := (alpha,beta)->[alpha-sin(alpha)*cosh(beta), 1-cos(alpha)*cosh(beta), 4*sin((1/2)*alpha)*sinh((1/2)*beta)]:
p1:=plot3d(Catalan1(alpha,beta), alpha = 0 .. 2*Pi, beta = -3 .. 3, scaling = constrained, title = "Catalan's surface", titlefont = [Courier, bold, 14]):
with(plots):
p2:=spacecurve( [Catalan1(alpha,-3), Catalan1(alpha,3)],alpha=0..2*Pi,color=red,thickness=5):
display(p1,p2);

 


 

It seems that now the Vector and Matrix constructors accept only scalars.

But we may use delayed evaluation.

 

Vector(2,(a) -> 'Matrix'(2,2,(b,c) -> m||a||b||c));

Vector(2, {(1) = Matrix(2, 2, {(1, 1) = m111, (1, 2) = m112, (2, 1) = m121, (2, 2) = m122}), (2) = Matrix(2, 2, {(1, 1) = m211, (1, 2) = m212, (2, 1) = m221, (2, 2) = m222})})

(1)

A:=<1,2;3,4>;B:=<2,3,4>;

A := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4})

 

Vector[column](%id = 18446744074182844158)

(2)

Vector([B,B]); #assemble

Vector(6, {(1) = 2, (2) = 3, (3) = 4, (4) = 2, (5) = 3, (6) = 4})

(3)

Vector([A,B]);

Error, (in Vector) initializer list contains elements of width > 1 and depth > 1

 

Vector(['A','B']);

Vector(2, {(1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4}), (2) = Vector(3, {(1) = 2, (2) = 3, (3) = 4})})

(4)

Matrix(1,2,[[A,B]]);

Error, (in Matrix) this entry is too tall or too short: Vector(3, {(1) = 2, (2) = 3, (3) = 4})

 

Matrix(1,2,[['A','B']])

Matrix(1, 2, {(1, 1) = Matrix(2, 2, {(1, 1) = 1, (1, 2) = 2, (2, 1) = 3, (2, 2) = 4}), (1, 2) = Vector(3, {(1) = 2, (2) = 3, (3) = 4})})

(5)

J:=int(ln(x)^n,x):
ch := t=ln(x):   IntegrationTools:-Change(J, ch):
simplify(eval(%, ch));

1. Don't use procedures. Use expressions:

SED2 := 32/3 * ...  

(if you really need procedures, for diff use unapply).

2. To have polynomials extract only the numerators:

SED2 := numer(SED2).

(Maybe you will have to take the derivatives before that, it depends on your intentions).

3. Use ":" instead of ";"  only after everything works OK,

 

rand(-2 .. 2)  generates coefficients from the set {-2,-1,0,1,2}.

If you want floats (real numbers), use rand(-2.0 .. 2.0)

restart;

Digits:=15;

15

(1)

 

Solving numerically the recurrence

 

F(0,y) = 0,

F(x,y) = y/(y+1)*F(x-1,y)^((y+1)/y) + 1/(y+1)

 

and approximating  limit( F(n,n),  n = infinity)

 

No chance for a closed form (probably).

 

F:=proc(x,y)
   if x=0 then return 0 fi;
   y/(y+1)*F(x-1,y)^((y+1)/y)+1/(y+1)
end:

F(2,2);

(2/27)*3^(1/2)+1/3

(2)

F(1000,1000.);

.420589864597856

(3)

F(10^4,10.^4);

.420522651099579

(4)

F(10^5,10.^5);

Error, (in F) too many levels of recursion

 

 

 

We must use a non-recursive version:

 

f:=proc(x,y)
local r:=0,a, z:=(y+1)/y, w:=y/(y+1), y1:= 1/(y+1);
to x do r:=  w*r^z+y1 od;
r
end:

f(2,2);

(2/27)*3^(1/2)+1/3

(5)

seq( [n, f(10^n,10.^n)],n=1..6);

[1, .428422578046699], [2, .421269413312481], [3, .420589864597856], [4, .420522651099579], [5, .420515940874970], [6, .420515270000679]

(6)

 


 

restart;

 

The exact (symbolic) absolute min and max.
Two variables. The constraints must define a compact domain.
Based on extrema and solve (which are supposed to work).

absminmax:=proc(f::algebraic, constr::set(relation),candi::name:='_candidates')
local bdr, n,P,i,j,u,s,cand,x,y;
s:=indets([f,constr],name) minus {constants};
if nops(s)<>2 then error "Two indeterminates only" fi;
bdr:=seq(lhs(u)-rhs(u)=0,u=constr):
x,y:=s[];  n:=0:  P:=Vector():
for j to nops(constr) do for i to j-1 do
  s:=solve([bdr[i],bdr[j]],{x,y},explicit);
  for u in [s] do n:=n+1; P(n):=u od;
od od:
for i to nops(constr) do
  extrema(f, {bdr[i]},{x,y}, 's'):
  for u in s do n:=n+1: P(n):=u od;
od:
s:=solve([diff(f,x),diff(f,y)],{x,y},explicit):
for u in [s] do n:=n+1: P(n):=u od:
cand:=select(u -> type(rhs~(u),set(realcons)), {entries(P,nolist)});
cand:=select(u -> is( `and`( eval(constr, u)[]) ), cand);
candi:=cand; if cand={} then return {} fi;
min[index]( [seq(eval(f,u),u=cand)]):  
  s:=`min`=eval(f,cand[%]), cand[%];
max[index]( [seq(eval(f,u),u=cand)]):  
  s, `max`=eval(f,cand[%]), cand[%];
end:

 

Examples

 

 

f1:=2*x^2+4*x*y+2*x-2*y^2+y+4:

constr1:={ y>=(1/21)*x-283/42,
          x<=(3/29)*y+329/58,
          y<=(1/9)*x+131/18,
          x>=-(1/9)*y-113/18 }:

absminmax(f1, constr1);

min = -137657/784, {x = -2267/392, y = 2601/392}, max = 379/2, {x = 13/2, y = 8}

(1)

_candidates;

{{x = -7, y = 13/2}, {x = 5, y = -13/2}, {x = -2267/392, y = -1745/392}, {x = -2267/392, y = 2601/392}, {x = -11/2, y = -7}, {x = -3/8, y = -1/8}, {x = 13/2, y = 8}}

(2)

f2:=4*x*y-2*y^2+4*x+y+4:
constr2:={y >= -(1/13)*x-85/13, y <= -(25/14)*x+26/7, y <= (23/12)*x+89/12}:

absminmax(f2, constr2,'ccc');

min = -245, {x = 6, y = -7}, max = 66, {x = -7, y = -6}

(3)

absminmax(x^2+y^2, {x<=1,y<=3,x>=0,y>=0});

min = 0, {x = 0, y = 0}, max = 10, {x = 1, y = 3}

(4)

absminmax(x+y, {(x-1)^2+y^2<=1, y>=x^2});

min = 0, {x = 0, y = 0}, max = 2, {x = 1, y = 1}

(5)

absminmax(exp(x+y), {(x-1)^2+y^2<=1, y>=x^2});

min = 1, {x = 0, y = 0}, max = exp(2), {x = 1, y = 1}

(6)

absminmax(x+y, {(x-1)^2+y^2<=1, y>=x^2+10});

{}

(7)

absminmax(x^2-y^2, {(x-1)^2+y^2<=1, y>=x^2});

min = -1/2, {x = 1/2, y = (1/2)*3^(1/2)}, max = 1/4, {x = (1/2)*2^(1/2), y = 1/2}

(8)

absminmax(x^4-y^2, {(x-1)^2+y^2<=1, y<=x^2});

min = ((1/6)*(54+6*87^(1/2))^(1/3)-1/(54+6*87^(1/2))^(1/3))^4-(1/36)*(-(54+6*87^(1/2))^(4/3)+12*(54+6*87^(1/2))^(2/3)-72*(54+6*87^(1/2))^(1/3)+72*87^(1/2)+612)/(54+6*87^(1/2))^(2/3), {x = (1/6)*(54+6*87^(1/2))^(1/3)-1/(54+6*87^(1/2))^(1/3), y = -(1/6)*((54+6*87^(1/2))^(2/3)*(-(54+6*87^(1/2))^(4/3)+12*(54+6*87^(1/2))^(2/3)-72*(54+6*87^(1/2))^(1/3)+72*87^(1/2)+612))^(1/2)/(54+6*87^(1/2))^(2/3)}, max = 16, {x = 2, y = 0}

(9)

 


Download absminmax-sent.mw

Diff(int(value(z), t), t);


 

restart;

f:=((z^4*exp(2*z)+1)/(z+I)^3) - ((z^3+z)/((z-2*I)*(z-5))) + 8*Pi*exp(1);  # probably

(z^4*exp(2*z)+1)/(z+I)^3-(z^3+z)/((z-2*I)*(z-5))+8*Pi*exp(1)

(1)

poles:=[-I, 2*I, 5];

[-I, 2*I, 5]

(2)

C:= z -> is( abs(z-1) < sqrt(11/2) );

proc (z) options operator, arrow; is(abs(z-1) < sqrt(11/2)) end proc

(3)

2*Pi*I*add( residue(f, z=a), a=select(C, poles) );

(2*I)*Pi*(12/29-(30/29)*I+(102+112*I+(-2-4*I)*((4*I)*(exp(I))^2+5*(exp(I))^2)/(exp(I))^2)/(-(15*I)*(exp(I))^2+3*(exp(I))^2))

(4)

evalf(%);

4.564531460+58.76512338*I

(5)

 


 

The fact is that pdsolve is not very competent with initial conditions
and we must do it ad-hoc:

ds:=pdsolve({sys}) ;
           {x(t, s) = _F1(s) sin(t) + _F2(s) cos(t),
             y(t, s) = _F1(s) cos(t) - _F2(s) sin(t)}
ds0:=eval(ds,t=0);
              {x(0, s) = _F2(s), y(0, s) = _F1(s)}
subs(ds0, [ic]);
                 [_F2(s) = a(s), _F1(s) = b(s)]
eval(ds,%);
             {x(t, s) = b(s) sin(t) + a(s) cos(t),
               y(t, s) = b(s) cos(t) - a(s) sin(t)}

 

 

For these kinds of maniputations, the vectors, lists, matrices etc were invented.
Example using column vectors:

gamma__w :=10:
z := <2, 1, 0, -1, -4, -7>:
h := <2, 1, 0,  0,  0,  0>:

gamma__w * (h-z);

                   

 

 

 

You have a polynomial systems with many parameters.
The result of solve would be huge and in terms of RootOfs.

Just to make an idea, let's eliminate C4 between the first two equations:

poly:=(numer@lhs)~([eq1,eq2,eq3,eq4]):
resultant(poly[1], poly[2], C4);

You will see that even this first step gives a huge polynomial.

For numerical results, give values to parameters and use fsolve.

 

The residuals are much smaller using LSSolve:

eq:=[seq(lhs(EQQ[i]),i=1..36)]:
Digits:=15:
s:=Optimization:-LSSolve(evalf(eq),iterationlimit=100000);


s := [0.960968723053680e-3, [AA[1] = -.347787136052672, AA[2] = 0.510086502851874e-1, AA[3] = 1.16178642934306, AA[4] = .283780970480705, AA[5] = 0.639701227912076e-1, AA[6] = 0.167348852743906e-2, AA[7] = .970111340350232, AA[8] = 0.123075237465221e-1, AA[9] = -2.56229943109674, AA[10] = .119761186424375, AA[11] = 0.514762128059566e-1, AA[12] = 0.653686059489268e-2, AA[13] = 1.17224901537396, AA[14] = 0.123075188025341e-1, AA[15] = -3.10469172766768, AA[16] = .119761196994863, AA[17] = 0.514762189628706e-1, AA[18] = 0.653685044254999e-2, AA[19] = .970010263800571, AA[20] = 0.122243656427024e-1, AA[21] = -2.56235367446998, AA[22] = .119187577004902, AA[23] = 0.512617524055109e-1, AA[24] = 0.636735006533654e-2, AA[25] = 1.17214793882475, AA[26] = 0.122243606766083e-1, AA[27] = -3.10474597103813, AA[28] = .119187587581231, AA[29] = 0.512617585634991e-1, AA[30] = 0.636733990163037e-2, AA[31] = .516890321334600, AA[32] = 0.510086073253494e-1, AA[33] = -1.15838655820066, AA[34] = .283780982288442, AA[35] = 0.639701289588585e-1, AA[36] = 0.167348506238467e-2]]

Digits:=40:
eval( evalf(eq), s[2]);


Unfortunately LSSolve seems to get stuck for Digits>15.

 

 

Because we already know what has to be proved, it could be done like this:

 

x1 := arcsin(1/2*(2+(2+(2+2^(1/2))^(1/2))^(1/2))^(1/2))

solve(sin(32*x)=expand(sin(32*x1)),allsolutions);

(1/32)*Pi*_Z1

(1)

a:=subs( indets(%)[]=n,%);

(1/32)*Pi*n

(2)

min[index]( [seq(abs(x1 - a), n=1..16)] );

15

(3)

'x1'=eval(a, n=%);

x1 = (15/32)*Pi

(4)

 

First 88 89 90 91 92 93 94 Last Page 90 of 120