C_R

2005 Reputation

19 Badges

4 years, 209 days

MaplePrimes Activity


These are replies submitted by C_R

@dharr 

This is exactly what I had in mind when I wrote my suggestions on transfer functions with units. As it turns out this simplification is relevant each time an unassigned  name is combined with compound units in a product. With this in mind I will suggest that Maplesoft takes a simplification functionality into consideration.

Thank you for your time. It was a real joy to see your original code evolve into a simple and elegant statement.

@dharr 

Beautiful!

This piece of code should be part of Maples unit documentation to provide a solution for (rare?) cases where simplify does not simplify Unit expressions with compound units.

A real alternative to my original suggestion for a dedicated command without any coding effort for Maplesoft.

Thank you again

(I use units wherever possible. It's worth a try, with the caveat that you may feel less confident after a while if you have to work without)

 

dharr has provided an alternative for C1 here

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

where expr is an expression with Unit expressions with compound units.

@acer 

The original question was about a way to expand unit expressions. I finally got a solution for that (sorry for being persistent). The follow-up question was more about converting a procedure to a compact inline statement (not necessarily a proc construct). My attempts on converting the original procedure have been miserable. Major hurdles where the dismantling of expressions and the if statement. dharr’s solution uses different techniques to avoid all this.

In case I am more interested in techniques or alternative ways, I will try to make this clearer and/or pic another example to avoid duplicate impression.

@dharr 

Excellent! This does exactly what I was looking. The identifier "name" seems to be key for compact inline code. I found a variant that also works in 2D with the arrow operator. 

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

Thank you for following up here. My original post was deleted as spam according to notice from Maplesoft Member Services. Strange

@specter123 

evalc is missing for the big expression

@Aung 

You are right. It does not change. I have no explanation for that. You can change ticks if you additionaly toggle 

 

and press apply.

You can also achieve something by

plot(strain1, stress1, tickmarks = [6, 12])

but it seems that 5 ticks in x and y direction is also not possible. Maybe because subdividing a range of 3 with 5 ticks does not make allot of sense.

(The origin does not seem to count as a tick.)

@nm @Thomas Richard 

Update: Below is the protocol of one session

In another attempt, a session was started without errors, but then errors occurred after reexecution (with !!!) .

All with Maple 2023.

@nm 

Keep us posted. A comparison will be of interest in any case. Memory management is not identical between operating systems and could pose limits on an application

@Carl Love 

The suggestion from the third paragraph only works if one is in the possion of a former version with a different purchase code. I use a commerical version where this is the case. I do not know if other licenses come with the same purchase code for different version.

Using a former version comes with the drawback that an error with the lastest version might not manifest. 

@mmcdara 

I found a solution that works with your proc as is

subsindets(expression_with_many_unit_commands, specfunc(anything, Units:-Unit), UnitFactors_1)

I also submitted a software change request concerning the gramms.

Thanks again & Merry Xmas

@TKChang99 

I don't mind at all. Note, I have only focussed on getting most out of the help system (a bit like a modern Robin Curso on an island with a laptop and a solar pannel). I haven't recommended any books or study guides for the simple reason that I've never read one (probably a missed opportunity).

I forgot one important fact to mention: Maple calculates complex. Results are vaild in the complex domain without restrictions. If there is no result returned, assumptions on variables can make a difference. Complex calculaus is beyond normal programming languages and not only in this sense Maple provides more. Maple is more of a mathematical environment that can be used in a variety of ways, as acer has explained.

@mmcdara 

Starting a blank session:

I would say that this is incorrect since ?Units,SI defines mass as kg.

@mmcdara 

Mass is the only base unit with a prefix. Is is probably not taken into account.

However, simplify simplifies to kg

simplify(Unit(N/m))

This is what I would expect but does not fit to the definition you found. Strange indeed.

@mmcdara 

Actually I was hoping for a way without dedicated procedures. Something using subsindets and a type identifier (maybe HasUnit?) in combination with a transformer (performing the core functionality you demonstrated here) using library commands. However, your answer is valuable as always:

Your first attachment provides the core functionality to expand a Unit expression with compound units

Unit('kg'*'m'/'s'^2);
lprint(%);
UnitFactors_1(%);
lprint(%)

but does not work on subexpressions that are products like:

123.456*Unit('kg'*'m'/'s'^2);
lprint(%);
UnitFactors_1(%);
lprint(%)

If it would, it could be mapped over larger expressions. I have added to my original post an example of a larger expression with units that cannot be simplified without beeing able to expand Unit expressions with compound units.

Your second attachment is valuable to determine unit conversion factors (which I called scaling factors in my attachment) in cases where an a priory knowledge is required. Knowing, for the example, that the input to the transfer function is in Volts one gets

This is similar to what I added in my attachment by hand to get a dimensionless expression that can be plotted. Such a decomposition to base units would be a handy addition to the unit packages to help the user to convert Maple output with units into something that can be more easily interpreted. Maples simplify command must use a decomposition like that internally to simplify units.

Thank you for the answer 👍

5 6 7 8 9 10 11 Last Page 7 of 37