C_R

2140 Reputation

19 Badges

4 years, 247 days

MaplePrimes Activity


These are questions asked by C_R

Example: Exanding the left hand side below to the right hand side

Unit('kg'*'m'/'s'^2) = Unit('kg')*Unit('m')/Unit('s')^2;

Such functionality would be useful for manipulating rational functions whose coefficients have units that can otherwise only be simplified by substituting new dimensionless independent variables as dicussed here.

Is there statement that can be mapped over an expression that identifies all subsexpressions with units and expands them to a products of units?

Probably not possible but also desireable: A variant that expands derived physical quantities to a product of base units as for example Newton to base units: Unit('N') = Unit('kg')*Unit('m')/Unit('s')^2;

Unit('N') = Unit('kg')*Unit('m')/Unit('s')^2;

Edit: Example from the link above on Unit expressions with compound units

``

Example that cannot be simplified

H(s) = 60.*Unit('m'*'kg'/('s'^2*'A'))/(.70805*s^2*Unit('kg'^2*'m'^2/('s'^3*'A'^2))+144.*s*Unit('kg'^2*'m'^2/('s'^4*'A'^2))+0.3675e-4*s^3*Unit('kg'^2*'m'^2/('s'^2*'A'^2)))

H(s) = 60.*Units:-Unit(m*kg/(s^2*A))/(.70805*s^2*Units:-Unit(kg^2*m^2/(s^3*A^2))+144.*s*Units:-Unit(kg^2*m^2/(s^4*A^2))+0.3675e-4*s^3*Units:-Unit(kg^2*m^2/(s^2*A^2)))

(1)

simplify(%)

H(s) = 60.*Units:-Unit(m*kg/(s^2*A))/(.70805*s^2*Units:-Unit(kg^2*m^2/(s^3*A^2))+144.*s*Units:-Unit(kg^2*m^2/(s^4*A^2))+0.3675e-4*s^3*Units:-Unit(kg^2*m^2/(s^2*A^2)))

(2)

After expansion of Unit expression (here done by hand) simplifcationis possible with other Maple commands

H(s) = 60.*Unit('m')*Unit('kg')/((.70805*s^2*Unit('kg')^2*Unit('m')^2/(Unit('s')^3*Unit('A')^2)+144.*s*Unit('kg')^2*Unit('m')^2/(Unit('s')^4*Unit('A')^2)+0.3675e-4*s^3*Unit('kg')^2*Unit('m')^2/(Unit('s')^2*Unit('A')^2))*Unit('s')^2*Unit('A'))

H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A))

(3)

factor(H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A)))

H(s) = 1632653.061*Units:-Unit(s)^2*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)*s*(19266.66666*s*Units:-Unit(s)+3918367.346+.9999999999*s^2*Units:-Unit(s)^2))

(4)

normal(H(s) = 60.*Units:-Unit(m)*Units:-Unit(kg)/((.70805*s^2*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^3*Units:-Unit(A)^2)+144.*s*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^4*Units:-Unit(A)^2)+0.3675e-4*s^3*Units:-Unit(kg)^2*Units:-Unit(m)^2/(Units:-Unit(s)^2*Units:-Unit(A)^2))*Units:-Unit(s)^2*Units:-Unit(A)))

H(s) = 60.*Units:-Unit(s)^2*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(5)

Normalization to a dimensionless equation expression (that still has units) by a scaling factor with units

Sc := Unit('s')^3*Unit('A')/(Unit('m')*Unit('kg'))

Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg))

(6)

(H(s) = 60.*Units[Unit](s)^2*Units[Unit](A)/(Units[Unit](m)*Units[Unit](kg)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))*(1/Sc)

Units:-Unit(m)*Units:-Unit(kg)*H(s)/(Units:-Unit(s)^3*Units:-Unit(A)) = 60./(Units:-Unit(s)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(7)

Rewriting the left hand side

(proc (x) options operator, arrow; x = convert(x, units, m/V) end proc)(Sc)

Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m)*Units:-Unit(kg)) = Units:-Unit(m/V)

(8)

isolate(Units[Unit](s)^3*Units[Unit](A)/(Units[Unit](m)*Units[Unit](kg)) = Units[Unit](m/V), Unit('m'))

Units:-Unit(m) = Units:-Unit(s)^3*Units:-Unit(A)/(Units:-Unit(m/V)*Units:-Unit(kg))

(9)

subs(Units[Unit](m) = Units[Unit](s)^3*Units[Unit](A)/(Units[Unit](m/V)*Units[Unit](kg)), Units[Unit](m)*Units[Unit](kg)*H(s)/(Units[Unit](s)^3*Units[Unit](A)) = 60./(Units[Unit](s)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))

H(s)/Units:-Unit(m/V) = 60./(Units:-Unit(s)*s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2))

(10)

Magnitude plot

