Illustrative examples of using calc [Type calc -v for the list of constants] [Type calc -h for help message] > > ># Jansky >calc Jy '1e-23*pow(gr,1)*pow(sec,-2)' >calc 'Jy*Hz*sqr(m)/watt' '1e-26' > > ># Solar Mass, Luminosity >calc Msun '1.989e+33*pow(gr,1)' ># Solar mass rest energy >calc 'Msun*pow(c,2)' '1.78762405050753e+54*pow(gr,1)*pow(cm,2)*pow(sec,-2)' ># Years left to shine (naive estimate) >calc 'Msun*pow(c,2)/Lsun/yr' '14805384383041.4' ># Using a different output format >calc %E 'Msun*pow(c,2)/Lsun/yr' 1.480538E+13 ># Hubble times left to shine ># value is rounded off to the nearest integer >calc %.f 'Msun*pow(c,2)/Lsun * H0' '1113' > ># Density of CDM in solar system neighborhood ># is known to be 0.3 GeV c^-2; how much is it in ># grams per centimeter cubed? >calc %.2E '0.3*GeV/sqr(c)/cub(cm)' 5.35E-25*pow(gr,1)*pow(cm,-3) > > ># Number of seconds in an hour >calc hr/sec '3600' ># Number of seconds in a year >calc yr/sec '31558150' > ># Time to travel Earth's circumference at the speed of light. >calc 2*pi*Rearth/c '0.133672995500078*pow(sec,1)' ># Time to travel between Sun and Earth, at the speed of light, in minutes. >calc AU/c/min '8.31686477360726' > ># Comparison of the Solar and Earth masses >calc Msun/Mearth '332942.751925008' > ># Critical density of the Universe >calc '3*pow(H0,2)/(8.*pi*G)' '1.01474229156068e-29*pow(gr,1)*pow(cm,-3)' ># Mean CDM density of the Universe >calc '3*pow(H0,2)*Om/(8.*pi*G)' '2.4049392309988e-30*pow(gr,1)*pow(cm,-3)' > ># Larmor radius of non-relativistic electron in 3 microgauss field ># expressed in astronomical units >calc 'me*c*c/(e*3*micro*gauss)/AU' '3.79792541286011e-05' > ># Electric units >calc volt '0.00333564095198152*pow(gr,0.5)*pow(cm,0.5)*pow(sec,-1)' >calc volt/ampere '1.11265005605362e-12*pow(cm,-1)*pow(sec,1)' >calc ohm '1.11265005605362e-12*pow(cm,-1)*pow(sec,1)' >calc farad '898755178736.818*pow(cm,1)' >calc henri '1.11265005605362e-12*pow(cm,-1)*pow(sec,2)' > > > > ># Error bahavior may seem slightly confusing, but here it is: >calc Foo AAAAAsgx2wr.c: In function 'main': AAAAAsgx2wr.c:162: error: 'Foo' undeclared (first use in this function) AAAAAsgx2wr.c:162: error: (Each undeclared identifier is reported only once AAAAAsgx2wr.c:162: error: for each function it appears in.) > ># Error behavior II: meaningless quantities, such as log(centimeter) these will have ># fractional physical dimension; there will be no error message but the user should notice. >calc 'exp(sec)' '2.71828182845905*pow(sec,1.71828)' >calc 'log(meter)' '4.60517018598809*pow(cm,0.19651)' > > ># All constants (the output may be different in your own calc version) >calc -v = = = = = The predefined macros and variables are = = = = = = = = = = = = = = /* Sources: P.D.G.: particle data group http://pdg.lbl.gov */ ; /* U.C.: online unit converter http://www.digitaldutch.com/unitconverter */ ; /* */ ; /* */ ; double giga = 1.E9 /* A prefix */ ; double mega = 1.E6 /* A prefix */ ; double kilo = 1.E3 /* A prefix */ ; double deci = 1.E-1 /* A prefix */ ; double centi = 1.E-2 /* A prefix */ ; double milli = 1.E-3 /* A prefix */ ; double micro = 1.E-6 /* A prefix */ ; double nano = 1.E-9 /* A prefix */ ; double pico = 1.E-12 /* A prefix */ ; double femto = 1.E-15 /* A prefix */ ; double atto = 1.E-18 /* A prefix */ ; double m = 100.*cm /* Meter */ ; double meter = m /* Meter */ ; double km = 1.0e3*m /* Kilometer */ ; double kg = 1.0e3*gr /* Kilogram */ ; double hectare = 100.*m * 100.*m /* One Hectare */ ; double newton = kg*m/(s*s) /* Force unit */ ; double dyn = 1.E-5*newton /* Force unit */ ; double cgsu_charge = sqrt(g*cub(cm)/sqr(s)); /* CGS electric charge unit */; double e = 4.80320441e-10*cgsu_charge /* Electorn charge, P.D.G. */ ; double hbar = 1.05457168E-27*g*sqr(cm)/s /* Planck constant, P.D.G */ ; double c = 2.99792458e10*cm/s /* Speed of light, P.D.G. */ ; double me = 9.1093826e-28*g /* Electorn mass, P.D.G. */ ; double mp = 1.67262171e-24*g /* Proton, P.D.G. */ ; double G = 6.6742e-8*cub(cm)/sqr(s)/g /* Graviatational constant, P.D.G */ ; double pi = 3.1415926535897932 /* Archimedes constant. */ ; double E = 0.5772156649 /* Euler const. Ab.St. p.255 */ ; double twopi = 2.*pi /* Archimedes constant. */ ; double bit = 1 /* Information unit */ ; double kilobit = 1000*bit /* Information unit */ ; double megabit = 1000*kilobit /* Information unit */ ; double byte = 8*bit /* Information unit */ ; double kilobyte = 1024*byte /* Information unit */ ; double megabyte = 1024*kilobyte /* Information unit */ ; double mile = 1609.344*m /* Mile (UK and US) */ ; double yard = 91.44*cm /* Yard (U.C.) */ ; double inch = 2.54*cm /* Inch P.D.G */ ; double foot = 30.48 * cm /* One Foot (UK/US) (U.C)*/ ; double cable = 182.88 * m /* Cable unit of length (U.C)*/ ; double erg = g*cm*cm/(s*s) /* erg CGS energy unit */ ; double joule = kg*m*m/(s*s) /* Joule energy unit, P.D,G. */ ; double watt = joule/sec /* Watt */ ; double horsepower = 745.699872*watt /* International horse power unit (U.C.) */ ; double ev = 1.60217653E-19*joule /* One electorn volt, P.D.G. */ ; double cal = 4.1868 * joule /* International Steam Table calorie (1956) (Wiki) */ ; double coulomb = c*sqrt(1.E-7*kg*m) /* One Coulomb, SI charge unit */ ; double ampere = coulomb/sec /* One Ampere, SI current unit */ ; double volt = joule/coulomb /* One volt, potential difference unit */; double ohm = volt/ampere /* One ohm, the SI unit of electrical resistance */; double henri = volt*s/ampere /* One Henri, SI unit of inductance */; double farad = coulomb/volt /* One Farad, SI unit of capacitance */; double weber = ampere*henri /* One Weber, the SI unit of magnetic flux */; double mu0 = 4.*pi*1E-7 * henri/m /* Permeability, vacuum: rot E = -mu0 d H / d t, in SI */; double eps0 = 1./(c*c*mu0) /* Permittivity, vacuum: rot H = eps0 d E / d t, in SI */; double tesla = volt*s/(m*m) /* One Tesla, SI magnetic field unit */ ; double gauss = 1.E-4*tesla*c /* One Gauss, CGS magnetic field unit (factor of c is correct, see README file) */ ; double hour = 3600.*s /* One hour */ ; double hr = hour; double minute = 60.*s /* One minute */ ; double min = minute; double Hz = 1./s /* One Hertz */ ; double A = 1.E-8*cm /* One Angstrem */ ; double kev = kilo*ev /* Kiloelectron-volt */ ; double Kev = kev; double mev = mega*ev /* Megaelectron-volt */ ; double Mev = mev; double gev = giga*ev /* Gigaelectron-volt */ ; double Gev = gev; double barn = 1.E-28*m*m /* Barn */ ; double day = 3600*24*sec /* Day */ ; double tru = 1/(kg*day) /* Rate in neutrino detection*/ ; double rad = 1. /* One radian */ ; double deg = pi/180. /* One degree */ ; double arcmin = deg/60. /* One arcminute */ ; double arcsec = deg/3600. /* One arcsecond */ ; double hpl = (2*pi)*hbar*g*sqr(cm)/s /* Planck constant */ ; double kb = 1.380658e-16*g*sqr(cm)/sqr(s) /* Boltzman constant. */ ; double mpl = sqrt(hbar*c/G) /* Planck mass. */; double lpl = sqrt(hbar*G/pow(c,3.)) /* Planck length. */; double tpl = sqrt(hbar*G/pow(c,5.)) /* Planck time. */; double mdeuteron = 1875.61282 *Mev/c/c /* Deuteron mass, P.D.G. */ ; double md = mdeuteron; ; double mau = 1.6605402e-24*g /* Atomic unit */ ; double mgev = Gev/(c*c) /* GEV mass */ ; double mhyd = 1.673534e-24 *g /* Hydrogen atom */ ; double mpev = mp*c*c/ev /* Proton in ev */ ; double mn = 1.6749286e-24*g /* Neutron */ ; double mnev = mn*c*c/ev /* Neutron in ev */ ; double mmu = 1.8835E-25*g /* Muon */ ; double mtau = 3.1802E-24*g /* Tau lepton */ ; double mpi = 138*(Mev/sqr(c)) /* pi meson */ ; double meta = 549*(Mev/sqr(c)) /* eta meson */ ; double mK = 496*(Mev/sqr(c)) /* K meson */ ; double mrho = 776*(Mev/sqr(c)) /* rho meson */ ; double momega = 783*(Mev/sqr(c)) /* omega meson */ ; double mKstar = 892*(Mev/sqr(c)) /* K star meson */ ; double mphi = 1020*(Mev/sqr(c)) /* phi meson */ ; double Na = 1/mau /* Avogadro gas constant */ ; double Jy = 1.0E-26*watt/sqr(m)/Hz /* Jansky */ ; double fm = 1.E-15*m /* Fermi length unit */ ; double fermi = fm; double au = 1.4960e13*cm /* Astronomical unit */ ; double AU = au; double pc = 3.0856776e18*cm /* parsec */ ; double kpc = 1.E3*pc /* kiloparsec */ ; double mpc = 1.E6*pc /* megaparsec */ ; double yr = 3.155815e7*s /* year, from Peacock */ ; double gyr = 1.E9*yr /* gigayear */ ; double Msun = 1.989e33*g /* Solar mass */ ; double Lsun = 3.826e33*erg/s /* Solar luminocity */ ; double Rsun = 6.9599e10*cm /* Solar radius */ ; double D_gc = 7.62*kpc /* Dist to Gal. center (Eisenhauer et al 2005)*/; double Tsun = 5770.0 /* Solar surface temperature */ ; double Mearth = 5.974e27*g /* Earth mass */ ; double Rearth = 6.378e8*cm /* Earth radius */ ; double gearth = 9.80665*m/s/s /* Standard gravitational acceleration, Earth */; double Ogal = 8.4e-16 /* pm 0.1, see BT, p17*//* Galaxy rotation in solar nb */ ; double Tgal = 2.*pi/Ogal /* Galaxy period in solar nb */ ; double rho_oort = 0.18*Msun/(pc*pc*pc) /* Local mass density (+-0.03) (Oort) B.T. p. 201*/; double Tcmb = 2.725 /* CMB Temperature */ ; double h0 = 0.735 /* Hubble constant, WMAP3 */ ; double H = 100.*(km/s)/mpc /* Hubble conversion */ ; double H0 = H*h0 /* Hubble constant */ ; double Om = 0.237 /* Omega CDM, WMAP3 */ ; double Or = Om/3234. /* Omega radiation */ ; double Ol = 0.763 /* Omega Vacuum, WMAP3 */ ; double Ov = Ol /* Omega Vacuum, alias */ ; double Ob = 0.0413 /* Omega Barionic, WMAP3 */ ; double rhom = 3.*sqr(H0)*Om/(8.*pi*G) /* Matter density */ ; double ar = (pow(pi,2)*pow(kb,4)*pow(hbar*c,-3)/15.) /* Radiation constant. */; double sb = ar*c/4. /* Stephan-Boltzmann Constant */; double alpha = sqr(e)/(hbar*c) /* Fine structure constant */; double lambdae = hbar/(me*c) /* Electron compton waveleng */; double mub = e*hbar/(2.*me*c) /* Bohr magneton */; double muN = e*hbar/(2.*mp*c) /* Nuclear magneton */; double R = (me*qua(e))/(2.*sqr(hbar)) /* Ridberg energy 13.68 ev */; double Rinf = (me*qua(e))/(4.*pi*cub(hbar)*c) /* Ridberg constant cm^-1 */; double Rgas = kb*Na /* Thermodynamic gas const */; double sigmat = 8.*pi/3.*sqr(sqr(e)/(me*sqr(c))) /* Thompson Cross section */; = = = = = end of the predefined macros and variables = = = = = = = = = = = = >