Thursday, 21 April 2011

Leave of Absence

Hi there fellow views and followers. I am sad to inform you that I will no longer be blogging for the next 3 months. This is mainly due to I need work to pay for school. Now your probably wondering and saying, "well i work and i can blog". This may be true, but for myself I will not have the privilege of internet and computer access.  In my line of work which I will not disclose with you.

On those regards, I shall be returning August 1st or sooner. Thus you can expect to read more programming math related posts around that time. Also for the voting post.

What Language to explain and possibly teach?

Total votes per language:

C: 0
Java: 7
CSS: 0
Javascript: 0
PHP: 2
Other(aka Ruby): 1

So as you can see it is a tie between Java and C++. Thus we need to take into consideration my vote.
I myself would like to learn and teach Java in the process. So in august before my object oriented programming starts. I will be getting a head start by learning java. So this is my last post. Have a good summer.

Tuesday, 19 April 2011

Portal 2

So finally Portal 2 came out. For those who have not even heard of Portal. You have to crawl out of your cave and game it. It has won all sorts of awards and is quite possibly the most original game I have played.

Here is a quick writeup from our good friend Wikipedia.

The game consists primarily of a series of puzzles that must be solved by teleporting the player's character and simple objects using the Aperture Science Handheld Portal Device (ASHPD, also dubbed the "portal gun"), a unit that can create inter-spatial portals between flat planes. The player character, Chell, is challenged by an AI named GLaDOS(Genetic Lifeform and Disk Operating System) to complete each puzzle in the Aperture Science Computer-Aided Enrichment Center using the portal gun with the promise of receiving cake when all the puzzles are completed.

In short summary for anyone who has played. The cake is a lie. This was quite possibly the best game of 2007.

So besides Portal being an awesome game. Such an awesome game as a sequel. Portal 2. Now i have not played the game yet. As i am waiting for my younger brother to get off the Xbox 360, and go to bed which should have been 2 hours ago.  I will soon be playing this game. I am extremely excited and I think after this post i will be kicking my brother off. Oh and obviously I will have to beat it all in one sitting.

The game description on the back of the game case.

The single-player portion of Portal 2 introduces a cast of dynamic new characters, a host of fresh puzzle elements, and a much larger set of devious test chambers. Players will explore never-before-seen areas of the Aperture Science Labs and be reunited with GLaDOS, the occasionally murderous computer companion who guided them through the original game.
The game's two-player cooperative mode features its own entirely separate campaign with a unique story, test chambers, and two new player characters. This new mode forces players to reconsider everything they thought they knew about portals. Success will require them to not just act cooperatively, but to think cooperatively.

Screenshot of one of the game's test chambers, showing the deterioration over the years (plant overgrowth, damaged panels and floors, etc.) Also demonstrates the crazed art left by the "Rat Man" character that reviews the events of the first game.

Monday, 18 April 2011

What Language to explain and possibly teach?

So starting this week, depending on how well comments go. I will be interacting with my fellow followers a bit. I want to see what you my followers want to see me talk about. To do this I will obviously ask you the reader to leave a nice comment/vote to determine what I talk about next. The topics I will be talking about will either be a programming language that i have not explored yet, or one that I am extremely familiar with. So this will be both a fun experience for myself and for the reader. I will hopefully brush up on some programming, or possibly learn a new language or at least better understand a language. I will also be referencing this post in my other posts so that you can get a chance to vote/comment. So I will now lay down the options for you to decide.

******* Please comment with the language you would like me to talk about*********
  1.  C
  2.  C++ 
  3. HTML
  4. CSS
  5. JavaScript
  6. PHP
  7. Java
  8. Other (state what language in comment)
Voting will be over by Wednesday or Thursday. 

 So I look forward to talking about one of these. Also even though school is over for myself. I have always wanted to learn Big "O" in math. So i think I will teach myself that and post it about that sometime.

Sunday, 17 April 2011

Javascript Tricks

I have read a few tricks across my travel through the Internets in regards to Javascript.

JavaScript, also known as ECMAScript is a prototype-based, object-oriented scripting language that is dynamic, weakly typed and has first-class functions. -

Now when i say tricks i mean something that manipulates the code of a site in a non harmful way to create personal enjoyment. You can also use these to benefit yourself or show off to friends. What ever order comes first.

All of the code presented can be copied and pasted into the URL bar. Hit enter and enjoy. Also it may help if JavaScript is turned on in your browser. 

Master Editor:

So anyhow here is some code to help you edit your site faster, or pretend to be editing a site in real time.

javascript:document.body.contentEditable='true'; document.designMode='on'; void 0

My personal favorite. Takes all images off the site and creates a Ferris wheel with them. 

