Eric Scott Barr
/
Recent content on Eric Scott Barr
Hugo  gohugo.io
enus
© 2017 Eric Scott Barr
Thu, 17 Dec 2020 04:46:16 0600

C++ Tips and Tricks: Swapish
/blog/2020/12/ctipsandtricksswapish/
Thu, 17 Dec 2020 04:46:16 0600
/blog/2020/12/ctipsandtricksswapish/
Swapping values in C++ is simple enough with the std::swap standard algorithm. But what if an operation logically requires some transformation on one or both values prior to swapping? Is there some idiomatic solution to combining a swap with transformations? Here’s a quick tip to show how to achieve this goal with a little inspiration from other languages.
The Standard Approach Given two variables of the same type, swapping and then performing some transforming operation like negating one of the values looks like the following:

Trigonometric Integrals
/blog/2016/01/trigonometricintegrals/
Thu, 21 Jan 2016 08:11:43 +0000
/blog/2016/01/trigonometricintegrals/
<p>This week I started back to my journey in mathematics, this time tackling Calculus II. Starting out the week was the section I ended with in Calc I, integration by parts. No sweat! However, the second section for the week was Trigonometric Integrals. I’m not certain what I was expecting exactly going into the section, however, after working a few problems I realized something very interesting: I really hadn’t learned any new skills, what I had learned was a way to leverage skills I already had to solve problems that were previously unapproachable. Let me demonstrate with finding a solution for the following integration problem:</p>
<link rel="stylesheet" href="/katex/katex.min.css" />
<script defer src="/katex/katex.min.js"></script>
<script defer src="/katex/contrib/autorender.min.js" onload="renderMathInElement(document.body,{"delimiters":[{"display":true,"left":"$$","right":"$$"},{"display":false,"left":"$","right":"$"},{"display":false,"left":"\\(","right":"\\)"},{"display":true,"left":"\\[","right":"\\]"}]});"></script><span>
\[\int \frac{\sin \phi}{\cos^{3}\phi}\ d\phi \]
</span>
<h3 id="whatamidoinghere">What am I doing here?</h3>
<p>I’ve learned that the asking and answering of this question for myself is critical to solving problems. In this case, I’m trying to solve an integration problem but, truth be told, I know of know way to integrate this problem as it is. It’s not in a basic form. The only option in this circumstance is to manipulate the equation until it resembles a basic form that can be solved. So if I had to take a wild guess as to what I’m really doing here, it would be that I’m going to be manipulating this equation to get it into a basic form.</p>
<h3 id="manipulatingtointegrate">Manipulating to integrate</h3>
<p>To this point I’ve learned a few ways to manipulate problems:</p>
<ol>
<li><strong>Algebraic</strong>  Perhaps the simplest manipulation, manipulating the problem algebraically to simplify it into a basic form that can be solved.</li>
<li><strong>USubstitution</strong>  Useful for solving integrals that are composed of a function <em>and its derivative</em>.</li>
<li><strong>Integration by Parts</strong>  Leveraging a proven relationship to break apart an integral into a function and a, hopefully, simpler integral to solve.</li>
</ol>
<p>Note that at times, these manipulation strategies can be combined in order to achieve a solution. However, in the case of the problem I am trying to solve, none of these situations directly apply.</p>
<p>It should come as no surprise then, that all there is to solving trigonometric integrals is leveraging trigonometric manipulations to get an equation into a basic, solvable, form.</p>

Areas Between Curves: Thinking Outside the Vertical Box
/blog/2015/12/areasbetweencurvesthinkingoutsidetheverticalbox/
Fri, 04 Dec 2015 08:11:43 +0000
/blog/2015/12/areasbetweencurvesthinkingoutsidetheverticalbox/
When learning a number of new math concepts in a short period of time, it can be tempting to just remember the processes and apply them unconditionally, and it often works. However, by not trying to understand a problem first and going straight for the process, we can actually make our lives much more difficult than is necessary. Lets take a look at this by considering the problem of finding the area between $ x = y^2  4y $ and $ x = 2yy^2 $.

