vv

14272 Reputation

20 Badges

11 years, 27 days

MaplePrimes Activity


These are answers submitted by vv

The homogeneous coordinates are very useful to avoid degenerate cases.
A similar construction can be obtained with Cartesian coordinates.

restart;
r:=rand(-12..12):
P,Q,R := 'r()*x+r()*y+r()'$3:
q :=(a,b) -> a*Q*R+b*P*R+P*Q:
plots:-implicitplot( [P, Q, R, q(6,-6)], x=-5..5, y=-5..5, color=[red$3,blue]);

This seems to be about twice faster.

SP:= proc(A::list(set), B::list(set))
local i,j, M:=Array(1..nops(A),1..nops(B),datatype=integer[4]);
for i to nops(A) do for j to nops(B) do
  if A[i] subset B[j] then M[i,j]:=j fi od od;
[seq(subs(0=NULL,[entries(M[i],nolist)]),i=1..nops(A))]
end:

 

Maybe you should always check the envelope.
In this case,  [y=sin(x+c), cos(x+c)=0] ==> y = +-1.

Note. For the IV problem

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

Maple gives  y(x)=-1, but it has infinitely many solutions in any nbd of 0, e.g.
S:=a -> piecewise(x<a, -1, -cos(x-a));    #  0 <= a,   x<a+Pi
which probably Maple will never (?) find. 

> 

f:=product(x+i, i=1..n):

> 

answer:=simplify(residue(f/x^3,x=0)) assuming n::posint;

-(1/12)*(Pi^2-6*gamma^2-12*gamma*Psi(n+1)-6*Psi(n+1)^2-6*Psi(1, n+1))*GAMMA(n+1)

(1)
> 

# check
simplify(eval(answer,n=10)) = coeff(expand(eval(f,n=10)),x^2);

12753576 = 12753576

(2)

 

Same result with:

simplify(coeff(series(f,x), x^2));

 

 

> 

restart;

> 

with(Physics):

> 

Setup(noncommutativeprefix = {A,B,C})

[noncommutativeprefix = {A, B, C}]

(1)
> 

(2*A+B*C)^*;

2*Physics:-Dagger(A)+Physics:-`*`(Physics:-Dagger(C), Physics:-Dagger(B))

(2)
> 

lprint(%);

2*Physics:-Dagger(A)+Physics:-`*`(Physics:-Dagger(C),Physics:-Dagger(B))

 
> 

(2*A * B^(-1) - C)^*;

2*Physics:-`*`(Physics:-`^`(Physics:-Dagger(B), -1), Physics:-Dagger(A))-Physics:-Dagger(C)

(3)
> 

lprint(%);

2*Physics:-`*`(Physics:-`^`(Physics:-Dagger(B),-1),Physics:-Dagger(A))-Physics
:-Dagger(C)

 
> 

 

 

ex:=sqrt(4*n^2+5*n-7)/n:
sqrt(expand(ex^2)); 

(assuming n>0).

You should be aware that in Maple it could be difficult to obtain the answer in a preferred form.

Maple can solve systems of polynomial inequalities. SemiAlgebraic is more flexible than solve.

sys := r-c>0, 0<=r^2 - 2*r*c -r +2*c, r^2 - 2*r*c -r +2*c  < (r-c)^2, 0<=c, c<=1 , 0<r, r<1, r<2*c:
SolveTools:-SemiAlgebraic([sys], [r], parameters=[c]);

       

The system has infinitely many solutions:

Sys:=lhs~(sys):
Groebner:-IsZeroDimensional(Sys);  # ==> false

To see some of them:

solve(sys, maxsols=10);

 

Somehow the names of the parameters returned by dsolve are local

 

> 

sol:=dsolve( {diff(x(t),t)=a, x(0)=1}, numeric, parameters=[a]): # x(t)=a*t+1

> 

type(a, `local`);

false

(1)
> 

sol(parameters);

[a = undefined]

(2)
> 

aa:=lhs(%[]);

a

(3)
> 

type(aa,`local`); # !!

true

(4)
> 

sol(parameters=[a=3]); # Works

[a = 3.]

(5)
> 

sol(10)

[t = 10., x(t) = HFloat(31.000000000000007)]

(6)
> 

sol(parameters=[aa=5]); # the locals not accepted

Error, (in dsolve/numeric/process_parameters) parameter(s) {a} are specified, but are not defined for the problem

 
> 

 

 

I don't see this as a real (annoying) bug, because sol(parameters)  and sol(parameters=...) is supposed to be used only for display purposes.

Here are two working solutions.

1. Create a file A.mpl and use $include

module A()
$include "B.mpl";
export foo:=proc()
  0;
 end proc;
end module;

and in the worksheet use
read "A.mpl"

2. Remove the export from B.mpl, i.e. it will contain 

boo:=proc()
return 0;
end proc; 

and use in the worksheet:

module A()
export boo,foo;
read "B.mpl";

foo:=proc()
  0;
 end proc;
end module;


 

You cannot, because they differ by a constant.

The transform seems to be conformal. The picture was copied from https://en.wikipedia.org/wiki/Conformal_map  but the aspect ratio is not the same, so, the angles are not exactly preserved.

A projective transformation does not preserve the angles but preserves the lines.

And yes, of course, plottools:-transform command can be used.

 

> 

restart;

> 

N:=15:

> 

# f:=(x,y) -> (Re,Im)(sin(x+I*y):

> 

f:=(x,y) -> (Re,Im)(ln(1+I*(1+x+I*y)^2/9)):

> 

P:=plot([seq([x,y,x=0..1],y=0..1,1/N), seq([x,y,y=0..1],x=0..1,1/N)]);
plot([seq([f(x,y),x=0..1],y=0..1,1/N), seq([f(x,y),y=0..1],x=0..1,1/N)],scaling=constrained);

 

 
> 

# Using plottools:-transform
with(plottools):with(plots):
F := transform((x, y) -> [f(x,y)]):

> 

plots:-display(<P|F(P)>, scaling=constrained); # Not executed, to be accepted by mapleprimes.

> 

 

 

The RootOf function is used to represent (not to compute) algebraic numbers (and other numbers). It will be used by many Maple commands, so, a compact and uniform representation is essential and the _Z notation seems to be convenient.
Commands like limit and sum are used in general to compute, not to represent expressions.
Anyway, a beginner seldom uses RootOf in input; he/she will see it only as a result of a computation (in solve, int etc) and any tutorial should mention this.
 
P.S. I was always puzzled by another unique Maple notation for a function name: GAMMA, instead of Gamma, the only one with all the letters capitalized.

Why dou you think that the integral can be expressed in terms of known functions?
Note that even int(sqrt(cos(t)^2+cos(2*t)^2),t)  has a complicated form and int(sqrt(cos(t)^2+cos(3*t)^2),t)  is already too much! 

1. The parantheses are not ignored; they are not displayed, being superfluous in this case, similar to a + (b*c), due to the order of precedence of the Maple operators.

2. Unfortunately Maple does not simplify the set operators; they are used mainly for explicit sets.
If you need to check or simplify expressions in set theory, you can use the Logic package because it works practically in a Boolean algebra.

First 35 36 37 38 39 40 41 Last Page 37 of 122