zenterix

350 Reputation

4 Badges

2 years, 230 days

MaplePrimes Activity


These are questions asked by zenterix

I am reading the documentation on the `Units[Simple]` package.

There is a section that says

"In the Simple Units environment, in contrast to the Standard and Natural environments, unassigned variables are not automatically assumed to represent unit-free quantities. For example, 5m+x is a valid expression if x is unassigned, because x may represent a length. On the other hand (5m+x)(6s+x) is an invalid expression because the first factor implies that x represents a length and the second factor implies that x is a duration."

The way I understood this paragraph is that in Units:-Simple an unassigned variable is not assumed to represent a unit-free quantity, but in Units:-Standard it is assumed to represent a unit-free quantity.

Consider the expression 5m+x. This expression works in Units:-Simple but not in Units:-Standard.

Units:-Simple adds a quantity 5m to a quantity without units. But why can one add a quantity with units to a quantity without units?

Units:-Standard tries to add a quantity 5m to a quantity that is assumed to have units. What units are assumed?

Next, consider (5m+x)(6s+x).

This fails in both packages, as can be seen below (actually, for some reason, the embed below is not showing the expressions typed in for Units:-Standard, but can be seen if you download the worksheet I imagine).

restart

with(Units:-Simple)

5*Unit('m')+x

5*Units:-Unit(m)+x

(1)

(5*Unit('m')+x)*(6*Unit('s')+x)

Error, (in Units:-Simple:-*) the following expressions imply incompatible dimensions: {5*Units:-Unit(m)+x, 6*Units:-Unit(s)+x}

 

restart

with(Units:-Standard)

(5*Unit('m')+x)*(6*Unit('s')+x)

Error, (in Units:-Standard:-+) the units `m` and `1` have incompatible dimensions

 

5*Unit('m')+x

Error, (in Units:-Standard:-+) the units `m` and `1` have incompatible dimensions

 

NULL

So my question is, what exactly is the difference between considering unassigned variables to be unit-free vs not unit-free?

Download Units_Simple_vs_Standard.mw

What is the problem with the integral below when I use a variable n?

with(Units:-Simple)

V__1 := Unit('m'^3) = Units:-Unit(m^3)NULL

V__2 := 2*Unit('m'^3) = 2*Units:-Unit(m^3)NULL

int(1/V, V = V__1 .. V__2)

ln(2)

(1)

`assuming`([int(n/V, V = n*Unit('m'^3) .. m*Unit('m'^3))], [n > 0, m > 0])

-ln(n)*n+ln(m)*n

(2)

NULL

Download Units_Int.mw

I was just using Maple to do a simple calculation but the units came out all complicated. 

The expression in question is work done by a van der Waals gas. The units should come out to Joules per mol. 

When I do the calculation manually (second expression below) I do get that result, albeit in more basic units than Joules.

In the first expression, in which I am using subs to sub in values with units into the expression, the final expression is very complicated. Why?

with(Units:-Simple)

simplify(subs({R = 8.314*Unit('J'/('K'*'mol')), T = 298*Unit('K'), V__1 = Unit('L'/'mol'), V__2 = 50*Unit('L'/'mol'), a = 2.283*Unit('L'^2*'bar'/'mol'^2), b = 0.4278e-1*Unit('L'/'mol')}, -R*T*ln((V__2-b)/(V__1-b))+a*(1/V__1-1/V__2)))

(-9798.522418*Units:-Unit(J/(K*mol))*Units:-Unit(K)*Units:-Unit(L/mol)+2.23734*Units:-Unit(L^2*bar/mol^2))/Units:-Unit(L/mol)

(1)

How do we simplify the units above so they become the same as the units in the same (manual) calculation below?

-(8.314*Unit('J'/('K'*'mol'))*298)*Unit('K')*ln((50*Unit('L'/'mol')-0.4278e-1*Unit('L'/'mol'))/(Unit('L'/'mol')-0.4278e-1*Unit('L'/'mol')))+2.283*Unit('L'^2*'bar'/'mol'^2)/Unit('L'/'mol')

-9570.222418*Units:-Unit(m^2*kg/(s^2*mol))

(2)

NULL

Download Units_-_Subs.mw


Consider the worksheet below.

restart

with(Physics[Vectors])

`dτ_` := -I*z*dz*B__0*x^2*_j/d^2-I*y*dz*B__0*x^2*_k/d^2

-I*z*dz*B__0*x^2*_j/d^2-I*y*dz*B__0*x^2*_k/d^2

(1)

I want to integrate the above expression. The differential is already present in the expression. Currently, I have to manually remove the differential to use the int procedure as below.

`τ_` := int(-I*z*B__0*x^2*`#mover(mi("j"),mo("∧"))`/d^2-I*y*B__0*x^2*`#mover(mi("k"),mo("∧"))`/d^2, z = l .. -l)

(2*I)*y*B__0*x^2*_k*l/d^2

(2)

Since I want to put this operation inside a procedure, this removal of dz needs to happen programatically.


For even more context, dtau is a differential torque. 

I am integrating these infinitesimal torques.

dtau is calculated based on a magnetic field B.

I would like to have a procedure that accepts a field B and computes the torque integral.

Download RemoveDifferential.mw

I tried inserting contents of my worksheet here but for some reason procedure test2 does not appear. Therefore, here is a screenshot.

What I would like is for the call r() above to print out 3,2 and then 5.

Basically, I'd like to know how I can call a function that has default parameter values with a value that makes the function use the default parameter value.

In the code above, the variable r is assigned to the return value of test2, which is the function called "inner". The function inner accepts an argument "b" and calls the function "test" passing in this "b" as the second argument. If I don't pass any argument to "inner" then it defaults to Null, which then gets passed to "test".

I want this Null to force "test" to use its default value for parameter "b".

PS As an extra, why does it give a "not able to parse" error when we declare a local inside of a proc as above? Note that I have it commented out. 

Download Curry.mw

1 2 3 4 5 6 7 Last Page 3 of 18