vv

2473 Reputation

9 Badges

1 years, 275 days

MaplePrimes Activity


These are answers submitted by vv

You just need:

Eigenvectors(K, evalf(M));

(omit evalf for a symbolic solution).

 

 

plot(cos(1/theta)/sqrt(1-theta^2), theta=0.2 .. 0.99,
     labels = ['theta', typeset(cos," (","1/",theta,") / ",sqrt(sort(1-theta^2,theta,ascending)))]);

Probably o solution using Typesetting exists but with more "acrobatics".
In my opinion Maple should provide a "LaTeX" option  for such situations:
label = ['theta', LaTeX(...)],    title = LaTeX(...)   etc.

 

int(1/(x^2*sqrt(1-x^4/b^4)), x = a .. b) assuming a>0,b>a ;

 

The definition of the differential order (DO) is recursive.
Suppose that we have a single indeterminate x.
E.g. if E is a (nonconstant) expression then DO(diff(E,x)) = DO(E) + 1  and  DO(h(E)) = DO(E), h being a function.
This approach seems to be natural.

Apollo:=proc()
local A:=table([[0,-1],[-1/2,2],[1/2,2],[2*I/3,3]]), N:=4, fifth, gen;
fifth :=proc(i1,i2,i3,i4)
  local k5,z5;
  if N>500 then return fi;  
  k5 := 2*(A[i1][2]+A[i2][2]+A[i3][2])-A[i4][2];  
  z5 := (2*(A[i1][2]*A[i1][1]+A[i2][2]*A[i2][1]+A[i3][2]*A[i3][1])-A[i4][2]*A[i4][1])/k5;
  if k5<200 and not member([z5,k5],A) then N:=N+1; A[N]:=[z5,k5];
    gen(i1,i2,i3,N);
  fi;
end:
gen:= proc(i1,i2,i3,i4) fifth(i1,i2,i3,i4);fifth(i1,i2,i4,i3);
                        fifth(i1,i3,i4,i2);fifth(i2,i3,i4,i1) end;
gen(1,2,3,4);   #print(N);
plots:-display(seq(plottools:-circle([Re(A[i][1]),Im(A[i][1])],1/A[i][2]), i=1..N),
    axes=none, caption=cat("Apollonius gasket: ",N, " circles plotted"), size=[800,800])
end:

Apollo();


 

Maple does not know to manipulate indexed variables from a symbolic sum such as

s:=sum(f[i](x[i]),i=1..n);

sum(f[i](x[i]), i = 1 .. n)

(1)

For example, diff will act syntactically, giving wrong mathematical results

diff(s,x[i]);  # wrong

sum(diff(f[i](x[i]), x[i]), i = 1 .. n)

(2)

diff(s,x[j]); # wrong

0

(3)

To differentiate versus x[j]  we must split each such sum in sums independent of x[j]

 

In the previous example:

 

 

sj:=sum(op(1,s),i=1..j-1) + sum(op(1,s),i=j+1..n) + subs(i=j, op(1,s));

sum(f[i](x[i]), i = 1 .. j-1)+sum(f[i](x[i]), i = j+1 .. n)+f[j](x[j])

(4)

diff(sj, x[j]);  # OK

diff(f[j](x[j]), x[j])

(5)

diff( x[j]*sj^2, x[j]);  # OK

(sum(f[i](x[i]), i = 1 .. j-1)+sum(f[i](x[i]), i = j+1 .. n)+f[j](x[j]))^2+2*x[j]*(sum(f[i](x[i]), i = 1 .. j-1)+sum(f[i](x[i]), i = j+1 .. n)+f[j](x[j]))*(diff(f[j](x[j]), x[j]))

(6)

Note that sometimes such a split could be tricky, for example:

 

sum(x[floor(i/3)]*x[i], i=3..n);

sum(x[floor((1/3)*i)]*x[i], i = 3 .. n)

(7)

 


 

Download split.mw


 

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);

1 2 3 4 5 6 7 Last Page 1 of 32