100% found this document useful (5 votes)
139 views

Download Full GNU Octave by Example: A Fast and Practical Approach to Learning GNU Octave Ashwin Pajankar PDF All Chapters

Ashwin

Uploaded by

arthosuranmw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (5 votes)
139 views

Download Full GNU Octave by Example: A Fast and Practical Approach to Learning GNU Octave Ashwin Pajankar PDF All Chapters

Ashwin

Uploaded by

arthosuranmw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Download the Full Version of textbook for Fast Typing at textbookfull.

com

GNU Octave by Example: A Fast and Practical


Approach to Learning GNU Octave Ashwin Pajankar

https://textbookfull.com/product/gnu-octave-by-example-a-
fast-and-practical-approach-to-learning-gnu-octave-ashwin-
pajankar/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

GNU Octave by Example A Fast and Practical Approach to


Learning GNU Octave 1st Edition Ashwin Pajankar Sharvani
Chandu
https://textbookfull.com/product/gnu-octave-by-example-a-fast-and-
practical-approach-to-learning-gnu-octave-1st-edition-ashwin-pajankar-
sharvani-chandu/
textboxfull.com

Practical Python Data Visualization: A Fast Track Approach


To Learning Data Visualization With Python Ashwin Pajankar

https://textbookfull.com/product/practical-python-data-visualization-
a-fast-track-approach-to-learning-data-visualization-with-python-
ashwin-pajankar/
textboxfull.com

An Introduction to Reservoir Simulation Using MATLAB GNU


Octave User Guide for the MATLAB Reservoir Simulation
Toolbox MRST Lie
https://textbookfull.com/product/an-introduction-to-reservoir-
simulation-using-matlab-gnu-octave-user-guide-for-the-matlab-
reservoir-simulation-toolbox-mrst-lie/
textboxfull.com

Autotools A Practitioner s Guide to GNU Autoconf Automake


and Libtool 2nd Edition John Calcote

https://textbookfull.com/product/autotools-a-practitioner-s-guide-to-
gnu-autoconf-automake-and-libtool-2nd-edition-john-calcote/

textboxfull.com
Python Unit Test Automation. Practical Techniques for
Python Developers and Testers 1st Edition Ashwin Pajankar

https://textbookfull.com/product/python-unit-test-automation-
practical-techniques-for-python-developers-and-testers-1st-edition-
ashwin-pajankar/
textboxfull.com

Practical Cryptography in Python: Learning Correct


Cryptography by Example 1st Edition Seth James Nielson

https://textbookfull.com/product/practical-cryptography-in-python-
learning-correct-cryptography-by-example-1st-edition-seth-james-
nielson/
textboxfull.com

Learning SAS by example a programmer s guide 2nd Edition


Ronald P. Cody

https://textbookfull.com/product/learning-sas-by-example-a-programmer-
s-guide-2nd-edition-ronald-p-cody/

textboxfull.com

IBM SPSS by example a practical guide to statistical data


analysis Second Edition Service Des Sociétés Secrètes

https://textbookfull.com/product/ibm-spss-by-example-a-practical-
guide-to-statistical-data-analysis-second-edition-service-des-
societes-secretes/
textboxfull.com

Raspberry Pi Supercomputing and Scientific Programming:


MPI4PY, NumPy, and SciPy for Enthusiasts 1st Edition
Ashwin Pajankar (Auth.)
https://textbookfull.com/product/raspberry-pi-supercomputing-and-
scientific-programming-mpi4py-numpy-and-scipy-for-enthusiasts-1st-
edition-ashwin-pajankar-auth/
textboxfull.com
GNU Octave
by Example
A Fast and Practical Approach to
Learning GNU Octave

Ashwin Pajankar
Sharvani Chandu
GNU Octave by
Example
A Fast and Practical Approach
to Learning GNU Octave

Ashwin Pajankar
Sharvani Chandu
GNU Octave by Example: A Fast and Practical Approach to
Learning GNU Octave
Ashwin Pajankar Sharvani Chandu
Nashik, Maharashtra, India Pittsburgh, PA, USA

ISBN-13 (pbk): 978-1-4842-6085-2 ISBN-13 (electronic): 978-1-4842-6086-9


https://doi.org/10.1007/978-1-4842-6086-9

Copyright © 2020 by Ashwin Pajankar and Sharvani Chandu


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Aditee Mirashi
Development Editor: Matthew Moodie
Coordinating Editor: Shrikant Vishwakarma
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected]; for
reprint, paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-6085-2.
For more detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper
I dedicate this book to
Srinivasa Ramanujan,
the great Indian Mathematician
—Ashwin Pajankar

My parents and my sisters who have been


my constant support
—Sharvani Chandu
Table of Contents
About the Authors��������������������������������������������������������������������������������ix
About the Technical Reviewer�������������������������������������������������������������xi
Acknowledgments�����������������������������������������������������������������������������xiii
Introduction����������������������������������������������������������������������������������������xv

Chapter 1: Introduction to GNU Octave�������������������������������������������������1


The GNU Octave Project����������������������������������������������������������������������������������������2
History of the GNU Octave Project�������������������������������������������������������������������2
Applications of Octave�������������������������������������������������������������������������������������3
Limitations and Drawbacks of Octave�������������������������������������������������������������3
Comparison of Octave with Alternatives����������������������������������������������������������4
The Online Octave Community������������������������������������������������������������������������5
Installing GNU Octave��������������������������������������������������������������������������������������������5
Installing on Windows�������������������������������������������������������������������������������������6
Installation on Ubuntu Linux����������������������������������������������������������������������������9
Installation on Raspberry Pi with Raspbian OS���������������������������������������������10
Exploring GNU Octave�����������������������������������������������������������������������������������������10
Octave GUI�����������������������������������������������������������������������������������������������������10
Octave CLI������������������������������������������������������������������������������������������������������19
Octave Programming with Jupyter Notebook�����������������������������������������������������19
Octave Code and Richtext in Notebook���������������������������������������������������������������26
Summary������������������������������������������������������������������������������������������������������������31

v
Table of Contents

Chapter 2: Getting Started with GNU Octave and Jupyter������������������33


Simple Mathematical Operations������������������������������������������������������������������������34
Built-in Mathematical Constants�������������������������������������������������������������������������37
Getting Help��������������������������������������������������������������������������������������������������������39
Variables in GNU Octave��������������������������������������������������������������������������������������41
Global Variables��������������������������������������������������������������������������������������������������42
Conventions for Naming Variables����������������������������������������������������������������������42
Clearing the Command Prompt���������������������������������������������������������������������������45
Summary������������������������������������������������������������������������������������������������������������45

Chapter 3: Data Types and Variables in Detail������������������������������������47


Data Types in GNU Octave�����������������������������������������������������������������������������������47
Arrays, Vectors, and Matrices�����������������������������������������������������������������������������50
Indexing in Arrays������������������������������������������������������������������������������������������54
Operations on Arrays�������������������������������������������������������������������������������������54
Array Creation Routines���������������������������������������������������������������������������������55
Matrix Manipulation Function�����������������������������������������������������������������������������57
Summary������������������������������������������������������������������������������������������������������������58

