MaplePrimes Questions

How does a user retain existing inline output (for example, computational output or inline plots) when re-executing an execution group in recent versions of Maple?  The "Replace existing output when re-executing groups" option is not available in Maple 2023 or in Maple 2020.

For example, I want to execute the same execution group 2 times to generate 2 different inline plots as the output. I want to retain the first inline plot when I generate the second inline plot.  However, the default Maple 2023 behavior is to overwrite the first inline plot with the second inline plot.

Several Maple versions ago (for example, Maple 18), there was the Tools > Option > Display > "Replace existing output when re-executing groups" option. When that option is checked, the second plot overwrites the first plot. In contrast, when that option is unchecked, the second plot appears after the retained first plot.

Where is the "Replace existing output when re-executing groups" option in recent Maple versions? Or do recent versions, like Maple 2023, use a different method to retain existing output when re-executing an execution group?

I think that the following worksheet is self-explaining: 
 

restartNULL

interface(version)

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

(1)

evalf(LinearAlgebra:-MatrixFunction(`<|>`(`<,>`(1, 0, 0), `<,>`(1, 1, I), `<,>`(3, 0, 2)), 'x'/(exp('x')-1), 'x'))

Matrix(%id = 36893489913840207380)

(2)

(* Yet in many cases, the input may be inexact, for we need to speed up computations and decrease memory usage. *)

m := Matrix([[1, 1, 3], [0, 1, 0], [0, I, 2]], datatype = complex(sfloat)):
Digits := 10:
do
    print(CodeTools:-Usage(LinearAlgebra:-MatrixFunction(m, 'x'/(exp('x') - 1), 'x'), quiet), Digits++)
until Digits > 20:

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.3333333333+.1931757357*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 10

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.33333333332+.19317573586*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 11

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.333333333321+.193175735853*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 12

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.3333333333209+.1931757358526*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 13

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.33333333332087+.19317573585263*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 14

 

Matrix(3, 3, {(1, 1) = .5819767069, (1, 2) = -.333333333320870+.193175735852624*I, (1, 3) = -.8068242642, (2, 1) = 0., (2, 2) = .5819767069, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352855}), 15

 

Matrix(3, 3, {(1, 1) = .5819767068693265, (1, 2) = .9999999999999999-3.806824264*I, (1, 3) = -.8068242641099854, (2, 1) = 0., (2, 2) = .5819767068693265, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352854993314}), 16

 

Matrix(3, 3, {(1, 1) = .58197670686932644, (1, 2) = .99999999999999997-3.806824264*I, (1, 3) = -.80682426410998598, (2, 1) = 0., (2, 2) = .58197670686932644, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .31303528549933112}), 17

 

Matrix(3, 3, {(1, 1) = .581976706869326423, (1, 2) = -.999999999999999997+2.19317573589001464*I, (1, 3) = -.806824264109985348, (2, 1) = 0., (2, 2) = .581976706869326423, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .313035285499331308}), 18

 

Matrix(3, 3, {(1, 1) = .5819767068693264245, (1, 2) = -.2500000000000000000-0.5682426411e-1*I, (1, 3) = -.8068242641099853627, (2, 1) = 0., (2, 2) = .5819767068693264245, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414214*I, (3, 3) = .3130352854993313037}), 19

 

Matrix(%id = 36893489913905117652), 20

(3)

# Is `linalg:-matfunc` better than `LinearAlgebra:-MatrixFunction`?!
Digits := 10:
linalg:-matfunc(m, 'x'/(exp('x') - 1), 'x');

Matrix(3, 3, {(1, 1) = .5819767070, (1, 2) = -.3386968877+.2092663986*I, (1, 3) = -.8068242645, (2, 1) = 0., (2, 2) = .5819767070, (2, 3) = 0., (3, 1) = 0., (3, 2) = -.2689414215*I, (3, 3) = .3130352855})

(4)

(*
Even for a 3×3 matrix, the number of digits has to be set to 20.
So … how can you certify that the following output is validated?
*)
_seed := 1234:

LinearAlgebra:-MatrixFunction(LinearAlgebra:-RandomMatrix(50, density = .5, generator = -2*Pi .. 2*Pi, datatype = complex[8]), 'x'/(exp('x')-1), 'x')

Warning, the use of _seed is deprecated.  Please consider using one of the alternatives listed on the _seed help page.

 

Matrix(%id = 36893490216779135924)

(5)


 

Download funm.mws

How do you confirm the validity of the last output? 

> op(3, eval(LinearAlgebra:-MatrixFunction));
 = 
  Copyright (c) 2002 Waterloo Maple Inc. All rights reserved.

