<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>O-Auto-Falante</title>
    <link>http://www.diale.org/w3log/08.fev.html</link>
    <description>W3log de Tiago Charters de Azevedo (Comentários para: tca@diale.org)</description>
    <language>en-us</language>
    <generator>Emacs Muse</generator>

<item>
<title>Algoritmo de Porter</title>
<link>http://www.diale.org/w3log/08.fev.html#Algoritmo%20de%20Porter</link>
<description><![CDATA[
<p>Tenho andado a implementar o <a href="http://tartarus.org/~martin/PorterStemmer/index.html">algoritmo de Porter</a> para <a href="http://snowball.tartarus.org/algorithms/portuguese/stemmer.html">português</a> em Emacs
Lisp. Está quase todo pronto. Pelo caminho encontrei o <a href="http://en.wikipedia.org/wiki/SNOBOL">SNOBOL</a> e teve como
consequência imediata a reescrita quase total do código original em termos de
funções em Lisp que implementam as instruções em SNOBOL. O prazo que impus a mim
mesmo, o dia de hoje, para acabar o código acabou. É pena.</p>

<p>Referências:</p>

<ul>
<li><a href="http://en.wikipedia.org/wiki/SNOBOL">http://en.wikipedia.org/wiki/SNOBOL</a></li>
<li><a href="http://tartarus.org/~martin/">http://tartarus.org/~martin/</a></li>
<li><a href="http://tartarus.org/~martin/PorterStemmer/def.txt">http://tartarus.org/~martin/PorterStemmer/def.txt</a></li>
<li><a href="http://portal.acm.org/citation.cfm?id=321203.321207">http://portal.acm.org/citation.cfm?id=321203.321207</a></li>
<li><a href="http://informationr.net/ir/12-3/paper315.html">http://informationr.net/ir/12-3/paper315.html</a></li>
<li><a href="http://snowball.tartarus.org/texts/introduction.html">http://snowball.tartarus.org/texts/introduction.html</a></li>
</ul>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Fri, 29 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Algoritmo%20de%20Porter</guid>
<enclosure url="http://tartarus.org/~martin/PorterStemmer/index.html" type="application/octet-stream"/>
</item>

<item>
<title>Verbos irregulares e sua evolução</title>
<link>http://www.diale.org/w3log/08.fev.html#Verbos%20irregulares%20e%20sua%20evolução</link>
<description><![CDATA[
<p>Num artigo do passado mês de Outubro sobre a evolução da linguagem
(<a href="http://www.nature.com/nature/journal/v449/n7163/abs/nature06137.html">Quantifying the evolutionary dynamics of language</a>,Nature 449,
713-716 (11 October 2007) ver link no fim do texto), e em
particular sobre a evolução dos verbos irregulares em regulares, podia ler-se:</p>

<blockquote>
<p class="quoted">
&quot;To quantify the dynamics of language evolution, we studied the regularization of
English verbs over the past 1,200 years. (...)
Here we describe the emergence of this linguistic rule amidst the evolutionary
decay of its exceptions, known to us as irregular verbs. We have generated a
data set of verbs whose conjugations have been evolving for more than a
millennium, tracking inflectional changes to 177 Old-English irregular verbs. Of
these irregular verbs, 145 remained irregular in Middle English and 98 are still
irregular today. We study how the rate of regularization depends on the
frequency of word usage. The half-life of an irregular verb scales as the square
root of its usage frequency: a verb that is 100 times less frequent regularizes
10 times as fast. (...)&quot;</p>

</blockquote>

<p>Uma das maneiras de pensar no problema seria estudar a evolução temporal da
probabilidade de encontrar um verbo irregular num texto num dado instante. Seja
<!-- $p_n(t)$--><img src="./latex/latex2png-08.fev__2386087606.png" alt="latex2png equation" class="latex-inline"> a probabilidade de encontrar <em>n</em> verbos num instante <em>t</em>. Se se
admitir que parte destes verbos se tornam regulares com uma probabilidade
<!-- $\mu n  p_n(t)\delta$--><img src="./latex/latex2png-08.fev__1920586359.png" alt="latex2png equation" class="latex-inline">, então um texto com <em>n</em> verbos irregulares teve origem num
texto com <em>n</em> ou <em>n+1</em> verbos irregulares, e logo</p>

<!-- $
p_n(t+\delta t)=\mu (n+1)p_n(t)\delta t+(1-\mu n \delta t)p_n(t)
$--><img src="./latex/latex2png-08.fev__1498073772.png" alt="latex2png equation" class="latex-inline">.

<p>Definindo a função geradora</p>

<!-- $
\displaystyle p(x, t)=\sum_{n=0}^\infty p_n(t) x^n
$--><img src="./latex/latex2png-08.fev__1322882553.png" alt="latex2png equation" class="latex-inline">

<p>e passando ao  limite  <!-- $\delta t\to 0$--><img src="./latex/latex2png-08.fev__2081467423.png" alt="latex2png equation" class="latex-inline"> obtém-se uma equação às derivadas
parciais com a forma</p>

<!-- $
\displaystyle \frac{\partial p}{\partial t}+\mu(x-1) \frac{\partial p}{\partial x}=0.
$--><img src="./latex/latex2png-08.fev__2321659310.png" alt="latex2png equation" class="latex-inline">

<p>Admitindo que inicialmente se tem <em>N</em> verbos irregulares a solução da equação
anterior é</p>

<!-- $
\displaystyle p(x,t)=\left(1+(x-1)e^{-\mu t}\right)^N
$--><img src="./latex/latex2png-08.fev__506045091.png" alt="latex2png equation" class="latex-inline">

<p>Se esta abordagem permite fazer mais qualquer coisa não sei...</p>

<p>Ref:  Erez Lieberman, Jean-Baptiste Michel Joe Jackson1, Tina Tang
&amp; Martin A. Nowak <a href="http://www.nature.com/nature/journal/v449/n7163/abs/nature06137.html">Quantifying the evolutionary dynamics of language</a>, Nature 449, 713-716 (11 October 2007)</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Tue, 26 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Verbos%20irregulares%20e%20sua%20evolução</guid>

</item>

<item>
<title>Número de operações</title>
<link>http://www.diale.org/w3log/08.fev.html#Número%20de%20operações</link>
<description><![CDATA[
<p>Quer calcular-se o valor do polinómio de grau <!-- $P(x)=a x^2 + b x +c$--><img src="./latex/latex2png-08.fev__1204908078.png" alt="latex2png equation" class="latex-inline">. Para
isso é necessário efectuar 5 operações 2 somas + 3 produtos. Uma maneira simples
de reduzir o número de operações, reduzindo a 4 operações (2 somas e 2
produtos), é factorizar o polinómio na forma
<!-- $P(x)=c + x(a x +b)$--><img src="./latex/latex2png-08.fev__2247644338.png" alt="latex2png equation" class="latex-inline">. A coisa engraçada é se implementar o cálculo de
<!-- $P(x)$--><img src="./latex/latex2png-08.fev__43176628.png" alt="latex2png equation" class="latex-inline"> em Lisp fica

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">P</font> (x a b c)
  (+ c (* (+ (* a x) b) x)))

(P 1 1 2 3)<font color="#b22222">; 6</font></pre>

que é a forma factorizada anterior que tem o numero mínimo de operações.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Tue, 26 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Número%20de%20operações</guid>

</item>

<item>
<title>Haar - GNU/Octave</title>
<link>http://www.diale.org/w3log/08.fev.html#Haar%20%2D%20GNU%2FOctave</link>
<description><![CDATA[
<p>Código em GNU/Octave que calcula a decomposição em wavelets (Haar).

<pre>
<font color="#a020f0">function</font> c=<font color="#0000ff">haar</font>(y,n)
  ly=length(y)-1;
  x=[0:1/ly:1];
  <font color="#a020f0">for</font> i=0:n
    <font color="#a020f0">for</font> j=0:2^i-1
      c(i+1,j+1)=2^(i)*trapz(x,y.*mf(2^(i).*x-j));
    <font color="#a020f0">endfor</font>;
  <font color="#a020f0">endfor</font>;
<font color="#a020f0">endfunction</font></pre>
</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Sat, 23 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Haar%20%2D%20GNU%2FOctave</guid>

</item>

<item>
<title>Quaterniões</title>
<link>http://www.diale.org/w3log/08.fev.html#Quaterniões</link>
<description><![CDATA[
<p>As rotações espaciais  podem ser parametrizadas pelos ângulos de Euler <!-- $(\phi,
\theta,\psi)$--><img src="./latex/latex2png-08.fev__4281653399.png" alt="latex2png equation" class="latex-inline"> e por quaterniões unitários <!-- $\mathbf{q}=(q_0,q_1,q_2,q_3)$--><img src="./latex/latex2png-08.fev__775776150.png" alt="latex2png equation" class="latex-inline">. Um
quaternião unitário é descrito por um vector unitário  num espaço 4D com a forma
<!-- 
\begin{eqnarray*}
\mathbf{q}&=&(q_0,q_2,q_2,q_3)\\
\mathbf{q}^T\mathbf{q}&=& q_0^2+q_1^2+q_2^2+q_3^2=1
\end{eqnarray*}
--><img src="./latex/latex2png-08.fev__2049017405.png" alt="latex2png equation" class="latex-display"></p>

<p>É possível relacionar os ângulos de Euler com os quaterniões através das expressões</p>

<!-- 
\begin{eqnarray*}
  \phi&=&\arctan\left(\frac{2(q_0q_1+q_2q_3)}{1-2(q_1^2+q_2^2)}\right)\\
  \theta&=&\arcsin\left(2(q_0q_2-q_3q_1)\right)\\
  \psi&=& \arctan\left(\frac{2(q_0q_3+q_1q_2)}{1-2(q_2^2+q_3^2)}\right)
\end{eqnarray*}
--><img src="./latex/latex2png-08.fev__3762604309.png" alt="latex2png equation" class="latex-display">

<p>A matriz de rotação fica com a forma</p>

<!-- $
  R=\left(
\begin{matrix}
2q_0^2-1+2q_1^2&2q_1q_2-2q_0q_3&2q_0q_2+2q_1q_3\cr 2q_1q_2+2q_0q_3&2q_0^2-1+2q_2^2&2q_2q_3-2q_0q_1\cr
    2q_1q_3-2q_0q_2&2q_0q_1+2q_2q_3&2q_0^2-1+2q_3^2
\end{matrix}
\right)
$--><img src="./latex/latex2png-08.fev__1533587902.png" alt="latex2png equation" class="latex-inline">

<p>forma mais simpática relativamente à matriz de rotação usando ângulos de Euler.</p>


<p><strong>Ref:</strong>  James Diebel, <em>Representing Attitude: Euler Angles, Quaternions, and Rotation Vectors</em>, <a href="http://ai.stanford.edu/~diebel/attitude/attitude.pdf">http://ai.stanford.edu/~diebel/attitude/attitude.pdf</a></p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Sat, 23 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Quaterniões</guid>

</item>

<item>
<title>Médias móveis - GNU/Octave</title>
<link>http://www.diale.org/w3log/08.fev.html#Médias%20móveis%20%2D%20GNU%2FOctave</link>
<description><![CDATA[

<pre>
<font color="#a020f0">function</font> mavgv=<font color="#0000ff">mavg</font>(x,m)
  n=length(x);
  mavgv=ones(1,m);
  <font color="#a020f0">for</font> j=m+1:n;
    mavgv(j)=mean(x(j-m:j));
  <font color="#a020f0">endfor</font>;
<font color="#a020f0">endfunction</font></pre>


<p>Claro que esta não é a maneira mais rápida de as calcular.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Sat, 23 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Médias%20móveis%20%2D%20GNU%2FOctave</guid>

</item>

<item>
<title>Mais funções</title>
<link>http://www.diale.org/w3log/08.fev.html#Mais%20funções</link>
<description><![CDATA[

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">list-to-string</font> (l)
  <font color="#bc8f8f">"Return a STRING which is the concatenation of the elements of
L."</font>
  (<font color="#a020f0">if</font> (not l)
      nil
    (<font color="#a020f0">if</font> (stringp (car l))
        (concat (car l) (list-to-string (cdr l)))
      (list-to-string (cdr l)))))
</pre>

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">join-string</font>(xs <font color="#228b22">&amp;optional</font> sep)
  (<font color="#a020f0">cond</font> ((null xs) <font color="#bc8f8f">""</font>)
        ((null (cdr xs)) (car xs))
        (t (concat (car xs) (or sep <font color="#bc8f8f">""</font>) (join-string (cdr xs) sep)))))
</pre>

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">mistura</font> (frase)
  <font color="#bc8f8f">"Faz o cut-up de uma dada frase, isto &#233;, retorna uma
   frase com os mesmo elementos mas com ordem aleat&#243;ria"</font>
  (setq frasecu ())
  (setq listafrase (split-string frase))
  (random t)
  (<font color="#a020f0">while</font> listafrase
    (setq palavra
          (nth (random (length listafrase)) listafrase))
    (setq frasecu (cons palavra  frasecu))
    (setq listafrase (delq palavra listafrase)))
  (insert (join-string frasecu <font color="#bc8f8f">" "</font>))
)</pre>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Fri, 22 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Mais%20funções</guid>

</item>

<item>
<title>Convert a string into a list of strings</title>
<link>http://www.diale.org/w3log/08.fev.html#Convert%20a%20string%20into%20a%20list%20of%20strings</link>
<description><![CDATA[

 <pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">string-to-strings</font> (s)
    <font color="#bc8f8f">"Convert a string into a list of strings."</font>
    (<font color="#a020f0">let</font> ((i (- (length s) 1)) (l '()))
      (<font color="#a020f0">while</font> (&lt;= 0 i)
        (setq l (cons (aref s i) l)
              i (- i 1)))
      (mapcar (<font color="#a020f0">lambda</font> (x) (char-to-string x)) l)))</pre>



   <pre>
(string-to-strings <font color="#bc8f8f">"Rosa Lim&#227;o"</font>) <font color="#b22222">; ("R" "o" "s" "a" " " "L" "i" "m" "&#227;" "o")
</font>
</pre>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Fri, 22 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Convert%20a%20string%20into%20a%20list%20of%20strings</guid>

</item>

<item>
<title>Binómio de Newton</title>
<link>http://www.diale.org/w3log/08.fev.html#Binómio%20de%20Newton</link>
<description><![CDATA[
<p>Ao contrário do que sucede  na <a href="./08.fev.html#R%8E9gua%20de%20Golomb">entrada anterior</a> o binómio de Newton tem uma
regularidade bem definida no que toca à distribuição dos números pares,
múltiplos de 3, etc.</p>

<table class="image" width="100%">
  <tr><td align="center"><img src="./img/binN.jpg" alt="Distribuição dos números múltiplos de: 2, 3, 4, e 5 no binómio de Newton, respectivamente, de cima para baixo."></td></tr>
  <tr><td align="center" class="image-caption">Distribuição dos números múltiplos de: 2, 3, 4, e 5 no binómio de Newton, respectivamente, de cima para baixo.</td></tr>
</table>

<p>Deixo aqui o código que o calcula assim como a imagem que se obtém no fim. Claro
que usei o <a href="http://www.octave.org">Octave</a> para fazer estas coisas.


<pre>
<font color="#b8860b">split_long_rows</font>=0;

<font color="#a020f0">function</font> a=<font color="#0000ff">onetozero</font>(a)
  n=length(a);
  <font color="#a020f0">for</font> i=1:n
    <font color="#a020f0">for</font> j=1:n
      <font color="#a020f0">if</font> a(i,j)<font color="#da70d6">&gt;</font>0
        a(i,j)=0;
      <font color="#a020f0">else</font>
        a(i,j)=1;
      <font color="#a020f0">endif</font>;
    <font color="#a020f0">endfor</font>;
  <font color="#a020f0">endfor</font>;
<font color="#a020f0">endfunction</font>;

n=60;
a=zeros(n,n);
a(1,1)=1;
a(2,1)=1;a(2,2)=1;
a(:,1)=ones(n,1);
<font color="#a020f0">for</font> j=2:n
  <font color="#a020f0">for</font> i=3:n
    a(i,j)=a(i-1,j-1)+a(i-1,j);
  <font color="#a020f0">endfor</font>;
<font color="#a020f0">endfor</font>;
<font color="#b22222">#a;</font>
a2=onetozero(mod(a,2));
a3=onetozero(mod(a,3));
a4=onetozero(mod(a,4));
a5=onetozero(mod(a,5));
sp=ones(10,n);

imshow([a2;sp;a3;sp;a4;sp;a5],<font color="#bc8f8f">"truesize"</font>);
</pre>
</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Wed, 20 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Binómio%20de%20Newton</guid>

</item>

<item>
<title>Régua de Golomb</title>
<link>http://www.diale.org/w3log/08.fev.html#Régua%20de%20Golomb</link>
<description><![CDATA[
<p>A <a href="http://en.wikipedia.org/wiki/Golomb_ruler">régua de Golomb</a> é constituída por uma série de marcas, com posição dada por um
inteiro, de modo a que qualquer distância entre duas marcas sucessivas quaisquer
nunca se repete.</p>

<p>Se as arranjar numa matriz (as linhas indexam a ordem da régua), ficam (usei o
<a href="http://www.octave.org">Octave</a> para estes cálculos),


<small>
<pre>
A=[
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 9 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 10 12 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 10 15 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 8 11 13 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 8 12 14 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 10 18 23 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 7 11 20 23 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 11 16 19 23 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 2 3 10 16 21 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 2 7 13 21 22 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 9 15 22 32 34 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 5 12 25 27 35 41 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 6 10 23 26 34 41 53 55 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 4 13 28 33 47 54 64 70 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 9 19 24 31 52 56 58 69 72 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 2 6 24 29 40 43 55 68 75 76 85 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 2 5 25 37 43 59 70 85 89 98 99 106 0 0 0 0 0 0 0 0 0 0 0 0;
0 4 6 20 35 52 59 77 78 86 89 99 122 127 0 0 0 0 0 0 0 0 0 0 0;
0 4 20 30 57 59 62 76 100 111 123 136 144 145 151 0 0 0 0 0 0 0 0 0 0;
0 1 4 11 26 32 56 68 76 115 117 134 150 163 168 177 0 0 0 0 0 0 0 0 0;
0 5 7 17 52 56 67 80 81 100 122 138 159 165 168 191 199 0 0 0 0 0 0 0 0;
0 2 10 22 53 56 82 83 89 98 130 148 153 167 188 192 205 216 0 0 0 0 0 0 0;
0 1 6 25 32 72 100 108 120 130 153 169 187 190 204 231 233 242 246 0 0 0 0 0 0;
0 1 8 11 68 77 94 116 121 156 158 179 194 208 212 228 240 253 259 283 0 0 0 0 0;
0 2 24 56 77 82 83 95 129 144 179 186 195 255 265 285 293 296 310 329 333 0 0 0 0;
0 1 9 14 43 70 106 122 124 128 159 179 204 223 253 263 270 291 330 341 353 356 0 0 0;
0 3 7 17 61 66 91 99 114 159 171 199 200 226 235 246 277 316 329 348 350 366 372 0 0;
0 9 33 37 38 97 122 129 140 142 152 191 205 208 252 278 286 326 332 353 368 384 403 425 0;
0 12 29 39 72 91 146 157 160 161 166 191 207 214 258 290 316 354 372 394 396 431 459 467 480]
</pre>
</small>
</p>

<p>Para tentar perceber se existe alguma regularidade nestes números fiz
<code>mod(A,2)</code>, substituindo os <code>0</code> por um espaço em branco. Obtém-se

<pre>
     1
     1  1
     1
     1     1  1
     1           1
     1        1  1
     1     1  1  1
     1           1
     1           1  1
     1  1  1     1  1
     1  1     1  1  1
        1        1  1
        1  1  1     1
     1     1  1
     1  1     1  1  1  1
     1        1        1  1  1
     1     1     1  1
     1  1  1     1           1
              1     1  1     1     1
        1  1  1  1  1     1  1     1
              1     1  1        1  1     1
              1  1           1  1        1  1
     1     1                 1  1        1     1
     1  1  1        1     1           1  1     1  1
              1        1  1           1  1        1
     1     1                    1  1  1        1  1
     1     1     1        1        1                 1  1  1
              1     1  1  1     1     1  1  1  1  1        1  1
     1  1     1                 1  1     1  1  1     1     1  1
     1  1  1  1     1  1     1  1  1        1     1     1
     1  1  1     1     1           1  1                    1        1  1
           1  1     1     1     1     1  1                          1  1  1

</pre>
</p>

<p>Ou retirando as réguas repetidas numa mesma ordem:

<pre>
     1
     1  1
     1
     1     1  1
     1           1
     1           1  1
     1     1  1
     1  1     1  1  1  1
     1        1        1  1  1
     1     1     1  1
              1     1  1     1     1
        1  1  1  1  1     1  1     1
              1     1  1        1  1     1
              1  1           1  1        1  1
     1     1                 1  1        1     1
     1  1  1        1     1           1  1     1  1
              1        1  1           1  1        1
     1     1                    1  1  1        1  1
     1     1     1        1        1                 1  1  1
              1     1  1  1     1     1  1  1  1  1        1  1
     1  1     1                 1  1     1  1  1     1     1  1
     1  1  1  1     1  1     1  1  1        1     1     1
     1  1  1     1     1           1  1                    1        1  1
        1  1     1     1     1     1  1                          1  1  1
</pre>
</p>

<p>Aparentemente, olhando para a distribuição de 1's, não há nenhuma regularidade.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Wed, 20 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Régua%20de%20Golomb</guid>

</item>

<item>
<title>Métodos numéricos em ELisp</title>
<link>http://www.diale.org/w3log/08.fev.html#Métodos%20numéricos%20em%20ELisp</link>
<description><![CDATA[
<p>Já está colocada a primeira pedra: <a href="../mnemacs.html">Métodos numéricos em Emacs Lisp</a>.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Tue, 19 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Métodos%20numéricos%20em%20ELisp</guid>

</item>

<item>
<title>Vectores e matrizes</title>
<link>http://www.diale.org/w3log/08.fev.html#Vectores%20e%20matrizes</link>
<description><![CDATA[

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">inner</font> (x y)
  <font color="#bc8f8f">"Inner product of two vectors x and y."</font>
  (<font color="#a020f0">let</font> ((i 0) (aux 0))
    (<font color="#a020f0">while</font> (&lt; i (length x))
      (setq aux  (+ aux (* (nth i x) (nth i y))))
      (setq i (1+  i)))
    aux))
</pre>
<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">sum</font> (x)
  <font color="#bc8f8f">"Sum of element of x."</font>
  (<font color="#a020f0">let</font> ((i 0) (aux 0))
    (<font color="#a020f0">while</font> (&lt; i (length x))
      (setq aux (+ aux (nth i x)))
      (setq i (1+ i)))
    aux))
</pre>
<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">sumsq</font> (x)
  <font color="#bc8f8f">"Sum of squares of elements x."</font>
  (<font color="#a020f0">let</font> ((i 0) (aux 0))
    (<font color="#a020f0">while</font> (&lt; i (length x))
      (setq aux (+ aux (* (nth i x) (nth i x))))
      (setq i (1+ i)))
    aux))
</pre>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Thu, 14 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Vectores%20e%20matrizes</guid>

</item>

<item>
<title>Método do ponto fixo</title>
<link>http://www.diale.org/w3log/08.fev.html#Método%20do%20ponto%20fixo</link>
<description><![CDATA[

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">fixedpoint</font> (f x <font color="#228b22">&amp;optional</font> tol)
 <font color="#bc8f8f">"Find the fixed point of f, i. e., f(p)=p."</font>
 (<font color="#a020f0">when</font> (null tol)
   (setq tol 0.00001))
 (<font color="#a020f0">let*</font>
     ((oldx x)
      (x (funcall f x))
      )
   (<font color="#a020f0">if</font> (&lt; (abs (- x oldx)) tol) x (fixedpoint 'f x tol))
   ))

</pre>
<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">f</font> (x) (cos x))</font>

(fixedpoint 'f 1 .001) <font color="#b22222">; 0.7387603198742113</font>
</pre>


]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Tue, 12 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Método%20do%20ponto%20fixo</guid>

</item>

<item>
<title>Método da bissecção</title>
<link>http://www.diale.org/w3log/08.fev.html#Método%20da%20bissecção</link>
<description><![CDATA[

<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">bisection</font> (f a b <font color="#228b22">&amp;optional</font> tol)
 <font color="#bc8f8f">"Solve the function f(x)=0 with bounds a and b and tolerance tol. a
and b need to bracket the solution."</font>
 (<font color="#a020f0">when</font> (null tol)
   (setq tol 0.00001))
 (<font color="#a020f0">let*</font>
     ((m (/ (+ a b) 2.0))
      (fm (funcall f m))
      (fa (funcall f a))
      )
   (<font color="#a020f0">if</font> (&lt; (abs fm) tol)
        m
     (<font color="#a020f0">if</font> (&gt; (* fa fm) 0.0)
          (bisection 'f m b tol)
        (bisection 'f a m tol)))))
</pre>
<pre>
(<font color="#a020f0">defun</font> <font color="#0000ff">f</font> (x) (- 2 (* x x)))

(bisection 'f 1 3) <font color="#b22222">; 1.414215087890625</font>
</pre>


<p>Ref: <a href="http://www.sfu.ca/~gswamina/2004.05.03.html">http://www.sfu.ca/~gswamina/2004.05.03.html</a></p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Mon, 11 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Método%20da%20bissecção</guid>

</item>

<item>
<title>Boarding method for airline passengers</title>
<link>http://www.diale.org/w3log/08.fev.html#Boarding%20method%20for%20airline%20passengers</link>
<description><![CDATA[
<blockquote>
<p class="quoted">
Using a Markov Chain Monte Carlo optimization algorithm and a computer
simulation, I find the passenger ordering which minimizes the time required to
board the passengers onto an airplane. The model that I employ assumes that the
time that a passenger requires to load his or her luggage is the dominant
contribution to the time needed to completely fill the aircraft. The optimal
boarding strategy may reduce the time required to board and airplane by over a
factor of four and possibly more depending upon the dimensions of the
aircraft. I explore some features of the optimal boarding method and discuss
practical modifications to the optimal. Finally, I mention some of the benefits
that could come from implementing and improved passenger boarding scheme.</p>

</blockquote>
Jason H. Steffen

<p>Ref: <a href="http://arxiv.org/abs/0802.0733">http://arxiv.org/abs/0802.0733</a></p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Sat, 09 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Boarding%20method%20for%20airline%20passengers</guid>

</item>

<item>
<title>Lisboa, vista</title>
<link>http://www.diale.org/w3log/08.fev.html#Lisboa%2C%20vista</link>
<description><![CDATA[
<table class="image" width="100%">
<tr><td align="center"><img src="../images/lisbon_photo.png" alt="Vista do miradoura da Graça."></td></tr>
<tr><td align="center" class="image-caption">Vista do miradoura da Graça.</td></tr>
</table>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Wed, 06 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Lisboa%2C%20vista</guid>

</item>

<item>
<title>Funcional vs imperativo</title>
<link>http://www.diale.org/w3log/08.fev.html#Funcional%20vs%20imperativo</link>
<description><![CDATA[
<p>A abordagem usual quando se fala em computação,  e em particular o que me agora
interessa, no ensino da matemática e no uso de computadores, é usar-se uma
abordagem imperativa. Foi a que aprendi. Qual a vantagem, se alguma existe, em
usar uma  análise, um paradigma, funcional?</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Wed, 06 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Funcional%20vs%20imperativo</guid>

</item>

<item>
<title>Cálculo Lambda</title>
<link>http://www.diale.org/w3log/08.fev.html#Cálculo%20Lambda</link>
<description><![CDATA[
<p>O  cálculo  <!-- $\lambda$--><img src="./latex/latex2png-08.fev__131653598.png" alt="latex2png equation" class="latex-inline">  é  mais  pequena, e  universal,  linguagem  de
programação. Consiste apenas numa  única regra de transformação (substituição de
uma variável) e um modo de  definir funções. Foi construída por Alonzo Church em
1930 como um modo de formalizar o conceito de computabilidade.
O cálculo  <!-- $\lambda$--><img src="./latex/latex2png-08.fev__131653598.png" alt="latex2png equation" class="latex-inline"> é  universal no sentido  em que  qualquer função
computável pode ser expressa e calculada (<em>evaluated</em>) usando este formalismo. É
pois equivalente a uma máquina de Turing. No entanto, este cálculo enfatiza o
uso de regras de transformação e não considera em muito detalhe qual a possível
máquina em que tais transformações poderiam ter lugar. Pode dizer-se que é uma
abordagem que se aproxima mais do <em>software</em> do que do <em>hardware</em>.</p>

<p>Algumas funções matemáticas são computáveis, outras não. Em geral nas linguagens
de programação é possível escrever um programa que implementa toda e qualquer
função computável em principio. Por outro lado o limite da computabilidade, ou
daquilo que é computável, também limita o tipo de coisas que uma linguagem de
programação pode fazer.</p>

<p>Uma função parcial é uma função que está definida para alguns valores do seu
argumento e não definida para outros, isto é, partilha da definição de função
apenas a unicidade da imagem dado um objecto.</p>

<p>Intuitivamente uma função é computável se existe um programa que a calcula
(computa). Mais especificamente, uma função é computável
se existe um algoritmo que para um dado <em>x</em> o programa
pára (halt), ao fim de um tempo finito,  e dá a resposta <em>y=f(x)</em>.</p>

<p>O que é mais estranho é que, apesar de se poder escrever programas que
implementam o cálculo de funções, muitas vezes nem sempre é possível responder à
pergunta simples: dado um input <em>x</em> será que um dado programa nos dá a resposta
<em>y</em>.  Em geral, o problema de determinar se um
dado programa pára, ou não, é não computável! Ou seja, não é possível, em geral,
dado um programa, construir um outro programa que nos diz se o primeiro nos dá a
resposta.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Wed, 06 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Cálculo%20Lambda</guid>

</item>

<item>
<title>Páginas, estas</title>
<link>http://www.diale.org/w3log/08.fev.html#Páginas%2C%20estas</link>
<description><![CDATA[
<p>Tomei hoje a decisão, e tenho consciência de ser contra corrente, de não colocar
nenhum  menu  nestas  páginas.  Tenho  alguma  dificuldade  em  complementar  as
especificações  de um  dado <em>browser</em>,  sim aquela  coisa que  usa para  ler estas
linhas, com devaneios de navegabilidade própria.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Tue, 05 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Páginas%2C%20estas</guid>

</item>

<item>
<title>Parece que</title>
<link>http://www.diale.org/w3log/08.fev.html#Parece%20que</link>
<description><![CDATA[
<p>já tenho uma página na web há quase 10 anos.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Mon, 04 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Parece%20que</guid>

</item>

<item>
<title>recursion, n:</title>
<link>http://www.diale.org/w3log/08.fev.html#recursion%2C%20n%3A</link>
<description><![CDATA[
<p>See recursion.</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Mon, 04 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#recursion%2C%20n%3A</guid>

</item>

<item>
<title>Some computer languages</title>
<link>http://www.diale.org/w3log/08.fev.html#Some%20computer%20languages</link>
<description><![CDATA[
<blockquote>
<p class="quoted">
Some  computer languages  simply amplify the  kind of thinking  that you
already do. Some computer languages  teach you fundamentally new ways of looking
at problems.  Python is  like Lisp in  that it  tends to teach  you new  ways of
thinking about problems to broaden your mental horizons.</p>

</blockquote>
Eric Raymond

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Mon, 04 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Some%20computer%20languages</guid>

</item>

<item>
<title>Coisa mais  bem distribuída</title>
<link>http://www.diale.org/w3log/08.fev.html#Coisa%20mais%20%20bem%20distribuída</link>
<description><![CDATA[
<p>Sobre o  bom senso  (Descartes, <em>O  discurso do método</em>).</p>

<blockquote>
<p class="quoted">
Não  existe no
mundo  coisa mais  bem distribuída  que o  bom senso,  visto que  cada indivíduo
acredita ser  tão bem provido dele que  mesmo os mais difíceis  de satisfazer em
qualquer outro aspecto não costumam desejar possuí-lo mais do que já possuem.  E
é improvável que todos se enganem a esse respeito; mas isso é antes uma prova de
que o poder de julgar de forma correta e discernir entre o verdadeiro e o falso,
que é  justamente o que  é denominado bom  senso ou razão,  é igual em  todos os
homens; e, assim  sendo, de que a diversidade de nossas  opiniões não se origina
do fato  de serem  alguns mais  racionais que outros,  mas apenas  de dirigirmos
nossos  pensamentos  por  caminhos  diferentes  e não  considerarmos  as  mesmas
coisas. Pois  é insuficiente ter o  espírito bom, o mais  importante é aplicá-lo
bem.  As maiores  almas são capazes dos maiores vícios,  como também das maiores
virtudes, e os que só andam muito devagar podem avançar bem mais, se continuarem
sempre  pelo  caminho recto,  do  que  aqueles que  correm  e  dele se  afastam.</p>

</blockquote>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Fri, 01 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Coisa%20mais%20%20bem%20distribuída</guid>

</item>

<item>
<title>Arquivo</title>
<link>http://www.diale.org/w3log/08.fev.html#Arquivo</link>
<description><![CDATA[
<p>- <a href="08.jan.html">2008 - Janeiro</a> [<a href="./08.jan.xml">RSS</a>]</p>

]]></description>
<author>Tiago Charters de Azevedo</author>
<pubDate>Fri, 01 Feb 2008 00:00:00 WET</pubDate>
<guid>http://www.diale.org/w3log/08.fev.html#Arquivo</guid>

</item>

  </channel>
</rss>
