a) To enter your math formula, you need to know the syntax:
- To get the square root, use
Sqr
(you did already)
- The power function is done with the ^ (caret) character
- There is no build in constant
e
, you can define it either by defining a constant or use Exp(1)
b) If you want to use your equation available in your Excel, create a UDF (User Defined Function).
Have a look at the following piece of code. I like to split complicated statements into pieces, so I have used 2 intermediate variables.
If your x
is in A1
, you can for example write the Formula =Equation(A1)
into cell B1
.
Public Function Equation(x As Double) As Double
Dim term1 As Double, term2 As Double, answer As Double
term1 = Sqr(1 + x ^ 2)
term2 = 1 + (1 / term1)
Equation = x * (Exp(1) ^ term1) * term2
End Function