dharr

Dr. David Harrington

8482 Reputation

22 Badges

21 years, 34 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. My research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity


These are replies submitted by dharr

@nm I agree a better simplification would help here, and I think that was @acer's point - it didn't help. In my answer I said I assumed you wanted the mathematical result, which requires factoring to see if polynomials have common factors, and this then leaves the simplification problem. There is also the issue of how hard you want to look for common factors. But if you only want it to cancel preexisting factors, then it would be done in a different way that might miss potential mathematical common factors.

@epostma I certainly didn't think of that. In my purist view, that is not a unit - certainly my graduate students would never be allowed to write that in a paper, though I see a lot of students find it useful in their assignments.

@acer The math is OK, but the way it appears is certainly ugly. Even in my example, the cubic is messed up in a way that is no longer the conventional way to write it. I originally thought of of using factors on each of the numerators and denominators to try to keep things together, but that does not solve the expansion issue either. (I guess I long ago gave up using Maple to put things in a specifc nice form, because for some example it will fail.)

Edit: It seems that the way that factor normalizes as part of its operation is the central problem, which means it is hard to get around. factor((x+y)^3+x); fails to factor but leaves the answer in expanded form. So it could be improved by returning the original if it failed to factor, but that is probably a lot of additional cosmetic code.

@C_R Thanks - you provided a significant shortening with the nested subsindets, so a definite joint effort.

@C_R  The code could be incorporated into simplify using

`simplify/Unit` := ex -> subsindets(ex, specfunc(Units:-Unit), x -> subsindets(op(x), name, Unit))

and used as simplify(ex,Unit) (the normal seems to be automatic in this case.)

Expansion_of_compound_units_shortest.mw

 

@C_R That's a nice variation. Even shorter is just

subsindets(ex, specfunc(Units:-Unit), x -> subsindets(op(x), name, Unit))

(I had already replied to the other thread when it was deleted. I don't use Units so didn't pay attention to this thread earlier.)

@Axel Vogt If you enter local gamma in 2-D notation and then convert it to 1-D, then it appears as _local(gamma). I assume this is some sort of internal form that is functionally equivalent. But to avoid confusion, local gamma is of course preferred.

@Carl Love @mmcdara When I looked at it I saw similar things to those listed by @Carl Love. I guessed that if you come from a traditional programming language and you see or use X[i,j] then you think that they are array elements, so you promptly declare an array for them to go into. Adding symbol = x just changes the X names for x. My solution was to comment out the array line; then I got stuck on "max" making it unsuitable for a linear problem with binary variable, for which Carl had a nice solution.

Please upload your worksheet using the large green up-arrow in the Mapleprimes editor.

@Preben Alsholm maybe inf=3 was just for debugging, and perhaps there are to be many more odes? I never like this sort of approximation for infinity and prefer to change variables to a finite range, e.g., [0..infinity) to [0..1].

@Scot Gould I don't have flow, but this should be equivalent

cat(C, 1..numelems(V)) := seq(V);

@dharr I think the problem may be that the code works only when the click-and-drag mouse pointer is used. After the image loads, click the plot, then on the plot toolbar select the   icon. Then reset button and click. (Spurious errors may occurr but the reset button should fix them.)

@Traruh Synred Start with just running my worksheet without any modifications. Looks like you might have removed the Plot0 component, which is the empty square below the xrng,yrng message:

When you run the worksheet (with the !!! icon) the image should appear inside Plot0 (it's slow to load). Once you get it working on mine, it is probably easier to modify my worksheet with your code.

 

@dharr This version draws a red line between the two selected points. (Reset doesn't remove the line because it is very slow to redraw the image, but the line disappears when you draw the next line.) If you want an arrow (there are many options for this), then the plottools:-line can be changed to plottools:-arrow in the plot component click code.

MeasureImage.mw

 

@Traruh Synred Did you see the reset button and start, end and distance displays below the plot? Try hitting the reset button, then click on a point on the image, then on a second point on the plot, and then look under "distance" to see what the distance between the two points is. You don't neet to do any programming, just run the program (the file takes a little while to load), then 3 clicks and you have your distance. I guess if you really want, it could be modified to draw the line or arrow between those two points as well as calculate the distance.

I don't think you can access the length of your drawn line on an image; I tried to do that before I did the programming for the plot component.

First 37 38 39 40 41 42 43 Last Page 39 of 89