Chapter 4: Loops, Functions, and Files�����������������������������������������������59


Decision Making with If Statements�������������������������������������������������������������������59
Loops in GNU Octave�������������������������������������������������������������������������������������������61
User-Defined Functions���������������������������������������������������������������������������������������64
Global Variables��������������������������������������������������������������������������������������������������66
Working with Files����������������������������������������������������������������������������������������������67
Summary������������������������������������������������������������������������������������������������������������72

vi
Table of Contents

Chapter 5: Data Visualization�������������������������������������������������������������73


Simple Plots��������������������������������������������������������������������������������������������������������74
Plotting Options���������������������������������������������������������������������������������������������������80
Errorbars�������������������������������������������������������������������������������������������������������������87
More Visualizations���������������������������������������������������������������������������������������������91
Scatter Graphs�����������������������������������������������������������������������������������������������92
Histograms����������������������������������������������������������������������������������������������������93
Contours��������������������������������������������������������������������������������������������������������95
Polar Graph����������������������������������������������������������������������������������������������������97
Pie Charts������������������������������������������������������������������������������������������������������99
Visualizing Data as Images��������������������������������������������������������������������������100
3D Visualizations�����������������������������������������������������������������������������������������������102
Summary����������������������������������������������������������������������������������������������������������110

Chapter 6: Data Analysis������������������������������������������������������������������111


Simple Statistics�����������������������������������������������������������������������������������������������112
Histogram���������������������������������������������������������������������������������������������������������113
Interpolation������������������������������������������������������������������������������������������������������115
1-D Interpolation�����������������������������������������������������������������������������������������115
2-D Interpolation�����������������������������������������������������������������������������������������117
Polynomial Fitting����������������������������������������������������������������������������������������120
Summary����������������������������������������������������������������������������������������������������������123

Chapter 7: Signal Processing�����������������������������������������������������������125


Signals��������������������������������������������������������������������������������������������������������������125
Continuous and Discrete Signals�����������������������������������������������������������������125
Analog and Digital Signals���������������������������������������������������������������������������128
Even and Odd Signals����������������������������������������������������������������������������������129

vii
Table of Contents

Periodic and Non-Periodic Signals��������������������������������������������������������������130


Fourier Transform����������������������������������������������������������������������������������������������133
Summary����������������������������������������������������������������������������������������������������������137

Chapter 8: Audio Processing������������������������������������������������������������139


Reading an Audio File���������������������������������������������������������������������������������������139
Creating Your Own Audio File����������������������������������������������������������������������������141
Plotting the Sound Wave Signal������������������������������������������������������������������������142
Summary����������������������������������������������������������������������������������������������������������146

Chapter 9: Image and Video Processing�������������������������������������������147


Image Processing���������������������������������������������������������������������������������������������147
Loading, Displaying, and Resizing Images���������������������������������������������������149
Color Space�������������������������������������������������������������������������������������������������150
Cropping, Rotating, and Saving Images�������������������������������������������������������154
FFT2������������������������������������������������������������������������������������������������������������������157
Video Processing�����������������������������������������������������������������������������������������������159
Summary����������������������������������������������������������������������������������������������������������161

Appendix�������������������������������������������������������������������������������������������163
S
 tructures���������������������������������������������������������������������������������������������������������163
Cell Arrays���������������������������������������������������������������������������������������������������������164
Operations for Structures and Cell Arrays���������������������������������������������������������165
Polynomials in Octave���������������������������������������������������������������������������������������166
Convex Hull�������������������������������������������������������������������������������������������������������166

Index�������������������������������������������������������������������������������������������������169

viii
About the Authors
Ashwin Pajankar holds a Master of Technology from IIIT Hyderabad. He
started programming and tinkering with electronics at the tender age of
seven, beginning with the BASIC programming language. He was gradually
exposed to C programming, 8085, and x86 assembly programming during
his higher secondary schooling. He is proficient in x86 assembly, C, Java,
Python, and shell programming. He is also proficient with Raspberry Pi,
Arduino, and other single-board computers and microcontrollers. Ashwin
is passionate about training and mentoring. He has trained more than
60,000 students and professionals in live and online training courses. He
has published more than a dozen books with many international and
Indian publishers. He has also reviewed numerous books and educational
video courses. This is his fourth book with Apress and he is working on
more books. He regularly conducts programming bootcamps and
hands-on training for software companies. He is also an avid YouTuber with
more than 10,000 subscribers to his channel. You can find him on LinkedIn.

Sharvani Chandu holds an MS in Computer Vision from CMU and a BTech


in Electronics and Communication Engineering from IIIT Hyderabad.
She has research experience in the areas of computer vision and machine
learning. She currently works for Amazon; she also worked in Bangalore
as a software engineer for a couple of years, focusing on machine learning
and natural language processing. During her undergraduate and graduate
studies, she worked as a research intern, teaching assistant, and research
assistant. She has also published research papers related to her work. She is
enthusiastic about working in the areas of mathematics, computer vision,
and programming. You can find her on LinkedIn.

ix
About the Technical Reviewer
Lentin Joseph is an author, roboticist, and
robotics entrepreneur from India. He runs
a robotics software company called Qbotics
Labs in Kochi/Kerala. He has 10 years of
experience in the robotics domain primarily
in Robot Operating System (ROS), OpenCV,
and PCL. He has authored eight books on ROS,
including Learning Robotics Using Python,
first and second editions, Mastering ROS for
Robotics Programming, first and second editions; ROS Robotics Projects,
first and second editions; and Robot Operating System for Absolute
Beginners. He pursued his Masters in Robotics and Automation from India
and has worked at the Robotics Institute, CMU, USA. He is also a TEDx
speaker.

xi
Acknowledgments
We want to express our gratitude to the technical reviewer and long-time
acquaintance, Lentin Joseph, for helping us make this book better. We
would also like to express our gratitude to the team from Apress. Aditee
Mirashi helped us coordinate the entire book process and Shrikant
Vishwakarma guided us through the editorial process. We are thankful to
Celestin Suresh for giving us the opportunity to write this book.

xiii
Introduction
During my days studying as an undergraduate student, I used MATLAB for
demonstrations in the areas of image and signal processing. MATLAB is
indeed a good tool and a very convenient programming interface for people
who want to focus on subject matters like image and signal processing
because it provides excellent support in these areas for demonstrations.
However, MATLAB is a paid and non-open source product.
GNU Octave is an open source alternative to MATLAB. It has a very
high degree of compatibility with MATLAB in terms of programming.
One of the most desired features of GNU Octave is that it can be used with
Jupyter Notebook. This makes it easier for everyone to write interactive
scripts and share them.
The GNU Octave project has an online repository called the
Octaveforge that hosts many useful libraries for tasks in the areas of signal
and image processing. You can create publication-quality visualizations
for scientific datasets using GNU Octave.
We wrote this book in such a way that novices and beginners will find it
easy to learn the important concepts. The step-by-step approach gradually
increases in rigor and difficulty of concepts and demonstrations. People
working in the areas of data science, signal and image processing, and
scientific domains will find this book extremely useful to get introduced to
GNU Octave and Jupyter Notebook.
While this book has been written for novices and beginners, it
is recommended that you have had some exposure to computer
programming and mathematics since a lot of the concepts in this book are
related to mathematics.
We hope that this book serves you, the reader, well and that you will
enjoy this book as much as we enjoyed writing it.

