From the course: Learning the Go Standard Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Trigonometry and other functions - Go Tutorial
From the course: Learning the Go Standard Library
Trigonometry and other functions
- [Instructor] Okay in this example, we're going to continue our investigation of the math package by using some of the more advanced math functions. So what we're going to do is in the start folder, let's open up the calculations folder and we'll use calc_start, and you can see, I have a variable named x that we're going to use in some of these examples. So I'll uncomment that, and I'll also uncomment the modules I'm going to need. Let's start with the absolute value function, which returns the value of a given argument, stripped of any positive or negative sign. So I'll call math.abs on x. And I'll do the same thing on minus x. And let's also try out the pow and x functions. So the power function, I'll call math.pow. And that raises x to the given power. So we'll raise x to the second power. And then for the next example, we're going to use the math.exp function, which raises e to the x power. And let's just…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.