vv

12453 Reputation

19 Badges

9 years, 284 days

MaplePrimes Activity


These are answers submitted by vv

restart;

conic:=(P,Q,R,a,b) -> a*Q*R+b*P*R+P*Q:

line:=(x1,y1,x2,y2)->(x-x1)*(y2-y1)-(y-y1)*(x2-x1):

Delta:=qq -> diff(qq,x,y)^2-diff(qq,x,x)*diff(qq,y,y):

########

pts:=[[1,2],[-2,2],[2,3]]:

PQR:=line(pts[1][],pts[2][]), line(pts[2][],pts[3][]), line(pts[3][],pts[1][]):

co:=conic(PQR, 2, b):

solve(Delta(co)>0); evalf([%]);

RealRange(-infinity, Open(3-2*2^(1/2))), RealRange(Open(3+2*2^(1/2)), infinity)

 

[RealRange(-infinity, Open(.171572876)), RealRange(Open(5.828427124), infinity)]

(1)

co1:=eval(co,b=2): co2:=eval(co,b=-8):

plots:-implicitplot( [PQR, co1, co2], x=-4..4, y=0..8, color=[red$3,blue,green], scaling=constrained);

 

 

Note. You may add a parabola for b=3+2*sqrt(2).

Use subs instead of alias

S:=[seq(_C||k=c[k], k=0..10)]:
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sort(subs(S,sol));    #sort~(subs(S,[sol]))[]

 

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.
First 24 25 26 27 28 29 30 Last Page 26 of 111