EDS 212: Day 1, Lecture 1

Course intro, algebra refresher


EDS 212 basics

Welcome to EDS 212 - Essential Math in Environmental Data Science



About your instructor


Carmen Galaz García (she/her)

  • Assistant Teaching Professor @ Bren

Before:

  • Data Scienist @ NCEAS
  • Ph.D. in Mathematics @ UCSB

Teaching & Research

  • Python courses and Capstone Projects for Masters in Environmental Data Science (MEDS)
  • Supporting math and data science across Bren!
  • NCEAS/TNC collaboration for invasive iceplant mapping analyzing remotely sensed images

About your TA


Cella Schnabel (she/her)

  • 2nd year PhD @ Bren advised by Ashley Larsen, Kelly Caylor, and Kathy Baylis

Before:

  • B.S. in Environmental Engineering @ Cornell
  • Farmer in upstate NY

Teaching & Research

  • Broadly interested in food + water security planning under climate change.
  • Mostly use methods from econometrics, remote sensing, and uncertainty analysis.
  • Also TAing EDS 217 at the end of the MEDS summer sessions!

About you!


image: Flaticon.com

Course description


  • Units: 2
  • Grading: Satisfactory/Unsatisfactory
  • This is an “offline course”, your only one in MEDS. What it means is we’ll be focusing on conceptual understanding and some pen-and-paper practice, instead of coding. Why? We want to make sure you understand some fundamental topics before jumping into implementing.

Let’s take a look at the course syllabus together.

Topics overview


  • Day 1: Course introduction & math basics refresher
  • Day 2: Limits & derivatives; Integration & ODEs
  • Day 3: Calculus practice session; Vectors and matrices
  • Day 4: Summary statistics; Basic probability theory
  • Day 5: Basic stats

Objectives (in general terms)


  1. Shake off the math dust

  2. Exercise core math skills needed to succeed in your Bren courses

  3. Explore how valuable math is to environmental data science

  4. Build a collaborative environment and get to know your cohort

Student expectations


We expect all students will:

  • Support and encourage all classmates

  • Be open to learning from each other

  • Bring a collaborative attitude and communicate respectfully

  • See opportunities to share kownledge as a chance to deepen understanding

  • Complete all in-class exercises

Student expectations


We expect all students will:

  • Support and encourage all classmates

  • Be open to learning from each other

  • Bring a collaborative attitude and communicate respectfully

  • See opportunities to share kownledge as a chance to deepen understanding

  • Complete all in-class exercises

Logistics

  • You are required to attend all sessions, unless there’s a significant reason not to. Always communicate with your instructors.
  • If you are feeling sick: stay home and take care of yourself! Please mask up if you are not feeling 100%.

Please fill out this survey


Math in Environmental Data Science

Why am I taking a math class?





or,


Why do I have to know math when a computer will do it for me?

A quantitative brain warm-up



MEDS students have diverse work & academic histories

This course (re)introduces math concepts and tools that:

  • Focus on applications to environmental data science
  • Are specifically relevant for MEDS projects, coursework
  • Provide an entryway into building computational skills
  • Refresh quantitative thinking skills generally
  • Refresh essentials like units, conversions, notation, language

Share with the person next to you:


What has been your life or professional experience with math? Best friend ever, mortal enemy, or something in between?


How do you see math being relevant to solving environmental problems?

Math is a core tool in environmental data science


Math helps us investigate the world and communicate our findings

  • Used by scientists to find evidence

  • Can be used to quantify relations, trends, and changes

  • Mathematical models can help us understand complex systems

  • Must be used responsibly and with awareness of potential biases and limitations

  • Helps us support arguments that can transform policy and actions

  • At the center of tools like statistics, machine lerning, and image processing


We need to understand the math to make decisions and efficient implementations using it!

Math at Bren


In your classes:

  • EDS 222: Statistics for Environmental Data Science

  • EDS 230: Modeling Environmental Systems

  • EDS 232: Machine Learning in Environmental Science

Today: Math brain warm up


  • Algebra review
  • Rules of exponents
  • Units
  • Functions
  • Understanding graphs
  • Linear functions
  • Exponential function
  • Natural logarithm

Algebra review

Rules of algebra


You can get far with a few rules:

  1. Follow order of operations (a.k.a. PEDMAS)

  2. Never change an equation. Instead, rewrite them into more useful forms

  3. Manipulate BOTH sides of an equation with the SAME PROCEDURE.

Always add/substract/multiply/divide by the same number on both sides. More generally, always apply the same function to both sides of the equation.

Order of operations (P-E-DM-AS)



P - Parentheses


E - Exponents


D/M - Division / multiplication


