acer

32717 Reputation

29 Badges

20 years, 83 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

This is a very good question.

Unfortunately, I don't know a way to completely prevent the AXEXLABELS substructure from being present (without forcibly removing it, as you already showed).

You are right that it is a waste of space, around the plots. And a smaller plot (eg. 200x200 or so pixels for the plot widow...) clearly reveal the wasted space.

As the author of several applications which utilize animated plots within PlotComponents I will say that this is the kind of sloppy GUI handling of plots that really gets in the way of producing better quality results. Jitter in the axes frame, loss of valuable space, lack of symmetry in the visible rendering, and trouble with aligning axes of stacked plots, are just some of the difficulties that application authors encounter that really ought all to be avoidable.

Here is another worksheet that demonstrates the problem. (Uncomment the plots:-display calls for yet another view of the wasted space.) This demonstrates, unfortunately, that Kitonum's suggestion to simply omit the labels option is wholly inadequate and does not fix the underlying issue.

wasted_label_space.mw

I am going to submit a bug report, not so much gainst the GUI's plot drivers for rendering the wasted space as against the Library-side plot constructors for including AXESLABELS("","")  when not requested. (Sometimes the latter kind of silliness gets introduced as a band-aid for irritations with GUI "plot persistence". But I get fed up with dealing with the ensuing difficulties of patches for patches...)

@shankrel You're very welcome.

There are many ways to use Maple to solve this problem.

Since you may be relatively new to Maple, here is one (of several possible) alternatives.

Worksheet_2_ac.mw

@mmcdara Sorry, I didn't read carefully enough, and thought you wanted only the standalone piecewise calls, instead of wanting the sum with only some terms retained. (I think I was confused by the use of the terms "extract" and "operators", which I over hastily took to mean extracting piecewise calls instead of restricting the addends of the sum.)

An adjustment to what I gave earlier is simple.

select(hastype,expr,And(specfunc(piecewise),
                        satisfies(pw->not depends(pw,[x]))));

That produces the result for the given example, and I believe it reads reasonably naturally.

In another, extended example it also excludes any term with a piecewise conditional such as t<0 or x[1]<0 .

You could also use depends(pw,x) in the above, but I thought the list-brackets in depends(pw,[x]) give a little visual hint that additional dependent names can be check together.

If you will eventually need to handle more involved conditionals then this is the time to mention them.

For example (making it up...),     

x(t)<0 and t<0

or,

x(t)<0 and t^2>0

@nitins You're welcome.

As a future consideration you might consider either:
1) Uploading and attaching the actual worksheet (as Georgios requested, using the Mapleprimes editor's green up-arrow),
or,
2) Telling us where you obtained the worksheet, so we don't have to Google it. Worksheets come from many different places. (This site's editor allows for URL links to be inserted in postings.)

@Carl Love The given code does subs(i1=id, eq1) where eq1 is not yet assigned anything. So some formula for eq1 is indeed needed prior to that. It is also true that an original definition of id is missing.

All three original definitions of eq1, eq2, and id are needed, yet missing.

@nitins Where is the original definition of the circuit equation? It should be assigned to eq1, prior to the pertinent subs call.

And where is eq2 defined?

Also, the calls to odeplot(...) won't do anything since the plots package is not being loaded. You could change those to plots:-odeplot(...) , after other corrections.

@Ramakrishnan Your claim is not correct. That font specification affects the sin but not the numeral 30. Try with Courier or Arial, and you can see that the numeral is unaffected.

That is why he followed up, to mention that fact.

And that is why I have now followed up with some alternatives, which do affect the numeral.

@mapleatha Sorry, I was focused on removing the italics, and forgot about your font specification.

You could choose from these, where I would guess that the first might be easiest (while still being programmatically flexible):

plots:-textplot({[4.2,1.9,sin(Typesetting:-mn(cat(30,"&deg;")))]},
                symbol=point,color=black,
                font=["Arial","Bold",25]);
plots:-textplot({[4.2,1.9,Typesetting:-mn("sin(30&deg;)",
                                          mathsize="25",
                                          fontfamily="Arial")]},
                symbol=point,color=black);
plots:-textplot({[4.2,1.9,Typesetting:-mn("sin(30&deg;)",
                                          mathsize="25",bold="true",
                                          fontfamily="Arial")]},
                symbol=point,color=black);