abs(H(s)/Units[Unit](m/V) = 60./(Units[Unit](s)*s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2)))

abs(H(s))/Units:-Unit(m/V) = 60./(Units:-Unit(s)*abs(s*(.70805*s*Units:-Unit(s)+144.+0.3675e-4*s^2*Units:-Unit(s)^2)))

(11)

H(s) = H(f), s = I*omega, omega = 2*Pi*f

H(s) = H(f), s = I*omega, omega = 2*Pi*f

(12)

subs(H(s) = H(f), s = I*omega, omega = 2*Pi*f, abs(H(s))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs(s*(.70805*s*Units[Unit](s)+144.+0.3675e-4*s^2*Units[Unit](s)^2))))

abs(H(f))/Units:-Unit(m/V) = 60./(Units:-Unit(s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units:-Unit(s)+144.-0.14700e-3*Pi^2*f^2*Units:-Unit(s)^2)))

(13)

plot(rhs(abs(H(f))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units[Unit](s)+144.-0.14700e-3*Pi^2*f^2*Units[Unit](s)^2)))), f = 0*Unit('Hz') .. 10*Unit('Hz'), labels = [f/Unit('Hz'), lhs(abs(H(f))/Units[Unit](m/V) = 60./(Units[Unit](s)*abs((2*I)*Pi*f*((4.448809357*I)*f*Units[Unit](s)+144.-0.14700e-3*Pi^2*f^2*Units[Unit](s)^2))))])

 

 


Download Expansion_of_Unit_command_and_simplification_to_m_per_V.mw

The attached integral is plotted quite quickly, but the search for the maximum and for the inverses of function values takes time. Can the search be accelerated or is the integrand simply too complicated?

Int(22.89730452*exp(-3.373250126*10^6*x^2)*sqrt(2)*(erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7)-x^2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*sqrt(2)*(sqrt(2.500000000*10^(-7)-x^2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc)

Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc)

(1)

plot(Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc), y = 0 .. .25)

 

unapply(int(op(1 .. 2, Int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3, method = _d01ajc))), y)

proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*x^2)*2^(1/2)*(erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*2^(1/2)*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc

(2)

CodeTools:-Usage(Optimization:-Maximize(proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*(x^2))*(2^(1/2))*(erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc, 0 .. .15))

[HFloat(0.0356073228322897), Vector[column](%id = 36893490875463313756)]

(3)

CodeTools:-Usage(fsolve((proc (y) options operator, arrow; int(22.89730452*exp(-3373250.126*(x^2))*(2^(1/2))*(erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)+(1/40)*y-0.1540000000e-2))+erf(1298.701299*(2^(1/2))*((0.2500000000e-6-x^2)^(1/2)-(1/40)*y+0.1540000000e-2))), x = -0.5000000000e-3 .. 0.5000000000e-3) end proc)-0.5e-2, 0 .. .15, maxsols = 2, method = subdivide))

0.2456248637e-1, 0.9863751363e-1

(4)

Download slow_maximize_and_fsolve.mw

Here is the layout challenge: Whenever the value of a physical quantity is one as in

mass = 1* Unit('kg')

automatic simplification removes the one and the output displays

Desired would be which reads better (in particular when used inline in text passages).

Using the Empty Symbol

mass = ``(1)*Unit('kg')

an expression with parenthesis is obtained (that can be removed in subsequent calculations with the expand command) which looks worse than my current workaround of using floats

(Introducing floats in expressions is not always acceptable)
So the idea would be to use the empty symbol for initial parameter definition in textbook style layout and remove it with expand in subsequent calculations.

Any other symbol that prints as "1" that can be removed in later calculations by Maple commands is welcome as well. It should be better than

mass=`#mrow(mo("1"));`*Unit('kg');
subs(`#mrow(mo("1"));` = 1, %);

 

Any smarter assumptions or substitutions I could try out on the left handside of the below

 

If this does not work I would be greatefull for fast numerical evaluation methods. Plotting for example takes to long.


Attached you will find some background on what I want to achieve.

Gaussian_integration.mw

With the following steps

S1: Open Help pressing F1

S2: enter `if in the search field

S3: click a topic in the result list

S4: search within the topic with find/replace (Crtl f) the term `if 

I get plenty of results where I cannot find the search term in the help topic. Why is that?

Is help ignoring the left single quotes ` ?

I don't think so: I get usefull results for `` and `i, which in the later case also lists the topic "ifelse" that contains `if in the textbody.

So, why does advanced searching with the exact phrase "`if" not list the "ifelse" topic?

Realted question:

Why does the search term "(* " not list the relevant help topic help(comment)?

Somehow related in the context of getting more specific results:

https://www.mapleprimes.com/questions/234462-Searching-The-Help-System-Why-Are-There-No-Hits-For-Solve

4 5 6 7 8 9 10 Last Page 6 of 27