How to do basic mathematical computations (in Excel)
Task
How do we write the most common mathematical operations in a given piece of software? For example, how do we write multiplication, or exponentiation, or logarithms, in Python vs. R vs. Excel, and so on?
Solution
Each of the formulas shown on the right of the table below is valid code for use in Excel formulas, in cells in a worksheet.
| Mathematical notation | Excel notation | Example |
|---|---|---|
| $x+y$ | x+y |
=A1+B1 |
| $x-y$ | x-y |
=A1-B1 |
| $xy$ | x*y |
=A1*B1 |
| $\frac xy$ | x/y |
=A1/B1 |
| $x^y$ | x^y |
=A1^B1 |
| $\vert x\vert$ | ABS(x) |
=ABS(A1) |
| $\ln x$ | LN(x) |
=LN(A1) |
| $\log_a b$ | LOG(b,a) |
=LOG(A1,B1) |
| $e^x$ | EXP(x) |
=EXP(A1) |
| $\pi$ | PI() |
=PI() |
| $\sin x$ | SIN(x) |
=SIN(A1) |
| $\sin^{-1} x$ | ASIN(x) |
=ASIN(A1) |
| $\sqrt x$ | SQRT(x) |
=SQRT(A1) |
Other trigonometric functions are also available besides just SIN,
including COS, TAN, etc.
Content last modified on 24 July 2023.
See a problem? Tell us or edit the source.
Contributed by Nathan Carter (ncarter@bentley.edu)