And does this mean that LinearAlgebra['MatrixFunction'] is so out-dated that the return value is less effective in certain cases?

I'm presently checking the ability of inttrans:-laplace to give results one can find in the literature.
Unfortunately the inttrans:-laplace's  answers are sometimes more complex than those published in the literature and I'm not capable to simplify the output.

For instance

f := (t+1)/sqrt(t^2+2*t);
L := laplace((t+1)/sqrt(t^2+2*t), t, p);

expresses L in terms of WhittakerW and BesselK(0, p) functions as the answer simply is

exp(p)*BesselK(1, p)

Laplace.mw

How can I get this result with Maple?

TIA

By default, CodeGeneration generates temporary names during optimize of t####. For compatibility with other code, I would like to have flexibility in choosing the preamble to the temporary variable name ("t" is default). Is there a way to do this?

I don't see anything in the documentation, but it seems like something one should be able to do.

(My target language is Python - although I'm not really using Python, the syntax is compatible).

I came across what looks to me like an error in Maple 2023.  If it stands alone, Maple evaluates z^0/0! to 1, but inside the sum command it appears to evaluate the same expression to 0.

Download Weird_sum_behaviour.mw

I've tried some simple uses of solve in MapleFlow without success. For example

solve(f=ma,a)

does not return

f/m

Does solve work in MapleFlow? Is there a problem with this Maple syntax in MapleFlow?

Hi,

I am trying to combine two simple plots of spacecurve and surface but can't manage. Asking for help because I know it doable, it is too simple not to be...

So I need something like this:

trying tirh spacecurve and surface and in general it appears together but cannot align axes so both are wrongly rotataed. Is there any simple and elegant way (without Maple programming language, I am not using it yet) in Maple document with few commands?

Thanks in advance

Marcin

I have a PDE

eq1 := du/dx+dv/dy = 0; eq2 := du/dt+u*du/dx+v*du/dy-nu*d^2*u/dy^2 = 0

where u(x, y, t), v(x, y, t) and

eta(x, y, t):=y/((nu*t*cos(alpha)+(nu*x)/(U[w])*sin(alpha))^(1/(2)));

psi(x, y, t):=U[w]*(nu*t*cos(alpha)+(nu*x)/(U[w])*sin(alpha))^(1/(2))*f(eta(x,y,t));

u = diff(psi, y); v= -diff(psi, x).

How to substitiute u = diff(psi, y); v= -diff(psi, x) in eq1 and eq2, Also find the value of nu.

Does Maple handle .graphml files correctly?  When I tell Maple to export a weighted graph as Example.graphml and then import it, the edge weights come back lower than before. 

Hi,

How can I find the same result reported in the figure for dsolve the differential equation?

nima.mw

 

 

When I input
restart;
a := 2;
b := 3;
p := x^2 - a*x - b*x +a*b ;

I get p := x^2 - 5*x + 6
How can I get x^2 - 2 x - 3x + 6.
General question. I have (a,b) in a list [[2,3],[-3,7],[9,10]]. How to subtitute them to get the result
[[x^2 - 2x - 3x + 6, x^2 + 3x - 7x -21, x^2 - 9x - 10x + 90]? 

I am trying to learn Maple and Fourier transform by calculating the coefficients and the resuting summation as follows:

restart;

assume(n>0);

assume(N>0);

target_f := x -> piecewise(-Pi < x and x < 0, 0, 0 < x and x < Pi, x, Pi < x and x < 2*Pi, 0, 2*Pi < x and x < 3*Pi, x - 2*Pi)

a0 := simplify(int(target_f(x), x = -Pi .. Pi)/(2*Pi))

a_n := int(target_f(x)*cos(n . x), x = -Pi .. Pi)/Pi

b_n := int((target_f(x)) . (sin(n*x)), x = -Pi .. Pi)/Pi

fourier_f := N -> a0 + sum(a_n*cos(n*x) + b_n*sin(n . x), n = 1 .. N)

I am making fourier_f as a function of N becasue I want to see the effect of increasing partial sums. The resulting output of the summation "fourier_f" has a lot of terms. The output looks like this:

               /        /  N      
               |        |-----    
               |        | \       
1         1    |   2    |  )   /  
- Pi + ------- |4 N  Pi | /    |- 
4            2 |        |----- |  
       4 Pi N  \        \n = 1 \  

                                        \                     
                                        |                     
                                        |                     
  sin(n x) (cos(n Pi) n Pi - sin(n Pi))\|   /   2             
  -------------------------------------|| + \I N  Pi LerchPhi(
                   2                   ||                     
                  n  Pi                //                     

                         2                                    
  -exp(-I x), 1, N) - 2 N  LerchPhi(-exp(-I x), 2, N) - I N Pi

      \                  
   + 2/ exp(I N (Pi - x))

   - I N Pi (LerchPhi(-exp(I x), 1, N) N - 1) exp(I N (-Pi + x))

        2                                                 
   - I N  Pi LerchPhi(-exp(-I x), 1, N) exp(-I N (Pi + x))

                                 /   2                            
   + I Pi N exp(-I N (Pi + x)) + \I N  Pi LerchPhi(-exp(I x), 1, N

         2                                       \            
  ) - 2 N  LerchPhi(-exp(I x), 2, N) - I N Pi + 2/ exp(I N (Pi

                          2                          
   + x)) + 2 exp(-I x N) N  LerchPhi(exp(-I x), 2, N)

                   2                         
   + 2 exp(I x N) N  LerchPhi(exp(I x), 2, N)

        2                            2                     
   - 2 N  polylog(2, exp(-I x)) - 2 N  polylog(2, exp(I x))

        2                             2                      
   + 2 N  polylog(2, -exp(-I x)) + 2 N  polylog(2, -exp(I x))

                                 \
                                 |
                                 |
                                 |
   - 2 exp(-I x N) - 2 exp(I x N)|
                                 |
                                 /

The target function is not that complicated. I am using the target function shown in this YouTube video: https://www.youtube.com/watch?v=praNtRezlkw&list=PLPBSZvbAshbxULtiBcygm1qh7BtsDv3DW&index=12

It gave me similar output when the target function was x2.  I am not sure what's going on because for a simple square wave, I was able to make this work correctly.

I am deliberately not using existing packages because I want to learn Maple syntax.

Can someone please tell me what's my mistake ?

Wolfram's marketing literature states that a compiled function may generate the dates for the years 1 through 5.7 million in a couple of seconds rather than in minutes (comparing to the "uncompiled implementation").
The given function in this link can be translated into Maple language as follows: 

(*
  Note that this is only a mathematical program that outputs some data,
   hence 'Easter(-2, 1)' will never return real Gregorian Easter dates!
*)
Easter:=proc(BEGIN::integer[4],END::integer[4],$)::Array(BEGIN..END,[integer[1..12],integer[1..31]]);# the parent function
	description "https://www.wolfram.com/language/12/code-compilation/compute-the-date-of-easter.html";
	local computus::procedure[[integer[1 .. 12], integer[1 .. 31]]](integer):=proc(Year::integer,` $`)::[integer[1..12],integer[1..31]];# the child function
		options threadsafe;
		local a::nonnegint,b::integer,c::nonnegint,d::integer,e::nonnegint,f::integer,g::nonnegint,h::nonnegint,i::nonnegint,j::nonnegint,k::nonnegint,Month::integer[1..12],Day::integer[1..31];
		(* For compatibility, when `Year` is nonpositive, the command `iquo` must be replaced with slower `floor`. *)
		if Year<=0 then
			a,b,c:=Year mod 19,floor(Year/100),Year mod 100;
			d,e,f:=floor(b/4),b mod 4,floor((8*b+13)/25);
			g,h,i:=19*a+b-d-f+15 mod 30,floor(c/4),c mod 4;
			j:=floor((a+11*g)/319);k:=2*e+2*h-i-g+j+32 mod 7;
			Month:=floor((g-j+k+90)/25);Day:=g-j+k+Month+19 mod 32
		else
			a,b,c:=irem(Year,19),iquo(Year,100),irem(Year,100):
			d,e,f:=iquo(b,4),irem(b,4),iquo(8*b+13,25);
			g,h,i:=irem(19*a+b-d-f+15,30),iquo(c,4),irem(c,4);
			j:=iquo(a+11*g,319);k:=irem(2*e+2*h-i-g+j+32,7);
			Month:=iquo(g-j+k+90,25);Day:=irem(g-j+k+Month+19,32)
		fi;
		[Month,Day]
	end;
	Array(BEGIN..END,computus)
end:

However, as "no nested procedures can be translated" to optimized native machine code (cf. ), executing Easter(1, 5700000) has to take at least two minutes

Is there some workaround that can provide improved performance for such a numerical procedure that contains a nested procedure? In other words, is it possible to produce the `result` (without modifying the algorithm) in two seconds in modern Maple as that Wolfram marketing literature claims?

I think this is a simple thing but I cannot find the solution. I have lots of complicated computations in Maple 2015 (with different functions of different packages), but I need the final result to be real numbers/functions. Is there a way to prevent maple following along with computations if it detects a potential complex number? For example, if in some internal step is taking sqrt(x) it should stop and tell something like: "you must assume x is positive".

First 59 60 61 62 63 64 65 Last Page 61 of 2308