Let’s make a start with the opening of the latex editor, i.e., texmaker. For this, you need to open the Ubuntu shell first with the “Ctrl+Alt+T” shortcut key. After opening the shell, write “texmaker” in the shell if you have already installed it on your system.
It will start the latex texmaker tool on your Ubuntu screen.
The texmaker screen will be ready to use now. Tap on the first menu from the taskbar, i.e., “File” and explore the create option to generate a new latex file. If not, try using the “Open” option to open the already existing latex file from your Ubuntu system.
We prefer to open the already existing latex file, i.e., “test.tex” from our system. Tap on the “Open” button to launch it within the texmaker.
Example 01:
Let’s start our today’s first example to demonstrate the commands used to display a square root in the latex file. Therefore, start your latex code with the \documentclass{article} command. Without using it, you will not be able to generate a file of the document type.
Now, the \begin command came up with the option {document}. It is used to show that the document will be started from here, and all the work will be done within it. We have been using some text and the representation of a square root within the “$” signs.
The \sqrt command will be used to create a square root in the document. This command takes two arguments normally. But, we have been using a single argument in curly braces, i.e., “base” value.
The base value has been used as 10. The \end command is used to end the document here. Let’s execute our latex code file with the arrow sign above the file name. After that, open the file in DVI mode.
\begin{document}
Square Root: $\sqrt{10}$
\end{document}
After opening the latex file in the DVI format, we got the below-shown result. The output has been showing the square root of “10” in a standard mathematical form.
Let’s say we want to add some extra information within the “$” expression. Therefore, we have tried to cover it as well. We have opened the same code file and updated our code.
This time, we have added the value 16 as a base and made it equal to 4. This shows that the square root of 16 is 4. Let’s make this updated code run once again and launch it within the DVI format.
\begin{document}
Square Root: $\sqrt{16}=4$
\end{document}
On running the latex file in the DVI format, we have got the below-demonstrated result. The result shows a very appealing representation of a mathematical expression having a square root within it.
Example 02:
Let’s take a new example to create a square root in the latex file. This time, we will be creating a cube root of some value. We have to use both the arguments in the square root command. The argument with [] braces will represent the root, and in {} will show the base value of square root. Thus, we have opened the same file and updated the \sqrt command.
We have taken 3 in [] as a root to a square root. While the value 16 has been used as a base. For which the square root has been taken. Let’s run this updated latex code first. After the code is executed and we have got no errors, it’s time to open it within the latex DVI format.
\begin{document}
Square Root: $\sqrt[3]{16}$
\end{document}
The output for this updated code shows the cube root of value 16 using the \sqrt command. Any value can be taken as root within this \sqrt command.
Let’s say we want to take a cube root of “x” in the latex document. Therefore, we need to use the [3] as root and {x} as a base for the \sqrt command.
Let’s execute this updated code to see how it works for a variable. After the code is executed, open the same latex file in the pdf or DVI file format to see the demonstration using the arrow from the texmaker taskbar.
\begin{document}
Square Root: $\sqrt[3]{x}$
\end{document}
You can see that the square root symbol has been covering the variable “x” while the value “3” has been used as the cube root of this square symbol.
Example 03:
Let’s take our last but not least example. We will be taking a mathematical expression taking a square root of fractional values within it. Thus, we have started the document by \begin command using the $ sign to use \sqrt command in it.
The \left and \right command is used to create() brackets in the file. The \frac command is used to create an expression in the “p/q” form. The “+” sign has been showing that there are a total of 3 fractional values. The \sqrt command has been applied at all these 3 fractions at a time wholly.
\usepackage{amsmath}
\begin{document}
$X=\sqrt{\left(\frac{ax}{at}\right)^{2}+
\left(\frac{ay}{at}\right)^{2}
\left(\frac{az}{at}\right)^{2}}$
\end{document}
You can see that the square root has been generated on all three fractional values.
Conclusion:
This is how we can create a square root in the latex documents. We have tried our best to provide you with simple code examples to illustrate the use of the \sqrt command to achieve our goal. We have added three different examples starting from simple ones to complex. Implementing them all by adding little changes in the script is suggested.