xv
CHAPTER 1

Introduction to GNU
Octave
We hope you have gone through the table of contents and the preface. If
not, we highly recommend you do so. This is the very first chapter of this
book and we welcome you to the exciting journey of learning GNU Octave.
In this chapter, you will learn the details of GNU Octave such as
its history, applications, limitations, and a comparison with other
contemporary and similar tools. This chapter is mostly dedicated to
general information about GNU Octave and its installation on various
popular OS platforms such as Windows, Ubuntu, and Raspberry Pi
Raspbian. You will not be writing any programs or learning about the
functionality of GNU Octave here. The following is the list of topics you will
learn about in this chapter:

• The GNU Octave Project

• Applications

• Limitations

• The community

• Comparison with other tools


• Installation of GNU Octave on various platforms

• Working with GNU Octave in different modes

© Ashwin Pajankar and Sharvani Chandu 2020 1


A. Pajankar and S. Chandu, GNU Octave by Example,
https://doi.org/10.1007/978-1-4842-6086-9_1
Chapter 1 Introduction to GNU Octave

The GNU Octave Project


GNU Octave is a high-level programming language. It is used for numerical
and scientific computing. It is part of the GNU Project so it is free and
open-source. In fact, anyone with the necessary skill set and will to so can
contribute to its development. The homepage of GNU Octave is located
at www.gnu.org/software/octave. It is basically a mathematics-oriented
programming language with convenient and easy-to-learn visualization
tools for scientific researchers.
The Octave interpreter is written in the C++ programming language.
Octave is an interpreted programming language because it uses the Octave
interpreter to run the Octave scripting language statements and scripts.
Octave has a lot of dynamically loadable modules. Octave uses OpenGL or
gnuplot for plotting. Octave has both a GUI (graphical user interface) and a
CLI (command line interface). If any of you have experience with working
with an OS shell interpreter or the Python programming language, consider
Octave as almost the same as working with shell or Python programming.

History of the GNU Octave Project


The GNU Octave Project started in 1988 as a companion for a textbook
that was under development for chemical engineering undergraduate
students. This was done after the faculty members observed that chemical
engineering students were spending a lot of time debugging FORTRAN
issues, which was used for their programming exercises. Full-time
development began in 1992. Gradually it became a part of the GNU
Project. The following is a timeline that shows the major milestones in the
development of GNU Octave:

• 1988: Conception of idea

• 1992: Beginning of full-time development

• 1994: Version 1.x.x

2
Chapter 1 Introduction to GNU Octave

• 1996: Version 2.0.x and Windows port

• 2007: Version 4.0

• 2015: Version 4.0.0 with stable GUI

• 2019: Octave 5.1.0

A
 pplications of Octave
Octave is used to solve different scientific and numerical computational
problems. It can be used for linear programming and optimization. Octave
is also deployed on many supercomputers because it supports parallel
programming. You can find GNU Octave deployed at supercomputers in
the Ohio Supercomputer Center (www.osc.edu/resources/available_
software/software_list/octave), the Oak Ridge National Laboratory
(www.olcf.ornl.gov/software_package/octave), the and University of
Minnesota (www.msi.umn.edu/sw/octave). In the research community,
Octave is actively used for data analytics, image processing, computer
vision, economic research, data mining, statistical analysis, machine
learning, signal processing, and many more scientific applications. You
will learn how to demonstrate programs pertaining to a lot of the above-­
mentioned scientific computing areas with GNU Octave.

Limitations and Drawbacks of Octave


The Octave programming language was primarily developed to perform
numerical and scientific computations. It is not supposed to be used as
a general purpose programming language like C and C++. Also, it is our
opinion that you should always choose a programming language suitable
for your own programming or computational needs. If you are looking to
do some system-level programming, then C and assembly languages are
your friend. However, if you are a subject matter expert (for example, a

3
Chapter 1 Introduction to GNU Octave

chemical engineer or a signal processing professional) who cannot spare


enough time to learn the intricacies of a programming language like C,
then you should use GNU Octave or the Python programming language
because you can quickly write code snippets to prototype your ideas.
We mentioned that GNU Octave is an interpreted programming
language. This means that it first converts the code or statements into a
machine-readable code format before the computer executes them. The
main drawback is that the program executes slowly compared to programs
written in compiled languages such as C or Fortran. And it is certainly
slower than assembly. The main advantage of this approach is that the
statements are easy to write and change, and the programmer does not
have to compile the code before executing it. It gives a very high degree
of control to the programmers. This is why Octave is not the first choice
when it comes to system programming or fast or parallel programs on a
supercomputer. The C programming language is more suitable for such
applications. However, as you will experience later in the book, Octave lets
you solve very advanced and computationally demanding problems with
only a few instructions or commands and with satisfactory speed.

Comparison of Octave with Alternatives


Octave is a part of GNU, thus it is a free and open-source package and
programming environment for numerical and scientific computations.
Many times it is promoted as a free alternative for MATLAB. MATLAB is
a short form of Matrix Laboratory. It is also a programming environment
and language for numerical and scientific computing. MATLAB is
developed and maintained by Mathworks. It is a proprietary and
commercial software. Octave tries to maintain a very high degree of syntax
compatibility with MATLAB. Many of the programs we will demonstrate
can be directly run as they are with MATLAB. Keep in mind that this
applies to many, but not all, of the programs.

4
Chapter 1 Introduction to GNU Octave

The other free alternatives of MATLAB are Scilab and FreeMat.


The Scilab project does not attempt much to maintain syntax-level
compatibility with MATLAB and Octave. The FreeMat project has not been
updated since 2013.

The Online Octave Community


You can find all of the information and downloadable setup files for Octave
at the project website at www.octave.org. Here you’ll find the official
manual, a Wiki page with tricks and tips (https://wiki.octave.org/
GNU_Octave_Wiki), latest news, a more detailed history, and other relevant
information. You can also get involved in the development; visit www.
gnu.org/software/octave/get-involved.html for more information.
StackOverflow is a good source of information and help. You can find
questions related to Octave at https://stackoverflow.com/questions/
tagged/octave.
There many additional packages that do not come preinstalled with
the standard Octave distribution. Many of them can be downloaded
from Octave Forge at https://octave.sourceforge.io. Octave Forge
is a community project for collaborative development of GNU Octave
extensions, called Octave packages. Here you can find specially designed
packages for scientific and numerical applications such as image
processing, signal processing, economics, information theory, analytical
mathematics, and so on.

Installing GNU Octave


In this section, you will learn how to install GNU Octave on multiple
platforms such as Windows, Ubuntu, and Raspberry Pi. All of the code
examples and interactive sessions we demonstrate in this book have been
tested on these platforms by the authors. So, let’s begin.

5
Chapter 1 Introduction to GNU Octave

