0
$\begingroup$

How do I create a table of fractions of numbers that are in scientific notation that suppresses the evaluation? I've tried using Hold and HoldForm but it always results in error.

particleclass = {10^-6, 10^-5, 10^-4, 10^-3, 10^-2, 10^-1};

alphaTESTwith = {5.261524149346547`*^-11, 5.261524149346548`*^-9, 
   5.261524149346547`*^-7, 0.000052615241493465474`, 
   0.005261524149346548`, 0.5261524149346547`};

alphaTESTwithout = {1.4251746149271436`*^-11, 
   1.4251746149271434`*^-10, 1.4251746149271435`*^-9, 
   1.4251746149271436`*^-8, 1.4251746149271436`*^-7, 
   1.4251746149271436`*^-6};

kappa = {1.32751827`*^8, 1.32751827`*^10, 1.32751827`*^12, 
   1.32751827`*^14, 1.3275182700000002`*^16, 1.32751827`*^18};

l = 1;

alphaKWith = Table[(alphaTESTwith*l)/kappa[[Mass]], {Mass, 1, 6}];
alphaKWithout = 
  Table[(alphaTESTwithout*l)/kappa[[Mass]], {Mass, 1, 6}];

gridWith = Grid[
  Insert[Transpose[
    Insert[Transpose[alphaKWith], N@particleclass, 1]]
   , Prepend[N@particleclass, "Table"], 1],
  Frame -> All]

gridWithout = Grid[
  Insert[Transpose[
    Insert[Transpose[alphaKWithout], N@particleclass, 1]]
   , Prepend[N@particleclass, "Table"], 1],
  Frame -> All]

Gives out Table Results

$\endgroup$
2
  • $\begingroup$ Since l does not appear in the tables, you must have set its value; however, you did not include this value in your code. It is unclear which fractions you want held. This does not appear to be a minimal example. Please show what the intended output should look like for a minimal example. $\endgroup$
    – Bob Hanlon
    Feb 7, 2022 at 15:41
  • $\begingroup$ Crossposted here. $\endgroup$ Feb 8, 2022 at 21:45

1 Answer 1

1
$\begingroup$

As you did not specify "l" I set it arbitrarily to 1. Then you can use "ReplaceAll" together with NumberFormat" to write everything in scientific notation. E.g.:

l = 1; 
Grid[Insert[
    Transpose[Insert[Transpose[alphaKWith], N@particleclass, 1]], 
    Prepend[N@particleclass, "Table"], 1] /. 
   x_?NumberQ -> ScientificForm[x], Frame -> All]

enter image description here

$\endgroup$
4
  • $\begingroup$ Thank you, this was helpful in fixing the decimal numbered labels above and at the side into scientific form. But I also have another question, how do I convert the scientific numbers on the inside to fractions? $\endgroup$
    – L_R_G_2021
    Feb 8, 2022 at 6:29
  • $\begingroup$ Why do you want to write a real number as fraction? In general, a real number can not be converted into a fraction without error. And to get some precision you need large denominators. Therefore, what exactly do you want. Something ungainly like 396343/1000000000000000000000000? $\endgroup$ Feb 8, 2022 at 9:37
  • $\begingroup$ I mean that I wanted to write the expression of the variables alphaTESTwith / kappa and alphaTESTwithout / kappa as fractions but does not evaluate the fraction. I wanted it to be expressed in the form of a scientific number divided by a scientific number. $\endgroup$
    – L_R_G_2021
    Feb 8, 2022 at 10:07
  • $\begingroup$ Try: MapThread[ScientificForm[#1]/ScientificForm[#2] &, {alphaTESTwith, kappa}] $\endgroup$ Feb 8, 2022 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.