Image Vortex:

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=(Math.sin(R*x1+i*x2+x3)*x4+x5)+"px";*y1+i*y2+y3)*y4+y5)+"px"}R++}setInterval('A()',5); void(0);

 If you look carefully in the above code, its rotating the HTML “img” tag. Just replace it with “a” or “p” and watch some links or text rotate instead of images.


Your screen is going to love this one.

avascript:function flood(n) {if (self.moveBy) {for (i = 200; i > 0;i--){for (j = n; j > 0; j--) {self.moveBy(1,i); self.moveBy(i,0);self.moveBy(0,-i); self.moveBy(-i,0); } } }}flood(6);{ var inp = "D-X !msagro na dah tsuj resworb rouY"; var outp = ""; for (i = 0; i <= inp.length; i++) {outp =inp.charAt (i) + outp ; } alert(outp) ;}; reverse 

 Sketchy Site, Inspect it:

If you find a site that you feel you cannot trust. You want to verify that it is authentic. You can with this.

javascript:alert("The actual URL is:\t\t" + location.protocol + "//" + location.hostname + "/" + "\nThe address URL is:\t\t" + location.href + "\n" + "\nIf the server names do not match, this may be a spoof.");

Roll up your broswer Katamari style:

javascript:var h='',i,n,ss=['',h+'Renderables.js',h+'Game.js'];for(i=0;i<ss.length;i++){n=document.createElement("script");n.src=ss[i]+'?';document.head.appendChild(n);}

This code only works for chrome and safari.  Thanks to "mac and me" for posting a comment about this.

Basic Calculator:
 Possibly the most helpful out of these tricks. 

javascript: alert(69696-76543+555);

Change the numbers inside the alert function to create your own equations. You can also not include numbers in the function, but instead write any comment that you want displayed like. Your computer will self destruct in 10 seconds. Freak your friends out. Have fun.

Saturday, 16 April 2011

PHP: File Input and Output

So i was meddling around today will File input and output functions. These functions are relatively the same as what i have dealt with in C and C++. One thing that's bothering me is the newline command is still acting weird for me. Another thing I experimented with was getting a string or value from a user input. This involves HTML forms. Which i have very little experience with too. So today was very hectic trying to learn and correct a lot of mistakes and errors while trying to code and learn new things. I also noticed what i was coding actually required a server this time. So i used a nice program called xampp to set up a PHP server for me. So testing the code on that has been splendid. So anyhow on to the coding.

Source Code
<html xmlns="" xml:lang="en" lang="en">
    <meta http-equiv="content-type" content="text/html; charset=us-ascii" />


    Form site
    <br />

    <form action="fileio.php" method="post">
        username:<input name="name" type="text" /> <input type="submit" />
Now the code that makes the least amount of sense is this.

Source Code
    <form action="fileio.php" method="post">
        username:<input name="name" type="text" /> <input type="submit" />
 Now you are probably wondering what in the world is this. Well, I will start with saying it is a form. If you haven't figured that out then i don't know if programmings right for you. What this form does is allows the user to enter a string into a box. Then hit a little submit button. This is appropriate for numerous situations and can be used as a login.

In this codes case it's to check the availability of a username. If it is free, it allows the user to use it.
Another important part of the form is the top where it says

action="fileio.php" method="post"

the action part is when the user clicks the submit button.It will bring them to another page i called fileio.php. I will show the code for that soon. The next important thing is the method="post". This takes whatever the user entered into the text box and transfers it over to the fileio.php page. Now this may be explained poorly and i am sorry if it is. This is how i understand it. So if this is not the case as to what is going on correct me in a comment.  So the user clicks submit after filling out the forms.

Now on to the fileio.php page.

Source Code


$fp = fopen("usernames.txt", "r") or die("Could not open requested file");