A/S - Addition / subtraction

Order of operations practice problems


✏️ Take a minute to solve these individually.


  • Simplify \frac{4-6}{2}(3+1)-\frac{1+2*4}{3}


  • Simplify 3x+4(8x-6x) -(2y-5)+\frac{2x(1-3)}{2}


  • If we are given the values of x=-3 and y=2, what would be the value of z? z = 4*(y-4)+(x+1)^2

Order of operations practice problems


💡 Let’s see a solution!


\frac{4-6}{2}(3+1)-\frac{1+2*4}{3}

3x+4(8x-6x) -(2y-5)+\frac{2x(1-3)}{2}

Order of operations practice problems


💡 Let’s see a solution!

If we are given the values of x=-3 and y=2, what would be the value of z? z = 4*(y-4)+(x+1)^2

Practice solutions


\small \begin{aligned} \frac{4-6}{2}(3+1)-\frac{1+2*4}{3} &= \frac{-2}{2}(4)-\frac{9}{3} \\ &= -1(4)-3 \\ &= -4-3 \\ &= -7 \end{aligned}

\small \begin{aligned} 3x+4(8x-6x) -(2y-5)+\frac{2x(1-3)}{2} &= 3x+4(2x)-2y+5+\frac{2x-6x}{2} \\ &= 3x+8x-2y+5+\frac{-4x}{2} \\ &= 3x+8x-2y+5-2x \\ &= 9x-2y+5 \end{aligned}

\small \begin{aligned} z = 4(y-4)+(x+1)^2 &= 4(2-4)+(-3+1)^2 \\ &= 4(-2)+(-2)^2 \\ &= -8+4 \\ z&=-4 \end{aligned}

Notation matters



Simplify the following: 6 \div 3(4+2)

What would be a harder-to-misinterpret way to write this?


An important takeaway:



Being readable & hard to incorrectly interpret is often as important as being technically “correct”



When designing things, it’s important to consider the different ways that users might misuse or misunderstand it - then build in safeguards to help them use it correctly. Clear communication and user-centered design is critical in environmental data science.

Solving equations


Equations help us find unknown values that satisfy certain conditions.

Remember the rules:

  1. Never change an equation. Instead, we rewrite them into more useful forms

  2. Manipulate BOTH sides of an equation with the SAME PROCEDURE.

Always add/substract/multiply/divide by the same number on both sides. More generally, always apply the same function to both sides of the equation.

Solving equations


Equations help us find unknown values that satisfy certain conditions.

Remember the rules:

  1. Never change an equation. Instead, we rewrite them into more useful forms

  2. Manipulate BOTH sides of an equation with the SAME PROCEDURE.

Always add/substract/multiply/divide by the same number on both sides. More generally, always apply the same function to both sides of the equation.

Example

Prices are important in economics, but not always available for environmental goods.

How do we get prices if we know quantity?

\begin{aligned} Q&=\frac{(400-P)}{80} &\text{Isolate P in terms of Q} \\ \end{aligned}

✏️ Take a minute to solve this individually.

Solving equations


💡 Let’s see a solution!

Prices are important in economics, but not always available for environmental goods.

How do we get prices if we know quantity?

\begin{aligned} Q&=\frac{(400-P)}{80} &\text{Isolate P in terms of Q} \\ \end{aligned}

Solving equations


💡 Let’s see a solution!

Prices are important in economics, but not always available for environmental goods.

How do we get prices if we know quantity?

\begin{aligned} Q&=\frac{(400-P)}{80} &\text{Isolate P in terms of Q} \\ 80Q&=\frac{(400-P)\cancel{80}}{\cancel{80}} &\text{ Multiply both sides by 80} \\ 80Q-400&=\cancel{400}-\cancel{400} -P &\text{ Subtract both sides by 400} \\ -1(80Q-400)&=-P(-1) &\text{Multiply both sides by -1} \\ 400-80Q&=P &\text{Flip terms for simplicity} \end{aligned}

It can be easy to make mistakes while doing algebra. Practice is key!


Solve all in terms of x

  1. 3x+2=10x-12


  1. 4-3(2x+1)=8-\frac{3x}{2}


  1. 3(x+7a)-5=b+2(c-4x)

✏️ Take a minute to solve these individually.

It can be easy to make mistakes while doing algebra. Practice is key!


💡 Let’s see a solution!

Solve all in terms of x

  1. 3x+2=10x-12
  1. 4-3(2x+1)=8-\frac{3x}{2}

It can be easy to make mistakes while doing algebra. Practice is key!


💡 Let’s see a solution!

Solve all in terms of x

  1. 3(x+7a)-5=b+2(c-4x)