I nstalling on Windows
You can install GNU Octave on Windows by downloading and executing
the installable file from the Octave download page at www.gnu.org/
software/octave/download.html. This page has options for 32-bit and
64-bit computers. There is an option for linear algebra for large data but
you will not need it for this book. So, choose the .exe file for installing to
32-bit or 64-bit Windows computers. Other formats, 7z and .zip, are also
available. But you should go for the .exe file. Download the file and execute
it to install GNU Octave. Once the setup has completed successfully,
add the directory location of the Octave executable to the Windows PATH
variable. In my case, it is C:\Octave\Octave-5.2.0\mingw64\bin. It could
be different for you based on the GNU Octave version and your computer
architecture (32-bit or 64-bit).
Once you are done installing it, you need to install Python 3 because
you will need the pip3 utility of Python 3 to install Jupyter Notebook
and Octave Kernel for it. Also, in the end, you will learn how to connect
Python 3 with GNU. You will use the Python 3 interpreter at that time.
Visit the Python 3 download page located at www.python.org/downloads/
and download the setup file of Python 3 for your computer, as shown in
Figure 1-1.

6
Chapter 1 Introduction to GNU Octave

Figure 1-1. Python project homepage

Run the setup file to install Python 3. During installation, check the
checkbox related to adding Python 3 to the PATH variable, as shown in
Figure 1-2.

Figure 1-2. Python Installation Wizard

7
Chapter 1 Introduction to GNU Octave

Also, choose the Customize installation option. This will show you
more options, as shown in Figure 1-3.

Figure 1-3. Python installation options

Check all the boxes and click the Next button to continue the setup.
Complete the setup. Once done, run the following command at the
Windows command prompt cmd:

python -V

It will return the version of Python 3 as follows:

Python 3.8.1

You can also check the version of pip3 as follows:

pip3 -V

8
Chapter 1 Introduction to GNU Octave

pip stands for Pip installs Python or Pip installs Packages. Its
name is a recursive acronym. It is a package manager for the Python
programming language. You can install the other needed components
for our demonstrations with pip. To install Jupyter, run the following
command at the command prompt:

pip3 install jupyter

Jupyter is an interactive environment for various programming


language. You will see the details of Jupyter at the end of this chapter.
To install the Octave Kernel for Jupyter, run the following command:

pip3 install octave_kernel

The Octave Kernel for Jupyter allows us to run the Octave programs
in a Jupyter notebook. As mentioned, you will see how to work with GNU
Octave and Jupyter in the end of this chapter.

Installation on Ubuntu Linux


Ubuntu Linux is a distribution based on Debian Linux. Both are popular
Linux distributions. Python 3 and pip3 come preinstalled in Ubuntu so
you do not have to install them separately. First, update the package list for
upgrades by running the following command in the terminal program:

sudo apt-get update

Then install GNU Octave with the following command:

sudo apt install octave -y

Then using pip3, install Jupyter and the Octave Kernel as follows:

pip3 install jupyter


pip3 install octave_kernel

Run the above commands and complete the setup.

9
Chapter 1 Introduction to GNU Octave

Installation on Raspberry Pi with Raspbian OS


Raspberry Pi is a popular single board computer. If a desktop computer
or a laptop is out of your budget, you can opt for a Raspberry Pi. The
recommended operating system for Raspberry Pi is Raspbian OS, which is
a Debian derivative for the ARM processor architecture that Raspberry Pi
boards use. The setup of Raspberry Pi is outside of the scope of this book,
but you can find detailed instructions at www.raspberrypi.org. Once you
get your Raspberry Pi ready, you can run the following commands on the
lxterminal, which is the terminal emulator for Raspbian OS, so to install
Octave, Jupyter Notebook, and Jupyter Kernel, type these commands:

sudo apt-get update


sudo apt-get install octave -y
sudo pip3 uninstall ipykernel
sudo pip3 install ipykernel==4.8.0
sudo pip3 install jupyter
sudo pip3 install prompt-toolkit==2.0.5
sudo pip3 install octave_kernel

Running the above commands in sequence will install all of the required
packages for this demonstration on the Raspbian OS of Raspberry Pi.

Exploring GNU Octave


Let’s start exploring various aspects of GNU Octave. We will start with GUI.

O
 ctave GUI
When you install Octave on Windows, you also get a shortcut to the Octave
GUI on your desktop. There is another way to launch it. You can search for
it in the search box of Windows by typing Octave. Two options will appear:

10
Chapter 1 Introduction to GNU Octave

Octave GUI and Octave CLI. Choose the GUI option. On Ubuntu, you can
launch it by searching for it in the search box and clicking the Octave icon
displayed in the search output, as shown in Figure 1-4.

Figure 1-4. GNU Octave on Ubuntu

In the Raspberry Pi Raspbian OS menu (the raspberry fruit icon


located at the top left corner on the Raspbian OS desktop), you can find it
under Education, as shown in Figure 1-5.

11
Chapter 1 Introduction to GNU Octave

Figure 1-5. GNU Octave on Raspbian

When you launch GNU Octave the very first time on the Raspberry Pi
with Raspbian OS, it shows the welcome message window, as shown in
Figure 1-6.

12
Chapter 1 Introduction to GNU Octave

Figure 1-6. GNU Octave welcome screen

13
Chapter 1 Introduction to GNU Octave

Click the Next button and you will see the window shown in Figure 1-7.

Figure 1-7. Community news

It is recommended to check the checkbox (to receive latest news and


information about the Octave community). Click the Next button and
you’ll see the window shown in Figure 1-8.

14
Chapter 1 Introduction to GNU Octave

Figure 1-8. Help information

Click the Finish button and the Octave GUI will be launched.
The GUI Window looks the same on all platforms. Figure 1-9 shows the
Octave GUI window running on a Windows computer.

15
Chapter 1 Introduction to GNU Octave

Figure 1-9. GNU Octave GUI on Windows

Let’s look at the details of the components in this window one by


one. In Figure 1-9, you can clearly see that the GUI is divided into three
vertical sections. The middle section is the Octave interpreter prompt.
You can interact with it like the command prompt of an OS. It runs the
Octave statements, which you will see soon. The vertical section on the
right is the variable editor. The vertical section on the left is divided into
three sub-sections: a file browser, a workspace, and a command history
window. You can rearrange these spaces anytime you want by dragging
and dropping them within the GUI window.
The top offers a menubar with the usual file operations and
their shortcuts. And if you pay close attention, in the bottom of the
window, you’ll see three tabs that read Command Window, Editor,
and Documentation. The command window is the interactive mode
command prompt that you can see in the screenshot. The Editor tab opens
a code editor window, and Documentation will bring up an index of the
browsable documentation. You will explore all of these things one by one.

16
Chapter 1 Introduction to GNU Octave

But first, let’s get started with the customary Hello World! program. Go
to the interactive window and type in printf("Hello, World!\n"); and
then press Enter. It prints the string enclosed in the double quotes in the
interactive window, as shown in Figure 1-10.

Figure 1-10. The command window of the GNU Octave GUI

