vv

13158 Reputation

20 Badges

9 years, 83 days

MaplePrimes Activity


These are answers submitted by vv

Maple can find them, but must be asked politely! :-)

X := (x, k)-> int(cos(s^k), s = 0 .. x):

X(infinity,k) assuming k>1;

X(infinity,5/2); evalf(%);

     0.7178115070

Similarly for Y.

 

lagrange:=proc(f, g::list, vars::list, lambdas::list)
local L;
if nops(g)<>nops(lambdas) then error "lambdas and g must agree" fi;
L:=f + add(g[i]*lambdas[i],i=1..nops(g));
solve( {seq( diff(L,u),u=vars),op(g)},{op(vars),op(lambdas)})
end:

lagrange(a*b,[z-a-b],[a,b],[p]);

lagrange(a[2]*b[2], [z-a[2]-b[2]],[a[2],b[2]], [lambda]);

 

lagrange(x^2+y+z,[x-2*y-3*z, x+4*y+z-2 ],[x,y,z],[a,b]);

 

 Edit.
In your code use:
solve({eq1,eq2,eq3},{x,y,lambda});
and it will work.

 

f:=cos(t),sin(t);  # on [0,Pi]
T:=Pi; dx:=2;
fper:=cos(T*frac(t/T))+dx*floor(t/T),sin(T*frac(t/T));  # for t>=0 only

plot( [fper, t=0..4*T],scaling=constrained);




You can simply add p[i]+p[j] <> 0 etc in the system. E.g.

expand((x+y)*x*(x+y+5)):
solve({%, x+y<>0, x<>0}, {x,y});

 

The expresion

f:=3^(-(1/2)*n)*2^((1/6)*n)-2^((2/3)*n)*6^(-(1/2)*n);

should simplify to 0 even for a complex n !!

Now, convert(f,exp) should produce exp( ln(3) *...)...
but it gives

(IIRC Maple used to get this right.)

Without any assumption:

subs(n = ln(z), f):

simplify(%);

    0

f:=x->piecewise(x<1,x^2,(2-x)^2):

f_per:=x->f(x-2*floor(x/2)):

seq is faster but $ works in symbolic contexts e.g.

[x[i], y[i]] $ i=1..n;

diff( exp(a*x),  x$n);

where n is a symbol.

You may use

simplify(g,radical,symbolic);


Be aware that the validity depends on the domain of u in this case. 

Why don't you switch to 1D math and use simply:

diff(u, y, y, t);

 

 

It is a Maple evaluation peculiarity. In sum, the argument  N[i] is evaluated first (before the index i is defined).

You must use

sum('N[i]', i = 1..4);
    1

Or, better, use add, for which the evaluation rule is different.
add(N[i], i = 1..4);
   
1

restart;
p:=10:
dx_:=seq(x[i]=0..1,i=1..p-1):
sx_:=add(x[i],i=1..p-1):
H:=int( Heaviside(xp-sx_)*Heaviside(1-xp+sx_),  dx_ ):
int( exp(-xp^3)*H, xp=0..p,  numeric);
        0.000002546120390

# However the method is slow for higher accuracy and does not provide the exact result.
# It has the advantage that it works in other situations too.

There are an infinity of equivalent systems: e.g.

F(a, b, c) = F( s/RootOf(_Z^2-s^2+s), -RootOf(_Z^2-s^2+s)/s, RootOf(_Z^2-s^2+s) )

where F is any bijection R^3 --> R^3 (or C^3 --> C^3).

Here, an interesting situation is to eliminate the RootOf. For this, denote it by r, and use its definition ==>

[a = s/r, b = -r/s, c = r, r^2-s^2*r+s=0 ];
# Then use eliminate
eliminate(%,r);

 

 

So, your equivalent system without RootOfs is

 

 

restart;
p:=10;
dx:= seq(x[i]=0..1,i=1..p);
h:= add(x[i],i=1..p);

We want to compute Int(exp(-h^3),  dx) 
(in older versions of Maple, dx must be replaced by [dx]).

Taking the power series of exp, we need to compute Int( h^k,  dx).
Maple is able to compute it symbilically, but the direct computation is extremely slow (for p=10) and I had to interrupt and help Maple:

f:=u^k:

for j to p do
  simplify(int(subs(u=u+t,%),t=0..1),size) * (k+j)
  assuming k>=0,u>0 od: simplify(%):
Jp:=subs(u=0,%)/mul(k+j,j=1..p):
J:=unapply(Jp,k):
result:=sum(J(3*k)/k!*(-1)^k,k=0..infinity);

 

evalf[50](result);

      0.000002546120389594240309918560289962734341705715230458

 

It was a pure luck that the series was obtained symbolically.
But note that anyway we can compute it numerically.
It is interesting to note that even if the convergence is very fast, the first terms are huge.
e.g.
max(seq(J(3*k)/k!,k=0..3000)):evalf(%);

 

max(seq(J(3*k)/k!,k=3000..4000)):evalf(%);

resultnum:=evalf[50]( add(J(3*k)/k!*(-1)^k, k=0..3000) );

 

 

The integral can be computed exactly: just replace Int by int.

For a 6 fold integral, a standard numerical integration is almost impossible. Consider the fact that if one has 100 division points in each interval, the function will be evaluated 10^12 times!

f:=series( exp(k*t)*cos(w*t),t=0);
series(f/exp(k*t),t=0);

 

First 108 109 110 111 112 113 114 Page 110 of 116