Template talk:Physical constants

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconPhysics Template‑class
WikiProject iconThis template is within the scope of WikiProject Physics, a collaborative effort to improve the coverage of Physics on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
TemplateThis template does not require a rating on Wikipedia's content assessment scale.

A place for exact values[edit]

Several of these constants are set by convention rather than measured and thus can be computed and presented to arbitrary precision (WP:CALC). In particular, I see value in providing ~20 digits so that software can use the most accurate value representable in double-precision floating-point format. I put in those digits but they were undone by @Primefac, who noted that the cited sources do not provide those digits. I'd like to provide the higher-precision values somehow; perhaps we could add a new field for them. However, I am unsure how other pages would make use of the new field. Or, maybe different approach would better achieve the desired ends. What do you think? —Quantling (talk | contribs) 17:04, 10 February 2021 (UTC)[reply]

Calculated or not, we can only really use what the sources say. If the references only give six sig figs, then we only report six. Additionally, I see little use in providing a number as long as 1.00000008887143810491801; after a certain point the precision becomes trivia rather than useful. Primefac (talk) 19:01, 10 February 2021 (UTC)[reply]
We are permitted to do simple math to build on what the sources tell us according to WP:CALC. I am thinking that the likes of dividing a provided value of h by 2π is pretty simple. The example of 1.00000008887143810491801 is the one case where the decimal expansion is both finite in length and longer than 20 digits, so I broke my template of using just 20 digits for that one case in order to give the exact value. I am hopeful that there is a place in Wikipedia where full double-precision values can be supplied, and would appreciate your help in deciding where that should be. —Quantling (talk | contribs) 23:04, 10 February 2021 (UTC)[reply]
Sure, we can do simple calculations using a {{#expr...}} or similar, but when it comes to this particular template, it provides a value and a reference. If the value does not match the reference, then we are not doing it properly. If there are instances where the full/extended/etc value is needed, then an #expr may be the best way to go. Primefac (talk) 13:22, 12 February 2021 (UTC)[reply]
My reading of WP:CALC is that, for example, if a source says that there are 2 blue cats and 3 red cats and no others then we can give that source in a citation for a sentence that says "There are 5 cats". Please let me know if you disagree. Or more to the point, please let me know if you think the likes of the calculation of h/2π is too complicated to qualify for WP:CALC. If you are worried about the accuracy of these double-precision values and are unsure how to check them yourself, I could make and give you a script in R (or maybe bc); would that help? On other fronts, is it that you find the additional digits to be unsightly or otherwise a negative for the reader? —if so, please give details. Thank you —Quantling (talk | contribs) 18:51, 12 February 2021 (UTC)[reply]
I know how to calculate h/2π, I conveniently have a degree in physics. I don't find any issue with the accuracy of your edits, but I find them unnecessarily detailed, especially for something like A90. We are an encyclopedia designed to provide summaries of values. We can tell people that to A90 = (KJ-90RK-90/KJRK)A (the majority of those values being complex equations themselves), or give them the truncated value provided by NIST, but we're not doing calculations with these values so the precision of 1.00000008887143810491801 is just simply too much; it doesn't mean anything. The folks that are using these full values likely are using the root equations (and wouldn't be checking Wikipedia for the value anyway), so a half-dozen truncated digits are more than sufficient for the lay-person. Primefac (talk) 11:34, 13 February 2021 (UTC)[reply]
Yes, calculating h/2π with a double-precision calculator is easy for pretty much anyone. I apologize that my comments came across as otherwise—my offer of R code is because that supports extended-precision arithmetic with its Rmpfr package, with the obvious benefit of computing even the least-significant of the 20 displayed digits correctly. Maybe that's my naïveté; maybe pretty much everyone has access to extended precision these days.
Would you be okay with my adding an additional field called something like valprecise that would have the WP:CALC'ed value with many more digits? We would enable editors of other pages the option of using it where consensus deemed it appropriate. (Obvious disclaimer: I could be such an editor.) Many people writing computer programs would appreciate the extra precision if it is easily available. And yes, mission critical folks would want to verify the numbers independently, but would find Wikipedia to be a nice sanity check. Thank you —Quantling (talk | contribs) 17:02, 13 February 2021 (UTC)[reply]

Quantling, I don't think it is a good idea. Wikipedia is an encyclopedia, not a scientific handbook. It is not a source for ultra-precise values for researchers; they will use accepted scientific references. And given the trickiness of numerical precision in computing they will let the software calculate the value of the Josephson constant from the easier to enter values of e and h themselves. This template was set up to make it easy to keep the CODATA values, and just those values, used in articles up to date. It needs to provide the values given in the source. StarryGrandma (talk) 00:52, 14 February 2021 (UTC)[reply]

It is a shame that this template isn't named "Template:CODATA values" because that would make it easier for me to understand the fixation on the values from that one source. Making high-precision values available via template would not require that they be used in any particular Wikipedia article. The editors of those articles would decide whether they were appropriately encyclopedic on a case by case basis. —Quantling (talk | contribs) 19:13, 15 February 2021 (UTC)[reply]
You're welcome to discuss changing the source on one or more of these values (and as a result the value), but given that NIST are one of the main bodies that define these values, it will probably need some discussion. Primefac (talk) 21:56, 15 February 2021 (UTC)[reply]
Changing the source from CODATA isn't what I had in mind. The CODATA source provides the fundamental constants exactly and simple CALCulations give us the values of the exact, derived constants to any precision we want, such as would be useful in a piece of software employing the usual precision. I am trying to get consensus on using simple calculations based upon the CODATA fundamental constants. —Quantling (talk | contribs) 01:00, 18 February 2021 (UTC)[reply]
I see a number of points to consider here, made all the trickier by this being a template.
  • Whatever the template name is (sort of irrelevant, though a renaming is not out of the question), it currently does provide CODATA values with the source. If it were to allow for presenting another kind of value (e.g. arbitrary precision based on assumed relationships), we would have to suppress the source footnote when used this way.
  • If we cannot find authoritative references that give extended precision, this would seem to suggest that WP should not buck that trend. It looks too unprofessional (already editors put in too much non-encyclopaedic material) if we present more than any sources do.
  • The theoretical expressions might be assumed to be exact, but understanding of physics is not where we can say that they are with certainty. For example, the metrology triangle (essentially measuring the elementary charge directly and calculating it from KJ and RK) is a crosscheck of such a case, and in principle could find a discrepancy as precision of measurements increase. This would suggest that we need to stick to the sources and not use the assumed formulae to be correct.
  • The presentation of ultra-precision values is a per-article choice (and hence not for template-providers to decide on). This would suggest that there is no reason not to provide a special mode of the template with ultra-precision other than that it might be seen to encourage its use (a concern). Nevertheless, I see this as being an exceptional use, and as such it probably makes sense for the editors of the article concerned to use an exceptional calculation method rather than extending the template for this.
At best, this not a simple extension of the precision of the values in the template data: it would be a template rework. On balance, I don't like the idea of giving editors the impression that selecting arbitrary precision is the norm. I'm pretty sure it would be abused. —Quondum 15:23, 18 February 2021 (UTC)[reply]
Given that Wikipedia does permit simple CALCulations, I worry that people who are arguing against these calculations here consider them to not be simple. Here is R code that can be run on your own computer or via a web service (such as this one):
 library(Rmpfr)
 bits <- 1000
 
 # Fundamental constants
 atm <- mpfr("101325", bits)
 c <- mpfr("299792458", bits)
 DnuCs <- mpfr("9192631770", bits)
 e <- mpfr("1.602176634e-19", bits)
 g0 <- mpfr("9.80665", bits)
 h <- mpfr("6.62607015e-34", bits)
 k <- mpfr("1.380649e-23", bits)
 KJ90 <- mpfr("483597.9e9", bits)
 Na <- mpfr("6.02214076e+23", bits)
 RK90 <- mpfr("25812.807", bits)
 
 # Useful numbers
 Pi = 4 * atan(mpfr("1", bits))
 
 # Derived constants
 KJ <- 2 * e  / h
 RK <- h / e / e
 V90 <- KJ90 / KJ
 assign("V90 - 1", V90 - 1)
 Omega90 <- RK / RK90
 assign("Omega90 - 1", Omega90 - 1)
 A90 <- KJ90 * RK90 / KJ / RK
 assign("A90 - 1", A90 - 1)
 C90 <- KJ90 * RK90 / KJ / RK
 assign("C90 - 1", C90 - 1)
 W90 <- KJ90 * KJ90 * RK90 / KJ / KJ / RK
 assign("W90 - 1", W90 - 1)
 F90 <- RK90 / RK
 assign("F90 - 1", F90 - 1)
 H90 <- RK / RK90
 assign("H90 - 1", H90 - 1)
 x <- mpfr("5", bits); repeat{xold <- x; x <- x - ((x - 5) * exp(x) + 5) / ((x - 4) * exp(x)); if (x >= xold) break;}; x5 <- x; rm(x, xold)
 x <- mpfr("4", bits); repeat{xold <- x; x <- x - ((x - 4) * exp(x) + 4) / ((x - 3) * exp(x)); if (x >= xold) break;}; x4 <- x; rm(x, xold)
 x <- mpfr("3", bits); repeat{xold <- x; x <- x - ((x - 3) * exp(x) + 3) / ((x - 2) * exp(x)); if (x >= xold) break;}; x3 <- x; rm(x, xold)
 x <- mpfr("2", bits); repeat{xold <- x; x <- x - ((x - 2) * exp(x) + 2) / ((x - 1) * exp(x)); if (x >= xold) break;}; x2 <- x; rm(x, xold)
 bwein <- h * c / k / x5
 assign("bwein'", k * x3 / h)
 c1 <- 2 * Pi * h * c^2
 c1L <- 2 * h * c^2
 c2 <- h * c / k
 eV <- e
 F <- Na * e
 G0 <- 2 * e^2 / h
 hbar <- h / 2 / Pi
 invG0 <- h / 2 / e^2
 NAh <- Na * h
 Phi0 <- h / 2 / e
 R <- Na * k
 sigma <- 2 * Pi^5 * k^4 / 15 / c^2 / h^3
 
 for (var in setdiff(ls(), c("bits", "var"))) { cat(sprintf("%11s = %s\n", var, format(get(var), digits=105, scientific=TRUE))) }
Does that help? —Quantling (talk | contribs) 14:05, 19 February 2021 (UTC)[reply]
This is not about the simplicity of performing these calculations, so I'm honestly flummoxed as why you keep trying to tell us how easy it is to perform these calculations. Primefac (talk) 14:13, 19 February 2021 (UTC)[reply]
I fail to see the appropriateness/motivations of a template that provides such values, as indicated in my previous post. At best this debate should be about inclusion of such values in a specific article. The motivation "Many people writing computer programs would appreciate the extra precision if it is easily available" seems to me to be out of scope of WP, and using WP as a check on precision details, no matter how cursory, is just not what WP is for. It is neither a textbook nor a workbook of worked problems. It seem clear that multiple people have concerns that updating the template in this way does not fit the purpose of WP. —Quondum 15:18, 19 February 2021 (UTC)[reply]
Try as I might, I cannot convince you fine souls of the utility and appropriateness of these values in this template, and thus there is cause for me to reconsider. Thank you for your time and feedback. —Quantling (talk | contribs) 20:29, 20 February 2021 (UTC)[reply]

Formatting dates?[edit]

I am working on bringing Nucleon magnetic moment to "Good Article" status. The reviewer notes that the date formats to some of the article citations are inconsistent... Some of these citations are from this template, which seems to insist on DD MM YYYY. Is there an option with this template for the date format? Bdushaw (talk) 11:46, 10 December 2022 (UTC)[reply]

Never mind...I've learned the joys of the {{use mdy dates}} template. Perhaps the description could indicate that template? Bdushaw (talk) 12:42, 10 December 2022 (UTC)[reply]

Planck and reduced Planck[edit]

Related discussion: Talk:Planck_constant#Seconds_vs._per_hertz. fgnievinski (talk) 04:36, 6 November 2023 (UTC)[reply]

A second-level shared reference idea[edit]

Primefac, since you seem to be active, I was wondering whether you might know of some way of implementing the double-stage referencing as in the CODATA value references at Hartree atomic units. That still has some shortcomings: (a) I have not found how to integrate the final full-detail CODATA 2018 reference cleanly into the references list rather than as a separate item, and (b) creating this reference from within the {{Physical constants}} template, including avoiding duplication, is totally beyond me.

If we can figure out how to do this, we would be able to put all detail we wish into the final CODATA 2018 reference while keeping the individual value references compact. —Quondum 14:22, 1 January 2024 (UTC)[reply]

See related discussion WP:TEA#Suppressing a footnote tag.[perma] A proposed solution outline is given there. Mathglot (talk) 22:08, 2 January 2024 (UTC)[reply]

Proposal[edit]

Opinions, please – I would like to get opinions on consolidating of the shared reference between all the references before I start sandboxing the changes to the template itself. I have a proposal with comparison here:

comparison of existing and proposed referencing
Existing

Body text1.[1] Body text2.[2] Body text3.[2] Body text4.[3] Body text5.[4]

  1. ^ "2018 CODATA Value: elementary charge". The NIST Reference on Constants, Units, and Uncertainty. NIST. 20 May 2019. Retrieved 2019-05-20.
  2. ^ a b "2018 CODATA Value: electron mass". The NIST Reference on Constants, Units, and Uncertainty. NIST. 20 May 2019. Retrieved 2019-05-20.
  3. ^ "2018 CODATA Value: proton mass". The NIST Reference on Constants, Units, and Uncertainty. NIST. 20 May 2019. Retrieved 2019-05-20.
  4. ^ "2018 CODATA Value: neutron mass". The NIST Reference on Constants, Units, and Uncertainty. NIST. 20 May 2019. Retrieved 2019-08-23.
Proposed

Body text1.[2] Body text2.[3] Body text3.[3] Body text4.[4] Body text4.[5]

  1. ^ a b c d e CODATA 2018, "The NIST Reference on Constants, Units, and Uncertainty", NIST Reference on Constants, Units, and Uncertainty, NIST, 20 May 2019
  2. ^ "elementary charge". CODATA 2018. Retrieved 2019-08-31.
  3. ^ a b "electron mass". CODATA 2018. Retrieved 2022-08-31.
  4. ^ "proton mass". CODATA 2018. Retrieved 2022-08-31.
  5. ^ "neutron mass". CODATA 2018. Retrieved 2022-08-31.

When there are few invocations in an article, the reference is simply split into two, but when there are many, around the space is used. We can also include more specific detail with the consolidated shared reference if we wish, without the extra multiplying in the article. Look at Hartree atomic units for an example that approximates the proposal. The only issue I see is that the list of back-links on the shared reference is nonfunctional. (Mathglot, thank you for the insightful input at WP:TEA.) —Quondum 16:23, 3 January 2024 (UTC)[reply]

Just to clarify the above: by your proposal as given above, you mean strictly what is rendered/viewable on the page; that is, the underlying wikicode is only a mockup and any successful implementation of your proposal will generate wikicode that will result in a page looking like what we see above, while most likely having wikicode done "the right way" and that looks quite different. I will respond to your specific proposal, but I'd like to put my response on hold for a moment, to place it in context by adding a sidebar below (forthcoming) reviewing how we deal with repetitive information in citations currently, which may affect either the proposal, or the implementation of it. Thanks, Mathglot (talk) 21:36, 3 January 2024 (UTC)[reply]
Correct. The wikicode on the page would be exactly as for the "Existing" case above: this template is already extensively used, and the only changes would be to the template itself. The proposal above is after template processing. However, I'm not sure that this is done "the right way", in the sense that it does some unusual things, especially hiding <ref>...</ref> code inside a string that the wikicode parser processes, but then gets dumped because it is inside an unused <span>...</span> parameter. I'm not very happy with it: it is still a hack, and would like to be able to do this more cleanly. My sandbox has two variants, where 'Variant 2' is less of a hack, but uses actual footnote tags rather than a bluelink, and is also not ideal in rendering. —Quondum 22:02, 3 January 2024 (UTC)[reply]

Sidebar on repetitive information in citations[edit]

There are some larger issues related to yours, and I think it would help to mention them, as it might clarify things by situating your issue in a larger context. Some questions arise when citing large sources or repositories:

  1. How do you best target information in a large source, such as a thousand-page book, or a large, online repository of like items?
  2. How do you avoid duplicating full citations in the References section that are exact duplicates of each other?
  3. How do you avoid duplicating full citations in the References section that are nearly duplicates of each other, except for a small, varying part?

It seems to me that this template attempts to (or should) deal with all three of these questions. A is already handled, via the url in the data table reference footnote. B and C are not, if I understand it correctly (but I'm still learning more about this template, each time I look at it).

Wikipedia has different ways of dealing with these issues currently. The cases for book/journal-based citations are somewhat different than for web-based citations due to their nature. Here are four use cases that will help distinguish them:

  1. multiple citations referring to the same page (or range) of a given book or journal article
  2. multiple citations referring to different pages (or ranges) of a given book or journal article
  3. multiple citations referring to the same web page (same URL) of a website database/repository on a single topic
  4. multiple citations referring to different web pages (different URLs) of a website database/repository on a single topic

The first three are well understood and have well documented, conventional solutions (i.e., named refs, or short footnotes with {{sfn}} templates). However, to my knowledge, there is no single, standard, recommended solution for #4, and as a result, different solutions are seen (e.g., use a linked 'loc' param in sfn; use a linked 'at' param in {{cite web}} or {{rp}}; include location within <ref> tags but outside and following the CS1 template; write a wrapper template that does one of these, like {{sfn legifrance}}. Template:Physical constants falls under the fourth use case, and therein lies the rub, I believe. Mathglot (talk) 01:08, 4 January 2024 (UTC)[reply]

A proposed solution[edit]

As labeled at the top of the previous subsection, question 'B' could be addressed by using standard named refs, if the data table and template were upgraded to handle the name attribute of the <ref> tag. If this were done, it would result in one full citation in the references section for each unique constant with a-b-c backlinks if the same exact constant were cited. An additional full, long citation would be generated for each additional constant, so if I understand what you want, this isn't desirable, because most of the same information identifying the NIST CODATA db would be repeated in the References section for every unique constant; close to what you have now; so that wouldn't be enough.

'C' could be handled as a combination of the solution for 'B', with the addition of a linked {{rp}} param following the <ref> emitted by the template currently, by e "small, varying part" as the title and url. (Another way, would be switching to emitting {{sfn}} templates instead of <ref> tags inline, and while that might've been easier if you were starting from scratch, but as there are already 87 transclusions, it's probably not worth it now.) This would make all your emitted refs except for the first one coded like this:

<ref name="CODATA-2018" />{{rp|at=[https://physics.nist.gov/cgi-bin/cuu/Value?bwien Wien wavelength displacement law constant]}}

and look like this,[1]: Wien wavelength displacement law constant which is very long for an inline {{rp}} link; maybe use an abbreviated title instead in the data table instead, like this?[1]: Wien λ This {{rp}} approach would require a modification to the data table and the template (most likely under control of a new param like |reuse=yes or |named=yes or similar to pull the value out of a slightly modified table which would supply the url query string (bpwien in this case) and the title on separate lines of the data item. (Actually, you could parse the title out of the existing ref, but just adding duplicate info is cheap, and keeps the template code simpler.) If it were me, I'd actually code it so that you could put any value for |reuse= as an override of the default title and it would substitute that value in instead of the data table title, which would give you some transclusion-time control of the display string for the link, which might be useful in some situations.

Note that this solution would not look like the "References" section in your boxed proposed solution above; rather, you'd have only one, single citation for CODATA-2018 in the References section (just like the References section below), with a whole pile of backlink letters attached; so that if you had 20 transclusoins of the template in the body, youid have superscript letters a through t on the one reference (just a and b in this example), but all the links would work, back and forth. The links to the individual CODATA pages would be found inline, look like the examples above, and link to the citations below. If you wanted a situation where the twenty citations appear in the reference section rather than inline in the body, that would be doable, with inline <ref>s linking to the NIST page for the constant, and containing an embedded {{sfnlink}} targeting the |ref= param of the single COVID-2018 citation. That would look pretty close to your proposal. That could be done like this.[2] Mathglot (talk) 02:12, 4 January 2024 (UTC)[reply]

That looks neat, but how would you insert the full citation in the into the reflist from the template? (My hack, or something else?) —Quondum 02:24, 4 January 2024 (UTC)[reply]
No hack, just paste the code from the 'Refs' section below into your Refs section (but change 'reflist-talk' to 'reflist'). I would recommend making that easier, too, maybe by passing a new value of |ref=, like, |ref=long or something; so you'd just code {{Physical constants|ref=long}} and it would just spit it out, hard-coded in the tmeplate. (You could add overridable values if you wanted, so that e.g., |access-date= would default to {{subst:TODAY}} but you could override it by setting it with a new param). Or maybe even simpler, same idea, but code |ref=long on only the first invocation of the template, so that one generates the long citation in the references section only for that one, and then all the other ones just pick it up because they use named refs; or they link to it via the other solution with {{sfnlink}} + citation |ref= param, if you like that style better. Mathglot (talk) 02:35, 4 January 2024 (UTC)[reply]
I only want to modify the template; we cannot require modification of the article that invokes the template. —Quondum 02:44, 4 January 2024 (UTC)[reply]
Okay, then the 'even simpler' one above. Mathglot (talk) 02:46, 4 January 2024 (UTC)[reply]
You say you generate the reference for the first one (for now ignoring that adding the parameter implies modifying the article), which the ref tag does, but without the variant part specific to the value. Unless we are happy with two footnote tags on the first invocation. —Quondum 02:52, 4 January 2024 (UTC)[reply]
If it were my decision, I wouldn't have two tags on the first one, I'd just have whatever variant part belongs to the first one, and then all the other ones just link to that. The situation is analogous to the common situation of a <ref name="Foo"> with a {{cite book|page=12}} embedded in it as the first one, and then later a <ref name="Foo" />{{rp|14–15}} later on which links to the first one. Everybody knows that the second one is pages 14–15, even if the first one says 12. This is perhaps just another aspect of the "we don't really have standards for #4" in the sidebar section above. Mathglot (talk) 08:34, 4 January 2024 (UTC)[reply]
That doesn't work for me: too clunky. I've come across an interesting possibility, which I'll add below. —Quondum 14:28, 4 January 2024 (UTC)[reply]

Refs (idea)[edit]

References

  1. ^ a b Tiesinga, Eite; Mohr, Peter J; Newell, David B.; Taylor, Barry N. (20 May 2019). "The NIST Reference on Constants, Units, and Uncertainty". NIST. Retrieved 2019-05-20.
  2. ^ CODATA-2018: Wien wavelength displacement law constant

Another proposed solution[edit]

Here is something based on an attribute that I found:

Proposal view

Body text1.[2] Body text2.[3] Body text3.[3] Body text4.[4] Body text4.[5]

  1. ^ Tiesinga, Eite; Mohr, Peter J; Newell, David B.; Taylor, Barry N. (20 May 2019). "The NIST Reference on Constants, Units, and Uncertainty". NIST. Retrieved 2019-05-20.
  2. ^ "elementary charge". CODATA 2018. Retrieved 2019-08-31.
  3. ^ a b "electron mass". CODATA 2018. Retrieved 2022-08-31.
  4. ^ "proton mass". CODATA 2018. Retrieved 2022-08-31.
  5. ^ "neutron mass". CODATA 2018. Retrieved 2022-08-31.

This is clean (the wikicode is not a hack, as my previous one was), and it does everything exactly as I wanted, including remotely injecting the long citation into the start of reflist without any backlinks (unnumbered and slightly separated, though). It does not prevent duplication, though, so the template needs to determine whether this is the first time that it is being invoked on the page. If I can find a way to avoid wikicode from being active the second time it appears in a page, I think the result will be good. —Quondum 15:06, 4 January 2024 (UTC)[reply]

Hmm. So maybe this is undefined behaviour: it is a using a side effect of an unintended use: see [1].
Very nice, I should've thought of that. That's using embedded refs, and the rendered page is close to what you originally wanted, so if that works for you, that's great. (By the way: if you want to cite a page at mediawiki (or meta, or commons, or wiktionary, and so on) you dont need to use a full url, just use the sister project shortcut, e.g., [[mw:Help:Cite]]mw:Help:Cite, and so on.) Mathglot (talk) 01:21, 5 January 2024 (UTC)[reply]
Except that I still need to solve the duplication problem: the template must only emit the long ref once. It is useless until I solve that ... —Quondum 01:30, 5 January 2024 (UTC)[reply]