acer

33400 Reputation

29 Badges

20 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Mariusz Iwaniuk 

They are so-called keyword options. You can supply them with custom values whenever you call the procedure, or omit them (in which case the default values are used).

I chose the defaults of guard=5 and maxtries=50 only because they seem reasonable to me. But guard::nonnegint:=0 and maxtries::posint:=1 also seem reasonable.

The purpose of that `guard` option is to strictly enforce that working precision Digits+guard is always used for evaluation of the function, regardless of which internal stage Rootfinding:-NextZero is operating (augmenting or adding to whatever its guardDigits adds).

The purpose of the `maxtries` option is to specify a finite number of roots to search for.

 

@isifesai Please post followup Replies here with additional details of your attempts to do this in Maple, rather than duplicate Questions.

@mmcdara You are very welcome.

FWIW, the idea for the template file outputleft.mw was just this: it's an empty worksheet, but with the Style for "Maple Output" forcibly set so that all output is left-jusified. There is no programmatic control (which you requested), but I considered it novel enough to mention.

@Carl Love Sorry for being unclear about the `with` call. I meant "Why do that (at all, in this code)?" rather than "What does it do?"

@Josci95 If you zip up the .csv file then you should be able to upload the .zip file here.

If the original is enormous then you could pare it down -- as long as it still exhibits the problem.

My point is that sometimes this avoids mismatches between description and the actual file. Surprises ensue. It does happen now and then. Thanks.

Upload an actual data file that exhibits the problem.

Doing so is always better than describing the data file in words.

Could the Original Poster please upload either the original "greg.csv" file, or at least another representative .csv with the same formatting  and which exhibits the same issues?

I mean the Original Poster, and and actual .csv file. It's not as useful to get a description, or a .csv file from someone else here.

Also, what's the intended purpose of the OP's code's statement,
   with(mydat);
?

 

As far as I can see this behavior goes back to Maple 6 (when the operator form of `or` was introduced?)

I suppose that it is either an oversight in the kernel builtin, or just maybe based on some corner case functionality.

But I have not thought of a useful and non-esoteric example that would rely upon it. Perhaps, something with structured types (though why not use `Or` now)? As I believe Carl alluded, it doesn't make a difference under evalb.

@danielpf The add command was introduced in Maple V Release 4 (1996).  See ?updatesR4,language

 

@Carl Love I have not had much overall joy when trying to export "array plots", whether by right-click or programmatically.

In the case of programmatic export the plot driver seems shaky (it can sometimes try and fake things by forming a single 2-D plot and adjusting the axes, but gridlines get lost and custom tickmarks act weirdly.)

It would be nice to discover whether the OP's example works out for him.

Sorry if I did not make my query clear. I'm interested in the comparative performance of this algorithm/method, implemented in Maple with various approaches to code optimzation, and in Matlab.

 

Please give input examples along with corresponding expected/acceptable output and runtime in Matlab.

Preferably there would be at least one example that takes more than 2 seconds to run.

 

@Kitonum I guessed that he was asking the general question about how to call add with any conditional, and the the mod example was just for illustration purposes.

@JLange In the attachment below, GetIds is intended as a command to find the identies of embedded components of the given kind in the current worksheet.

(An obvious improvement would be to allow multiple kinds to be queried at once, for efficiency.)

restart;

#
# GetIds is intended as a mechanism to find the identies of all the
# embedded components of the given kind in the current worksheet.
#

GetIds:=module()
  local ModuleApply,T,st;
  ModuleApply:=proc(nm::string, $)
    local xmlstr,xml,lowernm;
    lowernm:=StringTools:-LowerCase(nm);
    if not assigned(T[lowernm]) then
      error "expecting a string (of mixed case) in %1, but received \"%2\"",
            [indices(T,':-nolist')], nm;
    end if;
    xmlstr:=:-streamcall(':-INTERFACE_WORKSHEET'("extract"));
    st:=StringTools:-Search("<Worksheet>",xmlstr);
    if not st>0 then error "could not find start of worksheet"; end if;
    xml:=XMLTools:-FromString(xmlstr[st-1..]):
    map[2](eval,"id",
           map(`[]`@op,
               map2(select,type,
                    indets(xml,':-specfunc'(T[lowernm])),`=`)));
  end proc;
  T:=table(["codeeditor"='':-`_XML_EC-CodeEditor`'',"button"='':-`_XML_EC-Button`'',
            "togglebutton"='':-`_XML_EC-ToggleButton`'',"label"='':-`_XML_EC-Label`'',
            "checkbox"='':-`_XML_EC-CheckBox`'',"combobox"='':-`_XML_EC-ComboBox`'',
            "dial"=':-`_XML_EC-Dial`',"volumegauge"=':-`_XML_EC-Volume-Gauge`',
            "meter"='':-`_XML_EC-Meter`'',"rotarygauge"='':-`_XML_EC-Rotary-Gauge`'',
            "plot"='':-`_XML_EC-Plot`'',"mathcontainer"='':-`_XML_EC-MathContainer`'',
            "shortcut"=':-`_XML_EC-Shortcut`',"microphone"=':-`_XML_EC-Microphone`',
            "speaker"='':-`_XML_EC-Speaker`'',"radiobutton"='':-`_XML_EC-RadioButton`'',
            "datatable"='':-`_XML_EC-RTableBrowser`'']);
end module:

 

GetIds("codeeditor");

{"CodeEditRegion0", "CodeEditRegion1"}

GetIds("CoDEedItoR");

{"CodeEditRegion0", "CodeEditRegion1"}