You can even create a single-line program of this code and save it.
Go to the editor by choosing the Editor tab at the bottom. Type the same
line as above in the editor and save it. Octave automatically assigns the
.m extension to the file. MATLAB uses the same extension. The simple
program is shown in Figure 1-11.

Figure 1-11. A simple program

17
Another Random Scribd Document
with Unrelated Content
64. My father has a gig to make; the more him pare it the bigger it
get. 18
—Hole.

65. My father have a thing go up chimbly chip chirrup. 19

—Fire.

66. My father have one thing in his hand and throw it and it support
the whole of Jamaica. 20
—Corn-grain.

67. Me father sen’ ten men fe ketch one t’ief. 21


—Ten fingers to catch one louse.

a) Ten men go to Bullinton fe bring down one prisoner; only two


bring him down.

b) One prisoner stan’ pon Marley hill; ten policemen go fe tek him
down; two bring him to de station do, an’ de sentence pass pon de
finger-nail.

c) My father tek a bwoy to court; de sentence pass pon finger-nail.

68. My fader sen’ me fe go pick out a woman fe me wife; those


laugh will be the bes’ fe tek, but those not better left, fe they will kill
me.

—Ackee; this refers to the common warning that the fruit is safe to eat
only after it has ripened and split in the sun. [191]

69. My father plant a acre a kasava; only one white belly rat a eatey
off.
—Grater for preparing kasava meal.
70. My father give me one root kasava an’ a quart of fine salt; if I
don clever I wouldn’t taste it.

—Egg; the salt cannot penetrate the shell.

a) I put on one coco on the fire to boil and I put in a gallon of salt,
and the salt never tasted it.

b) I have a t’ing and don’t care how much salt I put in it, when I go
to eat it I have to put salt on it.

71. My father gave me some seed to sow; the ground is white and
the seed is black. 22
—Black ink on white paper.

72. My father was in Green Island cutting chip and the chip never
fly. 23

—Clock.

73. Mother put on a pot of food to boil; the top boil before the
bottom.

—Pipe.

74. Going up to town my face turn to town; coming back from town
my face turn to town.
—Climbing a tree.

75. I was going up to town one morning, met a man; I tell him
’Mawnin’ and he wouldn’t speak to me, and when I was coming back
early in the evening he speak to me.
—Trash, noiseless to the tread when cold, crackles when warmed by the
sun. [192]
76. I was going up Sand-hill and saw a man and suck his blood and
throw him over the wall. 24
—Orange.

77. When I was going up to town I met a man; his head is fire an’
his mouth is bone. 25

—Rooster.

a) As I was going through Bramble hall,


An old man gave me a call;
His beard was flesh, his mouth was horn,
And this old man was never born.

b) Got to a gentleman’s yard and his mouth was hard and his beard
was flesh.

78. I was going over Dingledown hill and I saw a grey horse.
—Moon.

79. Picking juketa (?) going to town, picking juketa coming from
town and can’t get my hands full.
—Dew and sweat. [193]

80. I gwine to town wid a hand o’ ripe plantain; I hungry an’


couldn’t taste it.

—Fingers.
81. I was going to town; I mash a plate and when I was coming
back I found it new.
—Ants’ nest.

82. As I was going up to town I hear the bells of heaven ring; man
tremble, beast tremble, cause the devil to break his chain.
—Earthquake.

83. Going up a lane I see a drink an’ see a chaw.

—Cocoanut.

a) Dere’s a cup an’ in de cup dere’s a chaw; no man to clear dis


chaw.

84. A man was going to Kingston, saw two roads and took both. 26
—Trousers.

85. I heard that my father was dead in Kingston; I went there and
took a piece of his bone and made increase.
—Kasava root.

86. I heave up a t’ing white an’ it come down red.


—Egg.

87. In England I am, in Jamaica I stand.


—A man took soil from Jamaica, put it in his boots, went to England.

88. I went to town, I walk in town, I eat in town, and yet I don’t
know town.
—A woman was breedin’. She went to town an’ after she come home the
baby born, grow a big man, don’ know town.
89. A man going to town and he face town, and when he coming
back he face down to Montego Bay.
—Train running between Kingstown and Montego Bay. [194]

90. A man going up to town; he walk on his head going up, he walk
on his head going back. 27
—Horse-shoe-nail.

91. Riding in to town, two talking to each other and none


understand what the other was saying.
—Two (?) new saddles creaking ru-u-u-u-u.

92. Four men going up to town; all were talking and not one could
understand the other.
—Four buggy wheels.

93. Four bredder walk a road and not one can touch. 28
—Four buggy wheels.

94. Some white ladies were walking to Kingston, and all the walk
they walk they couldn’t catch each other.
—Mile-posts.

95. Three brothers in one house and never see each others’ face
until dead.
—Three beans in one castor-oil pod.

96. Two sister on ribber side; no one could never wash the other.
—Two bottles.
97. Two sawyers were sawing from morning till night and never saw
a bit of dust. 29
—Clock. [195]

98. Three man start fe go a heaven; one go half way an’ turn back,
one go right up, and one no go at all.
—Fire: spark, smoke and ashes.

99. A man walk around four corners of the world and make a house;
rain come catch him a door, dew fall on him, sun burn him, and he
have no shelter of his own.
—Ladder.

a) A man build a fine up-stairs house, and he have to sleep outside.

100. A man mek him house an’ him sleep outside.


—Axe.

101. A man work for rich and work for poor and yet his head
outside.
—Nail-head.

102. There was an old man that live never building house till rain
come. 30
—John Crow: as soon as rain come he begin to cut posts, say he will
build him a house. When sun comes out, he come to dry himself; never
build house any more.

103. Man mek him house, an’ him bade da a do. 31


—Ear of corn.
a) Old man in his room and the beard out in the hall.

104. Vineyard man walk through vineyard grass-piece and neither


make track nor road.
—Sun.

105. I know a man talk every second.

—Sea.

a) I know a man; every talk he talk his mouth-corner foam.

106. Born from de worl’ mek an’ nebber a month ole yet. 32
—Moon.

107. Baby born an’ vanish.


—Moon. [196]

108. I know a baby born widout belly.


—Skelion (tin can).

109. Tallest man in Kingston don’ have any belly.


—Bamboo.

a) A man stan’ up widout guts.

110. Holler belly mumma, humpback pupa, pickney wid t’ree foot.

—Cooking-pot.

111. Born in white, live in green, die in red, bury in black. 33


—Coffee.
112. He laugh plain and talk plain but havn’t any life.
—Talking-machine.

113. Going up to town me coatie torn-torn and not a seamstress in a


town could sew it. 34
—Banana leaf.

a) Mrs. Queen coat-tail tear an’ never mend.

114. I think I will shoot God, and God say I mus’ shoot the earth. 35

—Banana shoot.

115. I was tying mat ever since an’ I never lay down on one.
—Pumpkin-vine.

116. If me stan’ me kimbo; if me lie me kimbo. 36


—Coffee-pot.

117. A thousand hungry men kill a thousand bullocks.


—Hunger kill men.

118. And smart as little Tommie be, one man kill the whole world.
—Mr. Debt.

