Hot answers tagged

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,...


24

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


23

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

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 ...


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

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.61625500000000006684132`4.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[QuantityUnits`Private`$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" "...


10

I resolved that using (Pi/4) * (180 Degree /Pi) Degree is a symbol similar to Pi, it contains a value Pi / 180 and it keeps the symbolic form unless used with finite precision numbers. All functions in Mathematica work with radians so this symbol is a convenient form of a scaling factor: 40 Degree is verbose but holds numerical value in radians. ...


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 - ...


9

Look at what this gives: Evaluate[h[x]/Hinf] This is clearly wrong, you're adding x of no quantity to a quantity of Centimeters, rather than parsing the units in the plotdomain, try it directly. Plot[Evaluate[h[Quantity[x, "Centimeters"]]/Hinf], {x, 0, 30.48}, AxesLabel -> {"cm", "Amperes"}]


9

You can look through all of the units for the ones that are physical constants: Quantity@"m"; Sort@Keys@QuantityUnits`Private`$UnitReplacementRules (You need the initial run of Quantity on a fresh kernel to load the package for the QuantityUnits context to be available.) Below is my attempt at extracting the constants from that list. The one in the list ...


9

You can use the UnitSystem option of EntityProperty, EntityValue[Entity["Planet", "Earth"], EntityProperty[ "Planet", "Radius", UnitSystem -> "Metric" ] ] (* Quantity[6371.008, "Kilometers"] *) Why am I talking about EntityValue when you asked about PlanetData? Because PlanetData calls EntityValue under the hood (as do all newer XXXData ...


9

TraditionalForm[ Column[{ Defer[m = Quantity[1, "Kilograms"]], Defer[a = Quantity[9.81, "Meters" ("Seconds")^-2]], Defer[F == m a], m = Quantity[1, "Kilograms"]; a = Quantity[9.81, "Meters" ("Seconds")^-2]; HoldForm[F] == m a}] ] For a function version: display[x_Quantity, y_Quantity] := Block[{m, a, F}, TraditionalForm[ Column[{ ...


9

Under the hood, units not recognized by Quantity use Wolfram|Alpha's NLP to parse the unit. In this case we see there are 2 possibilities: It's probably worth leaving feedback at the bottom of the Alpha page making your case that 'kilogram meters' should be the default for this query. I don't think there's a way to access all possibilities in Quantity ...


9

"Hours", "Weeks" and "Years" are all time units: UnitDimensions /@ {"Hours", "Weeks", "Years"} {{{"TimeUnit", 1}}, {{"TimeUnit", 1}}, {{"TimeUnit", 1}}} It is not easy to prevent Quantity arithmetic from cancelling these units. You could use UnitConvert to convert the output to the desired unit: UnitConvert[ Quantity[40,("Hours")/("Weeks")] * ...


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