GetIds("button");
GetIds("combobox");
GetIds("checkbox");
GetIds("radiobutton");
GetIds("dial");
GetIds("volumegauge");
GetIds("meter");
GetIds("rotarygauge");
GetIds("plot");
GetIds("mathcontainer");
GetIds("shortcut");
GetIds("microphone");
GetIds("speaker");
GetIds("label");
GetIds("datatable");
GetIds("togglebutton");

{"Button0", "Button1", "Button2"}

{"ComboBox0"}

{"CheckBox0"}

{"RadioButton0"}

{"Dial0"}

{"VolumeGauge0"}

{"Meter0"}

{"RotaryGauge0"}

{"Plot0"}

{"MathContainer0"}

{"Shortcut0"}

{"Microphone0"}

{"Speaker0"}

{"Label0"}

{"DataTable0"}

{"ToggleButton0"}

GetIds("foobar"); # test

Error, (in ModuleApply) expecting a string (of mixed case) in ["shortcut", "dial", "mathcontainer", "meter", "togglebutton", "datatable", "speaker", "codeeditor", "volumegauge", "rotarygauge", "checkbox", "radiobutton", "plot", "microphone", "button", "combobox", "label"], but received "foobar"

:-`_XML_EC-CodeEditor`:=43: # test`
GetIds("codeeditor");

{"CodeEditRegion0", "CodeEditRegion1"}

 

 

Download GetECIds.mw

@vv While I don't see any nice way to get Maple to solve even the reduced 2-dimensional problem (once x3 is eliminated), for fun here are Yet More Ways to get some plots out of Maple.

Here's a quick way, using the reduced system (without floor) cited as coming from Mma. I transform a 2-d plot using the isolated formula for x3, since implicitplot3d won't find any data on right on the plane.

restart;
# using the cited solution from Mma
eqs:=(155/2 < x1 and x1 < 78 and 744/7-4*x1*(1/7) < x2 and x2 < 62 or
 72 <= x1 and x1 <= 73 and 102-4*x1*(1/7) < x2 and x2 < 62 or 73 < x1 and x1 <= 147/2 and
 102-4*x1*(1/7) < x2 and x2 <= 726/7-4*x1*(1/7) or 147/2 < x1 and x1 < 74 and 60 <= x2 and
 x2 <= 726/7-4*x1*(1/7) or 74 <= x1 and x1 < 75 and 726/7-4*x1*(1/7) < x2 and x2 < 62 or 
 153/2 < x1 and x1 < 78 and 726/7-4*x1*(1/7) < x2 and x2 < 60 or x1 = 72 and 58 <= x2 and
 x2 < 60 or 72 < x1 and x1 < 74 and 58 <= x2 and x2 <= 708/7-4*x1*(1/7) or 75 <= x1 and 
 x1 < 76 and 102-4*x1*(1/7) < x2 and x2 < 60 or x1 = 74 and 442/7 < x2 and x2 < 64 or
 74 < x1 and x1 < 75 and 738/7-4*x1*(1/7) < x2 and x2 <= 744/7-4*x1*(1/7) or 74 <= x1 and
 x1 < 75 and 708/7-4*x1*(1/7) < x2 and x2 <= 102-4*x1*(1/7) or 151/2 < x1 and x1 < 76 and
 708/7-4*x1*(1/7) < x2 and x2 < 58 or 157/2 < x1 and x1 < 80 and 762/7-4*x1*(1/7) < x2 and
 x2 < 64 or 68 <= x1 and x1 < 137/2 and 56 <= x2 and x2 <= 666/7-4*x1*(1/7) or x1 = 137/2 and
 x2 = 56 or x1 = 70 and 56 < x2 and x2 < 58 or 70 < x1 and x1 <= 71 and 56 <= x2 and x2 < 58 or
 71 < x1 and x1 < 72 and 56 <= x2 and x2 <= 690/7-4*x1*(1/7) or 70 <= x1 and x1 <= 281/4 and
 54 <= x2 and x2 < 55 or 281/4 < x1 and x1 < 72 and 54 <= x2 and x2 <= 666/7-4*x1*(1/7)):

P2d:=plots:-inequal(eqs, x1=0..100, x2=0..100, nolines,
                    view=[default,default]):
P2d;

plottools:-transform((x1,x2)->[x1,x2,1-2*x1*(1/3)-7*x2*(1/6)])(P2d):
plots:-display(%,lightmodel=none,orientation=[80,50,0]);


 

Working with the original system involving floor, a 2-d implicit plot can be produced using the implicitplot command. It can find the complementary set more robustly (if the ranges and grid size vary) but the resolution seems poor unless it is refined so much that it takes a while to compute. Computing the set as below is quick, but seems prone to miss portions unless the ranges/grid are "just right".

foo:={4*x1+7*x2+6*x3 = 186,
      floor((1/2)*x1)+floor((1/5)*x2)+floor((1/3)*x3) = 18, 
      floor((1/5)*x1)+floor((1/2)*x2)+floor((1/4)*x3) = 21}:

px3:=solve(4*x1+7*x2+6*x3 = 186, {x3}):
new:=remove(`=`,map(rhs-lhs,eval(foo,px3)),0):

# seems tricky to ensure that all the region is found
P2d:=plots:-implicitplot(unapply((`or`(op(map(u->u>0 or u<0,new)))),[x1,x2]),
                         50..100,50..100,grid=[151,151],gridrefine=1):
P2d;

plottools:-transform((x1,x2)->[x1,x2,1-2*x1*(1/3)-7*x2*(1/6)])(P2d):
plots:-display(%,lightmodel=none,orientation=[80,50,0]);

It's a shame that solve knows little about floor/ceil/frac.

First 263 264 265 266 267 268 269 Last Page 265 of 612