acer

32490 Reputation

29 Badges

20 years, 8 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Adri van der Meer 

I notice that attached worksheet in the Original Poster's Question was made with Maple 2015.2.

And indeed your workaround to use one pair of (single right-quotes) unevaluation quotes works in version 2015.2 (and earlier, eg. version 18.02).

I also notice that in at least the 64bit Linux Maple versions 2016.0, 2016.1, 2016.2, and 2017.0 that approach of delaying any premature evaluation with just one pair of unevaluation quotes of the function call p(u,v) does not work. But it does seem to work on in Maple 2016 and Maple 2017 with two (nested) pairs of unevaluation quotes.

I am going to submit a bug report against this regression in behavior.

@Kitonum That's simple and very clear.

(We've switched earlier roles for this particular example, mine being geometrically inspired.)

You've motivated me to add a plot. (Perhaps it'd be more clear to show or mention that the red line goes through the origin...)

restart;

z:=x+I*y;
R:=evalc(3*abs(z-4-3*I)+4*abs(z-8-6*I) = 20);
eq:=x=4/3*y;
simplify(eval(R, [eq])) assuming y::real;
sols:=y=~solve(%,y);
A:=[eval(eq,sols[2]),sols[2]]:
a:=simplify(eval(sqrt(x^2+y^2), A)):
a,A;
B:=[eval(eq,sols[1]),sols[1]]:
b:=simplify(eval(sqrt(x^2+y^2), B)):
b,B;
with(plots): with(plottools):
P:=display(implicitplot(R, x=0..9, y=0..8,
                        color=blue, gridrefine=1),
           disk(rhs~(B), 0.1, color=black),
           disk(rhs~(A), 0.1, color=black),
           plot(3/4*x,x=0..9),
           plot([[4,3],[8,6]],style=point,symbol=circle,
                symbolsize=40,color=green),
           view=[0..9,0..8]):
display(transform((x,y)->[x,y,sqrt(x^2+y^2)])(P),
        transform((x,y)->[x,y,0])(P),
        view=[4..9,2..7,default]);

x+I*y

3*((x-4)^2+(y-3)^2)^(1/2)+4*((x-8)^2+(y-6)^2)^(1/2) = 20

x = (4/3)*y

(1/3)*(20*y-120)*signum(y-6)+5*signum(y-3)*(y-3) = 20

y = 3, y = 45/7

75/7, [x = 60/7, y = 45/7]

5, [x = 4, y = 3]

@mehdibaghaee 

Your first statement assigns a Matrix to the (typeset) 2D Input name

    `#mover(mi("Δ",fontstyle = "normal"),mo("&uminus0;"))`

Your second statement, which assigns to K, references another name,

    '`#mover(mi("Δ"),mo("&uminus0;"))`'

They both get pretty-printed the same, but they are distinct names.

You could delete the instances of the problematic name in the second statement, and then copy and paste the name from the first statement instead. That worked for me, using your document in 64bit Maple 2017.0 for Windows.

I discovered the problem by copying both names and pasting them into an execution group that was toggled to 1D Maple Notation.

@Carl Love He wrote that he'd initialized parameters (presumably to numeric values). But that doesn't necessarily mean that Matrix K is yet all of type numeric. See example below.

I'd say that the OP's particular call to convert is somewhat obscure and cryptic, though. In modern Maple there are lots of simpler ways to hit all of Matrix K with evalhf and make the result have datatype=float[8].

K:=Matrix([[sin(5)]]):

M:= Matrix(K, datatype= float[8]);
Error, (in Matrix) unable to store 'sin(5)' when datatype=float[8]

evalhf(K);
                            [-0.958924274663138]
rtable_options(%,datatype);
                                  float[8]

Matrix(evalhf(K), datatype= float[8]);
                            [-0.958924274663138]

Matrix(evalhf~(K), datatype= float[8]);
                            [-0.958924274663138]

# Even this is simpler, working as far back as Maple 6?
Matrix(map(evalhf,K), datatype= float[8]);
                            [-0.958924274663138]

Matrix(`~`[convert](K, float[8]), datatype = float[8]);
                            [-0.958924274663138]

@toandhsp Welcome to the party. We are all at the mercy of solve and other Maple commands.

Perhaps there are other tacks, for this new example:

restart;

z := a+I*b:
C:=evalc(3*abs(z-4-3*I)+4*abs(z-8-6*I) = 20):

eq:=a=4/3*b: # where the fun is

simplify(eval(C,eq)) assuming real;

         1                                                          
         - (20 b - 120) signum(b - 6) + 5 signum(b - 3) (b - 3) = 20
         3    
                                                      
b=solve(eval(C,a=4/3*b)) assuming b>=3, b>=6:
eval(abs(a+b*I),[%,eval(eq,%)]), eval(eq,%), %;

                             75      60      45
                             --, a = --, b = --
                             7       7       7 