The volume of the intersection of two similar pipes
/blog/2015/11/thevolumeoftheintersectionoftwosimilarpipes/
Sun, 29 Nov 2015 21:12:09 +0000
/blog/2015/11/thevolumeoftheintersectionoftwosimilarpipes/
Thanksgiving break is here and after the feasting, when the food weighs heavy and the mind drifts into that hazy place between sleep and awake thanks to loads of carbs and tryptophan, we might find ourselves wondering what the volume is of the space created by two intersecting pipes. At least, my calculus professor seems to think that would be a good quandary to mull over. In this article we will use Thanksgiving leftovers to help visualize the space created by two intersecting pipes and then try to determine the volume of that space; first via approximating and then by getting serious with the tools we’ve learned in first year calculus.

USubstitution? U Gotta Be Kidding
/blog/2015/11/usubstitutionugottabekidding/
Wed, 25 Nov 2015 04:24:27 +0000
/blog/2015/11/usubstitutionugottabekidding/
This week in class we’ve been learning the interesting things for which area’s under a curve provide an answer. And whats finding a definite integral but taking a couple antiderivatives and finding their difference? Nothing to it, right? Wrong!
Let me explain the situation. Currently, I’ve spent most of a semester working with the differential branch of calculus. I have a fair understanding of what derivatives are, what they represent. Having spent the first weeks of the semester using limits to find the slopes of tangent lines, I certainly have an appreciation for how powerful they are.

Reference Angles and the Fundamental Identity
/blog/2015/06/referenceanglesandthefundamentalidentity/
Sat, 13 Jun 2015 02:10:45 +0000
/blog/2015/06/referenceanglesandthefundamentalidentity/
In the previous article in the series on trigonometry, the focus was on solving right triangles using their unique properties. But what about angles that don’t fit nicely within quadrant I of the cartesian coordinate plane? This article will demonstrate how to solve these types of angles/triangles using reference angles. Finally, it will wrap up by explaining an interesting relationship between sine and cosine, also known as the Fundamental Identiy.

Trigonometry and Right Angles
/blog/2015/06/trigonometryandrightangles/
Fri, 12 Jun 2015 02:10:45 +0000
/blog/2015/06/trigonometryandrightangles/
Using all the tricks in the proverbial math bag that have been gathered in the course of this series on trigonometry, it is possible to determine what the measures of the sides and angles of a right triangle trigonometrically; without measuring them. This article will demonstrate how to solve a triangle but first it will start with a question. Given a right triangle, where one angle is 90° and another angle $ \alpha $, which must be $ 0° \le \alpha \le 90° $: what is the value of $ \alpha $ if the $ \text{sin}\ \alpha = \frac{\sqrt{2}}{2} $?

Trigonometric Functions
/blog/2015/06/trigonometricfunctions/
Thu, 11 Jun 2015 06:10:45 +0000
/blog/2015/06/trigonometricfunctions/
At the heart of trigonometry lies the study of the relationship between the angles of a triangle and the length of its sides. There exists 6 such relationships, known as the trigonometric functions. This article in the series on trigonometry aims to define the trigonometric functions as a set of ratios and show how they can be derived from certain common angles.
To begin consider an angle $ \alpha $ in standard position and a terminal side forming an angle between 0° and 90°, with a point $ \text{(x,y)} $ anywhere on the terminal side that is not the origin.

Angular and Linear Velocities
/blog/2015/06/angularandlinearvelocities/
Wed, 10 Jun 2015 22:10:45 +0000
/blog/2015/06/angularandlinearvelocities/
This article will look at objects that rotate around a circle and introduce two forms of velocity, which is the rate at which objects move in relation to time: angular and linear velocities. The initial article of this series on trigonometry defined an angle as one ray, the terminal side, rotating away from another ray, the initial side. In the second article, two points of those rays were fixed onto a unit circle.

