sursumCorda

1284 Reputation

15 Badges

3 years, 82 days

MaplePrimes Activity


These are questions asked by sursumCorda

According to print - Maple Help (maplesoft.com),

calling print[N] instead of print where N is an integer between -2 and +3, temporarily overrides the prettyprint interface variable.

However, I find that 

print[-2]();
Error, prettyprint must be an integer in the range 0..3
print[-1]();
Error, prettyprint must be an integer in the range 0..3

Also, 

interface(prettyprint = -2);
Error, (in interface) prettyprint must be an integer in the range 0..3
interface(prettyprint = -1);
Error, (in interface) prettyprint must be an integer in the range 0..3

Did I miss something?

I'd like to reproduce Initial Value DDE of Neutral Type in Maple.
The differential equation is: 

deq := D(y)(t) = 2*cos(2*t)*y(t/2)^(2*cos(t)) + ln(D(y)(t/2)) - ln(2*cos(t)) - sin(t): # with y(0) = 1 and known D(y)(0)

Unfortunately, if I type valid initial values, Maple will simply generate , and yet if I just give a partial initial condition, Maple will display and only return incorrect results. 
 

restart;

interface(version)

`Standard Worksheet Interface, Maple 2023.1, Windows 10, July 7 2023 Build ID 1723669`

(1)

deq := (D(y))(t) = 2*cos(2*t)*y((1/2)*t)^(2*cos(t))+ln((D(y))((1/2)*t))-ln(2*cos(t))-sin(t)

RealDomain:-solve(subs(t = 0, y(0) = 1, deq), (D(y))(0))

2, -LambertW(-2*exp(-2))

(2)

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[1]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = 2}

 