119. Woman have a chile an’ fust begin larnin’ larn him fe t’ief. 37
—Hawk. [197]

120. Black man dance on white man table.


—Black ink on white paper.
a) Mr. Blackman sit pon Mr. Whiteman table.

b) Black man sit down on white man chair.

c) Black man dance on white man head.

d) Black man dance on white man sheet.

121. A black man sit upon a white man head.


—Ackee.

122. A white man stand upon a black man head.


—Bammie on griddle.

123. A black man sit upon a red man head.


—Pot on fire.

124. John Redman tickle John Blackman till him laugh puco-puco. 38

—Fire under boiling pot.

a) A red man tickle a black man make him belly boil up.

b) John Redman beat John Blackman till him gallop.

125. Mr. Redman box Mr. Blackman make Mr. Whiteman laugh.
—Fire, baking-pan and bammie.

126. The white man take a red cloth tie his head.
—Tooth and gum.

127. Mr. Blackman was going to town; him drop him kerchief an’
couldn’t pick it up.
—Crow drops a feather.

128. Miss Nancy was going to Kingston; she drop her pocket
handkerchief never turn round to pick it up.

—Bird drops a feather.

a) Miss Nancy was going up-stairs and she lose her pocket
handkerchief and she would not turn round to pick it up.

b) Queen of Sheba riding out;


Her kerchief drop and couldn’t pick it up.

129. Little Miss Nancy sit at the pass; everyone that come give him a
kiss.
—Fly. [198]

130. Little Miss Nancy tie up her frock and wheel round three times.
—Turn-stick in the pot.

131. Little Miss Nancy like to dance and dance so rough.


—Pepper.

132. Miss D. June (?) cutting wood for a year, never get a bundle.
—Woodpecker.

133. Little Johnny fell in the water and never drowned.

—Bottle.

134. Aunty Mary cut two packey, not one bigger than the other. 39
—Heaven and earth.
a) Ole man Brenta sit on a stump, cut two packey not one bigger
than the other.
—Cloud on the earth (?).

135. Send bwoy to fetch doctor, doctor come before bwoy. 40

—Boy climbing after a cocoanut; nut falls before boy comes down.

136. Dead carry the living over Napoleon’s grass-piece. 41


—Ship at Sea.

a) Look through a diamond I see the dead carry the living. [199]

137. A hen have six chickens; and hold the hen, the chickens cry.
—Guitar with six strings.

138. Two horses were galloping and neither of them could catch one
another. 42
—Two mill-rollers.

139. One John-crow sit down on three cotton-tree.


—Cooking-pot set on fire-stones.

140. A fleety horse get up over a broken bridge. 43

—Needle and thread.

a) A frisky horse and a frisky mare was going up to mountain hill.

141. John, the mule, in the stable, his tail outside.

—Fire in the kitchen, smoke outside.

142. Stick a hog at its head and it bleed at its tail. 44


—Pipe.

143. Kingston bully-dog bark, Montego bully-dog answer.

—Rooster; when one crows at one end of the island, another answers at
the other end.

144. England dog bark, Jamaica dog sound.


—Newspaper.

145. Portland dog bark, Westmoreland dog hear. 45


—Thunder.

146. Jamaica bully-dog bark, Kingston bully-dog keep silent.


—Great gun.

147. Rope run, horse stan’ up.


—Pumpkin-vine and pumpkin.

148. Old England dead an never rotten.


—Bottle (of ale). [200]

149. Water grow.


—Sugar-cane.

150. Water stan’ up.


—Sugar-cane.

151. No ca how time hard, one coco full pot.


—Foot in a boot.

152. One bammie shingle off Mt. Olivet church.


—Moon.

153. One little bit o’ bag hold three.


—Castor-oil bean-pod.

154. A gully with two notch in it.

—Purse.

155. What water wash, sun can’t dry.


—Butter.

156. Up the hill, down the hill; yet never tired.

—Road.

a) Up the hill, down the hill;


Stand up still.

157. Chaw fine and never tired.


—Saw.

158. This corner, this corner is no corner at all.


—Ring.

159. Chip-cherry, beer, cedar.


—White man (cedar), black-wife (chip-cherry), brown child (beer).

160. Stump to stump; dig out stump out of dogwood heart.


—Jigger.

161. A ’tump in a pond; all the rain can’t cover the ’tump-head.
—Turn-stick in the pot.
162. There’s a rope and every bump a sheet of paper.

—Pumpkin-vine.

163. Sack a back an’ not de front.


—Finger-nail. [201]

164. Roomful, hallful; you can’t get a spoonful. 46

—Smoke.

165. Knock an’ stan’ up.


—Mat.

166. Water a-bottom, fire a-top.

—Lamp.

167. Hell a-top an’ hell a-bottom.


—Frying-pan.

168. Hair a-top, hair a-bottom; only a dance in the middle.

—Eye-lashes and eye.

169. Hairy within and hairy without; lift up your foot and poke it in. 47
—Stockings.

170. Outside black, inside red; cock up your foot and poke it in. 48
—Boot.

171. White a top, black a middle and red a bottom. 49


—Bammie, baking-iron and fire.
172. White as snow but not snow; green as grass but not grass; red
as blood but not blood. 50

—Coffee-blossom and berry. [202]

173. Green as grass, not grass; stiff standing in the bed; and the
best young lady is not afraid of handling it. 51
—Onion.

174. White within, black within, red without.


—Ackee.

175. Hard as rock, not rock; white as milk, not milk.


—Cocoanut.

176. High as the world; red as blood but not blood; blue as indigo;
but not indigo; high as granadillo temple.
—Rainbow.

177. When it come it does not come; when it does not come it
come. 52
—Rat and corn.

178. Four sit down on four waiting till four come.


—Cat on the table waiting for a rat.

179. Six and four waiting for twenty-four.


—Six holes in four horse-shoes waiting for twenty-four nails.

180. Nine run, one come, two run.


—Nine man run for the doctor, one baby born, two nipples run.
181. Ten on to four. 53
—Ten teats on a cow (?).

182. Six is in, the seventh is out; set the virgin free.

—Hen hatching six chicks. [203]

183. Blackey cover ten.


—Boots cover toes.

184. Two peepers, two pokers, two waddlers, and one zum-zum. 54
—Cow.

185. Up chip-cherry, down chip-cherry; not a man can climb chip-


cherry. 55
—Smoke.

186. Whitey whitey can’t climb whitey whitey.


—Smoke.

187. Half a ’tumpy sit down on ’tumpy; when a go, a don’ see
nothing but half a ’tumpy.
—Broken bottle on stump.

188. Climb up Zion hill, pick Zion fruit, come down Zion hill, drink
Zion water.
—Climbing a cocoanut tree, picking the nut, coming down, drinking the
milk.

a) Go up Mount Zion, drink Zion blood, eat de flesh, dash away de


bone.
189. Tetchie in, tetchie out; all hands can play on it.

—Lock and key.

a) Tickle me in, tickle me out; all hands can play on tickle.

190. Hip hop; hip hop; jump wide.

—Flea.

a) Dip dup, a yard wide. [204]

