sazroberson

60 Reputation

4 Badges

6 years, 251 days

MaplePrimes Activity


These are questions asked by sazroberson

While exploring a relatively simple sin equation, depending on how I process I get different forms of the root. Numerically, they appear to be the same, but I am having difficult figuring out how they could be, and would appreciate some guidance.

The more standard root is

21*arccos(RootOf(448*_Z^7+192*_Z^6-784*_Z^5-288*_Z^4+392*_Z^3+108*_Z^2-49*_Z-6, index = 2))/Pi


The less standard approach is

-(21*I)*ln(RootOf(7*_Z^14+6*_Z^13+6*_Z+7, index = 2))/Pi

Both of the RootOf appear to be irreducible, and it is not clear to me how you could transform the more complicated degree 7 polynomial into the simpler degree 14 polynomial while still retaining exactly the same roots?

If the equivalence holds up then it would be much easier for me to generalize the second form than the first.

I was, by the way, looking at minimizing sin(2/7*Pi*x) _+ sin(1/3*Pi*x) over its first complete cycle, as part of working up to a general rule for minimizing sum of sin of different amplitude and periods. diff(), then standard form is solve(), and less standard form is solve() of convert/exp() of the diff()

 

If I am in the Maple debugger, stopped in a routine, how can I navigate between stack frames, such as looking at the variables of the calling function?

"outfrom" is not sufficient for this purpose as that continues execution until return, which would change the variables of the routine I am in, and could potentially take a long time. And more importantly for my particular purpose, the routine I am stopped in is a package's "I found an error" routine which is (deliberately) throwing an exception, so there will not be any return.

I can use where or where? to look at the name of the calling routines. Unfortunately, for the code I am debugging, the calling routine is being dynamically loaded so I do not have a file name for it and I cannot put a persistent breakpoint in it: I need to climb the tree of dynamic calls with their various parameters in order to figure out how the error occured.

I find fsolve() to be curiously unstable. Some of the behaviour I can guess at, but other parts are not as clear.

 

Define a function.

P := x->fsolve(exp(-(1/100)*t^2)*cos(2*t),t=x):

plot(P,4..5,smartview=false);

I am working with a package that is not entirely stable and which can sometimes corrupt Maple's state. I would like to "sandbox" the risky operations, executing each of them in another kernel thread that I can destroy (or somehow reset), getting back just the return result of each operation (each return result involves only global names, numbers, and strings). What would be a good way to achieve this?

I see the Task model, but it is not clear to me that each kernel used is effectively restart()'d for each Task Start(). At the moment I would have a bit more confidence in manually using Thread Create(), except that I do not see any information on how to destroy a thread (just to destroy Mutex and Condition Variable resources.)

This is, I suppose, a kind of security, but it is not covered by EngineSecurity. (Not unless I need to process[popen] to achieve this.)

I am looking to return all the substrings of a string that match a particular pattern (regexp). This is a very common text processing operation.

StringTools[RegMatch] returns boolean about whether the given pattern exists somewhere in the string. That's a start, but it is not efficient to hunt around for where the match is in order to extract the characters.

StringTools[Search] and [SearchAll] can return position information, but they work on exact matches of the pattern space, not on regular expressions. I could pre-generate all the possible matching sequences of up to some length and search for those exactly, but that is inconvenient at best and pretty much useless if there is a .* or .+ in the regular expression (as the space of potential matches grows exponentially.)

StringTools[RegSub] can be used to find one match by using something like ".*(REALPATTERN).*" = "\1" but since this does not extract any position information, one would at the very least then have to StringTools[Search] of the exact match to determine the position, then take a substring of the original string, and continue searching. And if you are going to do that, you might as well just use StringTools[RegMatch] with an optional third argument of a symbol to return the matched characters, instead of fooliing around with deleting everything else using RegSub.

Have I overlooked a possibility?

Example of use:

I would like to search "variable %1 needs to be of the form %3+2.9 in order to use routine %2 to find the fizturl", extracting the "%1", "%3", "%2". This would be regular expression "%[0-9]+". Notice that there might be other digits in the string that I do not want to extract, so I cannot just search for digits. I also cannot just remove all characters "[^0-9%]" as that would leave digits and would, for example, merge together the %3+2.9 into %329 leaving post-processing to extract the true pattern matches.

For what I am doing at the moment, I do not need to know the positions those occured at, just the matches.

1 2 Page 1 of 2