$usrname = $_POST['name'];
$used = 0;
while ($str = fgets($fp)) {
    if ($usrname == $str) {
        print ("This username has already been used");
        $used = 1;

if ($used == 0) {
    $fp = fopen("usernames.txt", "a");
    fwrite($fp, "\r\n$usrname");

Okay so we have lots going on here in this code. I will try and touch on all bases.

$fp = fopen("usernames.txt", "r") or die("Could not open requested file");

This line of code has created a variable that points to a file. That file is usernames.txt and the "r" signifies that we have open that file for reading only. fopen stands for file open and takes two parameters a string and what you want to do to the file.

$usrname = $_POST['name'];

Remember that method="post" code from earlier. This is where that comes into play. What ever the user typed into that box is now a string held by the variable $usrname. As far as I know this is the only way to prompt the user for a variable. How neat.

 $used = 0;
while ($str = fgets($fp)) {
    if ($usrname == $str) {
        print ("This username has already been used");
        $used = 1;

Now this big ugly control structure. The variable $used is just there to keep track of whether or not the username has been used already. where it says while( $str = fgets($fp) ). This is a loop, and the condition for that loop is keep looping while there is still a string for use to get from the file.

$str = fgets($fp)

in other words the condition above is using fgets(). fgets() is a function that reads a line from a file. So what is happening is it is reading a line from the file and storing that string into the variable $str. Now this function fgets will keep being called until it finds no more lines left in the file. In this case it will stop running and when this happens the loops stops looping.

if ($usrname == $str) {
        print ("This username has already been used");
        $used = 1;

This line of code is saying hey! if the username is equal to a string already in the file then lets alert the user, change the value of the variable used to one, and then stop the loop by using break. Simply right.
So after this comes an important function for files once they are open.


fclose just closes your file that is opened.  In this case our file pointer $fp which points to usernames.txt.

if ($used == 0) {
    $fp = fopen("usernames.txt", "a");
    fwrite($fp, "\r\n$usrname");

This last piece of code is saying. Hey if the username was not already used. Then lets store it in the file so it can't be used again. We determine if the username has been used already from the while loop statement and by using the variable $used. Also you will notice we are pointing to the same file again. But the difference being this time. We are opening the file for appending. Denoted by "a" in the second parameter.

What is happening here is we have opened the file to add on to the file without erasing anything.

The last line of code we have not seen is

fwrite($fp, "\r\n$usrname");

fwrite() is a function that adds a string to the file. So we are adding the username to the file in this line of code. We are also creating a newline so the username is spaced out among the others.

So hopefully that was not too confusing and I will be adding onto this code as  i progress and get better.

Thursday, 14 April 2011

PHP: Declaring and Printing Variables

So i decided to go ahead and learn how to declare and display my variables in PHP. First thing i noticed is when declaring a variable you do not need to specify what type of data your variable is. Such as an integer, string, character, etc. Which i found really weird, but I got use to it. Next thing i noticed was I had a hard time using \n to create a newline in PHP. Which is a command. I just found it was a syntax error(aka parse error in PHP). But anyhow here is some code I created in order to test some things. Feel free to read the English parts of my code for non programmers. It might amuse you.

Source Code

   <body>Welcome to my PHP Test Page
    <?php /*Declaring and printing variables*/
        $var = 5;
        $name = "Hello World";
        $test = array("Hello","this","is","an","array");

    Testing out, printing declared variables <br />
    printing 5 to the screen from variable <?php print('$var ');?>  <br /><br />
    <?php print("$var");?> <br /><br /> 
    Well that seemed to have worked out nicely, Now wth is the code to print print a newline. <br />
    instead of having to use HTML's "br" to create a new line out of my php scope<br /><br />
    Time to print a string using echo and print command<br />
    <?php echo "$name"; print("   $name   "); ?> <br /><br />
    Time to print an array<br />
    <?php print_r($test); ?><br />
    Well that was really unexpected so much for that command being of any use.<br />
    Maybe i used it wrong oh well time to find another way to print an array.<br />
    <?php for($i = 0; $i<5; $i++){print("$test[$i] ");} ?><br /><br />
    Well that seemed to have worked out a lot nicer. Using a loop and accessing each index of the array was nicer then print_r.<br />
    I think I will end the tests for this blog. Thanks for reading!<br />


End of Source Code

 What is actually displayed here. So you can see what exactly I did. 

Welcome to my PHP Test Page
Testing out, printing declared variables
printing 5 to the screen from variable $var


Well that seemed to have worked out nicely, Now wth is the code to print print a newline.
instead of having to use HTML's "br" to create a new line out of my php scope

Time to print a string using echo and print command
Hello World Hello World

Time to print an array
Array ( [0] => Hello [1] => this [2] => is [3] => an [4] => array )
Well that was really unexpected so much for that command being of any use.
Maybe i used it wrong oh well time to find another way to print an array.
Hello this is an array

Well that seemed to have worked out a lot nicer. Using a loop and accessing each index of the array was nicer then print_r.
I think I will end the tests for this blog. Thanks for reading!

Wednesday, 13 April 2011

PHP Designer 7

So i am done my first year of Computer Science at Lakehead University. I Finished all my exams and feel confident I did good in the classes, that I do not currently have a mark to put with. I finished my computer Programming class with an 87% so I am happy and content with an A mark.  Now that I am done my math exams and I can now talk about other topics regarding more on the programming side of things.

First thing first. I was recommended a nice IDE called PHP Designer 7. For those who do not know what an IDE is.Here is a definition.

Integrated Development Environment. It has visual designer to allow you to put together the user interface visually, editor to let you edit the source code, compiler to compile your source to executable, debugger to debug your programs, etc.

So many IDE's make programming a lot easier and more convenient as it's a one stop shop. So anyhow I am currently teaching myself PHP for the sake of learning the language.

A definition of PHP :

PHP: Hypertext Preprocessor. It is a recursive acronym; the first "P" stands for "PHP," and the first "P" of that stands for "PHP" as well, thus the cycle continues. It originally stood for Personal Home Page, but was renamed when the language fell into common use on the web, at version 3.0

The one thing i find cool about this language is that unlike ordinary web code where you can write it in a text file then change the extension and load it up in your internet to view the outcome. PHP needs some sort of server in order for the code to become visual. Where as if you typed out your code changed the extension and went to view it you would see nothing locally.

This is where PHP Designer 7 comes into play. It allows you to be able to visually see what your code is doing instead of having to set up a server to view it. Which has to be the most iimportant feature of this IDE. So anyhow here is the generic Hello World code in PHP. 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 <!-- Fig. 26.1: first.php -->
  <!-- Our first PHP script -->
      $name = "Hello World"; // declaration
   <html xmlns = "">
          <title>A simple PHP document</title>
       <body style = "font-size: 2em">
                <!-- print variable name's value -->
               Welcome to PHP, <?php print( "$name" );?>!

This code displays Hello World. Enjoy!

Tuesday, 12 April 2011

Discrete Probability and Probability

So this blog will be about some of my study notes for probability and other things that i need to remember for my exam tomorrow. It will not be as informative for the most part. But it might be able to show you some cool things that math can do.

Binomial Theorem: 

This is helpful for if you want to find the coefficient of a large polynomial really fast. Lets say find the coefficient of

( x + y) ^13 for x^6*y^7. Your probably going to write all of this out which would take forever factoring this equation out. To solve for the coefficient of x^6*y^7. Take a look at the exponent over the factored equation. It is 13. Now look at the exponent over your first variable x. This is 6. So your coefficient for x^6y^7 is the combination of 13 choose 6. Which happens to be 1716.

A combination is usually left in this notation C(13 6).

Pigeon Hole: This is really simple and a great way of solving probability questions. Lets say you have only k boxes(pigeon holes) and n distributable objects. Each object gets on hole. Until there is no more room for an object in a hole, then that object shares a hole with another object. By this principle there must be a box with

roundup( n/k) elements. Where roundup means whatever your answer is round it up. Also known as the roof function.


61 people are in a classroom. Show that at least 6 people in the room share a birthday in the same month.

To break this down we know that there are 12 months.

The  by the formula plug in roundup(61/12) we get exactly 6 elements in one hole. So we know that atleast 6 people in the class share the same month for their birthday.

Indistinguishable Permutations:

Count the number of ways you can re arrange the word "dispose"

The answer is 7!.

Now this does not work for repeating characters. Such as in the word "goodbye" .
Where there is two "o".

The answer for this is the number of characters in the word. Divided by the factorial of the number of repeating characters.

The answer is 7!/2!.

Repetition allowed Combinations:

Giving by the formula:

C( n - 1  r , r)

Example: Suppose we have 10 loonies to give out to 5 children.

Our answer is C(5-1+10 , 10) = C(14 10) = 1001 ways.

Card Problems:

1. How many different 5 card hands can you make with a standard deck of cards.

C(52 5) = 2598960 ways.

2. 5 card hand with only spades. We know there is 13 spades in a deck. So for this just remove every other card and choose from your spade deck of 13 cards.

C(13 5)

3. The number of hands with 3 hearts and 2 diamonds. Split your deck into a deck of 13 hearts and 13 diamonds. Remove all spades and clubs. Pick from each deck appropriately 3 hearts and 2 diamonds. Multiple your combinations together.

C(13 3) * C(13 2)

Fruit Basket problem:

You have a basket with oranges and apples. You can only pick 4 fruit from the basket. How many ways can you pick four fruit.

You can just count them out.

Let O = orange and A = apples.

4O , 4A , 3O1A, 2O2A, 1O3A.

As you can see 5 ways.

Money Troubles:

You have a bag of money with different denominations: $1,2,5,10,20,50,100.

You want to how many ways can you pick 5 bills. We know there is 7 different values of bills in the bag. Using a combination that allows repetition we get

C(7-1+5 , 5 ) = C(11 5) = 462 ways.

Discrete Probability

Possibly my more favorite area of probability.

Must know formula :

P(E) = | E | / |S|   Where P(E) = the probability of an experiment. |E| = event, |S| = sample space


p(of drawing a queen from a standard deck) = |4| / |52| = 1/13. There is only 4 queens in a deck of 52.

If you roll two dice what is the probability that the sum of them add up to 5.

Show the number of ways to add up to five for visual purpose.

|E| = { 2 , 3} ,{3 , 2} , { 1 , 4 } , { 4 , 1 } = 4 ways.

We know that two standard dice have a possibility of 36 outcomes = 6*6.

So 36 is our sample space and 4 is our event. Therefore the answer is

P(sum of 5) = 4/36

Discrete Card Problems

Your dealt 5 cards from a 52 deck.

1. You want to get at least one ace.For this you have to find the hands with atleast one ace and minus it off the hands with no ace.

|E| = C(52 5 ) - C(48 5) <----removed aces from the deck
|S| = C(52 5)

2. You want to get a 4 of a kind. First we need a kind. Which is C(13 1)
Then we need the rest of the kind C(4 4)
Then we need another card from he remaining cards C( 48 5) 
So times these 3 events together to equal |E| and we know our sample space is C(52 5)

[C(13 1)* C(4 4)* C(48 5)] / C(52 5)


Euler circuit: Contains every edge once. Every vertex must have an even degree for one to exist. Must reach the same vertex. As denoted by a circuit.

Euler Path: Must visit every edge exactly once.

Hamilton Circuit: contains at least every vertex exactly once and returns to original as denoted by a circuit.

Hamilton Path: is just visiting every vertex exactly once.

Sequences and Formulas:

Just ways to determine what type of formula you should use.

Geometric: an = ar^n for n>= 0 
Arithmetic an = nd + a for n>=0
Recursion: usually my favourite.

Example: Find a solution to the sequence.

2,  5, 8 , 11, 14, 17, 20 ......

We can visually see this is incrementing by 3.

My solution for this would be

a0 = 2.
an = a(n-1) + 3 for n>=0.

Test it or yourself.

Composition of Relations:

Basically this has transitive properties.


A = { x, y, z} ,  B = { 0, 1} , C = { a, b, c, d}

Let R be a subset of  the product of A to B. Let S be a subset of the product of B to C.

R = { (x, 0) , (y , 1)} , S = { (0 , a), ( l, d)}.

The the Composition of S  and R denoted S o R or R o S is

S o R = R o S = { (x , a ) , (y , d)} You may be able to see how this is transitive.

Monday, 11 April 2011

4th Prestige in Call of Duty: Black ops

 First on a side note. I changed the title of this blog to Programming and Math. This is mainly because of my final exams majority of my content has been about math related content in order to help me study. This content will be mostly about math for a while at least. Until i feel i can post more content like this. Now for the actual post.

So once again i Prestige'd in COD Black Ops. This prestige round this time. I will mostly be using an assault rifle, with extended mag. Any pistol with extended mag. For grenades frag and concussion. Claymore for fun. For perks, lightweight, hardened, hacker. my objective this prestige is to be as big of a meany as possible and shoot people through walls. Shooting people through walls is the most important part of this prestige hence the perk hardened. I have had so much fun today aiming at a wall and just shooting it. Managing to pull of triple kill head shots and such.

Not my favorite prestige emblem. To be honest in game it looks like nothing but a blob. but whatever now I have something to work towards. That is changing it with the 5th prestige emblem.

Sunday, 10 April 2011

Rules of Inference and Basic Proofs

This is a small add-on to this post Propositional Logic and De Morgans Law Knowledge of this post will be required for understanding this post. I am posting this as a hope that i will remember it for my Discrete Math Final Exam.

A rule of inference: is a rule that can be used in proving a theorem or some logic directly and polished.

Addition:  is you just add another proposition onto it using the Logical OR.

p  = 'The sky is blue" 
p v q = "The sky is blue or red"
Simplification: is you just subtract a proposition

p ^ q = 2+2= 4 and grass is green
p = 2+2 = 4

Conjunction: adding two separate propositions together.

p = Grass is green.
q = Rome is in Italy
p^q = "Grass is green and Rome is in Italy".

Modus Ponens: Basically the end result of an implication.

P - > Q = "If I study, then i get an A".
Q = " I studied so i got an A"

Modus Tollens: Basically the opposite of Modus Ponens.

p - > q "If I go to the store, I buy milk"
~p = " I did not go to the store" Which means
~q = " I did not buy milk"

Hypothetical Syllogism: Say this out-loud to sound cool.Visually you can see how this works.

p -> q = "If i study, then i pass."
q - > r = " If i pass then i grad".
p -> r = "If i study then i grad".


p v q = " I will study or eat dinner".
~p v r  "I will not study or go to the party"

 q v r = " I will eat or go to the party"

Disjunctive Syllogism:

p v q = "I will study or I will eat"
~p = " I do not study"
q = "I will eat"

Basic Proofs:

Proofs usually involve implications.

So two ways of solving these can be

Contra-positive: p -> q this is equivalent to ~q - > ~p. So instead of proving p - > q. we test ~p - > ~q to see if this is true. If it is true then we know p - > q is true.


If n + 2 is odd, then n is odd.

Suppose that "if n is even, then n + 2 is even"

let n = 2k for some integer k. n + 2 = 2k + 2 = 2(k+1). Clearly 2(k+1) is divisible by two thus making it even. Therefore since the contra-positive is true then p -> q is true.

Contradiction: This is a little more difficult. We want to prove that. p - > q is true and p -> ~q is true.
If both of them is true we go with the original as being true. For clearly both q and ~q cannot be true.


If n + 2 is odd, then n is odd.

Assume that n is odd. Then n = 2L + 1 for some integer L. So n + 2 = 2L + 3. Which is odd.

Suppose that  If n + 2 is odd, then n is even.

Let n = 2k for some integer k. Then n + 2 = 2k + 2. which means n is even.

Since both is true, clearly if n + 2 is odd then n is odd is true.

Bam, Poison up in yo body!

If you have not heard this yet, or you have and your confused as to where it came from. It is a line that it said in a Sims commercial and it's actually kinda hilarious.

So i decided hey i enjoy hearing this guy talk in the commercial. The things he says is funny.So i decided I'm gonna make a really mediocre remix. So this is what i did. 

Friday, 8 April 2011

Partial Fractions

This technique is very appropriate for integrals when you have some mess of a fraction with no hopes of being able to integrate it nicely.

A partial fraction is just taking any fraction and breaking it up into smaller fractions that can later be added together to make the same original fraction.

The first thing you must do to determine if you can do te partial fraction technique is see if your equation is a candidate for it. To do this you check if the degree of the numerator is less than the denominator. If it is not you have yourself an improper fraction and will need to do long polynomial division. Else you can begin doing the partial fraction technique.

Example of an improper fraction

2x^3 + x^2 -10
-----------------  <----degrees are the same

Now to create your partial fraction:


These are the forms your broken up fraction will either be. These are in a sense your formula.

         A                                                   Bx + C
   --------------                                ----------------------
     ( x-a)^k                                    (x^2 + bx + y)^k

Where a , b, y are some values. Where k is some exponent.

1. If the denominator contains linear fractions. Factor them out.

    5                        5
-----------  =   -----------
x^2+x-6        (x-2)(x+3)

2. Use the formulas and break up your equation appropriately. 

  5                        5                             A                                     B
-----------  =   -----------     =      ------------------   +      ---------------------
x^2+x-6        (x-2)(x+3)                   (x-2)                               (x+3)

3. Multiple both sides by the left
5 = A(x+3) + B(x-2)

4. Takes the roots(the what the x's are) and plug them in to solve for A and B.

x = -3, 2

If x = -3 :    5 = A(0) + B(-5) =  -5B;   B = -1

If x = 2:      5 = A(5) + B(0) = 5A ;   A = 1

5. we have found our A and B. So time to fill in our partial fractions for A and B.

         1                                    -1
------------------   +      ---------------------
     (x-2)                               (x+3)

There you this looks like something you could integrate much easier. Enjoy.

Wednesday, 6 April 2011

C++ Final Exam Cheat Sheet

So last minute my computer science professor decides to email the class. That we are allowed to bring in a one sided cheat sheet. So seeing as my this is my final exam and is worth 42% of my mark in the class. I decided it might be a good idea to create such a sheet full of info for ease. Last time i heard the exam would only have C++ on it and will deal with mostly classes. So i took a look at all my "class" notes and came up with this cheat sheet/program that goes through everything i learned on classes this semester.

The program i created was rewritten extremely compressed and ugly to save space for future material i decide to put on it. At the moment though here is my cheat sheet.

Source Code
#include <iostream>
using namespace std;

class study
    study(){x = 0,y = 0; n++;}
    study(int a, int b);
    void print(void);
    void displayN(void)const;
    friend study change(study obj){ cin>>obj.x; cin>>obj.y; return obj;}
    friend int area(study);
    study& operator+(study);
    study& setX5(void){this->x = 5; return *this;}
    study& sety10(void){this->y = 10; return *this;}
    friend ostream& operator<<(ostream &output, study &obj){output<<"("<<obj.x<<","<<obj.y<<")"<<endl; return output;}//stream overloading friend
    ~study(){x = 0; y=0; if(n!=0){cout<<"Object deconstruction"<<" Objects remaining = "<<n--<<endl;}}
private://methods in here called utility function
    static int n;
    int x;
    int y;
int study::n = 0;

void study::print(void){cout<<x<<endl; cout<<y<<endl;}
void study::displayN(void)const{cout<<"The number of objects created is: "<<n<<endl;}
study::study(int a, int b){ n++; x = a; y = b;}

int area(study obj){ return obj.x*obj.y;}

study& study::operator+(study obj2){this->x = this->x + obj2.x; this->y = this->y + obj2.y; return *this;}

int main()
    study obj1;//x = 0 , y = 0
    study obj2(2,4);//x = 2 , y = 4
    const study obj3(5,4);
    study *obj4 = new study(5,5);
    obj1.print();//output: 0  endl 0
    obj2.print();//output: 2  endl 4
    cout<<"The area of obj2: "<<area(obj2)<<endl;//object from area function gets deconstructed
    obj1 = change(obj1);//x = 6 , y = 5
    obj1 = obj1.operator+(obj2);
    obj1.print();// 8, 9
    obj1 = obj1 + obj2;
    //obj3.print(); won't work because const objs can only use const methods
    obj1.setX5().sety10();//cascading member list
    cout<<obj1<<endl;//use of operator overloading of <<. Method has to be a friend. ostream for output. istream for input.
    delete obj4;
    return 0;

As you can see it is pretty ugly, but should really benefit me in terms of knowing the syntax of certain programing styles/commands.

Tuesday, 5 April 2011

The Area of bounded functions

The Area and Volume of bounded functions: 

This is not the most informative blog, but for those who have a rough idea of whats going on should be able to grasp and understand the examples shown.

Find the area between
y = 2 - x^2 and y = (1/2)x.

from x = 0  to x = 1 .

 Now as seen above we use integration to determine this. Basically you find the integral of the equation shown and solve for the domain of it. Which in this case is  x = 0 to x = 1.

Now the example jumps right to the answer being 17/12. The actual steps behind the seen is

= [ 2x - (x^3 / 3) - (x^2 / 4)] from x = 0 to x = 1

=[ (2(1) - (1^3 / 3) - ( 1^2 / 4) - (2(0) - (0^3)/3 - 0^2 / 4) ]

= [ 2 - 1/3 - 1/4 - 0 - 0 - 0]

= [ 2 - 1/3 - 1/4]

=  [ 6/3 - 1/3 - 1/4]  = [ 5/3 - 1/4] = [20/12 - 3/12] = 17/12 units squared. YAH!

So after these steps we have found the area between these two functions from x = 0 to x  = 1.

Find the area:

y = x^(1/3) , and y = x^3 from x = 0 to x = 2.

First thing we should notice about this is that they intersect at  x= 1. Therefore we need to split this up into two different integrals. One from x = 0 to 1, and the other from x = 1 to 2.


= [ 3/4 x ^(4/3) - 1/4 x ^4] from x = 0 to x = 1

= [ 3/4 (1) ^(4/3) - 1/4 (1) ^4 -  3/4 (0) ^(4/3) - 1/4 (0) ^4

= 3/4 - 1/4 - 0 - 0 = 3/4 - 1/4 = 2/4 = 1/2 YAH!

= [ 3/4 x ^(4/3) - 1/4 x ^4] from x = 1 to x =2

= [ 3/4 (2) ^(4/3) - 1/4 (2) ^4 -  3/4 (2) ^(4/3) - 1/4 (2)^4]

= 4 - 3/2(2)^1/3 - 1/4 - 3/4

= 4.5 - 1.5(2)^1/3

So add up the values of both these integrals to get

. 5 + 4.5 - 1.5(2)^1/3 = 3.11 approximate units squared.

This is how you find the area between two functions bounded.

Sunday, 3 April 2011

Critical Numbers

Critical numbers also know as critical points are numbers that can determine what is happening in the function using derivatives. Now that was poorly explained but i will demonstrate the uses.

Lets  find the critical points of the function f(x) = 3x^5 - 20x^3.

Step 1:

First find the first deriviative of f(x)

d(f(x))/dx = 15x^4 - 60x^2

Step 2:

Now set the derivative to zero

f(x)' = 15x ^4 - 60x^2 = 0

15x^2(x^2-4) = 0

15x^2(x+2)(x-2) = 0

so upon inspection we see that x =  -2 , 0 , 2

These x's are ciritical numbers.

Plugging in these found critical points into f(x) our original function we get

f(-2) = 3(-2)^5 - 20(-2)^3 = 64
f(0) = 3(0)^5 - 20(0)^3 = 0
f(2) = 3(2)^5 - 20(2)^3 = -64

These numbers determine where the function has a local max or local min.


Local Maximum: The point where the function has the high mountain or peak in the local area of the function. Being explained the point where y is equal to  a high point of the function or possibly the highest point.

Local Minimum: The point where the function has a low valley or canyon. where y is equal to a lower point on the graph in the local area.

Both definitions are terrible, but if you graph the function using graphing technology you will know what i am talking about.

  A local maximum and local minimum can be determined if the critical points found from the first derivative are plugged into the function. Such that a

local max can be found if f(x) > 0 . By plugging in the critical points of the first derivative.
local min can be found if f(x) < 0 . By plugging in the critical points of the first derivative.


concavity is just a fancy way of saying does the function at a point start to turn into a mountain or into a  valley. Also known as concave up or down.

To find concavity can be just as easy as finding the local min and max. Finding concavity is also another way of finding the local min and max. So you can really kill two birds with one stone by finding the second derivative. First find the second derivative of f(x).

d^2(f(x))/dx^2 = d(15x^4 - 60x^2)/dx = 60x^3 - 120x

So now all you have to do is plug in the critical points from the first derivative.

f(x)'' = 60x^3 - 120x

f(-2)'' = 60(-2)^3 - 120(-2) = -240
f(0)'' = 0 (which tells us nothing, you'll see why)
f(2)'' = 240

Just like the same way of determining the local min and max. This determines both that and concavity.

local max can be found if f(x)'' < 0 . By plugging in the critical points of the first derivative.
local min can be found if f(x)'' > 0 . By plugging in the critical points of the first derivative.

concave down can be found if f(x)'' > 0 . By plugging in the critical points of the first derivative.
concave up can be found if f(x)'' < 0 . By plugging in the critical points of the first derivative.

We know that the function is concave up at x = 2 and has a local min.
We know that the function is concave down at x = -2 and has a local max.

As far as x  = 0, this does not work for our rule/theorem. 

Absolute extreme values

Not so extreme. In a function there has to be a maximum value and a minimum value of the function. If the function was horizontal on a graph, there would be a tie for y = constant value.

so far we know that

We know that the function is concave up at x = 2 and has a local min.
We know that the function is concave down at x = -2 and has a local max.

 Now to find the absolute max and min. We just need to know where the function is at it's highest and where it is at it's lowest point.

So by comparison of all our values of critical points. We can see that our local min and local max are also are absolute min and absolute max.

Easy right!

Endpoint values:

 This is pretty much the simplest of all simple. Lets say our function f(x) was continuous between the closed interval of  [ -5 , 5]. For the endpoint values all you do is plug in these numbers into your equation.

If  f(5) > f(-5)  then 5 is an endpoint max else 5 is an endpoint min and -5 is an endpoint max.


Point of Inflection

A point of inflection is a point such that the function mirror's itself almost. Such a function is x^2 where a point of inflection is (0,0). You can determine a point of inflection easily. To do this you need to find an x such that the second derivative f(x)'' = 0.

So for our second derivative. A point of inflection can be determined by x = 0.

For f(0)'' =60(0)^3 - 120(0) = 0.

A point of inflection is a point such that ( f(x)'' = 0 , f(x)) this is equivalent to ( 0 , f(0))

Where f(0) = 0.

So our point of inflection is (0, 0). Which from observation of graphing technology makes sense. For the function mirrors itself at that point.

Conclusion : 
Knowing these things can help you sketch a graph of your function or understand what your function is doing at certain points. Making them of importance.

Well hopefully this blog helped you understand Critical points. Also i hope this helped me study for my calculus final exam.

Saturday, 2 April 2011

Intermediate Value Theorem

 Intermediate Value Theorem

If f is continuous on the closed interval [ a , b] and K is any number between f(a) and f(b), then there is at least one number c in the interval such that f(c) = K.

You can use this theorem to determine if a polynomial has at least one real root.

To begin using this we first need to know if

f(a) < 0 < f(b)    or  f(b) < 0 <  f(a)

If either of those cases are true. We know that there is a c in the closed interval such that f(c) = 0.

As an example:

we set f(x) = x^2 - 2. We will now test the function for some closed interval. Lets say [1 , 2]. Then lets test these numbers 1 and 2.

f(1) = -1 < 0 and f(2) = 2 > 0.

Therefore we know by the theorem that there exists a number c in the interval [1 , 2] such that f(c) = 0.

Since f increases on [1 , 2], there is only one such number. This number we can see is the square root of 2.

Friday, 1 April 2011

April Fools Day and my 100th Follower

First of all i would like to mention it is April Fools Day.So to start off this morning for my house. I decided to pull the fire alarm, run into my significant others rooms. Scream Fire at the top of my lungs. Get them running outside half nude. To realize that it's ridiculously cold outside and that i just trolled them. So have fun trolls, play safe.

Also  on a side note Donal is my 100th Follower. His blog is
At the moment he only has two posts. But damn are they ever songs you can dance to.