@mmcdara Such automatic pretty-printing of the Logic operators (in output) was introduced in Maple 2017.

It is possible to define printing procedures for &and, etc, for earlier versions such as Maple 2015. But note that such would require extra delimiter round-bracketing, to avoid problems with precedence. And the brackets look ugly when not necessary -- but discerning when necessary could get technically difficult within such a mechanism.

Here is a crude start on such pretty-printing in Maple 2015. As is, it will not get the bracketing correct. naive_log_pr.mw I actually think it's a waste of time to work on this for Maple 2015 as the Copy&Paste or such pretty-printing output doesn't properly work with this in even Maple 2015.2.

Even with interface(typesetting=extended) forced in one's Maple 2015.2 I don't think that the Typesetting:-RuleAssistant can be used successfully and conveniently to get those pretty-printing effects.

Overall, I'd say you're better off relying on your later Maple version, for such pretty-printing effects.

The ability to utilize names beginning with & as infix neutral operators is documented on the neutral Help page.

I have submitted a bug report (ie. SCR, software change request).

@C_R Quite a lot of your last response indicates that you consider ()() as a distinct piece of syntax. But it isn't, really. It is use together of two separate bits of syntax: one pair of parentheses for grouping or delimiting terms that will be applied (like an operator), and a second pair of parentheses that denotes function application (and groups the arguments of that, if any).

Yes, parentheses thus serve two different syntactic purposes here.  Both these purposes of parentheses (grouping or delimiting of terms, or denoting function application) can also be used separately. Yes, you can utilize both together, but it's not a single piece of syntax.

The case of grouping or delimiting expressions (that are to be used as an operator) isn't just useful for composition and arithmetic of the terms. Another important class of example is using parentheses to delimit an expression or an anonymous procedure.

There are currently at least seven examples of using the grouping/delimiting parentheses together with parentheses for function application, on the examples/functionaloperators Help page.

I like your example using parentheses to delimit an equation used in function application. An example such as (f=g)(x) would be useful on that Help page.

ps. I think that whattype isn't highly useful and shouldn't be emphasized as if it were.

pps. Round-bracket parentheses can also denote indexing of rtables.

@rlopez Here are some examples (using row Vectors to render results side-by-side without separating commas). You should be able to see which names in which subscripts are in italic versus upright roman. 

restart;

 

makesub:=(e,s)->nprintf("#msub(mi(\"%a\"),mn(\"%a\"));",e,s):

 

makesub2:=(e,s)->nprintf("#msub(mi(\"%a\"),%a);", e,
                         subs(['mi'='mn'],
                              convert(Typesetting:-Typeset(s),`global`))):

 

< x[p] | x__p | makesub(x,p) | makesub2(x,p)>;

Vector[row](4, {(1) = x[p], (2) = `#msub(mi("x"),mi("p"))`, (3) = x__p, (4) = x__p})

< U[Y] | U__Y | makesub(U,Y) | makesub2(U,Y) >;

Vector[row](4, {(1) = U[Y], (2) = `#msub(mi("U"),mi("Y"))`, (3) = U__Y, (4) = U__Y})

< U[U] | U__U | makesub(U,U) | makesub2(U,U) >;

Vector[row](4, {(1) = U[U], (2) = `#msub(mi("U"),mi("U"))`, (3) = U__U, (4) = U__U})

< U[4] | U__4 | makesub(U,4) | makesub2(U,4) >;

Vector[row](4, {(1) = U[4], (2) = `#msub(mi("U"),mi("4"))`, (3) = U__4, (4) = U__4})

< U[sin(x)] | `U__sin(x) ` | makesub(U,sin(x)) | makesub(U,sin(x)) >;

Vector[row](4, {(1) = U[sin(x)], (2) = `#msub(mi("U"),mi("sin(x) "))`, (3) = `#msub(mi("U"),mn("sin(x)"));`, (4) = `#msub(mi("U"),mn("sin(x)"));`})

< U[sqrt(H)] | `U__sqrt(H) ` | makesub(U,sqrt(H)) | makesub2(U,sqrt(H)) >;

Vector[row](4, {(1) = U[sqrt(H)], (2) = `#msub(mi("U"),mi("sqrt(H) "))`, (3) = `#msub(mi("U"),mn("H^(1/2)"));`, (4) = `#msub(mi("U"),msqrt(mn("H")))`})

