Category Archives: Mathematics


I recently saw this article ( from a comment iBall made on FaceBook.

First, this isn’t that new. It’s been worked on for about a decade now and founded/hypothesized back in 1968. And yeah, from 1968 to about 1999 most of the work was “theoretical.” What I am talking about is a material designed to “catch” electro[magnetism].

In Physics, there is something called the “index of refraction” which is measured by how electro[magnetic] energy changes velocity in a new material. A simple example of refraction is in the case of light into glass or water. Have you ever seen a long rigid pole go into water and thought that it looked bent?

This refraction is the cause for that bend. Light bends as it enters a denser material. This is also true with other forms of electromagnetism including WiFi. If we have an orthogonal normal and send light straight down it from air into glass, we will see the light bend to the left, for example. This would be normal refraction. If the light bent in the opposite direction into a material away from the orthogonal normal, it is said to be a negative index of refraction since it bends into the negative side of our point of reference.

A lot more diffraction/refraction/reflection physics goes on behind the scenes, but for generalization purposes, let’s use these simple examples. Now for a negative refraction to occur, the permittivity and permeability BOTH need to be negative. This is unusual, and doesn’t occur naturally in nature. Some metal materials can have negative permitivity at lower wavelengths of radiation, but to achieve negative permeability, the “meta” material needs to be align and designed to do so. A material which has one, but not both of these negative refraction properties will not allow WiFi’s electro[magnetism] to pass through it.

Let’s not confuse refraction with reflection:

Refraction is a surface phenomenon, but remember the article I wrote addressing the leakage of WiFi and how that should NOT be labeled a “crime” to analyze incoming signals that seemingly trespass (technically it is a shared ISM/free band anyways.) into one’s own property? Well, this “Mylar” material I was speaking of, actually has an extremely low transmittance level due to it’s amazing ability to reflect radiation. In fact, if we analyze a curve or wavelength and transmittance with Mylar, we see that the closer we get to the smaller wavelengths of WiFi (2.4-5GHz) we see the transmittance percent drop completely. This means that mostly all radiation is reflected and nothing passes through. Refraction is a different concept and relies on the density and molecular structure of how the material the light goes into is structured. Permeability and Permittivity are different from refraction and are why i have outlined the word “magnetism” in “electromagnetism” in this article. They deal with how magnetism effects the internal molecular alignment. Lining a room with Mylar, or emergency blankets is a cheap way to keep radiation in and/or out using reflection!

Now, to make a material which is not affected by an external magnetic field (in our case from the electro[magnetism] within an a WiFi signal), we need to make the permeability level negative. This is done in the construction of the meta-material. The meta-material is a set, or aligned grid of SRRs, or “split ring resonators.”

These resonators are just copper split-rings that when affected by electromagnetism generate an internal looping current which in turn generates it’s own magnetism which perfectly opposes the field from the WiFi signal’s electromagnetism. These “rings” are not rings. They are non continuous with a small section removed. This small gap is not visible in the article’s image because they have the SRRs in foam to brace them, but they are there. These rings with small gaps in them allow the SRR to accept a variable of wavelengths larger than the ring itself. If the ring were closed, it would only accept a tiny amount of frequencies.

The rest of the small circuit is just a DC doubler which utilizes the bias of the diodes to direct each portion (negative and positive from the wave) of the AC current into the twin capacitors. This is an extremely simple concept and design. The paper is mostly about how they are optimizing the captured current from the current loops in the SRRs when any RF at around 900MHz is received. WiFi has been used at 900MHz, and will more openly be used at 900MHz with the new 802.11 amendment “ah” The authors are able to harness 7.4VDC at 104mA at the load. Now, if you’re thinking, “great! I could use one of these, I have a WiFi router!” You may be missing the whole picture. This is low power we are talking about here, even if we are to swallow up a large charge into, say, a battery. It would cost less to harness the power to charge that battery directly from your power source at the wall outlet. Let’s take a look at why.

Your router, by default, most likely came equipped with a dipole antenna and is spraying signal at a higher TX than needed for your application. The whole time the little batteries that the authors have designed are filling up with energy from the signal, your router is most likely using 5-12VDC at .250-3A! If we are to lower the amount of low power material our router is spraying, such as beacons which are sent out every 100ms usually, and lower our TX, or transmit power in the router, then use a proper antenna for applications which are wireless but stationary, or close to stationary – we can save more energy – obviously. Also, RF doesn’t necessarily mean 802.11 packets. It can be any radiation at 900MHz or even below (higher wavelengths) due to the simple, yet efficient design of the SRRs. Now, if you thought, “wow! I can harness the power from all RF at 900MHz” – that makes more sense!

Now, let’s scare ourselves. Imagine a low powered trolling drone equipped with a switched GPS radio that searches for a BSSID, or MAC of a phone or station that is powered by leaked RF? :) Next article up: a few WiFi device patents that I can’t afford!



