----BEGIN CLASS----
[13:59] #startclass
[13:59] Roll call
[13:59] Priyanka Saggu
[13:59] Mayank Singhal
[13:59] Akshay Gaikwad
[14:00] Bhavin Gandhi
[14:00] Anu Kumari Gupta
[14:00] I did not have power, and it just came back. Hopefully, it lasts. If I disconnect, do not panic. I will try to login through my mobile connection.
[14:00] Pranjal Aswani
[14:01] Prashant Sharma
[14:01] Today is a good day to have a session.
[14:01] 0pooja sulakhe
[14:01] pooja sulakhe
[14:02] Today, we will go through Calc.
[14:02] Souvik Haldar
[14:02] Calc is an advanced calculator and mathematical tool that is part of GNUU Emacs.
[14:02] First, open Emacs using "emacs -Q"
[14:02] s/GNUU/GNU/
[14:03] You can do a quick calculation in the minibuffer using:
[14:03] => C-x * q
[14:03] At the minibuffer, it will prompt with "Quick calc:", and you can input "2 + 3"
[14:04] And the result is shown in the minibuffer as "Result: 2 + 3 => 5 (16#5, 8#5, 2#101, "^E")
[14:04] But, if you want to open Calc inside GNU Emacs, you can use:
[14:04] => C-x * c
[14:04] It will open two windows, Calc and *Calc Trail*
[14:05] The Calc window has "--- Emacs Calculator Mode ---" in it.
[14:05] You can stop Calc using:
[14:05] => q
[14:05] Sandeep Kumar Choudhary
[14:06] What you see in the "Calc" window is a representation of a stack.
[14:06] You can enter your calculation either in RPN (Reverse Polish Notation) or in algebraic form
[14:06] For example:
[14:07] => '2+3
[14:07] When you input ' (single quote), at the minibuffer, you will be prompted with "Algebraic:", where you can input '2 + 3' and hit enter
[14:08] The result 5 is displayed in the Calc window
[14:08] If you want to do this using the RPN syntax, you will have to do:
[14:08] => 2 RET 3 +
[14:09] When you input '2 RET' (RET is ), it is pushed to the Calc window.
[14:09] Then you input 3, and when you immediately give the '+' operator, it takes '3' and the top of the stack '2' and computes the sum
[14:10] Anytime, if you make a mistake and you want to abort the operation, use:
[14:10] => C-g
[14:10] You can undo the last operation using:
[14:10] => U
[14:10] You can also redo the last operation using:
[14:10] => D
[14:11] Let us try another example:
[14:11] => '2*(3+4) RET
[14:11] The above is the algebraic form.
[14:11] The same in RPN style will be:
[14:12] => 2 RET 3 RET 4 + *
[14:12] You should see the result 14 in the Calc window
[14:12] As you input commands and results are computed, these are also visible in the *Calc Trail* window
[14:13] If you want to reset Calc to initial state, you can use:
[14:13] => C-x * 0
[14:13] Or, you can also keep pressing "C-d" to remove the entries in the Calc window
[14:14] If you want to recall the last arguments, you can use:
[14:14] => M-RET
[14:14] The other arithmetic operators which you are familiar with are -, *, /
[14:14] If you want to raise to a power, you can use:
[14:14] => ^
[14:14] For example:
[14:15] => 2 RET 4 ^
[14:15] The result is 2 raised to the power 4 which is 16.
[14:15] You can find nth root using:
[14:15] => I ^
[14:16] For example:
[14:16] => 16 RET 2 RET I ^
[14:16] The result will be 4.
[14:16] You can change the sign of a number using:
[14:16] => n
[14:17] The sign of the top-most element of the stack will be updated.
[14:17] You can find the reciprocal 1/x using:
[14:17] => &
[14:18] If you have 5 in the stack, and used '&', it will result in 0.2
[14:18] You can find the square root of a number using:
[14:18] => Q
[14:18] Using RPN style, for example: "4 Q" will give you 2.
[14:19] You can refer to the previous result in the next computation using '$'. So, if you have 2 in the top of the stack
[14:19] And you executed the arithmetic expression:
[14:19] => '3*$^2
[14:20] It will yield the result 12 (=3 * 2^2).
[14:20] If you want, you can change the precision using:
[14:20] => p
[14:20] If you have a long arithmetic expression, you can scroll horizontally using:
[14:20] => <
[14:20] OR
[14:20] => >
[14:21] You can scroll the Calc buffer vertically using:
[14:21] => {
[14:21] or
[14:21] => }
[14:21] By default, you see the line numbers. You can toggle them on/off using:
[14:21] => d l
[14:22] If you do not want to see the trail display, you can also turn it on/off using:
[14:22] => t d
[14:22] If you are using large numbers, and you want to group the digits with comma for readability, you can use:
[14:22] => d g
[14:22] When you issue the command, you will see "Grouping is on" in the minibuffer
[14:23] So, if you input, say "100000", it will be displayed as "100,000".
[14:23] Let us know look at some basic notations that are used in Calc
[14:24] The scientific notation can be written as 6.02e23
[14:24] Fractions can be written as 3:4
[14:24] So, if you will get the result if you add 1:4 and 3:4
[14:25] => 1:4 RET 3:4 +
[14:25] Complex numbers are written as (x, y)
[14:25] Polar representation of complex numbers are written as (r; 0)
[14:26] Vectors are written as [1, 2, 3] (The comma is optional)
[14:26] You can do matrix computation as well! Matrices or nested vectors are represented as [1, 2; 3, 4]
[14:27] The Hour-Minute-Second (HMS) notation is 5@ 30' 0"
[14:27] The modulo form is 6 mod 24
[14:27] Let us know look at few scientific functions
[14:27] s/know/now/
[14:28] The Natural log function is given by:
[14:28] => ln
[14:28] The natural log of 1 is 0. The same in RPN style is as follows:
[14:28] => 1 ln
[14:28] And the result 0 is in the top of the stack.
[14:29] You can find logarithm to the base 10 using:
[14:29] => H L
[14:29] The logarithm of 2 to the base 10 is 0.3010, as can be seen using:
[14:29] => 2 H L
[14:29] When you press 'H', the minibuffer will say "Hyperbolic..."
[14:30] You can of course find logarithm to any base 'b' using:
[14:30] => B
[14:31] Let us try the same logarithm of 2 to base 10 using any base style:
[14:31] => 2 RET 10 B
[14:31] This should again give you the result 0.3010
[14:31] You can find exponential e^x as well using:
[14:31] => E
[14:32] You know that e^1 = 2.7182
[14:32] The RPN syntax for the above is:
[14:32] => 1 E
[14:32] You can also compute 10^x using:
[14:32] => H E
[14:33] So, for 10^2 = 100, in RPN style:
[14:33] => 2 H E
[14:34] But, there is more. You can do trigonometry as well!
[14:34] You know that sin 90 is 1. You can compute sin using:
[14:34] => S
[14:34] => 90 S
[14:34] The above is for computing sin 90 which will result in 1.
[14:35] You can compute cosine using:
[14:35] => C
[14:35] You know that cos 0 is also 1. So, the RPN style is:
[14:35] => 0 C
[14:35] For tan, you can use:
[14:35] => T
[14:35] You know that tangent 45 is 1.
[14:35] => 45 T
[14:36] Similarly, there are other trigonometric functions. For arcsin:
[14:36] => I S
[14:36] For arccos, use:
[14:36] => I C
[14:36] For arctan, use:
[14:36] => I T
[14:36] If you want the value of Pi, just use:
[14:37] => P
[14:37] You will the value 3.14159265359 in the stack
[14:37] If you want the angles to be measured in degrees, you can set this using:
[14:37] => m d
[14:38] If you want to switch to using radian mode, use:
[14:38] => m r
[14:38] You can also compute factorial using:
[14:38] => !
[14:38] The factorial of 5 is 120. In RPN style:
[14:38] => 5 !
[14:38] The factorial of 0 is 1. In RPN style:
[14:38] => 0 !
[14:39] You can also do permutations and combinations.
[14:39] To find combinations, use:
[14:39] => k c
[14:40] So, 5C3 is 10. In RPN style:
[14:40] => 5 RET 3 k c
[14:40] To find permutations, use:
[14:40] => H k c
[14:41] So, 5P3 is 60. In RPN style:
[14:41] => 5 RET 3 H k c
[14:42] You can find prime factorization for a number using:
[14:42] => k f
[14:42] For the number 60, if you find the prime factorization, you will get [2, 2, 3, 5]
[14:42] In RPN style:
[14:42] => 60 k f
[14:43] You can find the GCD of two numbers using:
[14:43] => k g
[14:43] The GCD of 10 and 5 is 5. In RPN style:
[14:43] => 10 RET 5 k g
[14:43] The LCM of two numbers can be found using:
[14:43] => k l
[14:44] The LCM of 10 and 5 is 10. In RPN style:
[14:44] => 10 RET 5 k l
[14:45] A number units can also be mentioned when you input numbers.
[14:45] For distance, the following units are supported: m, cm, mm, km, in, ft, mi, point
[14:45] For volume: l or L, ml; gal, cup, tbsp
[14:45] For mass: g, mg, kg, lb, oz, ton
[14:45] For time: s or sec, ms, us, ns, min, hr, day, wk
[14:46] For temperature: degC, degF, K
[14:46] Let us now look at some Programmer's functions
[14:46] You can display a number in binary using:
[14:46] => d 2
[14:47] So, if you have the number 10 in the top of the stack, and you issued 'd 2', you should see 2#1010, which is the binary equivalent of 10.
[14:47] If you want to display in octal, use:
[14:47] => d 8
[14:47] If you want to display in Hex, use:
[14:47] => d 6
[14:47] If you want to display it back in decimal, use:
[14:47] => d 0
[14:48] You can do a binary AND operation using:
[14:48] => b a
[14:48] You can perform a binary OR operation using:
[14:48] => b o
[14:49] A binary XOR can be performed using:
[14:49] => b x
[14:49] And a binary NOT operation can be done using:
[14:49] => b n
[14:49] You can perform a left shift operation using:
[14:50] => b l
[14:50] You can do a logical shift right using:
[14:50] => b r
[14:51] So, the number 5 in binary is 2#101. If you do a logical shift right, it will become 2#10, or the decimal number 2.
[14:51] You can do an arithmetic right shift using:
[14:51] => b R
[14:51] In this operation, the signed bit value is retained. For example:
[14:52] => 5 n b R d 2
[14:52] You will see that the leading bits are '1'
[14:52] The integer quotient in division can be found using:
[14:52] => \
[14:52] The remainder can be found using:
[14:52] => %
[14:53] You can find the floor of a number using:
[14:53] => F
[14:53] For example, if you want to find the floor of Pi, use:
[14:53] => P F
[14:53] It should show the result 3.
[14:53] You can find the ceiling of a number using:
[14:53] => I F
[14:54] Let us now look at some Vector operations
[14:55] You can create a vector of 1, 2, ..., n using:
[14:55] => v x n
[14:55] So, if you do 'v x 3', it will create the vector [1, 2, 3]. After you type 'x', it will prompt in the minibuffer with the message "Size of vector =".
[14:55] You can find the length of a vector using:
[14:55] =. v l
[14:56] => v l
[14:56] In the above example, it will return the result 3.
[14:56] You can reverse a vector using:
[14:56] => v v
[14:57] You can of course key in your own vector using the numbers separated by space, but, the vector will be displayed with the elements separated by comma.
[14:58] For example, to create the vector [1, 4, 5, 3, 2], you can input: [ 1 4 5 3 2 ]
[14:58] You can sort a vector using:
[14:58] => v S
[14:58]