acer

32622 Reputation

29 Badges

20 years, 43 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@mapleatha You wrote, "|| || is a symbol for a norm on a normed space. It has no business
in what I am doing for my DE classes. It appeared when I asked up here: `Why is this happenning in Maple?'"

In the Maple language || is a command that can be used as an infix concatenation operator. That's how it appears in the results in your Question's output above. (The example in your Question shows version specific behavior, related to how mixes of names and rationals were treated by the cat command.)

The || appearances in the output in your Question have nothing to do with norms.

 

@mapleatha You wrote in a Comment above, "I have never used the cat command anywhere." But in fact you used the cat command in the code in this very Question!

In your other, earlier Question you also had a rational value. I asked in my Answer there whether you needed that to be typeset (pretty-printed) in 2-D Math, rather than like "1/2" in 1-D text. You didn't confirm there. And now here you suddenly say that aspect is key.

It's not helpful if you don't give a complete description of what your trying to accomplish, at the start.

I'm not trying to berate you. It's a very common  situation on Mapleprimes. People ask about a technical difficulty in an approach they've decided is good for some goal, without telling us all the requirements. Then there's a big circus as we try and dig down to get the true requirements out of them, so that we could suggest a quite different but better overall approach.

This current Question has turned out to be simply a duplicate of another two Questions asked by you, asked close together. Please don't submit three duplicates like that because it splits the value, confuses readers, and separates detail unnecessarily. Please just ask followups details/comments/subcases to Replies/Comments on the original.

You have deleted a comment to which I had responded above. Now my response looks out of context. Please don't remove comments. (I'm trying to ask nicely. Some others here take that kind of thing very personally..)

[The Original Poster made an earlier Comment/Reply, to which I am responding below. The OP has since deleted that Comment, which makes the following look out of place and senseless.]

@mapleatha You claimed that I suggested you use printf, amongst other things. I have not once suggested that you use printf.

I know that you want normally printed output, centred with default blue.

The nprintf command works just like the printf command, the difference being that printf immediately line-prints (gray, left-aligned) while nprintf returns an actual name.

The name constructed by nprintf can be printed just like anything else, centred and in blue. 

So the result from nprintf will work just like your results from cat (when successful).

The result from nprintf can be assigned to a variable, just like the result from cat. The result from nprintf can be used with the actual `print` command, just like you can with the result from the cat command.

But nprintf is easier to use than cat, especially in your situation that not all the blobs are already names, and when there's lots of punctuation to stick in.

So go back and look at Rouben's Answer to your earlier Question, which used printf. But just change the command to nprintf.

That will give an easier way than using the cat command. And results will print in blue, centered.

 

@Christopher2222 In general (outside this context of using the `convert` command) symbol and name cannot be used interchangeably.

For example not everything of type name is of type symbol.

I don't understand why you would make such a potentially confusing and generally untrue statement in a clause that reads ambiguously (and could be easily interpreted as a general claim).

I messed around with code (originally from someone I know) to do that in Maple, about 5-8 years ago. It did wireframe 3-D plots, and relied on having those 3-D cinema glasses that filtered the two colors. The hard part to using that would be to find the worksheet...

But if I recall it was not very involved code. I'm sure several people here could implement the basic idea quite quickly.

@wilk007 That functionality to embed and automatically start playing relies on use of a PlotComponent, which only supports a pair of integers (pixel counts), and not the "golden" ratio.

A simple adjustment of the code allows the integer dimensions to be passed in.

I'll approximate using the golden ratio by obtaining the height as a suitable multiple of the width.

restart;

wave := (x,t) -> 12*(3+4*cosh(2*x-8*t)+cosh(4*x-64*t))/(3*cosh(x-28*t)+cosh(3*x-36*t))^2:

autoplay := proc( anim, {continuous::truefalse:=false},
                        {size::[posint,posint]:=[400,400]} )
  local P, T;
  uses DocumentTools, DocumentTools:-Layout,
       DocumentTools:-Components;
  P := Plot(':-identity' = "Plot0", anim,
            ':-continuous'=continuous,
            'pixelwidth'=size[1], 'pixelheight'=size[2]);
  T:=InsertContent(Worksheet(Group(Input(Textfield(P)))),
                   ':-output'=':-table');
  DocumentTools:-SetProperty(T["Plot0"],':-play',true);
  NULL:
end proc:

aniplot := plots:-animate( plot,[wave(x,t),x=-20..20],t=-1..1,frames=45,thickness=3 ):

autoplay( aniplot, size=[1500, floor(1500*0.61)] );

I wrote a fancier version of the "autoplay" procedure above. It came up recently in another thread. I'll try and find the link for you.

NB. Several of your Mapleprimes posts contain images (pictures) of code. Nobody enjoys having to retype stuff out. Please use the green up-arrow in the editor to upload worksheet attachments, or inline your complete code as plaintext, moving forwards. Thanks.

@mapleatha You can simply change the printf to nprintf in Rouben's suggestion.

The result would then be a name, similar to the concatenation you asked about your related Question. And it would then print in the usual way (centered, and in blue or according to the style).

The mimicing of a sentence by multiplication is somewhat dubious and awkward, in comparison. If you don't need 2D pretty-printing of any portions then using nprintf is so much more straightforward.

Using Maple 2017 for 64bit Linux I get a smoothly rendered curve for this example, displayed inline in the Standard GUI, simply by removing the high numpoints option.

More particularly, for this example I get a jagged display for the inlined plot display if the value for the numpoints option is 2000 or greater, and a much smoother curve if numpoints is less than 2000 (or absent).

 

@_Maxim_ 

Loss of detail occurs due to scaling (and possibly by encoding which involves GUI-side conversion to PNG).

In the attachment below those details are still quite clear, by Preview2D without altering the size.

As mentioned, a benefit is that the point-probe manipulator can be used. Other benefits include the fact that it is regular output like a plot and so doesn't have the Embed restriction of one result per execution-group (which affects all programmaticly embedded component assemblies). Also, the GUI can be slower to render image backgroups on 2-D plots. I agree, if those benefits aren't needed then Embed serves better.

[edit] By supplying the extra option axes=none the Preview2D result can be a closer match to the image size, since the axes and tickmarks don't contributes to the sizing bookkeeping. But the point-probe details can still be enabled and accessed. (See new attachment) Perhaps a better default would be with axes=none.

2dpreview3.mw

@vv Nice example.

Testzero:=u->evalb(radnormal(expand(convert(u,exp)))=0):

Testzero( sin((3/7)*Pi)-sin((1/7)*Pi)+sin((2/7)*Pi)-sqrt(7)/2 );

                           true

That Testzero handles the original Matrix M. I hope nobody interprets this as meaning that I think finding a strong-enough but fast-enough zero detection mechanism is easy or even always possible.

[edited] Also, getting an effective Testzero won't help with expression swell and obtaining results that are unwieldy. So obtaining a Normalizer that handles the swell usefully while not taking a great deal of time can also be important. I realize that most of the participants in this thread are aware of the difficulties.

@Robert Israel I believe I observed that kind of thing for M[1..4,1..4] with Testzero=testeq.

 

@_Maxim_ The "Point Probe" manipulator is not available for 3-D plots. And ImageTools:-Preview displays a 3-D plot with an appropriate orientation and the color/shading applied to a plane where z=constant. (You can even rotate it with the mouse...)

The ImageTools:-Preview command was written before the background option for 2-D plots was introduced.

Here's a procedure which can be used to display an Image (Array or Matrix) in a 2-D plot, after which the manipulator can be used see coordinates of points in the image. You may have to use the right-click contextmenu item on the plot output to enable or set the manipulator, as per usual.

Preview2D:=proc(im::{Matrix,Array}(datatype=float[8]),
                {size::{[posint,posint],
                        identical(NoUserValue)}:=':-NoUserValue'},
                {scaleopts::list:=[]})
  # `scaleopts` get passed to ImageTools:-Scale while
  # any other passed arguments get passed to `plot`.
  local dims,wlo,whi,hlo,hhi,scaled,sizeopt;
  dims:=[rtable_dims(im)];
  if numelems(dims)<>2 then
     error "expecting an Array with 2 dimensions, got %1",
           numelems(dims);
  end if;
  wlo,whi := (lhs,rhs)(dims[2]);
  hlo,hhi := (lhs,rhs)(dims[1]);
  if size=':-NoUserValue'
    or ( size[1]=whi-wlo+1 and size[2]=hhi-hlo+1 ) then
     scaled := im;
     sizeopt := NULL:
  else
     scaled := ImageTools:-Scale(im, 1..size[2], 1..size[1],
                                 op(scaleopts));
     sizeopt := ':-size'=size;
  end if;
  plot('axes'="frame",'view'=[wlo..whi,hlo..hhi],
       'background'=scaled, sizeopt,
       'axis'=[':-thickness'=0,':-location'="low"], _rest);
end proc:

And here is is with your code. 2dpreview.mw

As for the need to wrap ImageTools command in try..catch to avoid overlong error messages, that appears to be a regression that occurred between Maple 2015.2 and Maple 2016.0. In Maple 2015 the error string generated by a procedure's param_processing was elided for large rtables. I have submitted a bug report.

@Christopher2222 That's what used to happen, as I stated above.

I haven't figured out yet whether unprotect/rewrite of `error` could work around the issue nicely enough. (Let alone whether examination of the callstack could make it appear as if the rethrown error were being emitted from the original location...)

@uomcsg Tom is suggesting that you would use the combine, rather than use trigsubs.

You can pass the optional argument trig to the combine command, to restrict the action to trig subexpressions.

restart;

M:=Matrix([[-a3*c[1]*s[3]-a3*c[3]*s[1]-d2*s[1], c[1], -a3*(c[1]*s[3]+c[3]*s[1])],
           [a3*c[1]*c[3]-a3*s[1]*s[3]+d2*c[1], s[1], a3*(c[1]*c[3]-s[1]*s[3])]]);

_rtable[18446884722066116606]

U:=eval(M,[seq(s[i]=sin(theta[i]),i=1..3),
           seq(c[i]=cos(theta[i]),i=1..3)]);

_rtable[18446884722070627982]

map(combine,U,trig);

_rtable[18446884722070641470]

 


Download combine_trig.mw

In my opinion the applyrule command is very weakly coded. I am not aware of any involved maple procedure or package that relies on it in a major way while not inheriting applyrule's many flaws.

I would reach for other tools first, like structured types and access or replacement tools that used types (subsindets, evalindets, indets, etc).

First 272 273 274 275 276 277 278 Last Page 274 of 596