Practice solutions


\small \begin{aligned} 3x+2&=10x-12 \\ 3x+2+12&=10x-12(+12) \\ 3x-3x+14&=10x-3x \\ 14&=7x \\ x&=2 \end{aligned}

\small \begin{aligned} 4-3(2x+1)&=8-\frac{3x}{2}\\ 4-3-6x&=8-\frac{3x}{2} \\ 1-6x&=8-\frac{3x}{2} \\ 2-12x&=16-3x \\ -9x&=14 \\ x&=\frac{-14}{9}\\ \end{aligned}

Practice solutions


\small \begin{aligned} 3(x+7a)-5&=b+2(c-4x)\\ 3x+21a-5&=b+2c-8x \\ 11x+21a-5&=b+2c \\ 11x&=5+b+2c-21a\\ x&=\frac{5+b+2c-21a}{11} \end{aligned}

Let’s take a 5 minute break


image: Flaticon.com

Rules of exponents

Exponents make algebra more interesting!


Example

The expression x^3 means x multiplied by itself 3 times: x^3=x * x * x

More generally, x^n = x \text{ to the power of } n.

Intuitively, the exponent n tells us how many times to multiply the basis x by itself:

x^n = \underbrace{x \times x \times \ldots \times x}_{n \text{ times}}

But the exponent can be any (real) number, not only integers!

What are exponents good for?


They can describe really big numbers

Diameter of the Milky Way = 1,000,000,000,000,000,000,000 meters = 10^{21} \text{ m}

And also really small numbers

Diameter of a human red blood cell = 0.0000000001 meters = 10^{-10} \text{ m}

This way, we can use exponents to describe exponential growth and decay. Many environmental variables behave in this way.

Rules and properties of exponents (1)

✏️


  1. Product rule:


  1. Quotient rule:


  1. Any non-negative x to the power of 0 equals 1:


  1. Negative exponent means divide:


  1. Fractional exponent means take the n-th root:

Rules and properties of exponents (2)


✏️

  1. Power of a power means multiply the exponents:


  1. Exponents get distributed over products:


  1. And exponents get distributed over divisions:


  1. If a is the n-th root of x, then a to the n equals x:

Rules and properties of exponents (1)


  1. Product rule: x^a * x^b = x^{a+b}


  1. Quotient rule: \frac{x^a}{x^b} = x^{a-b}, \ \ \text{for } x \neq 0


  1. Any non-negative x to the power of 0 equals 1: x^0 = 1, \ \ \text{for } x \neq 0


  1. Negative exponent means divide: x^{-a} = \frac{1}{x^a}, \ \ \text{for } x \neq 0


  1. Fractional exponent means take the n-th root: x^{\frac{1}{n}} = \sqrt[n]{x}

Rules and properties of exponents (2)


  1. Power of a power means multiply the exponents: (x^a)^b = x^{ab}


  1. Exponents get distributed over products: (xy)^a = x^a y^a


  1. And exponents get distributed over divisions: \left( \frac{x}{y} \right)^a = \frac{x^a}{y^a}


  1. If a is the n-th root of x, then a to the n equals x:

a = \sqrt[n]{x} \Rightarrow a^n = x

Rules and properties of exponents

\begin{array}{|l|l|} \hline \textbf{Rule} & \textbf{Expression} \\ \hline \text{Product Rule} & x^{a} \cdot x^{b} = x^{a+b} \\ \hline \text{Quotient Rule} & \frac{x^{a}}{x^{b}} = x^{a-b}, \quad x \neq 0 \\ \hline \text{Zero Exponent} & x^{0} = 1, \quad x \neq 0 \\ \hline \text{Negative Exponent} & x^{-a} = \frac{1}{x^{a}}, \quad x \neq 0 \\ \hline \text{Fractional Exponent} & x^{\frac{1}{n}} = \sqrt[n]{x} \\ \hline \text{Power of a Power} & (x^{a})^{b} = x^{ab} \\ \hline \text{Power of a Product} & (xy)^{a} = x^{a}y^{a} \\ \hline \text{Power of a Quotient} & \left(\frac{x}{y}\right)^{a} = \frac{x^{a}}{y^{a}} \\ \hline \text{$n$-th Root Definition} & a = \sqrt[n]{x} \quad \Rightarrow \quad a^{n} = x \\ \hline \end{array}

Exponents practice


✏️ Simplify the following.

  1. \frac{6^5}{6^3}


  1. (x^2y)^4


  1. \frac{x^5y^6}{xy^2}

  2. \frac{24x^6}{12x^{-8}}