C Comments are hidden messages in the source code that only the developer(s) or anyone with access to the source can see. The generally are used for maintaining code, debugging, and making it easier for expanding your code. Its always good practice to use as much comments as possible when dealing with huge applications. Let’s take a look at how we can add comments into our source code, though we have come across one way already – the // comment.

// Comment

Above we can see someone with a slight obsessive problem to comment small applications in C. The compile simply ignores everything from the double slashes to the end of the line. That’s it. This is a pretty hefty application for what we are used to, but if you have followed along this far you should understand it well enough to know what it does. I just over commented for a nice screen shot :)
Now there’s one more type pf comment I’d like to brush on and that’s the multi-line comment /* */

/* Comment */

The compiler also allows a comment to spread across multiple lines. Once it see’s a starting /* anywhere in our code, it will ignore all lines until it hits a */ end.

And that his how we make a multi-line comment in C. If you were kinda hazy over the meaning of the application from the first example, I completely explain it in this example in a multi-lined comment. This concludes this small tutorial in C comments.


Boolean Logic

Boolean Logic was derived from George Boole’s Algebra that he did back in the mid 19th century. It consists of AND, OR, and NOT. Let’s first take a close look at AND.

AND Logic

Let’s say we have an integer variable a that equals 10. Let’s also assume that we have a while loop that loops 10 times and increments a each time. What could we do if we only wanted to printf(); a when it was 15,16,17,18 and 19? Well we could write out 5 if(){} statements in our compound statement fo rthe while loop like so:

   if(a==15){ printf("%d\n",a); }
   else if(a==16){ printf("%d\n",a); }
   else if(a==17){ printf("%d\n",a); }
   else if(a==18){ printf("%d\n",a); }
   else if(a==19){ printf("%d\n",a); }

This is tedious and not practical whatsoever. This is where AND can be used. Imagine if could just create a condition that said "if 'a' is greater than or equal to 15 AND 'a' is less than or equal to 19." This way we could print 'a' only when we needed to with just one line of code! Well, we can with AND. AND is represented in C with the double ampersand (&&). Let's take a quick look at this in action:

In the image above, I have highlighted the conditional. Here we actualy have two conditionals that MUST be met and return true for the printf(); function to print anything to our screen. The output form the above compiled and ran application is:

a = 15
a = 16
a = 17
a = 18
a = 19

Another great aspect about the Boolean Logic operators, is that you can have as many as you need within the same conditional argument to a if/else if/else statement. Let's try 3. What if we also want to print a if it equals 11, AND 15 through 19? This will require us to use an OR operator, because we literally want to satisfy the condition: "if 'a' is greater than or equal to 15 AND 'a' is less than or equal to 19 OR 'a' is equal to 11." The OR Boolean Logic Conditional Operator is || (that's two pipes (shift+backslash)).

OR Logic

Above I have highlighted again the conditionals that need to be met in the if(){} statement. The OR (||) is used to express that we also would like to have 'a' printed out if it equals 11. We have actually already used OR logic with the <= and >= operators, which state "less than OR equal to" and "greater than OR equal to."

Obviously OR is good when we want to print out either this, or that, or whatever. So let's just jump into another example. Say we want to print out ONLY when 'a' equals 11, 13, and 18. There's no range we can use like in the above example. We would either have to try out a few if/else if statements, or just use OR.

   printf("a = %d\n",a);
}else if(a==13){
   printf("a = %d\n",a);
}else if(a==18){
   printf("a = %d\n",a);

Tedious, redundant, not practical. Lets use OR and shorten that code into one single line:

   printf("a = %d\n",a);

Nice and tidy :) This compiled and ran application yields the following output:

a = 11
a = 13
a = 18

Which is exactly what we wanted. OR allows us to be very precise with what output we want and with minimal code. But, what if we wanted to print out a from 10 through 20 except for when 'a' equals 16, because we hate the number 16? Well, we can do that with a NOT or ! conditional logic operator.

NOT Logic

Let's say 'a' equals 11 and our while loop increments the value of 'a' until it reaches 20. We also want to printf(); 'a' each time, except when it equals 16. Well we can just printf(); 'a' each time through the while(){} loop from within a NOT equals if(){} statement:

When compiled and ran, the above application yields:

a = 10
a = 11
a = 12
a = 13
a = 14
a = 15
a = 17
a = 18
a = 19
a = 20

Perfect! Everything BUT 16! This is how the NOT conditional Logic Operator works. Remember we can have multiple conditional operators in the same if(){} conditional argument. So what if we didn't want to also printf(); 'a' when it equaled 18?

In the above code, I have buddied up AND and NOT to select all 'a' printf(); except when 'a' equals 16 AND when 'a' equals 18.

Multiple Contidionals

Always remember that you may have as many conditional operators as you wish the the conditional argument for while(){},if(){},else if(){}, and for(;;){}. This makes our program far more powerful with minimal code. That's a goal to struggle for! I hope you have enjoyed these tutorials so far, and if you have learned anything from me in how I explain things, please consider hitting that donate button up and to the right - it really helps me to help you! :S If you have found discrepancies please email me at the address in the above header image. Let's continue on to write some comments into our code!


Looping Around

In programming we have something called a “loop.” It looks like the if(){} statement and runs exactly the same, but repeats over and over ONLY while the conditional portion (in parenthesis) returns false. This is good for doing repetitive tasks or checking how many items are in a list by looping through them. It’s a fundamental concept that you’ll easily get familiar with and use in almost all of your applications. In this tutorial I will be covering three different finds of loops, the while, for and do while loops. Let’s first take a look at the for loop.

For Loops

Remember the increment unary operator from the first tutorial? It simple increments a variable by one. If we have an integer variable ‘a’ and it holds the value of 41, we can use the increment operator on a in either a postfix or prefix manner to boost that value up by one making it 42:

int a = 41;
a++; // postfix
printf("the value of a is %d\n",a);

This code snippet when used in a C program will print out “the value of a is 42” and exit. Remember the comment is just a way to put comments into your source code for your eyes only and we can make them with two forward slashes. The compiler will ignore all the stuff from there until the end of the line. In the example above we put in a comment saying that we are using the postfix unary increment operator. So how does this apply to loops? Well, let’s use that ‘a‘ variable and print out ‘a‘ and increment it until it reaches 50:

The application source code above shows how easy it is to start and end a for loop. The for(){} structure is just like the if(){} structure, but repeats itself over and over until the conditional statement returns false. Let’s take a look at the conditional statement in the for loop. It consists of 3 parts that are semi-colon separated: int a=41, a<=50, and a++. The first part initializes the local integer variable 'a' to hold the value of 41. Now, if we are using a shell, we may need to add -std=c99 to the gcc command to get this source code to compile correctly:

[trevelyn@shell ~/study]$ gcc c99.c -o c99
c99.c: In function 'main':
c99.c:3: error: 'for' loop initial declaration used outside C99 mode
[trevelyn@shell ~/study]$ gcc -std=c99 c99.c -o c99
[trevelyn@shell ~/study]$ ./c99
the value of a is 41
the value of a is 42
the value of a is 43
the value of a is 44
the value of a is 45
the value of a is 46
the value of a is 47
the value of a is 48
the value of a is 49
the value of a is 50
[trevelyn@shell ~/study]$

This is because that syntax wasn't used until standard c99 and the compiler needs to be in that compatibility mode to compile this correctly. We could, however, declare 'a' outside of the for loop like so:

int a;
   printf("a is now: %d\n",a);

Which would work just fine. The second portion of the conditional says a<=50 and means just that "keep going until 'a's stored value reaches 50." The third part means to postfix increment 'a' after each iteration of the code within curly braces. A prefix increment to 'a' (++a) would increment 'a' before each interval. The rest we already know - a printf(); in the block with a simple integer format specifier interpolated for 'a.'

This is a for(){} loop. Very simple and yet very powerful. We can put incredibly complex code into the compound statement (in the curly braces), or we could use something as simple as just printing to our screen using the handy printf(); function provided by stdio.h

While Loops

Another type of loop we will cover is a while(){} loop.

The code above has a simple while loop. "While 'a' is less than 50 then printf(); the value of 'a'" It looks almost just like the for(){} loop statement, but doesn't have it's own initializer for 'a' and doesn't have it's own operation on 'a' (like how for(){} had a++).

We can prove the fact that the code within our compound statement runs ONLY if the while loop condition returns true by decrementing a variable until it reaches 0 which is the same as it being false. Let's give that a try:

When compiled and ran, this will yield:

a is 9
a is 8
a is 7
a is 6
a is 5
a is 4
a is 3
a is 2
a is 1