dsolve({deq, y(0) = 1, (D(y))(0) = (2, -LambertW(-2*exp(-2)))[2]}, 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

Error, (in dsolve/numeric/DAE/initial) too many initial conditions, the following are not needed: {D(y)(0) = -LambertW(-2*exp(-2))}

 

dsn := dsolve({deq, y(0) = 1}, 'type' = 'numeric', 'delaymax' = Pi, 'range' = 0 .. 2*Pi)

plots['odeplot'](dsn, 0 .. 2*Pi)NULL

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

`[Length of output exceeds limit of 1000000]`

 

Warning, cannot evaluate the solution past the initial point, problem may be complex, initially singular or improperly set up

 

 


 

Download ndelay.mw

The output is wrong. Note that "y(0) = 1" is insufficient to uniquely specify a solution, as "D(y)(0)" can be either -LambertW(-2/exp(2)) or 2. But Maple does not allow sufficient constraints here. How do I avoid such an unexpected behavior?

Here is a test: 

For small matrices, apart from the first call, the performance is almost perfect (🎉!). 
As a comparison, an equivalent test may be performed in modern Python:

As you can see, for 1024×1024, 2048×2048, 4096×4096, 8192×8192, and 16384×16384 matrices, Maple's performance gets pretty poor. Is the FFT procedure not well optimized for larger matrices? I do have read the Fourier Transforms in Maple, yet I cannot find any information on this subject. 
In accordance with the following output 

showstat(DiscreteTransforms::FFT_complex8, 3):

FFT_complex8 := proc()
       ...
   3   :-DiscreteTransforms:-FFT_complex8 := LinkExternal('hw_FFT',2003);
       ...
end proc

it appears that the code hasn't been developed for 20 years. Is it possible to improve the performance of the FFT built into Maple in order that the computation on such a 2¹⁴×2¹⁴ matrix can be achieved in about twenty seconds (rather than in two minutes)?

Note. For these matrices, exact transform results (see below) can be obtained symbolically.

for n from 0 to 12 do
    m := LinearAlgebra:-HankelMatrix(<$ (1 + 1 .. 2**n + 2**n)>, datatype = complex[8], shape = []): gc();
    print(n, andseq(abs(_) < HFloat(1, -10, 2), _ in SignalProcessing:-FFT(m, normalization = none, inplace = true) - Matrix(2^n, <2^(2*n)*(2^n + 1), <'2^(2*n - 1)*(:-cot((k - 1)/2^n*Pi)*I - 1)' $ 'k' = 1 + 1 .. 2^n>>, shape = symmetric, storage = sparse, datatype = complex[8])) (* faster than `rtable_scanblock` and `ArrayTools:-IsZero` and much faster (🎊!) than `comparray` and `verify/Matrix` with testfloat *) )
od:
 = 
                            0, true

                            1, true

                            2, true

                            3, true

                            4, true

                            5, true

                            6, true

                            7, true

                            8, true

                            9, true

                            10, true

                            11, true

                            12, true

However, the main goal is to test the numerical efficiency of Maple's fast Fourier transform algorithm.

It appears to me that "simplify/siderels" with two arguments is simply some special "simplify" procedure that just makes use of assumptions, but the results of experiments seem to tell an opposite story. 

simplify(sqrt(x**2), [x = 0]);
                               0

simplify(sqrt(x**2), assume = [x = 0]);
                               0

simplify(ln(exp(x)), [x = 0]);
                               0

simplify(ln(exp(x)), assume = [x = 0]);
                               x

`assuming`(simplify(ln(exp(x))), [x = 0]);
                               x

simplify((1 - cos(x)**2 + sin(x)*cos(x))/(sin(x)*cos(x) + cos(x)**2), [sin(x)**2 + cos(x)**2 = 1]);
                            2                
                  1 - cos(x)  + sin(x) cos(x)
                  ---------------------------
                   cos(x) (cos(x) + sin(x))  

simplify((1 - cos(x)**2 + sin(x)*cos(x))/(sin(x)*cos(x) + cos(x)**2), assume = [sin(x)**2 + cos(x)**2 = 1]);
                             tan(x)

How to explain these? 

Why can't a singular call fully simplify them? 
 

restart;

(* in △ABC *)

tp1 := [cot((1/2)*A)/(cot(A)+cot((1/2)*A))-cos((1/2)*B)*cos((1/2)*C), ((sin(B)+sin(C))*cos((1/2)*A)+4*sin((1/2)*A)*cos((1/2)*B)*cos((1/2)*C))*(1-sin((1/2)*A)/(cos((1/2)*B)^2+cos((1/2)*C)^2))-(sin(B)+sin(C))*sec((1/2)*A), (1+cos(2*A))/(1+cos(A))+(1+cos(2*B))/(1+cos(B))+(1+cos(2*C))/(1+cos(C))]

tp2 := [sin((B-C)*(1/4))^2+sin((1/2)*A)*(2-csc((1/2)*A))^2/(4*tan((Pi-A)*(1/4))*(cot(A)+cot((1/2)*A))), 16*sin((1/2)*A)^2*sin((B+C)*(1/4))^2*sin((B-C)*(1/4))^4/(cos((1/2)*B)^2+cos((1/2)*C)^2), 1+(tan((1/2)*B)*sin(C)-tan((1/2)*C)*sin(B))^2+(tan((1/2)*B)*cos(C)+tan((1/2)*C)*cos(B)-tan((1/2)*A))^2]

simplify(`~`[`-`](tp1, tp2), {A+B+C = Pi}, 'mindeg', assume = positive)simplify(%)

[(1/4)*(-4*cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^2+(-4*cos((1/2)*B)*(cot(A)+cot((1/2)*A))*sin((1/2)*A+(1/2)*B)+4*cot((1/2)*A))*cot((1/4)*Pi+(1/4)*A)-sin((1/2)*A)*(csc((1/2)*A)-2)^2)/(cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))), (-16*sin((1/2)*A)^2*cos((1/4)*Pi+(1/4)*A)^2*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^4+4*sin((1/2)*A)*cos((1/2)*B)*sin((1/2)*A+(1/2)*B)^3+(cos((1/2)*A)-sec((1/2)*A))*(sin(B)+sin(A+B))*sin((1/2)*A+(1/2)*B)^2+(4*cos((1/2)*B)^3*sin((1/2)*A)-4*sin((1/2)*A)^2*cos((1/2)*B))*sin((1/2)*A+(1/2)*B)+((cos((1/2)*A)-sec((1/2)*A))*cos((1/2)*B)^2-cos((1/2)*A)*sin((1/2)*A))*(sin(B)+sin(A+B)))/(cos((1/2)*B)^2+sin((1/2)*A+(1/2)*B)^2), (-(1+cos(B))*(cos(B)^2+sin(B)^2)*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)^2+2*(1+cos(B))*((sin(A+B)*sin(B)+cos(B)*cos(A+B))*tan((1/2)*B)+tan((1/2)*A)*cos(B))*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)-(1+cos(B))*(1+cos(A))*cos(2*A+2*B)-(cos(A+B)-1)*(sin(A+B)^2+cos(A+B)^2)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)^2-2*tan((1/2)*A)*cos(A+B)*(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)-(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*A)^2+((1+cos(B))*cos(2*A)+(1+cos(A))*cos(2*B)-cos(A)*cos(B)+1)*cos(A+B)+(-cos(B)-1)*cos(2*A)+(-cos(A)-1)*cos(2*B)-cos(A)-cos(B)-2)/((cos(A+B)-1)*(1+cos(B))*(1+cos(A)))]

 

[0, 0, 0]

(1)

simplify(`~`[`-`](tp1, tp2), {B+C = Pi-A}, 'mindeg', assume = positive)simplify(%)