b=solve(eval(C,a=4/3*b)) assuming b>=3, b<=6:
eval(abs(a+b*I),[%,eval(eq,%)]), eval(eq,%), %;

                               5, a = 4, b = 3

@smiths I added my Comment above onto Kitonum's Answer, because (obviously, I had imagined) I was utilizing the same observation about "fixed points  A(-3, 2)  and  B(3, 8)".

If I had possessed a straightforward way to obtain the simple real-real restrictions on the a (or the b) of z=a+b*I then I would have submitted as an Answer instead. 

I was simply pointing out that, having introduced the a and b (and having made the observation about their ranges), it was not necessary to also work out and introduce a parametrization by t. And I also wanted to mention that there were at least (related) two ways of doing that.

I had thought that all the sensible people engaged in the discussion were already aware that the weakness (of solve, mostly) in generating the range restrictions on a and b was the outstanding issue. I didn't see much point it stating what others had already mentioned.

If I think of some reasonable, automated way, I'll mention it.

@sand15 My suggestion entails having all your source in plaintext files. After that, their text would never get re-imported back into any worksheet format (whether Maple Notation or otherwise).

Suppose you have an entire module, M, whose source definition is in the text file srcM.mpl . In that case you could, in either the GUI or the commandline interface, "load" that module with the command,

 read "srcM.mpl";

Having loaded the module in any session, you could then call it's exports (or itself, it is is an appliable module. That would cover both the interactive application as well as any unit testing.

I don't understand how Shift-Enter issues would come into that.

If procedure in module M also call procedures from outside M (user-defined top-level procs, or exports of user-defined module N, say) then you would load both before executing. Eg.

 read "srcM.mpl";
 read "srcN.mpl";

Another way would be to use LibraryTools to save(lib) both M and N to the same .mla Library archive. A worksheet's Startup Code could contain either the simple read statements, or a statement that appends to libname (so as to pick up any .mla archive).

I usually have a very small text file (of Maple code) which:
1) sets the Maple include path
2) reads the module defn files (which may contain $include directives)
3) saves to .mla archive
And then I just need to augment libname to get the package into play. If it's very useful then I may even end up putting the .mla into a toolbox folder, so that libname is augmented automatically, upon normal launch of the GUI or commandline interfaces.

The key thing is that, once my source gets migrated to plaintext then it never gets put pack, literally as code, into any worksheet.

Having said all the above, I'm afraind that I don't understand your comment about WorksheetToMapleText and difficulties with references from within a module to other user-defined procedures. And I'm afraid that I also don't understand the comments about Shift-Enter, after using the menubar's File->Export as..., because the format to export to is plaintext (ie. .mpl or .txt, but certainly not some other .mw variant or anything with input prompts).

I forgot to mention it before but additional benefits of plaintext files are A) the stand-alone Maple language Syntax Checker mint can be used easily and to its full power, and B) plaintext files are extremely well protected against file-corruption when using mature editors such as vi, emacs, etc.

As far as Carl's comment goes, yes of course you don't necessarily have to split up module sources into seperate files for each procedure. If you do, then the $include directive (and includepath) is very handy. That's a matter of taste. I find that as my project gets large, and the revision histories get long, then it helps me to make sense of the revision diffs if I don't have to visually process too much at once. This aspect is colored by your choice of revision control tool, naturally.

Or, without parametrizing by `t`,

restart;

z:=a+b*I:

C:=abs(z+3-2*I) + abs(z-3-8*I) = 6*sqrt(2):

# Key observation, the constraint allows the problem
# to be represented as univariate problem.

eq:=isolate(evalc(C),a);

                eq := a = b - 5

# The univariate expression to be optimized, now with
# only the simple bounds on `b` as remaining constraints.

expr:=evalc(abs(eval(z,eq)));

                          2    2 1/2
          expr := ((b - 5)  + b )

simplify( [ maximize( expr, b=2..8, location) ] ):

# Beautify
op(1,%), op([2,1,1,..],%), eval(eq, op([2,1,1],%));

             1/2
           73   , b = 8, a = 3

simplify( [ minimize( expr, b=2..8, location) ] ):

# Beautify
op(1,%), op([2,1,1,..],%), eval(eq, op([2,1,1],%));

             1/2
          5 2
        ------, b = 5/2, a = -5/2
           2

# Alternative way, by getting the extreme points of
# the univariate problem.

Student:-Calculus1:-ExtremePoints( expr, b=2..8 );

                   [2, 5/2, 8]

simplify( [seq([expr,'b'=b,eq],b=%)] )[];

       1/2
    [13   , b = 2, a = -3],

          1/2
       5 2
    [------, b = 5/2, a = -5/2],
       2

       1/2
    [73   , b = 8, a = 3]