Radians, Arcs, and Everything Between
/blog/2015/06/radiansarcsandeverythingbetween/
Wed, 10 Jun 2015 02:10:45 +0000
/blog/2015/06/radiansarcsandeverythingbetween/
In everyday life when most people think of angles and their measurements, they think of a measurement in degrees. However, as previously mentioned, this unit of measurement is based on a crude likening of rotations around a point to the rotation of the earth around the sun. This results in some rather complicated formulas when working with degrees. For this reason, another type of measurement was divised, one that is based in mathmatics.

Angles and Their Measurements
/blog/2015/06/anglesandtheirmeasurements/
Mon, 08 Jun 2015 02:10:45 +0000
/blog/2015/06/anglesandtheirmeasurements/
What are angles? How are they measured? Answering these questions is the focus of this article, part of a series on trigonometry. This article will identify all the constituants of an angle, describe several special angles, and show how angles have been measured for thousands of years.
The first step to understanding angles, is understanding what a ray is. Rays are defined by a point on a fixed line, and all the points to one side, or the other, of that point.

Driving Boost.Test with CMake
/blog/2015/06/drivingboost.testwithcmake/
Tue, 02 Jun 2015 02:10:45 +0000
/blog/2015/06/drivingboost.testwithcmake/
Boost.Test is one of the more popular C++ based test frameworks on the market. With it being a boost library, chances are its already installed in the local environment, or can be easily built. This article doesn’t aim to show how to use Boost.Test. Rather, it shows how to incorporate building and running those tests with CMake, one of the most popular build systems for C++ projects. This article assumes that a CMake based project already exists.

C++14 and SDL2: Managing Resources
/blog/2014/04/c14andsdl2managingresources/
Thu, 17 Apr 2014 04:39:34 +0000
/blog/2014/04/c14andsdl2managingresources/
Update: The final solution in this article has been updated based on feedback from nanofortnight on Hacker News. This change, while not solving the complexity of what it means to work with C++ templates, does help significantly with the readability of this solution.
Update 2: Added a final example that shows how the general make_resource helper can be used to simplify writing higher level C++ abstractions around C libraries
Update 3: In order to offer proper RAII semantics the make_resource function now throws if the resource fails to create.

Sphinx and CMake: Beautiful Documentation For C++ Projects
/blog/2012/03/sphinxandcmakebeautifuldocumentationforcprojects/
Tue, 13 Mar 2012 00:00:00 +0000
/blog/2012/03/sphinxandcmakebeautifuldocumentationforcprojects/
Let’s face it, documentation for (most) developers is boring and more often than not this is reflected in the quality of a project’s documentation. This is often a barrier that prevents adoption of otherwise well crafted projects in widespread production use. In this article we’ll take a look at how to integrate a documentation generator called Sphinx into an existing CMake based project for documentation that is regenerated each time you build the source.

Building Boost.Python for Python 3.2
/blog/2012/03/buildingboost.pythonforpython3.2/
Mon, 05 Mar 2012 00:00:00 +0000
/blog/2012/03/buildingboost.pythonforpython3.2/
Boost.Python is an excellent tool for exposing C++ code to Python. Building Boost with support for the latest version of Python is not that difficult but as most unix systems ship with Python 2.7 or earlier the default options are generally not sufficient.
To start out, make sure that you have the latest version of Python installed. On Ubuntu or debian based environments this is as simple as running the following command.

Installing Jenkins on Ubuntu Server
/blog/2012/03/installingjenkinsonubuntuserver/
Sun, 04 Mar 2012 00:00:00 +0000
/blog/2012/03/installingjenkinsonubuntuserver/
Jenkins is an excellent platform for managing automated builds and getting started on Ubuntu Server is a snap. This guide covers the setup of Jenkins as well as how to use the default Ubuntu Apache webserver installation as a frontend to make URL’s nicer.
Installing Jenkins Installing Jenkins itself is pretty straightforward using default package system:
sudo aptget install jenkins After the installation completes you can access the Jenkins installation at http://SERVER_IP:8080/