expr := Int(f(x),x=a..b):
< U[expr] | makesub(U,expr) | makesub2(U,expr) >;

Vector[row](3, {(1) = U[Int(f(x), x = a .. b)], (2) = `#msub(mi("U"),mn("Int(f(x),x = a .. b)"));`, (3) = `#msub(mi("U"),mrow(msubsup(mo("&int;"),mn("a"),mn("b")),mn("f"),mo("&ApplyFunction;"),mfenced(mn("x")),mo("&DifferentialD;"),mn("x")))`})

Download subscriptroman.mw

That makesub2 is a little "stronger" than that makesub, as it can handle pretty-printing of some additional compound expressions.

ps. I see only mention of indexed names in the current version of the Question. Did the OP actually ever ask about "subscripted" names? Otherwise, I don't understand why Carl wrote at length here about so-called atomic, subscripted names versus indexed names.

Thank you Carl, that is what I meant (but failed to convey adequately, sorry). A wrapping procedure around the integrand can raise working precision (Digits). In this way the functional evaluations of the integrand can be computed to higher accuracy while the numeric quadrature scheme can still be the externally-compiled/hardware-double-precision NAG function d01ajc (which has some decent handling around singularities).

However I don't quite use the form that Carl showed for the wrapper procedure around the integrand calls, for a reason I'll now try to explain.

@vv Some years ago the evalhf mechanism was enhanced to allow for temporary escape from within a procedure running in/under evalhf-mode. It was also amended to allow Digits to be set within such a procedure. But such a setting of Digits would only affect the temporary "escapes", not the evalhf running of the current proc. (I think that this is a slightly flawed design because I imagine that it can confuse people -- tripping them up into thinking that such a Digits change might affect the running proc itself...)

Here are some examples which I hope will illustrate more. Personally I usually throw in a dummy list reference to forcibly disable evalhf when I really want to be 100% sure I've disabled evalhf-mode under the `evalf/Int` or Optimization or plotting call that I'm testing.

[edit. Extra calls to forget(evalf) might assist insight in some cases, even if it doesn't alter the results... ]

restart;

Digits:= 25:

F := proc(x)
       if 1 = true then
         print("running under evalhf");
       end if;
       sin(x);
end proc:


         

S1:= proc(x::realcons)
    Digits:= 50;
    evalf(F(x));
end proc:

evalhf(S1(1.2));

"running under evalhf"

.932039085967226288

evalf(S1(1.2));

.9320390859672263496701344

S2:= proc(x::realcons)
    []; # this is now non-evalhf'able
    Digits:= 50;
    evalf(F(x));
end proc:

evalhf(S2(1.2));

Error, unable to evaluate expression to hardware floats: []

evalf(S2(1.2));

.9320390859672263496701344

S3:= proc(x::realcons)
    Digits:= 50;
    eval(evalf(F(x)));
end proc:

evalhf(S3(1.2));

.932039085967226288

evalf(S3(1.2));

.9320390859672263496701344

S4:= proc(x::realcons)
    Digits:= 50;
    F(x);
end proc:

evalhf(S4(1.2));

"running under evalhf"

.932039085967226288

evalf(S4(1.2));

.9320390859672263496701344

 

Download evalhf_notes.mw

One of my points is this: when I want to deliberately prevent computation under evalhf (because, say, I'm testing performance and wish to examine the case without it) then I have to take special care to prevent it altogether. Otherwise the "escaped evalhf" business can be a little too tricky for me to know exactly what the control flow and effective working precision has been.

I know that some Optimization/evalf-Int/plotting commands have userinfo messages that indicate which of the evalhf/evalf modes they are using. And some respect UseHardwareFloats=false for the control flow. But those things are no guarantee against implementation bugs. When I want a wrapper that definitely won't work under evalhf, or which is guaranteed to force and utilize some higher working precision, then I make my proc non-evalhf-able. (An exception might be when a no-op list reference confused codegen's gradient. Such fun.)

ps. Yes, I meant to convey that forcing a tolerance through the epsilon option is more careful and robust than passing a small value for the digits option, for evalhf(Int(...)) .

What would you do with such a solution, if say it turned out to involve expressions that took 100 pages to pretty-print?

It's a serious question: what, precisely, are your plans for such a symbolic solution?

First 139 140 141 142 143 144 145 Last Page 141 of 599