a = 0 is not displayed because that is where the while loops conditional (a) becomes false. During every other iteration 'a' equaled a positive integer that made 'a' true. This is the simplest while loop example I can think of. Let's next cover our last loop, the loop do while loop.

Do While

The do{}while(); statement is just like the while statement, but rearranged and the word "do" is added. Also, this statement MUST be terminated with a semi-colon.

This yields the output:

a = 9
a = 8
a = 7
a = 6
a = 5
a = 4
a = 3
a = 2
a = 1

In the image I have highlighted the statement which I spread across a few lines. This make it easier to read when debugging. With these loops we can do quite a lot. The conditional statement can have more than one conditional using Boolean's logic (OR, and AND). Let's take a look at how we can expand what we know now with loops using Boolean Logic operators in or next tutorial.


Checking Sanity

Let’s check to see if it is worth continuing or not after receiving user data. This is commonly referred to as a sanity check. We will be using a new syntax for this called an if clause that will check to see if our user input integer is at least 3 in value. First, let’s take a look at some simple mathematical comparison operators.

x == y : x value equals y’s value (not to be confused with the left hand assignment operator!)
x < y : x's value is less than y's value.
x > y : x's value is greater than y's value.
x <= y : x's value is less than or equal to y's value.
x >= y : x's value is greater than or equal to y's value.
x != y : x's value does not equal y's value.
x : x is true.
!x : x is not true.

Now that we got those, which we have learned early on in school. How do we use these? Well, we just put them into parenthesis in our application. Just after those parenthesis we put a block of code in curly braces that we want to execute if the statement evaluates to true. Let's take a look at a simple example to get our feet wet with an if(){} clause/conditional/statement.

In the above code we see some new syntax. The code within the curly braces {} is the block of code (in our example is only one line, 6) that will execute if the statement (a < b) returns true. Which it does. This statement literally just says "if a is less than b then print this sentence: 'a is less than b'". This is very easy to do. Also, you may have noticed that the entire statement that contains the clause and block of code doesn't get terminated with a semi-colon! No semi-colon goes after the if(){}. Doesn't this look just like a function? if(argument){code to run} <-- It is, but runs ONLY if the condition statement (in that example "argument") returns true. The if(){} statement can be thought of as a function that takes only 1 argument that is a conditional statement and runs ONLY if that argument returns true.

What if we want something to run if a < b and something else if a > b? then we need an else{} block of code right after our if(){} statement. Let's take a look at the same example modified to say whether OR NOT a is less than b.

This new syntax if(){}else{} will cause our application to print out "a is less than b!" when compiled and ran. Let's try this again using user input.

There we go! Something our users will actually want to use! Let's brush up on our syntax as a whole as we go down through this new piece of code. The first two lines are preprocessor directives that include headers files, stdio.h and stdlib.h that reside somewhere on our file-system in the compiler's path. Next we define our main(){} function. Always remember if not using an IDE that our C Programs will always need a main(){} function to run. We then define two arguments that main(){} takes. the integer count of total arguments argc, and the character pointer list of the actual arguments argv[]. In the compound statement of main(){} (within the curly braces) we define two integer variables a an b that are actually argv[1] and argv[2] respectively. So if we run this application with "run 4 5" on or "./a.out 4 5" in our shell, 'a' will equal 4 and 'b' will equal 5. Next, we have what call an if else statement. It states that if 'a' is less than 'b,' then print "a is less than b!" That only leaves us with two other states this relationship could be in: 'a' equals 'b' or 'a' is greater than 'b'.

Well, wait a minute, if the first and second arguments are equal to eachother then we will get an output similar to:

5 is greather than 5!

Which is absurd. This is what is commonly referred to as a semantic error. It's not an error in syntax, but one in logic. Let's go ahead and add an else if clause into our statement and modify the else code block to say that the integers are equal.

There we go! Much better! Now if we pass 5 and 5 as arguments to the application, (with do "run 5 5" and with a Linux or UNIX-like shell, do ./appname 5 5) it will tell us that they are equal. By now you should fully understand the application above. And look at it, isn't it a beauty? It uses header files and pointers and special functions and logic. It's a sweet application!

Now that we know all about data-types, that input is always a char pointer and how to convert the data into integers using atoi(); we can write just about any number function in C Programming that doesn't involve loops. Loops are also pretty awesome. They allow us to loop over lists or sets of data. That about wraps up our tutorial on C If/Else/Else If statements. In our next tutorial we will look at - you guessed it - loops!


Layout mode
Predefined Skins
Custom Colors
Choose your skin color
Patterns Background
Images Background