Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
Hi
Not sure why I am get the incorrect units and the problem cascades down work sheet to produce incompatible units.
Thanks in advance.
How about this
Mike
As a further note, to get Prime to display anything other than the base units (eg, microfarads rather than farads), you have to delete the whole of the displayed units before typing in the unit you want (and the simplest way to do this is to press the End key, then Backspace; this will select the units. Then either press Backspace again to delete them or just start typing your new units).
Stuart
StuartBruff wrote:
As a further note, to get Prime to display anything other than the base units (eg, microfarads rather than farads), you have to delete the whole of the displayed units before typing in the unit you want (and the simplest way to do this is to press the End key, then Backspace; this will select the units. Then either press Backspace again to delete them or just start typing your new units).
Stuart
A little cumbersome if you ask me.
Mike
Mike Armstrong wrote:
StuartBruff wrote:
As a further note, to get Prime to display anything other than the base units (eg, microfarads rather than farads), you have to delete the whole of the displayed units before typing in the unit you want (and the simplest way to do this is to press the End key, then Backspace; this will select the units. Then either press Backspace again to delete them or just start typing your new units).
Stuart
A little cumbersome if you ask me..
Compared to the M15 way, I think it is. For a single letter unit, you just have to press Backspace once to clear it, though, not twice as I misremembered.
...Hmm. Talking of remembering, I wrote a toy, symbolic, general purpose unit handler back in the Matchad 11 days. I wonder if it will work in Prime now that static type checking is gone ... or did I use some Maple programming operations. Ah well, yet another thing to add my list of programming projects.
Stuart
StuartBruff wrote:
...Hmm. Talking of remembering, I wrote a toy, symbolic, general purpose unit handler back in the Matchad 11 days. I wonder if it will work in Prime now that static type checking is gone ... or did I use some Maple programming operations. Ah well, yet another thing to add my list of programming projects.
Stuart
Another one to look forward to.
Mike
Mike Armstrong wrote:
StuartBruff wrote:
...Hmm. Talking of remembering, I wrote a toy, symbolic, general purpose unit handler back in the Matchad 11 days. I wonder if it will work in Prime now that static type checking is gone ... or did I use some Maple programming operations. Ah well, yet another thing to add my list of programming projects.
Stuart
Another one to look forward to.
Unfortunately, probably not for some time. I've had a look at it and it does use some Maple-specific "unofficial" operations (such as nops) to get at the structure. I'll have a look at it later to triage it for modification to run under Prime ... or I might write a parser for it.
Stuart
You have too much time on your hands
Mike
Mike Armstrong wrote:
You have too much time on your hands
Mike
Au contraire! I have far too little time to do the things on my looonnnggg list of things I'd like to do! And every time I look at something, I almost invariably start thinking things like "That's interesting", "I wonder ..", "Ooh! Shiny!" or, even worse, "That's odd ...". All of which means my list grows exponentially, and my opportunities to get diverted (*) follow a similar growth pattern.
Stuart
Note: (*) I got diverted earlier on into thinking about how to find the maximum sum of contiguous elements of a vector, where the sum must be equal to or less than some given value - a problem on spoj (SPOJ.com - Problem HOTELS). I found a solution pretty quickly, but noticed reference to something called Kadane's algorithm, which led me to John Bentley's book Programming Pearls. Whilst skimming the book, I noticed a problem concerning identifying all of the anagrams in a dictionary. A glance at the accompanying diagram immediately suggested a way to solve it in Mathcad. However, I needed a stable sort to implement it the way I wanted. I've got one somewhere, based on merge sort, but I can't find it so now I've got to rewrite it. Needless to say, the Hotels problem was accidentally found whilst I looking up something completely different, and the Anagram problem is moving me even further away from where I was. C'est la vie ... and I live on Markov Street.
I needed a stable sort to implement it the way I wanted.
What do you mean by "a stable sort"?
Richard Jackson wrote:
I needed a stable sort to implement it the way I wanted.
What do you mean by "a stable sort"?
One that keeps the unsorted horses in their original running order.
Stuart
Richard Jackson wrote:
Something like this?
Maybe. I had more in mind this:
Stuart
I don't see where my Csort2 differs from what you show:
Richard Jackson wrote:
I don't see where my Csort2 differs from what you show:
No, hopefully you wouldn't on the small scalar examples shown. There are two big differences - one favouring your method and one favouring mine.
First, speed - yours is considerably quicker for large arrays. Timer2 returns a 2-vector containing the result of the sort and the time taken. T20=T30 shows that the results have the same values (and so are presumably sorted the same). The Tn1 figures are a measure of the execution times and show that the horses out of your stable are in with a chance at Aintree; mine, however, are probably best suited to ploughing fields or pulling milk carts.
Second, complex numbers - mine sorts complex numbers (or any other data type that can be given a sort order) whereas yours doesn't (because it uses csort, which doesn't sort the complex component). I found the thread that triggered my development of a flexible stable sort: Sorting complexes. The example below sorts on Re(z) and then Im(z) if the comparison Re(z)s are equal.
The trick now is for me to not get diverted into trying to make your csort handle a user-defined comparison function.
Stuart
I think we could do with splitting this sequence of messages off into its own thread ...
StuartBruff wrote:
Richard Jackson wrote:
I don't see where my Csort2 differs from what you show:
The trick now is for me to not get diverted into trying to make your csort handle a user-defined comparison function.
Drat! Failed!
Second, complex numbers - mine sorts complex numbers (or any other data type that can be given a sort order) whereas yours doesn't (because it uses csort, which doesn't sort the complex component).
As soon as I posted this, I looked in a bit more detail at how Csort worked and instantly realized that the real(!) problem wasn't so much that you were using csort per se, but that the Rank function didn't handle complex numbers. So, after I'd done part of the thing I didn't want diverting from, I wrote a very dirty and nasty complex number rank function, based on Csort2. I also changed the ranking system to use consecutive integers, as this would make it easier to know how many ranks there were and to partition the array. Rank0 in the image below is your original Rank function, Rank is a compact rank range replacement for Rank0, reRank is just a test function to verify zRank's parent function, and zRank is a complex rank function.
The resulting function CSort4 now sorts complex number in the same timescale as Csort2.
Stuart
Rank0 in the image below is your original Rank function
Tom's original Rank function
The resulting function CSort4 now sorts complex number in the same timescale as Csort2.
This is excellent! I put this on my to-do list, but it seems I procrastinated long enough that you did the work, rather than me! My motto is "never do today what you can put off until tomorrow", and sometimes it pays dividends
Except...
...you didn't attach the worksheet with Csort4
Richard Jackson wrote:
Rank0 in the image below is your original Rank function
Tom's original Rank function
I did note your attribution in the worksheet but, sadly, not many of the newcomers would know who Tom is. Shame he departed for shores unknown.
The resulting function CSort4 now sorts complex number in the same timescale as Csort2.
This is excellent! I put this on my to-do list, but it seems I procrastinated long enough that you did the work, rather than me! My motto is "never do today what you can put off until tomorrow", and sometimes it pays dividends
I think you need to put a Warning on your motto. As a strong adherent of the Principle of Maximal Laziness, I thought this might be useful. But then I tried to put off 'never doing today what I couild put off until tomorrow' until tomorrow. Now my brain hurts.
...you didn't attach the worksheet with Csort4
There's a reason for that. The implementation is messy and I didn't like the code. So I'm playing with it a bit. Unfortunately, I've been a bit rough over the past few days, so that's delayed it, and probably will for a few more days.
Stuart
In fact, there's a thread containing the worksheet here: mixed units in ODE solver
Stuart
Unfortunately I can't read your file as my Prime 3 can't open files in 3.1 format.
But you were already told that the second assignment, where you did not use any units, was the reason for your problem.
I guess this assignment was done for documentation reasons and you might consider using the symbolic evaluation with the keyword "explicit" instead.
I have redone the first assignment in Mathcad 15 but it should work the same in Prime:
In Mathcad we also have the option to hide the keywords and to change the arrow for an equal sign, so it looks like this
Unfortunately these options are not available in Prime, being just a subset of Mathcad15.
You can also use the assignment directly followed by the symbolic evaluation with explicit in one line.
Again, the second display is not available in Prime (you could also let the := being displayed as a normal 😃
Also bear in mind, that "explicit" works fine in this example, but its use is limited and it may not always give you the display you have in mind.
But all the other alternatives, like writing the expression a second time using the boolean equal sign just for documentation or disabling the second assignment have the huge drawback, that the documentation doesn't really show the actual calculation. You could change the value of C.1 and if you don't update your doc, its showing the wrong values.
Werner
Thank for the tip on explicit notation I full understand where you are coming from and did fully understand this function. Is it possible to only have part of the equation in
explicit, see example below.
Thanks
Hi All
From Werner comments above it is not possible to hide the keywords or to change the arrow for an equal sign, does anyone have any other ideas how to do this?
Can the keyword colour be change to little grey so it not so obtrusive?
Is it possible to increase the spacing between the calculation to improve readability?
To retain full numerical precision you can do something like this:
You may follow the symbolic evaluation by a numeric one to immediately show the result, if you like.
Notice the assignment C.S:=C.S= at the righthand page (which is not printed). You may also put it in a collapsed region.
I have no idea why some of the units are not labeled blue when I do the symbolic evaluation. I don't see this effect in the screenshots added by others, so I guess its a difference between Prime 3.0 and 3.1?
Also in the eval of C.e, using "explicit" seems not to be necessary at all.
Unfortunately I see no way to get rid of the keywords. Changing the font color affects the whole regions, so thats probably not an option.
I have tried putting a small white rectangular graphic on top and then I tried a text region without any text. In MC15 this would do the job as we can bring regions to the background/foreground as needed, but in Prime a math region seems to be always on top. So no success.
Werner
StuartBruff wrote:
I'm going to shout again! NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!
I feel better for that
The float keyword does not just change the precision of the displayed result, it changes the precision of the calculations. It should almost never be used. In MC14 they (i.e. Mathsoft) finally implemented result formatting for symbolic results, so that people could stop (incorrectly) using the float keyword. In Prime, they (i.e. PTC) took that away again, and we are once again back in the dark ages of Mathcad
Richard Jackson wrote:
StuartBruff wrote:
I'm going to shout again! NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO!
I feel better for that
The float keyword does not just change the precision of the displayed result, it changes the precision of the calculations. It should almost never be used. In MC14 they (i.e. Mathsoft) finally implemented result formatting for symbolic results, so that people could stop (incorrectly) using the float keyword. In Prime, they (i.e. PTC) took that away again, and we are once again back in the dark ages of Mathcad
Mea culpa. I should have been clearer when I said "limit the result" that I didn't just mean the displayed precision (I mean, we're talking capacitors here, so they're going to have to be to the nearest value in the series plus tolerance, so it's not that bad a solution .... says he, lamely looking for an excuse ....
Stuart
You do have a point. 0.0001% tolerance capacitors are something of a rarity