Are you wondering how to calculate inverse cosine in Excel? You’ve landed on the appropriate Excel tutorial. Keep reading to learn more!
As a data analyst professional, you might need to calculate angles, side length ratios, height, distance, etc., in engineering and physics. Or you’re an engineering graduate or instructor and must figure out such values for learning purposes.
Excel functions for mathematics and trigonometry will come in handy in such scenarios. In today’s Excel tutorial, I explain various intuitive ways of calculating the inverse cosine in Excel.
To know more about the inverse values (radians or degrees) of sine and tan, read these articles already covered by me:
What Is Inverse Cosine?
Inverse cosine (cos) is a mathematical function that operates as the inverse value of the given cosine value or the ratio of the adjacent side and hypotenuse of the right-angle triangle. You can denote it as cos^-1 or arccos or arccosine.
Usually, the cosine function accepts an angle as an input. Then, it returns the ratio of the adjacent side to the hypotenuse in a right triangle. However, inverse cosine does the opposite.
If a trigonometrical problem has the ratio between the adjacent side and the hypotenuse, you can calculate the degree of the acute angle horizontally opposite to the right angle. However, the ratio or the cosine value must be within the range of -1 to 1.
In mathematical terms, the domain of the arccosine function is [-1, 1], and its output (range) is typically [0, π] radians or [0, 180] degrees since it represents angles in the first and second quadrants of the unit circle.
Reasons to Calculate Inverse Cosine
- Inverse cosine helps determine an angle when you know the ratio of the adjacent side to the hypotenuse in a right triangle. This is especially useful in fields like trigonometry and geometry.
- When you’re solving trigonometric equations you often need to find angles with specific cosine values. Inverse cosine helps obtain these angles.
- In various engineering and physics applications, it’s necessary to find angles that correspond to certain cosine values either as a ratio or values given as the lengths of the adjacent side and the hypotenuse.
- In navigation and astronomy, determining angles based on celestial bodies’ positions can be done using inverse cosine calculations.
- When designing robotic arms or working on computer graphics, you might need to calculate angles for proper positioning. Inverse cosine aids in such calculations.
- In signal processing and statistics, determining phase shifts or angles of vectors can involve inverse cosine calculations for accurate error analysis.
Inverse Cosine Calculation Using ACOS Function
The native trigonometric function of Excel to calculate the inverse cosine values for given cos values is the ACOS function.
It’s available in Microsoft Excel desktop editions for Windows since Excel 2007. Also, you’ll find the function in Excel for the web.
Get Inverse Cosine in Excel From Side Lengths
Suppose you got the side lengths and you need to find the inverse cosine. Here are the steps you must follow:
- Let’s consider column A contains Adjacent Side and column B contains the Hypotenuse values.
- In
C2
, enter the following formula:
=DEGREES(ACOS(A2/B2))
- Hit Enter to get the arccosine value or angle in degrees.
- If there are more values in columns A and B, simply drag down the auto-fill handle from the cell
C2
to instantly get inverse cosine.
Do you need the inverse cosine value in radians instead of degrees? Use the following formula instead:
=ACOS(A2/B2)
Calculate Inverse Cosine From Cosine
Finding the inverse cosine from given cos values is a super easy task. Here’s what you need to do:
- Highlight a cell adjacent to the first cos value on your worksheet.
- Put the following formula into the selected cell and hit Enter:
=ACOS(A2)
- If there are more cos values in the source data column, simply drag the fill handle from the calculated cell to convert cos values to arccosine values.
Data generated using the ACOS function is always in the radians unit. If you need the output values in degrees, use the following formula instead:
=DEGREES(ACOS(A2))
Calculate Inverse Cosine Using Power Query
Power Query is suitable for arccosine calculation for both imported and internet data sources.
However, when importing from external sources, you can transform data in Power Query to inverse cosine. Then, only enter arccosine values to the worksheet if you don’t need the raw data anymore. Here’s how to proceed:
- Click the Data tab and select the Get Data button inside the Get & Transform Data block.
- From the Get Data context menu, choose your preferred data source like From Azure, From Database, etc.
- You should now see your datasets in the Power Query tool.
- If you need to import data from the existing worksheet, highlight the data and click the Data tab.
- There, select the From Table/Range button.
- On the Create Table dialog box, click OK to import and open the internal dataset in Power Query.
Now, follow these steps to learn how to create a new column for inverse cosine in Power Query and insert a formula in it to calculate arccosine for the whole column:
- Click the Add Column tab on the Power Query ribbon.
- Inside the General block, select the Custom Column button.
- On the Custom Column dialog box, give a name to the new column in the New column name field.
- Inside the Custom column formula field, enter the following formula:
Number.Acos([Cosine])
- Click OK.
Now, you should see the new column on the Power Query tool. It also shows the cos to inverse cosine converted values. The formula will work in your worksheet as long as the source data column header is Cosine.
If it’s something else, modify the formula accordingly. You simply need to put the column header as is inside the square brackets in the above formula.
The arccosine values calculated this way are radian values. If you need the values in degrees, follow these steps on the Power Query tool:
- Create a new custom column by following the instructions mentioned earlier.
- On the Custom Column wizard, give a new name for the custom column.
- Inside the column formula field, enter this formula:
([Inverse Cosine])*(180/Number.PI)
- Click OK.
The new column will appear with the converted values from radians to degrees. To modify the formula according to your own dataset, simply put the column header name as is in the square brackets, in place of Inverse Cosine
.
Now that you’ve completed the data transformation process, here’s how you can import the converted data into your Excel worksheet:
- Click the File menu and choose Close & Load To.
- On the Import Data dialog box, click Existing worksheet and highlight a cell as the destination.
- Click OK.
- Power Query will export the new and existing columns to the highlighted worksheet.
Calculate Inverse Cosine in Power Pivot (DAX)
You can use the Data Analysis Expressions (DAX), ACOS, on Power Pivot to calculate inverse cosine in bulk for the entire column. Later, you can import the converted values to a PivotTable or the Excel worksheet. Here are the steps you must try:
- Highlight the input cos values and click the Power Pivot tab.
- There, select the Add to Data Model button.
- On the Create Table dialog, click OK.
- The highlighted data will now open in the Power Pivot tool.
- Click the Add Column placeholder text and rename it to Inverse Cosine.
- Select the newly-created Inverse Cosine column and click the formula bar to enter this DAX formula:
=(ACOS([Cosine])*(180/Pi()))
- Hit Enter to convert cos to inverse cosine in degrees instantly for the whole input data column.
The above image shows the results after the conversion. If you need inverse cosine in radians, use this formula instead:
=ACOS([Cosine])
Now, to import these values into your Excel worksheet, right-click on the Inverse Cosine column on Power Query and click Copy on the context menu.
Highlight the destination cell and press Ctrl + Alt + V. On the Paste Special dialog box, click Csv and hit OK.
You should now see the inverse cosine values on the worksheet.
Calculate Inverse Cosine in Excel VBA
The methods explained so far are a bit manual. You’re performing a few steps or you need to remember the steps before you can get arccosine values in Excel.
However, if you’re okay with learning basic Excel VBA scripting, you can automate the process to a great extent.
Read this easy and intuitive article to learn how to use Excel VBA scripts on your worksheets:
Now that you know how to utilize Excel VBA scripts, find below two scripts you can use to convert cos to inverse cos in Excel:
Excel VBA Script for Arccosine From Side Lengths
Sub CalculateInverseCosine()
Dim ws As Worksheet
Dim adjacentRange As Range
Dim hypotenuseRange As Range
Dim cell As Range
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Sheet2") ' Replace "Sheet2" with your actual sheet name
' Set the input ranges
Set adjacentRange = ws.Range("A2:A5") ' Change this range as needed
Set hypotenuseRange = ws.Range("B2:B5") ' Change this range as needed
' Loop through the corresponding cells in adjacent and hypotenuse ranges
For Each cell In adjacentRange
' Find the corresponding hypotenuse value in the same row
Set hypotenuseCell = hypotenuseRange.Cells(cell.Row - adjacentRange.Cells(1).Row + 1)
' Calculate inverse cosine in radians
cell.Offset(0, 2).Value = WorksheetFunction.Acos(cell.Value / hypotenuseCell.Value)
' Calculate inverse cosine in degrees
cell.Offset(0, 3).Value = WorksheetFunction.Acos(cell.Value / hypotenuseCell.Value) * (180 / WorksheetFunction.Pi())
Next cell
End Sub
The above VBA script will help you convert cosine values in a cell range to inverse cosine values. You’ll get inverse cosine in radians in column C and in degrees in column D.
If you don’t need values in radians, delete the following code line from the above script:
cell.Offset(0, 2).Value = WorksheetFunction.Acos(cell.Value / hypotenuseCell.Value)
Also, if you just need the results in radians but not degrees, delete this code line from the script:
cell.Offset(0, 3).Value = WorksheetFunction.Acos(cell.Value / hypotenuseCell.Value) * (180 / WorksheetFunction.Pi())
To help you modify the script, I’ve also included comments in the code snippet. Follow the comments and modify the script according to your worksheet.
Excel VBA Script for Inverse Cosine From Cosine
Sub CalculateInverseCosine()
Dim ws As Worksheet
Dim cosineRange As Range
Dim resultRangeRadians As Range
Dim resultRangeDegrees As Range
Dim cell As Range
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Sheet7") ' Replace "Sheet7" with your actual sheet name
' Set the input cosine range and result ranges
Set cosineRange = ws.Range("A2:A5") ' Change this range as needed
Set resultRangeRadians = ws.Range("B2:B5") ' Change this range as needed for radians
Set resultRangeDegrees = ws.Range("C2:C5") ' Change this range as needed for degrees
' Loop through the cosine values
For Each cell In cosineRange
' Calculate inverse cosine in radians
resultRangeRadians.Cells(cell.Row - cosineRange.Cells(1).Row + 1).Value = WorksheetFunction.Acos(cell.Value)
' Calculate inverse cosine in degrees
resultRangeDegrees.Cells(cell.Row - cosineRange.Cells(1).Row + 1).Value = WorksheetFunction.Acos(cell.Value) * (180 / WorksheetFunction.Pi())
Next cell
End Sub
Use the above VBA script to convert cosine values to arccosine in a few clicks for a large range of source data.
Use Office Scripts to Calculate Inverse Cosine
Find below two distinct methods to convert input data source to inverse cosine in Excel using Office Scripts:
Office Scripts Code for Arccosine From Side Lengths
- Click the Automate button on the Excel desktop or web app.
- Select the New Script button.
- Copy and paste the following script into the Code Editor:
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Set range C2 on selectedSheet
selectedSheet.getRange("C2").setFormulaLocal("=ACOS(A2/B2)");
// Auto fill range
selectedSheet.getRange("C2").autoFill("C2:C5", ExcelScript.AutoFillType.fillDefault);
// Set range D2 on selectedSheet
selectedSheet.getRange("D2").setFormulaLocal("=DEGREES(ACOS(A2/B2))");
// Auto fill range
selectedSheet.getRange("D2").autoFill("D2:D5", ExcelScript.AutoFillType.fillDefault);
}
- Click the Save script button to save the code.
- Hit the Run button to execute the code.
Here’s how to modify the script:
C2
is the destination of results, so change accordingly.- In the ACOS formula,
A2
represents adjacent side length andB2
represents hypotenuse. So, alter these references according to your worksheet. C2:C5
is for formula auto-fill. So, change this cell range reference as well. For example, if input data exists tillA100
andB100
, thenC2:C5
should beC2:C100
.D2
is the destination for inverse cosine in degrees.- Also, change
D2:D5
if input data in columns A and B are more than four rows.
Office Scripts Code for Arccosine From Cosine
function main(workbook: ExcelScript.Workbook) {
let selectedSheet = workbook.getActiveWorksheet();
// Set range B2 on selectedSheet
selectedSheet.getRange("B2").setFormulaLocal("=ACOS(A2)");
// Auto fill range
selectedSheet.getRange("B2").autoFill("B2:B5", ExcelScript.AutoFillType.fillDefault);
// Set range C2 on selectedSheet
selectedSheet.getRange("C2").setFormulaLocal("=DEGREES(ACOS(A2))");
// Auto fill range
selectedSheet.getRange("C2").autoFill("C2:C5", ExcelScript.AutoFillType.fillDefault);
}
The above Office Scripts code will produce inverse cosine in radian in column C and in degrees in column D.
Don’t forget to modify the script before using it in your own worksheet.
Note: Office Scripts is only available with a paid Microsoft 365 subscription. Also, the subscription plan must be a Business Standard plan or higher.
Conclusion
These are all the methods Excel offers to you so you can get inverse cosine from different input data sources. Follow along with the steps for the above methods to get the data you need.
Also, comment below to express your own experience in trying the above techniques.
0 Comments