# And of course we can sort the above, to get the max and min.

If you have grief using the main menubar's item File->Export as... as a way to export (module and procedure sources) from .mw files to plaintext then you could also compare with the results from the undocumented command Worksheet:-WorksheetToMapleText.

If I recall, that command accepts a filename (string), and returns a string (with input code lines split by \n). So you then could use FileTools:-Text:-WriteFile command to push the result string into a .txt file.

@sand15 I do my source code edits using the text files directly. I use `vi` for which one can get maple syntax highlighting. But syntax highlighting is also available for emacs or other good editors. I'm not sure about git itself.

I also write so-called "unit tests" of the computational procedures, in plaintext files which I name as ".tst". For those I use Maple's TestTools package. There's something on this in the Programming Manual. I run the unit tests using the command line interface.

nb. The .mw format allows so-called Code-Edit Regions, which offer some syntax highlighting. But since .mw is completely at odds with decent, workable revision control then I would not try and maintain an involved packages source in it.

I would not tie myself to any format which cannot be read and re-used and rebuilt using the command line maple interface. That's one reason I would never use that IDE mentioned in another answer. 

The text-file approach can be used to rebuild from within the command line, Std Java GUI, or Classic GUI.

I understand that Maplets is a mature and quite full-fledged platform for the graphical interface aspect. I dont know how involved your app is, in those interactive ways. But have you considered using programmatically generated embedded components instead? I am not sure what future there is for Maplets in the Maple Cloud or the Maple Player.

I'll look for an old note about a programmatic command for exporting code from .mw to .txt. 

@nm screenshots are useless.

Upload an actual worksheet. Use kernelopts(version) not interface(version) which is no help. Execute `libname;` to show us what else might be in play. What's in your initialization file? You've been around long enough to realize why this stuff may matter.

Your first example worked just like your second example for me, in 64bit Maple 2017.0 running in 64bit Windows 7 Pro, pasted in line by line as either 1D Maple Notation or 2D Input.

Indeed, from the help page ?combine,trig

"Products and powers of trigonometric terms involving sin, cos, sinh and cosh are combined into a sum of trigonometric terms by repeated application of the transformations..."

"The form of the result is a sum of trigonometric terms whose arguments are integral linear combinations of the original arguments."

You could try entering it into Maple.

If I may make a few comments:

I'd like the documentation to explicitly mention that when both dot and prime settings are enabled, with the same symbol for both, then output is displayed with the prime notation. So, for example, if one wants to get diff(y(x),x) pretty-printed as 2D Output in dot notation then it is also necessary to set useprime=false as well as dot=x. That was the case in Maple 2016.2 as well, but as mentioned in Maple 2017.0 one must also set typesetdot=true.

To some it may seem a quibble, but I've always found it awkward that the over-dot is rendered centrally, which doesn't take into account that the variable names are (by default) rendered using italic font for 2D Output. This makes the dot look misplaced, too far to the left of the oblique name symbol. (Note that this effect doesn't show in the inlined code below, here on Mapleprimes, but it certainly does in my Maple proper for Linux.)

I can see the usefulness of the primenotationbound setting. But why does Typesetting:-Settings not also have a dotnotationbound setting?

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

diff(y(x),x);

diff(y(x), x)

Typesetting:-Settings(useprime=false, dot=x):

diff(y(x),x);

diff(y(x), x)

restart;

kernelopts(version);

`Maple 2016.2, X86 64 LINUX, Jan 13 2017, Build ID 1194701`

diff(x(t),t);

diff(x(t), t)

Typesetting:-Settings(prime=t):

diff(x(t),t);

diff(x(t), t)

Typesetting:-Settings(useprime=false):

diff(x(t),t);

diff(x(t), t)

 

Download typesetdotprime2016.mw


restart;

kernelopts(version);

`Maple 2017.0, X86 64 LINUX, May 17 2017, Build ID 1231047`

Typesetting:-Settings(typesetdot=true, dot=x):

diff(y(x),x);

diff(y(x), x)

Typesetting:-Settings(typesetprime=true, prime=x):

diff(y(x),x);

diff(y(x), x)

Typesetting:-Settings(useprime=false):

diff(y(x),x);

diff(y(x), x)

restart;

kernelopts(version);

`Maple 2017.0, X86 64 LINUX, May 17 2017, Build ID 1231047`

Typesetting:-Settings(typesetdot=true):

diff(x(t),t);

diff(x(t), t)

Typesetting:-Settings(typesetprime=true, prime=t):

diff(x(t),t);

diff(x(t), t)

Typesetting:-Settings(useprime=false):

diff(x(t),t);

diff(x(t), t)

 

Download typesetdotprime2017.mw

First 280 281 282 283 284 285 286 Last Page 282 of 594