vv

5238 Reputation

9 Badges

3 years, 120 days

MaplePrimes Activity


These are answers submitted by vv

Maple does not have a predicate logic package.

Sometimes we can use the assume facility  but only for very simple situations.
(For the existence quantifier probably only for a single variable!)
For other situations use solve, isolve, Logic package etc.

 

# Example:  Maple cannot prove Fermat theorem.

coulditbe(x^n + y^n = z^n) assuming x::posint, y::posint,z::posint,n::posint,n>2;  

FAIL

(1)

 

### Your problems

## 1 ##   cn2Z, 2*n > n+2   

is(2*n>n+2) assuming n::integer;

false

(2)

# compare:
is(2*n>=n+2) assuming (n/3) :: posint;

true

(3)

## 2 ##   dn2Z, 2 |( 3n+1)   

coulditbe( ((3*n+1)/2) :: integer)  assuming n::integer;

true

(4)

##  compare:

coulditbe( ((3*n+1)/2) :: integer)  assuming n::even;

false

(5)

## 3 ##   dk2Z,  cn2Z,  n=k*n
solve(n=n*k);
has([%], n=n);

{k = k, n = 0}, {k = 1, n = n}

 

true

(6)

 

restart:
A:= <x1,y1,z1>:
B:= <x2,y2,z2>:
P :=<x3, y3, z3>:
H:=A+t*(B-A):
solve( (P-H)^+ . (B-A), t ):
'H'=eval(H, t=% );

 

For multivariate polynomials there is no unique quotient and remainder. quo and rem work for univariate polynomials.

The "long division" must be defined in terms of a monomial order, see wiki-link

 

In Maple the computations can be done with the Groebner package.

 

Example.

 

A:=a*x^5*y^3+b*x*y+c*y^4+x+1;

a*x^5*y^3+c*y^4+b*x*y+x+1

(1)

B:=x^2+e*x*y^2+f*y^2+y+2;

e*x*y^2+f*y^2+x^2+y+2

(2)

r:=rem(A,B,x);  # A,B seen as univariate in variable x.

(a*e^4*y^11-3*a*e^2*f*y^9-3*a*e^2*y^8-6*a*e^2*y^7+a*f^2*y^7+2*a*f*y^6+4*a*f*y^5+a*y^5+4*a*y^4+4*a*y^3+b*y+1)*x+a*e^3*f*y^11+a*e^3*y^10+2*a*e^3*y^9-2*a*e*f^2*y^9-4*a*e*f*y^8-8*a*e*f*y^7-2*a*e*y^7-8*a*e*y^6-8*a*e*y^5+c*y^4+1

(3)

q:=quo(A,B,x);

a*y^3*x^3-a*e*y^5*x^2+(a*e^2*y^7-a*f*y^5-a*y^4-2*a*y^3)*x-a*e^3*y^9+2*a*e*f*y^7+2*a*e*y^6+4*a*e*y^5

(4)

normal( A - (B*q+r) );

0

(5)

######### Now, using Groebner.

r1:=Groebner:-NormalForm(A, [B], plex(x,y));  # lexicographic order

a*e^4*x*y^11-3*a*e^2*f*x*y^9-3*a*e^2*x*y^8+y^7*x*(-6*a*e^2+a*f^2)+2*a*f*x*y^6+y^5*x*(4*a*f+a)+4*a*y^4*x+4*a*y^3*x+b*x*y+x+a*e^3*f*y^11+a*e^3*y^10+y^9*(2*a*e^3-2*a*e*f^2)-4*a*e*f*y^8+y^7*(-8*a*e*f-2*a*e)-8*a*e*y^6-8*a*e*y^5+c*y^4+1

(6)

q1:=normal((A-r1)/B);

-(e^3*y^6-e^2*x*y^4-2*e*f*y^4+e*x^2*y^2-2*e*y^3+f*x*y^2-4*e*y^2-x^3+x*y+2*x)*a*y^3

(7)

normal( A - (B*q1+r1) );

0

(8)

r2:=Groebner:-NormalForm(A, [B], tdeg(x,y));   # tdeg order

-a*x^6*y/e+a*f*x^5*y/e^2+a*x^5/e^2+(-2*a*e^4-a*e^2*f^2)*x^4*y/e^5-2*a*f*x^4/e^3+(2*a*e^3*f+a*e*f^3+a*e^3)*x^3*y/e^5+(2*a*e^3+3*a*e*f^2)*x^3/e^5+(-2*a*e^2*f^2-a*f^4-2*a*e^2*f)*x^2*y/e^5+(-4*a*e^2*f-4*a*f^3)*x^2/e^5+(b*e^5+2*a*e*f^3+3*a*e*f^2)*x*y/e^5+(e^5+6*a*e*f^2)*x/e^5+c*y^4-a*f^5*y^3/e^5-5*a*f^4*y^2/e^5+(-2*a*f^4-4*a*f^3)*y/e^5+(e^5-8*a*f^3)/e^5

(9)

q2:=normal((A-r2)/B);

(e^4*x^4*y-e^3*f*x^3*y+e^2*f^2*x^2*y-e^3*x^3-e*f^3*x*y+2*e^2*f*x^2+f^4*y-3*e*f^2*x+4*f^3)*a/e^5

(10)

normal( A - (B*q2+r2) );

0

(11)

 

