# Tag Info

35

If we pre-evaluate the expression: x1 B[Quantity[ll, "Micrometers"], Quantity[1000, "Kelvins"]] then the run time can be reduced by about factor 10. We can do this by hoisting the expression out of the loop and pre-evaluating using With: p = Module[{ll} , With[{v = x1 B[Quantity[ll, "Micrometers"], Quantity[1000, "Kelvins"]]} , Table[{Quantity[...

34

This is certainly the optimal way of obtaining the list you are looking for Quantity;QuantityUnitsPrivate$UnitReplacementRules[[1, All, 1]] EDIT for v10 (thanks @DavidCreech) In v10 this undocumented variable format has been changed into an association, whose keys are the units. Quantity; Keys[QuantityUnitsPrivate$UnitReplacementRules]

29

There are system options available that should restore the old behavior for most of the currated data paclet: SetSystemOptions[SystemOptions["DataOptions"] /. True -> False] {"DataOptions" -> {"ReturnEntities" -> False, "ReturnQuantities" -> False, "UseDataWrappers" -> False}} Note that this prevents these paclets from returning Entity,...

27

I believe you can use "DimensionlessUnit" to get the desired result: Quantity[3, "DimensionlessUnit"] 3 (note this is the unit produced by QuantityUnit on a dimensionless value): QuantityUnit[3] "DimensionlessUnit"

24

This should list you all available units in Mathematica. Needs["QuantityUnits"] Keys[QuantityUnitsPrivate$UnitReplacementRules] Inspired by eldo I made a little dynamic interface: Needs["QuantityUnits"] table = Keys[QuantityUnitsPrivate$UnitReplacementRules]; Panel[DynamicModule[{f = ""}, Column[{Text[Style["Mathematica Unit Search:", Bold]],...

21

Oops - found it! QuantityMagnitude[quantity] does the job. For example, In[1]:= QuantityMagnitude[Quantity[1, "Feet"]] Out[1]= 1

21

In physics, the Planck constant may be used as a natural unit. If you want to switch to another unit system, use UnitConvert[]. For example, you can switch to standard SI units this way: UnitConvert[Quantity[1, "PlanckConstant"], "SIBase"] which will give you: Quantity[6.626070*10^-34, ("Kilograms" ("Meters")^2)/("Seconds")] This can be done at the ...

20

This is a long comment for Nick Lariviere's answer. You can use Trace to see how lengthy the entity and quantity logic is. Version 9: Tuples@{Range@112, {"Symbol", "Group"}} // First ElementData @@ % // Trace; % // ByteCount 78336 TreeForm[%%, VertexLabeling -> False, ImageSize -> 800, AspectRatio -> 2] Version 10: ... % // ByteCount ...

19

This appears to be a bug. The dimensions of the Boltzmann constant are incorrect. In fact, all the physical constants I checked have TemperatureUnit where they should have TemperatureDifferenceUnit. You should only have to make a substitution when making calls to physical constants in Quantity: q = UnitConvert[Quantity["elementary charge"]]; k = (...

19

You need to use 'better' units: UnitConvert[Quantity[1, "GiB"], "MiB"] Quantity[1024, "Mebibytes"] See explanation and definitions in https://en.wikipedia.org/wiki/Gigabyte

18

Not a solution but an extended comment. You misunderstand the physical underpinnings of quantities and units. Every physical quantity has an inherent margin of error, even if it is very small (negligible) and thus tacitly suppressed. The quantity 1 meter truly means approximately 1 meter, give or take a few millimeters/nanometers/Planck distances. The ...

17

Just some analysis to try to find where the slow down. On my PC, it took 25 seconds to build the table. ps. I never used Units before. Your main loop: x = UnitConvert@Quantity["PlanckConstant" "SpeedOfLight"/"BoltzmannConstant"] x1 = UnitConvert@Quantity[2, "PlanckConstant" ("SpeedOfLight")^2] B[L_, T_] := (L^(-5))/(Exp[x/(L T)] - 1) c = Quantity[1000, "...

15

I have mined the Units package for the names of all units defined therein and correlated them to the built-in strings recognized by Quantity(referenced here). I then define a new function Quantify to convert the old school units into Quantity objects. unitRules = Dispatch[{Abampere -> Quantity[1, "ABAmperes"], Abcoulomb -> Quantity[1, "...

15

At the beginning of your notebook set the Metric system as default. $UnitSystem = "Metric" This works for me. If not try below suggestion Remember you are reading the data from wolfram alpha! it's a regional thing so if the upper solution didn't work, you can try something like (I don't remember exactly though) SetOptions[WolframAlpha, PodStates -> {"... 14 Below is some code I use to work with units. I am aware that the unit system I am calling "CGS" is only semi-CGS, since I am keeping the SI electromagnetic units, but this is the flavor of consistent unit system we sometimes use in our lab. Really, though, this is a recipe for choosing your own set of base units. The method works by applying ... 14 You can use the relative uncertainty 1.1*10^-5 from the CODATA website you also referenced, and use Around to construct a value for the Planck length with uncertainty which has a much nicer formatting for showing the relevant digits of the number: Around[UnitConvert[Quantity["PlanckLength"], "m"], Scaled[1.1*^-5]] (1.616255±0.000018) x 10^-35 m Since ... 13 Running RebuildPacletData[] solved the problem, but only on Windows, not on Mac. On my Mac I had to use Get["EntityFramework"] EntityValue[] and restart Mathematica. 12 UnitConvert[Quantity[179., "Centimeters"], MixedRadix["Feet", "Inches"]] returns Quantity[MixedRadix[5, 10.472440944881885], MixedRadix["Feet", "Inches"]] which formats as 5'10.4724" 12 First, regarding the substance of the calculation apart from Mathematica's unit handling: I think your input suggests some confusion about what you're trying to calculate. You say your working days total to 251/7 weeks for a particular year. I assume that there are 251 working days in that year (this is a fairly typical number). However, your 251/7 ... 11 The following works for V10. First we define some abbreviation rules: rule = {"Newtons" :> N, "Meters" :> m, "Pascals" :> Pa, "Farads" :> F}; (* add more rules here *) Then: unit = TextString[QuantityUnit[Quantity[1, "Newtons/Meters^2"]] /. rule] "N/m^2" StringQ[unit] True TextString[QuantityUnit[Quantity[1, "Meters*Pascals/Farads^2"]] /.... 11 The difference between 0 °C and 100 °C in Fahrenheit is 180 °F. The difference between 0 K and 100 K in Fahrenheit is 180 °F. But 100 °C is 212 °F, while 100 K is 279.688 °F. The underlying reason are, of course, the differing scale origins (zero points); the conversions are therefore not direct proportions (not homogeneous functions). Instead they are ... 11 A bit too long for a comment... My best guess is that WolframAlpha["earth's gravity", "MathematicaResult"] is simply rounding to too few digits. It returns 32.2 ft/s^2, which seems pretty round for what it represents. Now maybe that's ok to do because gravity varies around the globe: data = GeogravityModelData[{{-90, -180.}, {90, 180.}}, "Magnitude", ... 11 Rightly or wrongly, if the unit specification is unknown, then WA is used behind the scenes to decide if it could be interpreted as a standard unit. You can see this with the error message provided: Quantity["AccelerationOfGravity"] Quantity::unkunit: Unable to interpret unit specification AccelerationOfGravity. Quantity["AccelerationOfGravity"] So,... 11 The 4.652... at the end of 1.616255000000000066841324.652207380644164*^-35 should tell you that Mathematica knows this constant only up to 4.65 decimal digits. You have to enforce first to treat the number as a higher precision number first: NumberForm[ SetPrecision[ QuantityForm[UnitConvert[Quantity["PlanckLength"], "Meters"], "LongForm"], 7], {7,... 11 Is Mathematica V4 still for sale? This answer proposes less drastic solutions than moving back for Version 4. "Global" solution For the problems you encounter and approach you take one -- not that good -- proposal is to redefine Quantity: Unprotect[Quantity]; (*Quantity[x_,___]:=x;*) Quantity[0, ___] := 0; Protect[Quantity]; Remark 1: I have not ... 10 Expanding a little bit on paw's nice discovery: Needs["QuantityUnits"] table = Keys[QuantityUnitsPrivate$UnitReplacementRules]; Since this table is very long one can restrict the output, f.e. with Union @ Flatten[StringCases[#, "Feet" ~~ ___] & /@ table] // TableForm UPDATE A similar question could arise with the more than 1000 inbuilt ...

10

As noted in the comments, inverse centimeters do not have dimensions of energy, unless you consider $h$ and $c$ to be dimensionless, which Mathematica has no way to tell that you are doing. (Wolfram|Alpha can guess that you want that, but Mathematica, thankfully, is designed not to try to guess.) One approach would be to define wavenumbers = "Wavenumbers" "...

9

A hint about what is going on is provided by searching on MixedRadix in V10.2 or later. You will find the symbol was overloaded to allow the user to specify a sequence number bases for integers represented in mixed-base form. This has produced the unfortunate consequences that I mentioned in the question. I brought this to the attention of Wolfram tech ...

9

You may use either MixedRadixQuantity or Quantity with MixedMagnitude and MixedUnit. In both cases the units you need are {"AngularDegrees", "ArcMinutes", "ArcSeconds"}. p1 = MixedRadixQuantity[{20, 32, 15.828}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}]; p2 = MixedRadixQuantity[{22, 32, 12.8}, {"AngularDegrees", "ArcMinutes", "ArcSeconds"}]; p1 - ...

Only top voted, non community-wiki answers of a minimum length are eligible