Anthrazit

760 Reputation

11 Badges

4 years, 315 days

MaplePrimes Activity


These are replies submitted by Anthrazit

@Ronan 

That seems to me 2 different questions now.

The one important to me is why the < operator doesn't work with the Units-Standard package. That is the most important one to fix.

The other one is the question about the workaround with "is". That one apparently doesn't give the desired results either, so for my part this isn't a path I am going to follow further on.

The intermediate solution is to change all my if clauses, and convert the values that should be checked to unit_less ones, before doing the calculations. Needless to say that the main reason for implementing the check in the first run is that Maple often exits with an error if units get lost.

The main problem for all this behaviour is, that Maple cuts out units when a value becomes zero. This is a bug in my opinion, and as I have posted before, other software like Mathcad does not show this behaviour.

@Ronan 

The last line should give "True" not "False".


 

with(Units[Standard])

[`*`, `+`, `-`, `/`, `<`, `<=`, `<>`, `=`, Im, Re, `^`, abs, add, arccos, arccosh, arccot, arccoth, arccsc, arccsch, arcsec, arcsech, arcsin, arcsinh, arctan, arctanh, argument, ceil, collect, combine, conjugate, cos, cosh, cot, coth, csc, csch, csgn, diff, eval, evalc, evalr, exp, expand, factor, floor, frac, int, ln, log, log10, log2, max, min, mul, normal, polar, root, round, sec, sech, seq, shake, signum, simplify, sin, sinh, sqrt, surd, tan, tanh, trunc, type, verify]

(1)

a := 15*Unit('kN')

15*Units:-Unit(kN)

(2)

b := 0*Unit('kN')

0

(3)

NULLNULL

if a < b then "True" else "False" end if

Error, cannot determine if this expression is true or false: 15*Units:-Unit(kN) < 0

 

NULL

if is(a < b) then "True" else "False" end if

"False"

(4)

NULL

if is(a <> b) then "True" else "False" end if

"False"

(5)

NULL


 

Download CompareUnits.mw

@Ronan 

This is indeed an interesting approach that seems to work.

@Thomas Richard 

The Simple package doesn't allow for unit conversions and a lot of other stuff, so we need Standard package.

@acer 

Looks like you are right.

The problem was that there is an argument switch between Excel and Maple.

Excel arctan2(x, y), while Maple arctan(y, x).

arctan(1, 0)``

(1/2)*Pi

(1)

arctan(-1, 0)

-(1/2)*Pi

(2)

arctan(0, 1)

0

(3)

``

arctan(0, -1)

Pi

(4)

NULL


 

Download arctan.mw

@acer 

Thanks a lot again. I did understand my original mistake in your first explanation already.

The crucial thing is to understand, when something gets evaluated. And I still think that is not always clear.

  • "When entries of a Vector are accessed individually they get evaluated."
    Nice, but where do I find this information?
     
  • This following entry in Maple Help (look for "eval) is also a bit tricky to understand:
    "Applying eval to mutable container objects like tables, rtables, and modules does not map over the elements.  Use map(eval,M) to evaluate elements in an object, M."

    Does "map over" mean the same as thing we are talking about here?

 

@acer

Thanks a lot, that was very helpful.

But one more question, as I need to understand when an object is mutable, and when it isn't anymore.

I've used one of your examples in the following code, and added something to the end. When do the values in that code become unmutable? A change of the values of aVectorList don't have any consequences to the resultlist.


 

restart; aVectorList := [Vector(2, [1, 2]), Vector(2, [3, 2])]

[Vector[column](%id = 36893490930679169140), Vector[column](%id = 36893490930679169260)]

(1)

" results:=Array():  AddVector:=Vector(4): for i from 1 to nops(aVectorList) do     AddVector:=Vector(4):     AddVector[1] := aVectorList[i][1];     AddVector[2] := aVectorList[i][2];     results(i):= AddVector; end do: resultlist:=convert(results,list);"

[Vector[column](%id = 36893490930679162868), Vector[column](%id = 36893490930679163108)]

(2)

aVectorList[1] := Vector(2, [4, 5])

[Vector[column](%id = 36893490930679159012), Vector[column](%id = 36893490930679169260)]

(3)

resultlist

[Vector[column](%id = 36893490930679162868), Vector[column](%id = 36893490930679163108)]

(4)

NULL


 

Download Mutable1.mw

@dharr 

Ok, thanks.

Btw., it works by using convert tools via sets as well.

@acer 

So to get rid of duplicates, one would first have to convert the vector to lists, and then convert the list to a set?

And then the whole operation back again, converting the lists to vectors again?

@acer 

Thanks a lot for the clarification.

Just wondering what the alternatives to using global variables in a procedure would be?

The only other option I can think of, is to explicit hand over all global variables in the procedure interface, isn't it?

@tomleslie 

The "indices" solution worked fine, thanks.

I just wanted to say that it seems that the iteration of the table itself doesn't seem to work, contrary to working with a matrix.

@tomleslie 

What i wanted is to have a loop over the contents of the table, similar to the example with a matrix.

The Maple Help states as following in the "do" section.

When expr is a table, the order in which the entries are processed depends on the underlying storage order, which may not correspond to any natural order (such as numeric or alphabetic order).

...

A for...in loop can optionally have two loop variables. In this case, during each iteration of the loop, the first variable takes as value the index of the entry, or operand number of the operand. The second variable takes on the corresponding value.

Apparently the code above doesn't do what I intended, giving me both the index and the value.

The "entries" and "indices" solution seems to do the trick however.

It is possible to do the loop over "indices(x)" instead of x.

Probably MapleCloud needs to be opened first.

At least I did that after a couple of unsuccessful trys, and then it worked.

@TechnicalSupport 

Yes, of course, I have no problem downloading our own (and other) libraries.

The question is just how Maple Player could use them.

@Joe Riel 

The "Publish an Update" is not the problem, the problem is that application type is set to "Maple", and not "MaplePackage".

First 6 7 8 9 10 11 12 Last Page 8 of 17