(calculation with scalc)[calc_txt_en_som] {= () { This file contains calculations that can be performed automatically with the [scalc_cpp_en]. It serves as a test for scalc The mentor environment macros for the calculation are : &cc to calculate the current line &cb to calculate the line block selected by the F3 and F4 function keys &cp to calculate the [bloc_de_texte_en] current defined by braces. Example of a macro when using scalc independently of the mentor environment. The &cc macro calculates the expression of the current line map &cc !!_xcm/bin/scalc -i where _xcm is an abbreviation determining the path to the bin directory where the executable is located to be defined for example as follows :abbr _xcm /home/user/bin - the function keys F3 and F4 are used to define the line block containing the calculation :map ma :map mb"ay'a - the macro &cb calculates the expression in the buffer determined by F3F4 :map &cb 'a!'b_xcm/bin/scalc -i - the &cp macro calculates the expression in the current text block determined by the braces :map &cp [[jmak%kmb:'a,'b!_xcm/bin/scalc -i - you can define locally the vim S macro to execute a calculation on a line and go to the next line : :map S &ccj - the vim command " u" (" u" key in command mode vi) allows you to backtrack on the execution of a calculation command if you are not satisfied with the result or if the command crashes ! the program may crash or give an unexpected result if there is a syntax error on the operations. } (Simple example of calculation with scalc ) { simple example: 1 + 1 = 180 - 72 = 12 * 12 = 1 * 0 = impossible division 1 / 0 = an approximation of pi : 355 / 113 = powers: 2^10 = 33 ^ 2 = 2 ^ 0.5 = 2 ^(1/2)= factorial: 5!= 7!= 7!= 7!*2/10= 17!= 5!*4!= example with precision: 1 + 1.5 = 1.0 + 1 = 1.124 + 1.126 = 1.126 + 1.126 = example on several lines: (use F3 F4 to select and &cb ) 15 + 12 + 14 = 2 * 2 * 3 * 3 * 3 = 2^2 *3^3 = 2^2 *3^3 *4^4 *5^5 = 2^2 *3^3 *4^4 *5^5 *6^6 = 2^2 *3^3 *4^4 *5^5 *6^6 * 7^7 = 2^2 *3^3 *4^4 *5^5 *6^6 * 7^7 * 8^8 * 9^9 = 2^-2 *3^-3 *4^-4 *5^-5 *6^-6 * 7^-7 * 8^-8 * 9^-9 = } (Example with operator precedence) { precedence of operators: 3 + 1 / 2 = 3 + 1 / 2 + 4 = 3 + 3 * 2 = 9 - 2 * 2 = 1 + 2 ^ 4 = 9 * 2 / 3 = 2*3 / 6*4 = 2 ^ 3 / 2 = 2 ^ 3 * 2 = 10 - 4 * 4 = 4! * 3! = 1 + 2 * 4 = 1/2*4^2 = 2 * 3^2 = 2^2 * 3^3 = 2^4 * 3^2 * 7 = 12 / 2 / 2 / 3 = 12 + 10 / 5 * 1/2 + 1 = 12.0 + 11 / 5 * 1/2 + 1 = } (scalc constants) { ( scalc mathematical constants) { golden number phi= pi= base of neperian logarithms nep= } ( scalc physical constants) { speed of light c= elementary charge e= gravitational constant G= planck's constant h= dielectric permittivity of vacuum epsilon0= [constante_de_structure_fine] alpha= ^-1 = Avogadro number Navo= [constante_de_boltzmann] k= } } { example with intermediate results: 1 + 2 = + 3 = + 4 = + 5 = } ( nested operations) { example with intermediate operations (parenthesis) (3 + 1) / (2 + 4) = 3 * ( 2 / 3 ) = 5 ^ ( 1/2 ) = 5 * ( 1/2 ) = 2 ^ (1/2) = 2 * ( 2 + 1 / 2 ) = the following operations must have the same result: 1 / 12 = 1 / ( 4 * 3 ) = 1 / ( ( 2 + 2 ) * 3 ) = (2 * ( 2 + 1 / 2 )) = 5 / (2 * ( 2 + 1 / 2 )) = nesting of brackets: 6 * (3+2) / (2 * ( 2 + 1 )) = 6 * (3+2) / (2 * ( 2 + 1 / 2 )) = score six : 6 * (3+2) / (2 * ( 2 + 1 / 2 )) = combination formula: 10! / (4!* (10 - 4)!) = } (precision control with the setprec directive ) { calculation of alpha : e^2 / ( 2 * epsilon0 * h * c ) = you can force the precision of the result with the setprec directive: setprec=4 ; e^2 / ( 2 * epsilon0 * h * c ) =0.0073 ^-1 = alpha^-1= setprec=6 ; calculation of the golden ratio : (1 + 5^0.5) / 2 = phi = } { polynome: (1/2) * 6 + 6^2 + (3/2) * 6^3 + 2 * 6^4 = (1/2) * 6 + 6^(1/2)+ (3/2) * 6^(1/3)+ 2 * 6^(1/4)= the same with intermediate results (1/2) * 6 =3 + 6^(1/2)=5.44949 + (3/2) * 6^(1/3)=8.175171 + 2 * 6^(1/4)= } (processing of the cal precision ) { precision : 1.2 + 1 = 1 + 1.2 = 1 + 1/2 = 1/2 + 1 = 2^ 0.5 = 2^(1/2)= 2 + 2 ^ 0.5 = 2.000000000 + 2 ^ 0.5 = 2^0.5 + 2 = 2+2^(1/2)= precision: the division overrides the decimals of the operands if it is larger. ( 1.1 / 2.0 ) = 2 ^ (1/2) = 1.00000000001 + 2 ^ 0.5 = 1.00000000001 / 2 = } ( ten cal power operations) { powers of 10: Sign less with power 10^-3= 10^(-3)= the display limit with powers of ten is 10 10^(-6)= 10^(-10)= 10^(-11)= 10^(-12)= 10^(-14)= 10^(-15)= 10^-15= maximum number before displaying with powers of 10 : 10^15= 10^16= calculation with powers of 10: 3 *10^16 * 4 *10^16 * = 5 *10^89 * 3 *10^44 * = 5 *10^89 * pi *10^44 * = } () { Un avantage de l'utilisation de scalc est que les calculs peut-être commenté. Exemples de bloc de calcul commenté : ( utiliser la macro &cp avec le curseur dans le bloc entre accolades) () { Quelle est la masse atomique moyenne pondérée du gallium ? Le gallium existe à l'état naturel sous la forme de deux isotopes. le gallium69 dont la masse atomique est de 68.926 u * et l'abondance relative de 0.601 % + (le gallium71 dont la masse atomique est de 70.925 u * et l'abondance relative de 0.399 % ) ce qui donne une masse moyenne de = } ( Mass of the proton according to the formula of Nassim Haramein ) cf [masse_du_proton_en] { 4 times * the Planck mass 2.176434*10^-8 Kg multiplied by the Planck length * 1.616255*10^-35 m divided by the charge radius of the proton / 0.8775*10^-15 m is equal to the mass of the proton= } (: :20230201) { setprec=6; ( h * G / (2 * pi * c^3))^ 0.5 = m } (calculation of the planck mass) { (c*h/(2*pi*G))^(1/2)= kg setprec=6; (c*h/(2*pi*G))^(1/2)= kg } ( Calculation of the mass of the proton with the expression of the Planck units according to the fundamental constants.) { 4 times * the Planck mass (c*h/(2*pi*G))^(1/2) multiplied by the Planck length * ( h * G / (2 * pi * c^3))^ 0.5 divided by the charge radius of the proton / 0.8775*10^-15 m is equal to the mass of the proton = } ( calculation of the mass of the proton with the definition of constants) { setprec=6; [masse_de_planck_en] set mp = (c*h/(2*pi*G))^(1/2); mp= [longueur_de_planck_en] set lp = ( h * G / (2 * pi * c^3) ) ^ (1/2) lp= charge radius of the proton set rP=0.8775*10^-15 rP= mass of the proton set mP= 4 * mp * lp / rP mP= setprec=3; mass of the proton set mP= (2 * h) / (c * pi * rP) mP= } ( the reason for answer 42 according to the formula of Nassim Haramein ) { setprec=3; the measured mass of the proton 1.67262192 * 10^-27 kg * multiplied by the charge radius of the proton 0.84184 * 10^-15 m gives : = and 4 times * h / 2 * pi the reduced Planck constant /c divided by the speed of light gives : = } } ( commenting on a calculation) { the hash sign comments the end of the line # 1+1= 1+1= # 2+2= } (basic mathematical function) { sin(pi/6)= cos(pi/6)= sin(pi/6)^2= cos(pi/6)^2= sin(pi/6)^2 + cos(pi/6)^2= tan(pi/4) = arctan(1)= * 4 = tan(pi/6) = sin(pi/4)= * 2 = ^2 = arcsin(2^0.5/2)= * 4 = cos(pi/3)= arccos(0.5)=1.047198 * 3 = cos (pi)= cos (-pi)= sin (3 * pi / 2)= exp(0)=1 log(1)=0 log(nep)=1 log(pi)= exp(5*log(10))= exp(15*log(10))= log(h) = log(e) = log(epsilon0)= log(G) = log(Navo) = int(12.3)= int(12.6)= round(12.3)= round(12.6)= sinh(1)=1.175201 cosh(1)=1.543081 tanh(1)=1 set fct(x)=cosh(x)^2-sinh(x)^2 } ( definition of cal function) { ( redefinition of the tangent: standard mathematical function call in defined functions ) { set tangente(x)=sin(x)/cos(x) tangente(pi/3)= with the direct call of the tan() function tan(pi/3)= } { set fct(x,y)=x^2+y^2; fct(4,3)= fct(5,5)= fct(51,51)= set fct3(x,y,z)=x^2+y^2+z^2; fct3(4,3,2)= fct3(5,5,5)= fct3(12,18,24)= set fct33(x,y,z)=x^3+y^3+z^3; fct33(4,3,2)= fct33(5,5,5)= fct33(12,18,24)= set x²(x)=exp(2*log(x)) x²(2)= x²(3)= x²(5)= } ( combination formula) { set C(n,p)= n! / (p!* (n - p)!); C(10,4)= C(10,2)= C(15,4)= C(15,3)= C(45,2)= } (: Calculation of the mass of the proton with definition of a function ) { setprec=6; [masse_de_planck] set mp = (c*h/(2*pi*G))^(1/2); [longueur_de_planck] set lp = ( h * G / (2 * pi * c^3) ) ^ (1/2) old measurement of the proton charge radius set rP2=0.8775*10^-15 new measurement of the proton charge radius set rP=0.84087*10^-15 mass of the proton formula set mP(r)= 4 * mp * lp / r mP(rP2)= mP(rP)= } ( calculation of the schwarzschild condition) { setprec=4; schwarzchild's formula of the black hole mass: set mTN(r) =r * c^2 / ( 2 * G); set rCygnusX_1=2.5*10^4; mTN(rCygnusX_1)= kg - radius of the black hole corresponding to the mass of the earth : 8.8 mm mTN(8.8716*10^-3)= kg new measurement of the proton charge radius set rP=0.84184 * 10^-15 m mTN(rP)= kg ( 10 % power directive ) setp10=4; mTN(rP)= kg } } ( Mass of the proton considered as a black hole according to the theory of Nassim Haramein ) { (number R, eta and phi for the proton : function nesting test ) { [longueur_de_planck] set lp = ( h * G / (2 * pi * c^3) ) ^ (1/2) [masse_de_planck] set mp = (c*h/(2*pi*G))^(1/2); number R : set R(r) = 8 * r^3 / lp^3; number eta : set eta(r) = 16 *r^2/ lp^2; number phi : set phi(r) =R(r)/eta(r); set phi2(r) = ( 8 * r^3 / lp^3 ) / ( 16 *r^2/ lp^2); set phi3(r) = r / 2 * lp; new measurement of the proton charge radius: set rP=0.8775*10^-15 m setprec=6 R(rP)= eta(rP)= phi(rP)= phi2(rP)= phi3(rP)= formula of the holographic mass : set mh(r) = R(r) * mp /eta(r); mh(rP)= formula of the mass of the proton : set mP(r) = 2 * eta(r) * mp / R(r); mP(rP)= } ( calculation using the predefinition file) cf [fichier_de_precalcul_scalc_en] { to perform these calculations it is necessary to have set the environment variable SCALC_PATH cf [fichier_de_precalcul_scalc_en] with the content of the text block [exemple_de_contenu_d_un_fichier_de_precalcul_en]. setp10=6 setprec=6 R(rP)= eta(rP)= phi(rP)= mh(rP)= mP(rP)= } ( Example of the content of a pre-calculation include) { condition de schwarzschild : set mTN(r) =r * c^2 / ( 2 * G); } ( holographic mass and schwarzschild relation with an include) { # To access the includes functionality, with the setinc directive # it is necessary to have installed the utags module which manages the mentor hypertext. cf http://textoffice.org setinc [exemple_de_contenu_d_un_include_de_precalcul_en] setp10=6 setprec=6 the definition of this function is in the precalculation file (holographic mass) cf [calcul_utilisant_le_fichier_de_predefinitions_en] the print directive allows to display the expression of a function or a constant if it is not displayed it is not defined. print mh: mh(r) = R(r) * mp / eta(r) mh(rP)=5.66193*10^11 the definition of this function is in the include (relation de Schwarzschild) print mTN: mTN(r) =r * c^2 / ( 2 * G) mTN(rP)=5.66193*10^11 The use of include allows to better organize the calculations by domain. As well as having several buffers for storing function definitions or constants. } } ( Example of a precalculation file content, to be copied in a text file defined by the SCALC_PATH environment variable ) { # definition for the physics article by Nassim Haramein : https://www.researchgate.net/publication/302941651_Quantum_Gravity_and_the_Holographic_Mass [longueur_de_planck] : set lp = ( h * G / (2 * pi * c^3) ) ^ (1/2) [masse_de_planck] : set mp = (c*h/(2*pi*G))^(1/2); number R : set R(r) = 8 * r^3 / lp^3; number eta : set eta(r) = 16 *r^2/ lp^2; number phi : set phi(r) =R(r)/eta(r); new measurement of the proton charge radius: set rP=0.8775*10^-15 m formula of the holographic mass : set mh(r) = R(r) * mp / eta(r); formula of the mass of the proton : set mP(r) = 2 * eta(r) * mp / R(r); } ( scalc vademecum: elements of scalc calculation control ) { ( directive number of decimal places: indicates the number of decimal places displayed in the result of the operation ) setprec=5; ( 10 % power directive: indicates from which power of 10 the result of the operation is displayed as a power of 10) setp10=4; ( scalc comment) # the hash character comments a calculation line: 1+1= - a pre-computation file can be defined by the SCALC_PATH environment variable ( scalc pre-calculation file: library of definitions of constants and mathematical functions) - the SCALC_PATH environment variable specifies the path of a file that serves as a library of mathematical constants and functions definitions. - sample file: ( $BASE is an environment variable of the utags module specifying the installation directory of the module files) $BASE/ht/precalc.txt put the content of the text block [exemple_de_contenu_d_un_fichier_de_precalcul_en] within. - example of a vim definition macro command: let $SCALC_PATH='$BASE/ht/precalc.txt' let $SCALC_PATH='' - example of a definition shell command: export SCALC_PATH='$BASE/ht/precalc.txt' - example of an include directive for calculation pre-definitions. setinc [exemple_de_contenu_d_un_include_de_precalcul_en] } }