Jumpi’s Notepad

My annotations about the life, universe and everything!!! ;)

Archive for the ‘english’ Category

Visualizing Floats

with 2 comments

Continuing the posts about data types and your characteristics, I read a nice article about Floating point numbers published by gamasutra:

http://www.gamasutra.com/view/feature/1965/visualizing_floats

See ya!!!

Advertisements

Written by jumpi

January 14, 2009 at 3:50 pm

Posted in english, Math, Programming

The Practice of Perl II

with one comment

Upon requesting made and continuing my posts about perl practicality, show here a very elaborated code, extract from classic book that I have reading again, Pike & Kerninghan Practice of Programming.

Yes, this book have a very interesting example of Markov Chains in perl.

For those that dont knowing about Markov Chains, this is a particular case in stochastic process, where previous states are irrelevant for prediction of following states, since that actual state is knowing. This technique is very used for generate random text, as in the book example, but, the author uses only cases that envolve two-word prefixes, for test effects.

The code used in the example, written in perl language:

$MAXGEN = 10000;
$NONWORD = “\n”;
$wl = $w2 = $NONWORD;
while (<>) {
foreach (split) {
push(@{$statetab{$w1}{$w2}}, $_);
($w1, $w2) = ($w2, $_);
}
}
push(@($statetab{$w1}{$w2}}, $NONWORD);
$w1 = $w2 = $NONWORD;
for ($i = 0; $i < $MAXGEN; $i++) {
$suf = $statetab{$w1}{$w2};
$r = int(rand @$suf);
exit if(($t = $suf->[$r]) eq $NONWORD);
print “$t\n”;
($w1, $w2) = ($w2, $t);
}

And more impressive is what the result is make of simple and rapid form, very rapid, in the final of chapter has a performance table where perl losing only for C implementation, other implementations are written in Java, C++/STL/Deque, C++/STL/List and AWK, being that have 150 lines of code in C versus only 18 in perl.

Well, I dont make apologies to perl, because I love C too, but, as the author says and define in the final of paragraph, scripting languages (perl, in this case) are a good choice for experimental programming and making prototypes, and I conclude, for rapid tasks and tests, perl is again language of my choice.

Written by jumpi

January 6, 2008 at 8:43 pm

Posted in english, Programming

Tagged with , , , ,

The Excel 2007 Bug

with 4 comments

About the bug that affected Excel 2007, I think that is very hard to work with floating point calculations and approximation is very complex and find a problem in logic of this is a true nightmare!!!!

The summary of problem: Excel 2007 store six floating point numbers using binary representation between 65534.99999999995 and 65535, and dont store six between 65535.99999999995 and 65536 and this numbers are the cause of this problem.

I work with arbitrary precision in my scientific intiation and using libraries for care of this part for me, because of difficulties that involve the manipulation of calculate numbers that need arbitrary precision. IMHO, working with type of development demands very attention and very pacience.

The two links have a good explanation of this problem… Its a good lecture!!!

The Excel Bug Explanation by Good Math, Bad Math Blog
The Excel Bug Explanation for Mathematica Developers Blog

See ya people and have a good fun!!!

In play: Emerson, Lake and Palmer – Works (Black) Vol. 1 – 07: The Enemy God

Written by jumpi

October 3, 2007 at 8:54 pm

Posted in english, Math, Programming

Tagged with , ,

Really, Code::Blocks Rocks!!!

with 2 comments

Really, Code::Blocks Rocks!!!

Well… after a long time I post here again, because of this IDE… yeah… a many time that I try to test it and after tests of my friend Marcio that use and talk about the tool I decided test too. I’m very surprise with this IDE, the installation is very easy and work with this IDE is very easy too… I install it in my VM with WinXP and I testing the OpenGL app and it works very fine… The OpenGL app works fine in my VM too, in considerable time… I decided now use the Code::Blocks for developing my personal project at this time!!! Its convinced me!!! 😀

Today, after reading some pages of the Programming Challenges Book I’m trying applying some memoization and dynamic programming techniques for solve some problems in SPOJs and UVA’s online-judge of life. Its a very utility tool for solving many problems. But I need more training for good application of this. I like this… 😀

In play: Bruce Dickinson – The Very Best Of (CD 1) – 02: Tattooed Millionarie

Written by jumpi

September 15, 2007 at 11:13 pm

Posted in english, Programming

The Practice of Perl

with one comment

Well.. a sugestive title for an post, but I decide for this title because of Perl is one of my prefer programming languages, my “swiss army knife”… and dont first time that I using perl for solving my problem… ehehehhehehehhee…

But why I talking about perl here??? Because of one problem, for more exactly, the problem 5 of Project Euler (http://projecteuler.net/), a site with mathematical problems that resolve with the use of algorithms. The problem 5 it follows below:

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

I trying resolve this using C, but I dont have an simple compiler in my work machine,because in my opinion, Visual C is much complex for this task… (some of my friends dont think it…)

But I think… I have perl interpretor in my machine and write this program in perl dont much harder and I starting the port of C for Perl and write this piece of code for solving my problem:

for ( my $n = 20; 1; $n++ ) {
for ( 1..20 ) {
if ( $n % $_ ) {
last;
}
if ( $_ == 20 ) {
die $n;
}
}
}
Well… is an idiot program, extremaly simple but I have the answer of problem with this… dont consider the execution time, “only” 20 min of the pure brute force for answering the problem… ehehhehehehehehhehe…

And perl with your practical syntax save my world one more time!!!! 😀

In Play: Gorguts – The Erosion of Sanity – 04: Orphans of Sickness

Written by jumpi

August 9, 2007 at 4:22 am

Posted in english, Programming

You’re Perl

with 3 comments

After long time that dont post here… I’m posting here again the result of language test that I see and answering… 😀

Ohhhhhhh… This test is very funny!!!! Perl is my favorite language for write scripts… I like this…

You’re Perl

“You are Perl. People have a hard time understanding you, but you are always able to help them with almost all of their problems.”

For all that answering the questions too, the phrase above contains the link!!!

Thanks for all that see this blog… 😀

Written by jumpi

April 30, 2007 at 5:07 pm

Posted in english, Pessoal

Love and Tensor Algebra

leave a comment »

Come, let us hasten to a higher plane
Where dyads tread the fairy fields of Venn,
Their indices bedecked from one to n
Commingled in an endless Markov chain!
Come, every frustrum longs to be a cone
And every vector dreams of matrices.
Hark to the gentle gradient of the breeze:
It whispers of a more ergodic zone.
In Riemann, Hilbert or in Banach space
Let superscripts and subscripts go their ways.
Our asymptotes no longer out of phase,
We shall encounter, counting, face to face.
I’ll grant thee random access to my heart,
Thou’lt tell me all the constants of thy love;
And so we two shall all love’s lemmas prove,
And in our bound partition never part.
For what did Cauchy know, or Christoffel,
Or Fourier, or any Bools or Euler,
Wielding their compasses, their pens and rulers,
Of thy supernal sinusoidal spell?
Cancel me not – for what then shall remain?
Abscissas some mantissas, modules, modes,
A root or two, a torus and a node:
The inverse of my verse, a null domain.
Ellipse of bliss, converge, O lips divine!
the product o four scalars is defines!
Cyberiad draws nigh, and the skew mind
Cuts capers like a happy haversine.
I see the eigenvalue in thine eye,
I hear the tender tensor in thy sigh.
Bernoulli would have been content to die,
Had he but known such a^2 cos 2 phi!

Written by jumpi

March 4, 2007 at 2:47 am

Posted in english, Math