[(1/4)*(-4*cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^2+(-4*cos((1/2)*B)*(cot(A)+cot((1/2)*A))*sin((1/2)*A+(1/2)*B)+4*cot((1/2)*A))*cot((1/4)*Pi+(1/4)*A)-sin((1/2)*A)*(csc((1/2)*A)-2)^2)/(cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))), (-16*sin((1/2)*A)^2*cos((1/4)*Pi+(1/4)*A)^2*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^4+4*sin((1/2)*A)*cos((1/2)*B)*sin((1/2)*A+(1/2)*B)^3+(cos((1/2)*A)-sec((1/2)*A))*(sin(B)+sin(A+B))*sin((1/2)*A+(1/2)*B)^2+(4*cos((1/2)*B)^3*sin((1/2)*A)-4*sin((1/2)*A)^2*cos((1/2)*B))*sin((1/2)*A+(1/2)*B)+((cos((1/2)*A)-sec((1/2)*A))*cos((1/2)*B)^2-cos((1/2)*A)*sin((1/2)*A))*(sin(B)+sin(A+B)))/(cos((1/2)*B)^2+sin((1/2)*A+(1/2)*B)^2), (-(1+cos(B))*(cos(B)^2+sin(B)^2)*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)^2+2*(1+cos(B))*((sin(A+B)*sin(B)+cos(B)*cos(A+B))*tan((1/2)*B)+tan((1/2)*A)*cos(B))*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)-(1+cos(B))*(1+cos(A))*cos(2*A+2*B)-(cos(A+B)-1)*(sin(A+B)^2+cos(A+B)^2)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)^2-2*tan((1/2)*A)*cos(A+B)*(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)-(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*A)^2+((1+cos(B))*cos(2*A)+(1+cos(A))*cos(2*B)-cos(A)*cos(B)+1)*cos(A+B)+(-cos(B)-1)*cos(2*A)+(-cos(A)-1)*cos(2*B)-cos(A)-cos(B)-2)/((cos(A+B)-1)*(1+cos(B))*(1+cos(A)))]

 

[0, 0, 0]

(2)

simplify(`~`[`-`](tp1, tp2), {A = Pi-B-C}, 'mindeg', assume = positive)simplify(%)

[(1/4)*(-4*cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^2+(-4*cos((1/2)*B)*(cot(A)+cot((1/2)*A))*sin((1/2)*A+(1/2)*B)+4*cot((1/2)*A))*cot((1/4)*Pi+(1/4)*A)-sin((1/2)*A)*(csc((1/2)*A)-2)^2)/(cot((1/4)*Pi+(1/4)*A)*(cot(A)+cot((1/2)*A))), (-16*sin((1/2)*A)^2*cos((1/4)*Pi+(1/4)*A)^2*cos((1/4)*Pi+(1/4)*A+(1/2)*B)^4+4*sin((1/2)*A)*cos((1/2)*B)*sin((1/2)*A+(1/2)*B)^3+(cos((1/2)*A)-sec((1/2)*A))*(sin(B)+sin(A+B))*sin((1/2)*A+(1/2)*B)^2+(4*cos((1/2)*B)^3*sin((1/2)*A)-4*sin((1/2)*A)^2*cos((1/2)*B))*sin((1/2)*A+(1/2)*B)+((cos((1/2)*A)-sec((1/2)*A))*cos((1/2)*B)^2-cos((1/2)*A)*sin((1/2)*A))*(sin(B)+sin(A+B)))/(cos((1/2)*B)^2+sin((1/2)*A+(1/2)*B)^2), (-(1+cos(B))*(cos(B)^2+sin(B)^2)*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)^2+2*(1+cos(B))*((sin(A+B)*sin(B)+cos(B)*cos(A+B))*tan((1/2)*B)+tan((1/2)*A)*cos(B))*(cos(A+B)-1)*(1+cos(A))*cot((1/2)*A+(1/2)*B)-(1+cos(B))*(1+cos(A))*cos(2*A+2*B)-(cos(A+B)-1)*(sin(A+B)^2+cos(A+B)^2)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)^2-2*tan((1/2)*A)*cos(A+B)*(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*B)-(cos(A+B)-1)*(1+cos(B))*(1+cos(A))*tan((1/2)*A)^2+((1+cos(B))*cos(2*A)+(1+cos(A))*cos(2*B)-cos(A)*cos(B)+1)*cos(A+B)+(-cos(B)-1)*cos(2*A)+(-cos(A)-1)*cos(2*B)-cos(A)-cos(B)-2)/((cos(A+B)-1)*(1+cos(B))*(1+cos(A)))]

 

[0, 0, 0]

(3)


 

Download trigReduce.mw

Is there any limitation of `simplify/trig`?

 

First 11 12 13 14 15 16 17 Last Page 13 of 24