\begin{array}{|l|l|} \hline \textbf{Rule} & \textbf{Expression} \\ \hline \text{Product Rule} & x^{a} \cdot x^{b} = x^{a+b} \\ \hline \text{Quotient Rule} & \frac{x^{a}}{x^{b}} = x^{a-b}, \quad x \neq 0 \\ \hline \text{Zero Exponent} & x^{0} = 1, \quad x \neq 0 \\ \hline \text{Negative Exponent} & x^{-a} = \frac{1}{x^{a}}, \quad x \neq 0 \\ \hline \text{Fractional Exponent} & x^{\frac{1}{n}} = \sqrt[n]{x} \\ \hline \text{Power of a Power} & (x^{a})^{b} = x^{ab} \\ \hline \text{Power of a Product} & (xy)^{a} = x^{a}y^{a} \\ \hline \text{Power of a Quotient} & \left(\frac{x}{y}\right)^{a} = \frac{x^{a}}{y^{a}} \\ \hline \text{$n$-th Root Definition} & a = \sqrt[n]{x} \quad \Rightarrow \quad a^{n} = x \\ \hline \end{array}

Exponents practice


✏️ Let’s see a solution.

  1. \frac{6^5}{6^3} = 6^{5-3} = 6^2


  1. (x^2y)^4 = (x^2)^4*y^4 = x^8y^4



  1. \frac{x^5y^6}{xy^2} = \frac{x^5}{x}*\frac{y^6}{y^2} = x^{5-1}*y^{6-2} = x^4y^4 = (xy)^4



  1. \frac{24x^6}{12x^{-8}} = 2x^6x^{(-(-8))}=2x^6x^8 = 2x^{6+8} = 2x^{14}

Multiplying expressions (FOIL)



First, Outside, Inside, Last


Example:

(2x+5)(x-3) ✏️ Expand this expression.

Multiplying expressions (FOIL)



First, Outside, Inside, Last


Example:

(2x+5)(x-3) ✏️ Let’s see a solution.

= (2x \times x) (2x \times -3) (5 \times x) (5 \times -3)

= 2x^2 - 6x + 5x - 15

=2x^2-x-15

Polynomials describe more complex relationships through exponents


A polynomial is a function of the form: \large \begin{align} a_nx^n+a_{n-1}x^{n-1}+...+a_1x+a_0 \end{align}

  • x is the variable
  • a_i are constants (fixed numbers) that are called the coefficients of the polynomial
  • each a_ix^i is called a term of the polynomial,
  • n is called the degree of the polynomial, this is the largest exponent in the polynomial.

Polynomials describe more complex relationships through exponents


A polynomial is a function of the form: \large \begin{align} a_nx^n+a_{n-1}x^{n-1}+...+a_1x+a_0 \end{align}

  • x is the variable
  • a_i are constants (fixed numbers) that are called the coefficients of the polynomial
  • each a_ix^i is called a term of the polynomial,
  • n is called the degree of the polynomial, this is the largest exponent in the polynomial.

Example:

  • x^5 + x^2 - 1 is a polynomial of degree five with three terms.

  • Linear functions like mx + c where m and c are constants are polynomials of degree 1!

Polynomials often represent real world data better than a linear function.

Units

UNITS. UNITS. UNITS.



Think about these statements, which all contain the same value of 4:


  • There are four in the refrigerator.

  • There are four burritos in the refrigerator.

  • There are four roaches in the refrigerator.

  • There are four million dollars in the refrigerator.

UNITS. UNITS. UNITS.


Think about this sign at New Cuyama. Anything odd here?

Units are critical in environmental data science




We cannot responsibly work with data without knowing the units of each variable we’re working with.


That means we need to always familiarize ourselves with metadata, carefully check units and any unit conversions, and understand how units combine into the units of a dependent variable.

Dimensional analysis (unit conversions)


In dimensional analysis, we multiply initial units by a sequence of unit conversion factors to arrive at the final desired units.

Example: How many centimiters are there in 6 inches?

✏️ Let’s solve this together.

Dimensional analysis (unit conversions)


In dimensional analysis, we multiply initial units by a sequence of unit conversion factors to arrive at the final desired units.

Example: How many centimiters are there in 6 inches?

We know: 1 inch = 2.54 cm. This gives us two unit conversion factors:

\frac{2.54 \text{ cm}}{1 \text{ in}} \text{ and } \frac{1 \text{ in}}{2.54 \text{ cm}}. Important: the fraction the numerator and denominator represent the same quantity.

Then we multiply by the appropriate conversion factor and simplify:

