C_R

3537 Reputation

21 Badges

6 years, 60 days

MaplePrimes Activity


These are replies submitted by C_R

@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 👍

Why it did not work:

The left hand side in

(seq('L'[q,  q+1] , q=1..2)) := (0 $ 2);

is resolved to a name but not evaluated to a sequence of Matrix elements.

 

@acer 
Thank you for the detailed reply. I tried to print the operators to see if there is any explict declaration of local variables but instead found interesting differences in attachment 2 and 3 of the first answer from you

 

I don't know if this gives a hint why the above call to fsolve did not work as the call to Maximize did.

@acer 

Among all the things I tried I did not put evalf inside the operator definition. Makes sense now.

What I do not understand is the change of variable names y=Y. Why is

F := y->evalf(Int(unapply(op(1,ig),x),rhs(op(2,ig))));

not working (I tried this as well).

I tried also nested operators which I see at last work.

As always, thank you

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