If you set Digits:=15 at the beginning of the worksheet (which is always a good idea), the integral will be finite (6.32 ...). Even TP(3, 10^(-5)) will be finite (7.59...).

Explanation. For Digits=10, if you replace in TP int with Int, you will see that TP(3, 10^(-4)) is
const * int(1/sqrt(1.0 - cos(theta)) ,  theta = 0 .. const).
So, the integral is divergent.
Here 1.0 appears due to roundoff errors; the exact value is strictly > 1. For a larger Digits ==>  1/sqrt(1+eps - cos(theta)) and the integral is convergent.

 

By default, verify checks syntactically the equality (without any simplification).
We can use:
verify(2*cos(phi)^2-1, cos(2*phi), simplify);
or
verify(2*cos(phi)^2-1, cos(2*phi), expand);
to obtain the desired result (true).

So, you actually want

asympt( (2 * Pi * n) ^ (1/(2*n)), n, 2);
           

(the fact that taylor also works instead of asympt is strange; it should not).

You are expecting O(ln(n)^2/n^2) instead of O(1/n^2).
This would be true in terms of the standard Landau notation  O(...).  But Maple uses a modified version where the sub-polynomial functions are ignored; e.g. in this Maple notation O(ln(n)) = O(1).

Note that MultiSeries:-asympt  uses the true Landau notation. So,

MultiSeries:-asympt( (2 * Pi * n) ^ (1/(2*n)), n, 2);
will produce the expected result.

You cannot do much about this. The automatic simplification in Maple transforms 5*(x+1)+y into 5*x+5+y.
There are some tricks (such as Kitonum's) but they work only temporarily (i.e. the next evaluation reverses the transform) or can be used only for display purposes (and not for computations). It is more convenient to accept it.

Q:=proc(k::list(nonnegint))
local P,i;
P := combinat:-cartprod([seq([seq(0..i)],i=k)]);
while not P[finished] do 
  print( add(i, i = P[nextvalue]()) ) 
end do;
end:

Q([2,3]);
                               0
                               1
                               2
                               3
                               1
                               2
                               3
                               4
                               2
                               3
                               4
                               5

In more recent versions it is better to use Iterator:-CartesianProduct

P:=proc(k::list(nonnegint))
local M,i,v;
M := Iterator:-CartesianProduct(seq([seq(0..i)],i=k);
for v in M do print(add(v[])) od
end;

 

The integrand has the form

F := a*exp(b*v^2)*v^c;
So,
int(F, v) :  simplify(%);


i.e. it can be expressed via incomplete GAMMA ( = the  2-arguments GAMMA).

 

If you select that line and convert it to 1D Math input (even if it appears to be 1D), the asterisk will be visible.

Why don't you use worksheet mode with 1D input?

L1 := [{3,5},{4,3},{4,6},{3,2},{2,6}]:
L2 := [1,5,4]:
evalb( `union`(L1[]) intersect {L2[]} <> {} );

    true

pde0:=diff(u(x,t),t)+diff(u(x,t),x)=0;
sol0:=pdsolve(pde0,u(x,t)) assuming x>0;
pdetest(sol0,pde0);

diff(u(x, t), t)+diff(u(x, t), x) = 0

 

u(x, t) = _F1(-x+t)

 

0

(1)

pde:=diff(u(x,t),t)+diff(u(x,t),x)=0;
bci:= u(0,t)=0, u(x,0)=sin(x);
sol:=pdsolve([pde,bci],u(x,t)) assuming x>0;
pdetest(sol,pde);

diff(u(x, t), t)+diff(u(x, t), x) = 0

 

u(0, t) = 0, u(x, 0) = sin(x)

 

u(x, t) = -sin(-x+t)*Heaviside(x-t)

 

0

(2)

restart;

# Executing all (with (!!!)) ==> 0
# Executing then only the 2nd execution group ==> <>0

#    Dirac(t-x)*sin(t)*cos(x)-Dirac(t-x)*cos(t)*sin(x)-Dirac(x-t)*sin(t)*cos(x)+Dirac(x-t)*cos(t)*sin(x)

 

This is strange but not a real bug. Let's call it "semi-bug".

Note first that the solution of the pde (with bci) is not a classic one. In fact, the solution (containing Heaviside) is continuous but not C^1; actually the partial derivatives do not exist on the line x=t.

I don't know what pdetest does to test the solution but obviously sol does not satisfy the pde everywhere. On the other side, the nonzero result of pdetest  simplifies to 0 with assuming x>t; also for assuming x<t

So, both results of pdetest(sol,pde)  (zero or not zero)  are correct; the problem is that this depends on the order of execution!

 

I mention that I used Maple 2018.2 without any update.

 

 


Download pde!!!.mw

I'd use

A:=[x1,x2,x3]:
B:=[f(x),g(x)]:
[seq([seq(eval(b,x=a),a=A)],b=B)];

        [[f(x1), f(x2), f(x3)], [g(x1), g(x2), g(x3)]]

The command  Get('xxx1')   returns a string, but you need an exprseq. Use parse(Get('xxx1')).
Or, simply add the line
xxx := parse(xxx);  o := parse(o);  co := parse(co);

These are mathematical conventions. For degree(0) alternative conventions are -1  and "undefined".
- infinity is preferable because e.g. the equality  degree(f*g) = degree(f) + degree(g)  remains valid.
These conventions are related (and compatible) with other two standard ones:
max({}) = - infinity  and  min({}) = infinity.

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