zenterix

400 Reputation

5 Badges

2 years, 363 days

MaplePrimes Activity


These are questions asked by zenterix

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

I'd like to be able to define functions with units and then use them.

In the example below, things don't work with Maple input. I've shown one example, with the function f2.

It seems to work better with 2D input, but it seems that it is not possible to make plots.

In the example below, I define f4 as a function of two variables that returns a function of one variable.

I'd like to call the outer function, obtain a function as a result (r1 below) and then plot the latter.

restart

with(Units:-Simple)

NULL

f1 := proc (x) options operator, arrow; x*Unit('m') end proc

proc (x) options operator, arrow; Units:-Simple:-`*`(x, Unit('m')) end proc

(1)

f1(2)

2*Units:-Unit(m)

(2)

f2:=x->xUnit(m)

Units:-Unit(m)

(3)

f2(2)

f2(2)

(4)

f3 := proc (x, y) options operator, arrow; x*Unit('m')*y*Unit('m') end proc

proc (x, y) options operator, arrow; Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(x, Unit('m')), y), Unit('m')) end proc

(5)

f3(2, 3)

6*Units:-Unit(m^2)

(6)

f4 := proc (x, y) options operator, arrow; proc (z) options operator, arrow; x*Unit('m')*y*Unit('m')*z*Unit('m') end proc end proc

proc (x, y) options operator, arrow; proc (z) options operator, arrow; Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(x, Unit('m')), y), Unit('m')), z), Unit('m')) end proc end proc

(7)

r1 := f4(2, 3)

proc (z) options operator, arrow; Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(Units:-Simple:-`*`(2, Unit('m')), 3), Unit('m')), z), Unit('m')) end proc

(8)

r1(4)

24*Units:-Unit(m^3)

(9)

plot(r1)

 

NULL

The contents above aren't showing the error that Maple gives when I try to plot.

Here is a screenshot

Download FunctionUnits.mw

3 4 5 6 7 8 9 Last Page 5 of 20