191. Drill a hall, drill a room; lean behind the door. 56


—Broom.

a) Jig a hall, jig a room; go a corner, go stan’ up behin’ de door.

192. Little titchie above ground.


—Ants.

193. Every jump shiney jump, whitey hold it back.


—Needle and thread.

194. Miss Witty wit and wit till she wit out her last wit.
—Needle and thread.

195. Earie, hearie, earie, knock, pom!

—Brushing (the hair).

196. Papa take hairy-hairy put in blackey-blackey.


—Brush and blacking.
197. Unco Joey takin’ long hairy-hairy somet’ing; shubbin’ Aunty
Mary hairy-hairy somet’ing.

—Making a broom.

198. Long Aunty Long-long, no one can long as Aunty Long-long.


—Road.

199. Whitey-whitey send whitey-whitey to drive whitey-whitey from


eating whitey-whitey.
—White man sends his white boy to drive the white goat out of the
cabbage-patch.

200. Sleepy-sleepy under nyammy-yammy tree; killy-killy come to


sleepy-sleepy; nyammy yammy drop, kill killy-killy; walkey-walkey
come nyam (eat) nyammy-yammy, leave sleepy-sleepy. 57
—Man sleeping under a tree; snake comes to kill man; cocoanut falls and
kills snake; another man comes, eats the cocoanut, leaves the first man.
[205]

201. Limb fell lamb; down fell lamb in the cow coram.
—Limb falls, knocks lamb into the cow-dung.

202. If I had my pretty little caney, bigny-pigny could not kill kum-
painy.
—If I had my revolver, the wild hog could not kill my dog.

203. I was going out and I saw some pigs, and if I had my hansom-
cansom I would carry home some bigny-pigny.
—If I had my gun, I would carry home some pigs.
204. I send for my man Richard to bring me tomery-flemery-doctory
to mortify unicle-cornicle-current out of my pinkicle-pankicle-
present. 58
—To bring my three dogs to drive three pigs out of the garden.

205. There is a boat an’ in that boat a lady sat, an’ if I should tell
you the name of that lady I should be blamed, for I’ve told you the
riddle twice. 59

—The lady’s name was Anne. [206]

206. I was going up to Hampton lane (a local name); I met a man,


an’ drew off his hat an’ drew off his glove, an’ he gave me his love.
Take him an’ call him; his name is twice mention as this riddle
begun. 60
—His name is Andrew.

a) As I was going up to St. Andrew’s church, I met St. Andrew’s


scholar. St. Andrew’s scholar drew off his hat an’ drew off his gloves:
tell me the name of the scholar.

b) I was going up on Oxford street, I met an Oxford boy. He took


out his pen an’ drew his name; what was his name?

c) Once as I was crossing the Montego Bay bridge, I met a


Montegonian fellow. He took off his hat an’ drew off his glove; guess
me his name; I’ve mentioned it in this riddle.

207. I an’ my dog ben up the lane catching a buck an’ a doe.
Whoever tell me my dog’s name, there is my dog. 61

—The dog’s name is Ben.


a) “Good morning, Mr. Ben; ben meke a meet. I come to borrow yo’
dog go hunting. I don’ know his name.” “Take him an’ call him; his
name is twice mention as this riddle begun.” [207]

208. Megs, Pegs an’ Margaret is my true lover; but it’s neither Megs,
Pegs nor Margaret.
—Anne is my lover.

209. Trick, track and trawndy,


Which was Trawndy Grawnby?
—Witch.

210. There are 4000 people to draw in one carriage; how can they
do that?
—Mr. & Mrs. Thousand and their two children.

211. Mr. Lets was walking and Mr. Lets was riding and Mr. Lets was
walking again. Can you tell me who the gentlemen were?
—Horse, master and dog, all named ’Lets’.

212. My father has a long bench in his house, an’ to guess me how
many people sit on that bench.
—One man named ‘More’. (The trick is, at each guess to say M o r e .)

213. Bees bite honey, honey run.

—A horse named H o n e y .

214. Twelve pear hanging high,


Twelve men passing by;
Each pick a pear,
How many pear remain? 62
—Eleven; the man’s name is E a c h .

215. A man without eyes


Went out to view the skies;
He saw a tree with apples on,
He neither took apples off nor left apples on. 63
—A one-eyed man; two apples on the tree. [208]

216. I was going up Hampton lane, I met a man have seven wives;
the seven wives have seven sacks, the seven sacks have seven kits,
how many were there going to Hampton? 64
—Only one—I.

217. A duck before a duck, a duck after a duck, a duck in the midst
of two ducks. How many ducks was going along?
—Three.

218. I was travelling and six ducks flying, one before the five; and I
took up my gun and I shoot one of the ducks and drop on the
ground. Guess how many ducks remain? 65
—None; the rest fly away.

219. A parson and his daughter, a doctor and his wife; and there is
three apples to share among them. How will they share it? 66
—Each takes one; the parson’s daughter is the doctor’s wife.

220. Run, Ricky, run; run up the Ahe river, run; run with a long trail,
run up the Ahe river, run; run, Ricky, run? How many r’s in that?

—No r’s in ‘that’.

221. Mr. Parott was sitting on a tree; some pigeons were flying by.
The pigeon say, “Good morning, Mr. Parrot.” The parrot say, “Good
morning, Mr. Hundred.” The pigeon say, “I’m not ‘hundred’; want
twice as much, half as much, quarter [209]as much, and you, Mr.
Parrot, to make a hundred.” Tell me how many pigeons were flying. 67
—Thirty-six.

222. I hire laborers for a shilling a day; I get twelve laborers. I give
a man two pence, a woman ha’ penny, a pickney one farthing. How
many of each do I hire?

—Five men, one woman, six pickney.

223. My father gave me a horse to go sell for ten pounds and to eat
my breakfast out of the money and bring home the same ten
pounds. How could I do that?

—Take the shoes off the horse and sell them separately.

224. In a rainy season the Cabrietta overflows a path where a poor


coolie-man and his family had to cross. He then made a dray for
conveying them to and from their work. Dray cannot carry more
than 150 lbs. at a time. Coolie-man weighs 150 lbs., wife 150 lbs.
and two sons together 150 lbs. How must they get over.
—Two sons go over; one remains, the other returns. The mother goes
over; boy returns, takes over brother returns. Father goes over; boy
brings over brother. 68

a) The same story with a fox, goose and bag of corn. [210]

225. My fader got six sheep. He send his son to de pen. ‘My son, go
an’ count me six sheep, but you musn’ count me “one, two, t’ree,
four, five, six”. You musn’t count “four an’ two, six”. You musn’t
count “t’ree an’ t’ree, six”. You musn’ count “five an’ one, six”, but
count me my six sheep!
—Dis, dat, de other,
De ewe, de ram, de wether.

226. I gwine to make a dance; I want you there. You mus’n’t come a
day, you mus’n’t come a night, you mus’n’t ride a horse, you mus’n’t
ride a mule, you mus’n’t ride a jackass. An’ if you come, you mus’n’t
come into me house an’ you mus’n’t stay outside. 69
—You must come riding a cow, between day and night; and when you
come, stand on the threshold, neither in nor out.