\begin{align*} 6 \text{ in} &= 6 \text{ in} \cdot \frac{2.54 \text{ cm}}{1 \text{ in}}\\ &= 6 \frac{2.54}{1} \cdot \text{ in}\frac{\text{ cm}}{\text{ in}} \\ &= 15.24 \cancel{\text{ in}}\frac{\text{ cm}}{\cancel{\text{ in}}} \\ &= 15.24 \text{ cm} \end{align*}

Dimensional analysis (unit conversions)


Example. Convert 100 \frac{g}{cm^3} into units of \frac{kg}{in^3}, given that 1 cm3 = 0.061 in3.

✏️ Let’s solve this together.

Dimensional analysis (unit conversions)


Example. Convert 100 \frac{g}{cm^3} into units of \frac{kg}{in^3}, given that 1 cm3 = 0.061 in3.

We need one unit conversion factor for g: \frac{1 \text{ kg}}{1000 \text{ g}}.

And another one for \text{cm}^3: \frac{1 \text{ cm}^3}{0.061 \text{in}^3}.

Then we multiply by the conversion factors and simplify

\begin{align*} 100 \frac{\text{ g}}{\text{cm}^3} &= 100 \frac{\text{ g}}{\text{cm}^3} \cdot \frac{1 \text{ cm}^3}{0.061 \text{ in}^3} \cdot \frac{1 \text{ kg}}{1000 \text{ g}}\\ &= 100 \frac{1}{0.061} \frac{1}{1000}\cdot \frac{\text{ g}}{\text{cm}^3} \frac{\text{ cm}^3}{ \text{ in}^3} \frac{ \text{ kg}}{\text{ g}}\\ &= \frac{1}{0.61} \cdot \frac{\cancel{\text{ g}}}{\cancel{\text{cm}^3}} \frac{\cancel{\text{ cm}^3}}{ \text{ in}^3} \frac{ \text{ kg}}{\cancel{\text{ g}}}\\ &=1.639\frac{kg}{in^3} \end{align*}

Unit conversion practice


  1. Convert 8.1\frac{km}{s} to miles per hour, given that 1 km = 0.621 miles.


  1. You are combining information from multiple sources to estimate the total annual oil spilled in a watershed, reported by different companies. The following are reported for the year:
  • Company A: 14.6 barrels spilled (with 9.3 barrels recovered)
  • Company B: 692 liters spilled (94% recovered)
  • Company C: 18.1 gallons spilled (0% recovered)

What is the total unrecovered amount of oil spilled into the watershed that year, in barrels. Use the conversion 1 barrel = 42 gallons = 159 liters and a calculator when needed.

Unit conversion practice: solutions


  1. Convert 8.1\frac{km}{s} to miles per hour, given that 1 km = 0.621 miles.

✏️ Let’s see a solution!

Unit conversion practice: solutions


  1. You are combining information from multiple sources to estimate the total annual oil spilled in a watershed, reported by different companies. The following are reported for the year:
  • Company A: 14.6 barrels spilled (with 9.3 barrels recovered)
  • Company B: 692 liters spilled (94% recovered)
  • Company C: 18.1 gallons spilled (0% recovered)

What is the total unrecovered amount of oil spilled into the watershed that year, in barrels. Use the conversion 1 barrel = 42 gallons = 159 liters and a calculator when needed.

✏️ Let’s see a solution!

Unit conversion practice: solutions


8.1\frac{km}{s} \times 60\frac{s}{min} \times 60\frac{min}{hr} \times 0.621\frac{mi}{km} = 18108.36 \frac{mi}{hr}

  1. You are combining information from multiple sources to estimate the total annual oil spilled in a watershed, reported by different companies. The following are reported for the year:
  • Company A: 14.6 barrels spilled (with 9.3 barrels recovered)
  • Company B: 692 liters spilled (94% recovered)
  • Company C: 18.1 gallons spilled (0% recovered)

What is the total unrecovered amount of oil spilled into the watershed that year, in barrels. Use the conversion 1 barrel = 42 gallons = 159 liters and a calculator when needed.

Company A: 14.6\text{ barrels} - 9.3\text{ barrels} = 5.3\text{ barrels unrecovered}

Company B: 692\text{ liters} \times (1-0.94) = 41.52\text{ liters unrecovered} \rightarrow 41.52\text{ L} \times \frac{1\text{ barrel}}{159\text{ L}} = 0.26\text{ barrels}

Company C: 18.1\text{ gallons} \times \frac{1\text{ barrel}}{42\text{ gal}} = 0.43\text{ barrels unrecovered}

Total: 5.3\text{ barrels} + 0.26\text{ barrels} + 0.43\text{ barrels} = 5.99\text{ barrels unrecovered}

Lunch break!


image: Flaticon.com