Interclass Problem #2


For this interclass problem you can choose to do one of the following options. As practice you should probably consider attempting all of them at some point, but for the in-class presentation you just need to have one of them

  1. You can use a tuple to represent a complex number. The first element (_1) is the real part and the second element (_2) is the complex part. You can also use assignment to pull these out with something like val (r,c)=z if z is a tuple. For this IcP option I want you to write the following functions that take tuples and return tuples and treat them as complex numbers.

    If you feel like a little extra challenge (more to your math knowledge than your programming) you can also write these functions.

  2. For this option you will do something very similar to the last one except that instead of doing complex numbers, you will do rational numbers. A rational number is a number that can be expressed as a ratio of two integers. In other words, fractions. You can also represent a rational as a tuple of (numerator,denominator). Use that to write the following functions.

    If you feel like a little extra challenge make it so that your functions always return the fraction in the lowest form. This is best done by introducing another function.

  3. In this option you will write a little script that does part of a 1040-EZ. We don't know enough for you to do the whole thing, but you can write enough to ask questions and do most of the calculations for lines 1-13. Do what you can and remember this is a learning exercise you will present in class so don't stress the details. You might break sections up into functions.

  4. This option has you doing a little scientific calculation. We can't do all that much yet, but we will work our way up. We are going to play with calculating the non-greenhouse temperatures for planets with moderate to fast spin rates. This might seem like a complex thing to do, but it isn't really all that bad. You really just need two pieces of information and a little algebra. The first piece of information is the Stefan-Boltzmann Law for the amount of energy given off in thermal radiation by any body. The second is the fact that intensity of radiation drops off as 1/r2.

    To calculate the non-greenhouse temperature of a planet you need the following pieces of information. You should prompt the user for values to these. To keep things simple use mks units and keep temperatures in Kelvin.

    Use the Stefan-Boltzmann law to determine the energy output per square meter on the stars surface. Make that into a function that takes the needed values. Using the inverse square relationship you can calculate the intensity at the location of the planet. Make this another function. The Sun light will cover the planet with an area of PI*r2 where r is the planets radius. A fraction of that, determined by the albedo, is reflected. What isn't reflected warms the planet. The planet cools through its own thermal radiation from a surface of 4/3*PI*r2. Setting the absorbed and emitted values equal allows you to solve the temperature. Make a function that takes the incident power and albedo and gives you back a temperature.