227. Under the earth I stand,


Silver and gold was my tread.
I rode a t’ing that never was born,
And a bit of the dam I hold in me han’. 70

a) On green grass I stand


On gravel I stand,
I ride a colt that was never in foal,
And I beat up the mother old dum-skin in me hand.

b) Under de eart’ I go,


Plant trash I stan’;
I ride a t’ing that never was born
Wid an ole be damn in me han’.

[211]

228. Little Miss Netticoat with her white petticoat,


She has neither feet nor hands;
The longer she grows the shorter she stands. 71
—Candle.

a) Miss Nancy sits around de door;


The longer him stan’ deh, de shorter him grow.
229. Hoddie Doddie with a round black body
Three legs and a wooden hat—What’s that? 72
—Cooking-pot.

230. Humpty Dumpty sat on a wall,


Humpty Dumpty had a great fall;
And all the king’s horses and all the king’s men
Couldn’t put Humpty Dumpty together again. 73
—Egg. [212]

231. Round as a marble, deep as a cup;


Ten men from Jericho can’t lift it up. 74
—Sink-hole.

232. Handsome protector dressed in green,


Handsome protector sent to the queen. 75
—Parrot.

233. Under gravel, top o’ gravel;


Tell the devil I’ll travel.
—Water.

234. Tires a horse, worries a man;


Tell me this riddle if you can. 76
—Saddle.

235. Hitchity, hitchity on the king’s kitchen door;


All the king’s horses and all the king’s men
Could never move Hitchity, hitchity off the king’s kitchen door. 77
—Sunshine. [213]

236. Flour from England, fruits from Spain,


All met together in a shower of rain;
Had on a napkin tied with a string,—
If you tell me this riddle, I’ll give you a ring.
—Duckanoo (pudding boiled in a cloth).

237. I was going through a field of wheat,


I picked up something nice to eat;
It was neither feather, flesh nor bone,
But I kept it till it walk alone. 78
—Egg.

238. In a garden was laden a beautiful maiden


As ever was seen in the morn.
She was made a wife the first day of her life,
And she died before she was born. 79
—Eve.

239. There was a man of Adam’s race,


He had a certain dwelling-place;
He wasn’t in earth, heaven or hell,—
Tell me where that man did dwell. 80
—Jonah in the whale’s belly.

240. Formed long ago, yet made to-day,


Employed while others sleep;
What few would like to give away,
Or any like to keep. 81
—Bed.

241. Legs have I but seldom walk,


I backbite all, but never speak.
—Flea.

242. There was a man of Adam’s race


Who had no legs, no body but waist.
—Ring. [214]

243. When first I appear I seem mysterious,


But when I am explained I am nothing serious.
—Riddle.

244. A curtain drawn as fine as silk,


A marble stone as white as milk;
A thief appear and break them all,
Out start the golden ball. 82
—Egg.

245. I came from beyond the ocean,


I drink water out of the sea,
I lighten a many a nation,
And give myself to thee.
—Sun.

246. My first is a circle, my second a cross;


If you meet my whole, lock out for a toss. 83
—O-X.

247. My father send me to market to carry home three-fourths of a


cross, a circle complete, a right angle with two semi-circles meet, a
triangle with a cross, two semi-circles, and circle complete. 84
—T-O-B-A-C-C-O.

248. Five letters in an invitation spell my name,


Backward and forward it answer the same;
Take away the first letter and the first of humanity race,
Take away the second and the thing that make the water-wheel
turn.
Take away the third, and the first of the alphabetical verb.
—Madam, Adam, dam, am. [215]

249. Give a number that isn’t even: cut off the head, you get it
even; cut off the tail, your mother’s name you shall find. 85
—Seven, even, Eve.

250. What word of one syllable, take away two letters and leave two
syllables? 86
—Plague, ague.

251. A word of one syllable which, when two is taken off, ten
remain.
—Often, ten.

252. Give me ‘black water’ in three letters.


—I-n-k.

253. Spell me a broken wall in three letters.


—G-a-p.

254. What is it that is once in a minute, twice in a moment, and not


once in a thousand years? 87
—Letter M.

255. What is it that we see every day, King George himself sees, and
God never sees? 88
—Our equal. [216]

256. What is that which if you have not you would not like to get
and if you have you would not like to lose? 89
—A bald head.

257. What is it, when Adam was four days old it was four days old,
and when Adam was four-score years and four days old it remained
four days old? 90
—Moon.

258. What is that which Christ had not, Napoleon had, Kaiser has
and no woman ever has?
—A wife.

259. What is it that is too much for one, enough for two, and
nothing at all for three?
—A secret.

260. The river is bank to bank; how will you get over?
—By bridge.

261. Suppose all the tree was one tree and all the man was one man
and all the axes one ax; and suppose the one ax fell the one tree
and the one tree kill the one man, who would leave to tell the tale?

—Women.

262. Higher than God, lower than the devil; the dead feed on it but
not the living. 91
—Nothing.

263. There was a woman born, live an’ die; never go to corruption,
never see God face.
—Lot’s wife. [217]
264. There is a thing on earth that God could do but didn’t, the devil
had’nt got the power, and men do it. 92
—Baptism.

265. What is the cleanest thing in a dirty woman’s house?


—Egg.

266. What is the bes’ furniture for a man’s house?


—The daughter.

267. Why do a tailor and a plantain resemble?


—One cuts to fit, the other is fit to cut.

268. Why do a well-dressed lady and a chair resemble?


—Because they both use pins.

269. Why does a judge and a mile-post resemble?


—One justifies the mile and the other the law.

270. What makes the devil and a shoemaker resemble?


—The devil seek after a sinner’s soul and the shoemaker after a boot
sole.

271. Mr. Bigger has a baby; out of Mr. Bigger and his baby which is
the bigger?

—Baby is a little Bigger.

272. If an elephant’s four feet cover four acres of land, what will his
tail cover?
—The skin.
273. What money in the world is the hardest money to change?
—Matrimony.

274. A reason why a moth-eaten coat is like a bible?


—Both of them is holy (holey). [219]

1 Cf. No. 140, p. 199. ↑


2 Cf. No. 142, p. 199. ↑
3 Cf. Suaheli (Velten):
85. There is a buried thing; who can tell the sort of banana, to him will I give an
amulet.
—Woman with child. ↑
4 Cf. No. 114, p. 196. ↑
5 Cf. No. 113, p. 196. ↑
6 Cf. No. 64, p. 190. English: Riddles (Boston):
What thing is that which is lengthened by being cut at both ends?
—A ditch. ↑
7 Cf. Porto Rican (Mason and Espinosa):
288. Una arquita muy chiquita, blanquita como la sal; todo el mundo la sabe abrir,
pero nadie la sabe cerrar. ↑
8 Cf. West Highlands (Campbell):
A little clear (?) house and its two doors shut.
Suaheli (Velten):
4. My house has no door.
Suahili (Steere):
1. My house is large; it has no door.
Eastern Bantu (Seidel):
9. There is a house without a door.
Porto Rican (Mason and Espinosa):
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like