100% found this document useful (2 votes)
20 views

Beginning Mathematica and Wolfram for Data Science Applications in Data Analysis Machine Learning and Neural Networks 2nd Edition Jalil Villalobos Alva - Download the full ebook now to never miss any detail

The document provides information about the book 'Beginning Mathematica and Wolfram for Data Science Applications in Data Analysis Machine Learning and Neural Networks' by Jalil Villalobos Alva, including details on its content, structure, and how to download it. It also lists additional recommended ebooks related to data science and machine learning. The book covers various topics such as Mathematica environment, data manipulation, and working with datasets.

Uploaded by

qoxusuzhilin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
20 views

Beginning Mathematica and Wolfram for Data Science Applications in Data Analysis Machine Learning and Neural Networks 2nd Edition Jalil Villalobos Alva - Download the full ebook now to never miss any detail

The document provides information about the book 'Beginning Mathematica and Wolfram for Data Science Applications in Data Analysis Machine Learning and Neural Networks' by Jalil Villalobos Alva, including details on its content, structure, and how to download it. It also lists additional recommended ebooks related to data science and machine learning. The book covers various topics such as Mathematica environment, data manipulation, and working with datasets.

Uploaded by

qoxusuzhilin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 76

Visit https://ebookultra.

com to download the full version and


explore more ebooks

Beginning Mathematica and Wolfram for Data


Science Applications in Data Analysis Machine
Learning and Neural Networks 2nd Edition Jalil
Villalobos Alva

_____ Click the link below to download _____


https://ebookultra.com/download/beginning-mathematica-
and-wolfram-for-data-science-applications-in-data-
analysis-machine-learning-and-neural-networks-2nd-
edition-jalil-villalobos-alva/

Explore and download more ebooks at ebookultra.com


Here are some suggested products you might be interested in.
Click the link to download

Domain Specific Computer Architectures for Emerging


Applications Machine Learning and Neural Networks 1st
Edition Chao Wang
https://ebookultra.com/download/domain-specific-computer-
architectures-for-emerging-applications-machine-learning-and-neural-
networks-1st-edition-chao-wang/

Statistical and Machine Learning Data Mining Techniques


for Better Predictive Modeling and Analysis of Big Data
Second Edition Bruce Ratner
https://ebookultra.com/download/statistical-and-machine-learning-data-
mining-techniques-for-better-predictive-modeling-and-analysis-of-big-
data-second-edition-bruce-ratner/

Statistics Data Mining and Machine Learning in Astronomy A


Practical Python Guide for the Analysis of Survey Data
Željko Ivezi■
https://ebookultra.com/download/statistics-data-mining-and-machine-
learning-in-astronomy-a-practical-python-guide-for-the-analysis-of-
survey-data-zeljko-ivezic/

Data Mining Practical Machine Learning Tools and


Techniques 2nd Edition Ian H. Witten

https://ebookultra.com/download/data-mining-practical-machine-
learning-tools-and-techniques-2nd-edition-ian-h-witten/
Feature Engineering for Machine Learning Principles and
Techniques for Data Scientists 1st Edition Alice Zheng

https://ebookultra.com/download/feature-engineering-for-machine-
learning-principles-and-techniques-for-data-scientists-1st-edition-
alice-zheng/

Machine Learning with R Expert Techniques for Predictive


Modeling to Solve All Your Data Analysis Problems 2nd
Edition Brett Lantz
https://ebookultra.com/download/machine-learning-with-r-expert-
techniques-for-predictive-modeling-to-solve-all-your-data-analysis-
problems-2nd-edition-brett-lantz/

Microarray Data Analysis Methods and Applications 2nd


Edition Pietro Hiram Guzzi

https://ebookultra.com/download/microarray-data-analysis-methods-and-
applications-2nd-edition-pietro-hiram-guzzi/

Data Mining for Genomics and Proteomics Analysis of Gene


and Protein Expression Data Wiley Series on Methods and
Applications in Data Mining 1st Edition D. M. Dziuda
https://ebookultra.com/download/data-mining-for-genomics-and-
proteomics-analysis-of-gene-and-protein-expression-data-wiley-series-
on-methods-and-applications-in-data-mining-1st-edition-d-m-dziuda/

Data Analysis and Applications 2 1st edition Edition


Bozeman

https://ebookultra.com/download/data-analysis-and-applications-2-1st-
edition-edition-bozeman/
Beginning Mathematica and Wolfram for Data Science
Applications in Data Analysis Machine Learning and
Neural Networks 2nd Edition Jalil Villalobos Alva Digital
Instant Download
Author(s): Jalil Villalobos Alva
ISBN(s): 9798868803475, 886880347X
Edition: 2
File Details: PDF, 9.77 MB
Year: 2024
Language: english
Beginning Mathematica
and Wolfram for Data
Science
Applications in Data Analysis,
Machine Learning,
and Neural Networks
Second Edition

Jalil Villalobos Alva


Beginning Mathematica and Wolfram for Data Science: Applications in Data
Analysis, Machine Learning, and Neural Networks
Jalil Villalobos Alva
Mexico City, Mexico

ISBN-13 (pbk): 979-8-8688-0347-5 ISBN-13 (electronic): 979-8-8688-0348-2


https://doi.org/10.1007/979-8-8688-0348-2

Copyright © 2024 by Jalil Villalobos Alva


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: Melissa Duffy
Development Editor: James Markham
Editorial Project Manager: Gryffin Winkler
Copyeditor: Kim Burton
Cover designed by eStudioCalamar
Cover image designed by Mathew Schwartz on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, 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 http://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. For more detailed information, please visit https://www.apress.com/gp/services/
source-code.
If disposing of this product, please recycle the paper
To my family, who supported me in all aspects
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

About the Technical Reviewer���������������������������������������������������������������������������������xv


Acknowledgments�������������������������������������������������������������������������������������������������xvii

Introduction������������������������������������������������������������������������������������������������������������xix

Chapter 1: Introduction to Mathematica������������������������������������������������������������������ 1


Why Mathematica?����������������������������������������������������������������������������������������������������������������������� 1
The Wolfram Language����������������������������������������������������������������������������������������������������������������� 2
Structure of Mathematica������������������������������������������������������������������������������������������������������������� 3
Design of Mathematica����������������������������������������������������������������������������������������������������������� 6
Mathematica Environment������������������������������������������������������������������������������������������������������������ 9
Notebook Interface������������������������������������������������������������������������������������������������������������������ 9
Text Processing��������������������������������������������������������������������������������������������������������������������� 12
Palettes���������������������������������������������������������������������������������������������������������������������������������� 14
Notebook Style and Features������������������������������������������������������������������������������������������������ 15
Expression in Mathematica��������������������������������������������������������������������������������������������������������� 18
Assigning Values������������������������������������������������������������������������������������������������������������������� 19
Built-in Functions������������������������������������������������������������������������������������������������������������������ 22
Dates and Time���������������������������������������������������������������������������������������������������������������������� 23
Strings����������������������������������������������������������������������������������������������������������������������������������� 25
Basic Plotting������������������������������������������������������������������������������������������������������������������������� 27
Logical Operators and Infix Notation������������������������������������������������������������������������������������� 30
Algebraic Expressions����������������������������������������������������������������������������������������������������������� 33
Solving Algebraic Equations�������������������������������������������������������������������������������������������������� 34
Using Wolfram Alpha Inside Mathematica����������������������������������������������������������������������������� 37
Delayed and Immediate Expressions������������������������������������������������������������������������������������� 40

v
Table of Contents

Improving Code��������������������������������������������������������������������������������������������������������������������������� 41
Code Performance����������������������������������������������������������������������������������������������������������������� 42
Handling Errors���������������������������������������������������������������������������������������������������������������������� 43
Debugging Techniques���������������������������������������������������������������������������������������������������������� 45
How Mathematica Works������������������������������������������������������������������������������������������������������������ 47
How Computations are Made (Form of Input)������������������������������������������������������������������������ 47
Searching for Assistance������������������������������������������������������������������������������������������������������� 50
Notebook Security����������������������������������������������������������������������������������������������������������������� 53
Summary������������������������������������������������������������������������������������������������������������������������������������ 54

Chapter 2: Data Manipulation��������������������������������������������������������������������������������� 55


Lists�������������������������������������������������������������������������������������������������������������������������������������������� 55
Types of Numbers������������������������������������������������������������������������������������������������������������������ 56
Working with Digits��������������������������������������������������������������������������������������������������������������� 60
A Few Mathematical Functions��������������������������������������������������������������������������������������������� 61
Numeric Function������������������������������������������������������������������������������������������������������������������ 63
Lists of Objects��������������������������������������������������������������������������������������������������������������������������� 64
List Representation��������������������������������������������������������������������������������������������������������������� 65
Generating Lists��������������������������������������������������������������������������������������������������������������������� 65
Arrays of Data������������������������������������������������������������������������������������������������������������������������ 68
Nested Lists��������������������������������������������������������������������������������������������������������������������������� 71
Vectors����������������������������������������������������������������������������������������������������������������������������������� 72
Matrixes��������������������������������������������������������������������������������������������������������������������������������� 73
Matrix Operations������������������������������������������������������������������������������������������������������������������ 75
Restructuring a Matrix����������������������������������������������������������������������������������������������������������� 76
Manipulating Lists����������������������������������������������������������������������������������������������������������������������� 77
Retrieving Data���������������������������������������������������������������������������������������������������������������������� 77
Assigning or Removing Values���������������������������������������������������������������������������������������������� 79
Structuring List��������������������������������������������������������������������������������������������������������������������������� 82
Criteria Selection������������������������������������������������������������������������������������������������������������������� 84
Summary������������������������������������������������������������������������������������������������������������������������������������ 87

vi
Table of Contents

Chapter 3: Working with Data and Datasets����������������������������������������������������������� 89


Operations with Lists������������������������������������������������������������������������������������������������������������������ 89
Arithmetic Operations to a List���������������������������������������������������������������������������������������������� 90
Applying Functions to a List�������������������������������������������������������������������������������������������������� 91
Defining Own Functions�������������������������������������������������������������������������������������������������������� 93
Pure Functions����������������������������������������������������������������������������������������������������������������������� 95
Indexed Tables���������������������������������������������������������������������������������������������������������������������������� 96
Tables with the Wolfram Language��������������������������������������������������������������������������������������� 96
Associations������������������������������������������������������������������������������������������������������������������������ 101
Dataset Format������������������������������������������������������������������������������������������������������������������������� 103
Constructing Datasets��������������������������������������������������������������������������������������������������������� 103
Accessing Data in a Dataset������������������������������������������������������������������������������������������������ 109
Adding Values���������������������������������������������������������������������������������������������������������������������� 113
Dropping Values������������������������������������������������������������������������������������������������������������������� 117
Filtering Values�������������������������������������������������������������������������������������������������������������������� 119
Applying Functions�������������������������������������������������������������������������������������������������������������������� 122
Functions by Column or Row����������������������������������������������������������������������������������������������� 127
Joining and Merging Datasets��������������������������������������������������������������������������������������������� 132
Customizing a Dataset��������������������������������������������������������������������������������������������������������� 134
Generalization of Hash Tables��������������������������������������������������������������������������������������������� 138
Summary���������������������������������������������������������������������������������������������������������������������������������� 145

Chapter 4: Import and Export������������������������������������������������������������������������������� 147


Importing Files�������������������������������������������������������������������������������������������������������������������������� 148
CSV and TSV Files���������������������������������������������������������������������������������������������������������������� 148
XLSX Files���������������������������������������������������������������������������������������������������������������������������� 150
JSON Files��������������������������������������������������������������������������������������������������������������������������� 153
Web Data����������������������������������������������������������������������������������������������������������������������������� 156
Semantic Import����������������������������������������������������������������������������������������������������������������������� 157
Quantities���������������������������������������������������������������������������������������������������������������������������� 159
Datasets with Quantities����������������������������������������������������������������������������������������������������� 160
Costume Import (Dealing with Large Datasets)������������������������������������������������������������������� 164

vii
Table of Contents

Export���������������������������������������������������������������������������������������������������������������������������������������� 166
Other Formats���������������������������������������������������������������������������������������������������������������������� 169
XLS and XLSX Formats�������������������������������������������������������������������������������������������������������� 173
JSON Formats���������������������������������������������������������������������������������������������������������������������� 174
Content File Objects������������������������������������������������������������������������������������������������������������ 177
Searching Files with Wolfram Language����������������������������������������������������������������������������� 178
Connecting to External Services����������������������������������������������������������������������������������������������� 179
External Connections����������������������������������������������������������������������������������������������������������� 179
External Resources�������������������������������������������������������������������������������������������������������������� 181
Database and File Operations (SQL)������������������������������������������������������������������������������������ 184
Summary���������������������������������������������������������������������������������������������������������������������������������� 186

Chapter 5: Data Visualization������������������������������������������������������������������������������� 187


Basic Visualization�������������������������������������������������������������������������������������������������������������������� 187
2D Plots������������������������������������������������������������������������������������������������������������������������������� 187
Plotting Data������������������������������������������������������������������������������������������������������������������������ 191
Plotting Defined Functions�������������������������������������������������������������������������������������������������� 196
Customizing Plots��������������������������������������������������������������������������������������������������������������������� 197
Adding Text to Charts����������������������������������������������������������������������������������������������������������� 197
Frame and Grids������������������������������������������������������������������������������������������������������������������ 200
Filled Plots��������������������������������������������������������������������������������������������������������������������������� 202
Filling Patterns and Gradient����������������������������������������������������������������������������������������������� 204
Combining Plots������������������������������������������������������������������������������������������������������������������������ 206
Multiple Plots����������������������������������������������������������������������������������������������������������������������� 207
Multiaxis Plots��������������������������������������������������������������������������������������������������������������������� 210
Coloring Plot Grids��������������������������������������������������������������������������������������������������������������� 211
Colors Palette���������������������������������������������������������������������������������������������������������������������������� 216
3D Plots������������������������������������������������������������������������������������������������������������������������������������� 218
Customizing 3D Plots����������������������������������������������������������������������������������������������������������� 219
Hue Color Function and List3D�������������������������������������������������������������������������������������������� 220

viii
Table of Contents

Contour Plots����������������������������������������������������������������������������������������������������������������������������� 222


3D Plots and 2D Projections������������������������������������������������������������������������������������������������ 226
Plot Themes������������������������������������������������������������������������������������������������������������������������������ 227
Summary���������������������������������������������������������������������������������������������������������������������������������� 231

Chapter 6: Statistical Data Analysis��������������������������������������������������������������������� 233


Random Numbers��������������������������������������������������������������������������������������������������������������������� 233
Random Sampling��������������������������������������������������������������������������������������������������������������� 235
Systematic Sampling����������������������������������������������������������������������������������������������������������� 237
Commons Statistical Measures������������������������������������������������������������������������������������������������ 239
Measures of Central Tendency�������������������������������������������������������������������������������������������� 239
Measures of Dispersion������������������������������������������������������������������������������������������������������� 240
Statistical Charts����������������������������������������������������������������������������������������������������������������������� 242
Bar Charts���������������������������������������������������������������������������������������������������������������������������� 242
Histograms�������������������������������������������������������������������������������������������������������������������������� 245
Pie Charts and Sector Charts����������������������������������������������������������������������������������������������� 250
Box Plots������������������������������������������������������������������������������������������������������������������������������ 252
Distribution Chart���������������������������������������������������������������������������������������������������������������� 254
Charts Palette���������������������������������������������������������������������������������������������������������������������� 256
Ordinary Least Squares Method������������������������������������������������������������������������������������������������ 262
Pearson Coefficient������������������������������������������������������������������������������������������������������������� 264
Linear Fit����������������������������������������������������������������������������������������������������������������������������� 265
Model Properties����������������������������������������������������������������������������������������������������������������� 266
Summary���������������������������������������������������������������������������������������������������������������������������������� 269

Chapter 7: Data Exploration���������������������������������������������������������������������������������� 271


Wolfram Data Repository���������������������������������������������������������������������������������������������������������� 271
Wolfram Data Repository Website��������������������������������������������������������������������������������������� 272
Selecting a Category����������������������������������������������������������������������������������������������������������� 274
Extracting Data from the Wolfram Data Repository������������������������������������������������������������������ 275
Accessing Data Inside Mathematica����������������������������������������������������������������������������������� 278
Data Observation and Querying������������������������������������������������������������������������������������������� 281

ix
Table of Contents

Descriptive Statistics���������������������������������������������������������������������������������������������������������������� 287


Table and Grid Formats������������������������������������������������������������������������������������������������������� 289
Dataset Visualization����������������������������������������������������������������������������������������������������������� 293
Data Outside Dataset Format���������������������������������������������������������������������������������������������� 296
2D and 3D Plots������������������������������������������������������������������������������������������������������������������� 297
Summary���������������������������������������������������������������������������������������������������������������������������������� 301

Chapter 8: Machine Learning with the Wolfram Language����������������������������������� 303


Gradient Descent Algorithm������������������������������������������������������������������������������������������������������ 303
Getting the Data������������������������������������������������������������������������������������������������������������������� 304
Algorithm Implementation��������������������������������������������������������������������������������������������������� 305
Multiple Alphas�������������������������������������������������������������������������������������������������������������������� 307
Linear Regression��������������������������������������������������������������������������������������������������������������������� 308
Predict Function������������������������������������������������������������������������������������������������������������������ 308
Boston Dataset�������������������������������������������������������������������������������������������������������������������� 309
Model Creation�������������������������������������������������������������������������������������������������������������������� 310
Model Measurements���������������������������������������������������������������������������������������������������������� 316
Model Assessment�������������������������������������������������������������������������������������������������������������� 318
Retraining Model Hyperparameters������������������������������������������������������������������������������������� 319
Logistic Regression������������������������������������������������������������������������������������������������������������������� 321
Titanic Dataset��������������������������������������������������������������������������������������������������������������������� 321
Data Exploration������������������������������������������������������������������������������������������������������������������ 325
Classify Function����������������������������������������������������������������������������������������������������������������� 327
Testing the Model���������������������������������������������������������������������������������������������������������������� 332
Data Clustering������������������������������������������������������������������������������������������������������������������������� 338
Clusters Identification���������������������������������������������������������������������������������������������������������� 338
Choosing a Distance Function��������������������������������������������������������������������������������������������� 340
Identifying Classes�������������������������������������������������������������������������������������������������������������� 342
K-Means Clustering������������������������������������������������������������������������������������������������������������� 343
Dimensionality Reduction���������������������������������������������������������������������������������������������������� 345
Applying K-Means��������������������������������������������������������������������������������������������������������������� 347
Changing the Distance Function������������������������������������������������������������������������������������������ 349

x
Table of Contents

Different k’s������������������������������������������������������������������������������������������������������������������������� 350


Cluster Classify�������������������������������������������������������������������������������������������������������������������� 353
Summary���������������������������������������������������������������������������������������������������������������������������������� 357

Chapter 9: Neural Networks with the Wolfram Language������������������������������������ 359


Layers��������������������������������������������������������������������������������������������������������������������������������������� 360
Input Data���������������������������������������������������������������������������������������������������������������������������� 360
Linear Layer������������������������������������������������������������������������������������������������������������������������� 360
Weights and Biases������������������������������������������������������������������������������������������������������������� 361
Initializing a Layer��������������������������������������������������������������������������������������������������������������� 362
Retrieving Data�������������������������������������������������������������������������������������������������������������������� 364
Mean Squared Layer����������������������������������������������������������������������������������������������������������� 365
Activation Functions������������������������������������������������������������������������������������������������������������ 368
Softmax Layer��������������������������������������������������������������������������������������������������������������������� 372
Function Layer��������������������������������������������������������������������������������������������������������������������� 374
Encoder and Decoders�������������������������������������������������������������������������������������������������������������� 375
Encoder������������������������������������������������������������������������������������������������������������������������������� 375
Pooling Layer����������������������������������������������������������������������������������������������������������������������� 379
Decoders����������������������������������������������������������������������������������������������������������������������������� 380
Applying Encoder and Decoders������������������������������������������������������������������������������������������ 382
NetChains and Graphs�������������������������������������������������������������������������������������������������������������� 383
Containers��������������������������������������������������������������������������������������������������������������������������� 383
Multiple Chains�������������������������������������������������������������������������������������������������������������������� 386
NetGraphs���������������������������������������������������������������������������������������������������������������������������� 387
Combining Containers��������������������������������������������������������������������������������������������������������� 393
Network Properties�������������������������������������������������������������������������������������������������������������� 395
Exporting and Importing a Model���������������������������������������������������������������������������������������� 399
Summary���������������������������������������������������������������������������������������������������������������������������������� 402

Chapter 10: Neural Networks Framework������������������������������������������������������������ 403


Training a Neural Network�������������������������������������������������������������������������������������������������������� 403
Data Input���������������������������������������������������������������������������������������������������������������������������� 403
Training Phase��������������������������������������������������������������������������������������������������������������������� 405

xi
Table of Contents

Model Implementation��������������������������������������������������������������������������������������������������������� 406


Batch Size and Rounds�������������������������������������������������������������������������������������������������������� 408
Training Method (NetTrain)�������������������������������������������������������������������������������������������������� 412
Measuring Performance������������������������������������������������������������������������������������������������������ 413
Model Assessment�������������������������������������������������������������������������������������������������������������� 415
Exporting a Neural Network������������������������������������������������������������������������������������������������ 417
Wolfram Neural Net Repository������������������������������������������������������������������������������������������������� 418
Selecting a Neural Net Model���������������������������������������������������������������������������������������������� 419
Accessing Inside Mathematica�������������������������������������������������������������������������������������������� 421
Retrieving Relevant Information������������������������������������������������������������������������������������������ 422
LeNet Neural Network��������������������������������������������������������������������������������������������������������������� 423
LeNet Model������������������������������������������������������������������������������������������������������������������������ 423
MINST Dataset��������������������������������������������������������������������������������������������������������������������� 424
LeNet Architecture��������������������������������������������������������������������������������������������������������������� 425
MXNet Framework��������������������������������������������������������������������������������������������������������������� 426
Preparing LeNet������������������������������������������������������������������������������������������������������������������� 428
LeNet Training���������������������������������������������������������������������������������������������������������������������� 430
LeNet Model Assesment������������������������������������������������������������������������������������������������������ 432
Testing LeNet����������������������������������������������������������������������������������������������������������������������� 434
GPT and LLM Basics������������������������������������������������������������������������������������������������������������������ 436
A Brief Overview������������������������������������������������������������������������������������������������������������������ 437
LLM in the Wolfram Language��������������������������������������������������������������������������������������������� 437
Chat Notebooks������������������������������������������������������������������������������������������������������������������� 438
Wolfram Prompt Repository������������������������������������������������������������������������������������������������ 441
LLM Functionalities������������������������������������������������������������������������������������������������������������� 444
GTP-1 and GPT-2 Models����������������������������������������������������������������������������������������������������� 446
Final Remarks��������������������������������������������������������������������������������������������������������������������������� 448

Index��������������������������������������������������������������������������������������������������������������������� 451

xii
About the Author
Jalil Villalobos Alva is a Wolfram Language programmer and Mathematica user. He
graduated with a degree in engineering physics from the Universidad Iberoamericana
in Mexico City. His research background comprises quantum physics, bioinformatics,
proteomics, and protein design. His academic interests cover the topics of quantum
technology, bioinformatics, machine learning, artificial intelligence, stochastic
processes, and space engineering. During his idle hours, he likes playing soccer,
swimming, and listening to music.

xiii
About the Technical Reviewer
Andrew Yule is a co-founder and managing partner of
Pontem Analytics, a global consulting company in the
energy industry specializing in combining domain expertise
with data-driven solutions. Andrew has over 13 years of
professional experience leveraging the Wolfram Language
and was the recipient of the Wolfram Innovator Award in
2017. He is an editor for the Society of Petroleum Engineers,
The Way Ahead magazine, and is also currently a member
of the Young Entrepreneurial Council. His technical
background includes a bachelor’s degree in chemical
engineering from the Colorado School of Mines and a
master’s degree in data science from Southern Methodist
University.

xv
Acknowledgments
I want to thank the collective support and guidance received throughout the
development of this project’s second edition. The contributions of numerous past and
present individuals have played an integral role in shaping this work. Their assistance,
feedback, and mentorship have been invaluable, enriching the content and presentation
of this edition. I also want to thank the technical and staff reviewers for their valuable
comments and feedback during this manuscript. They both helped me improve the
material’s presentation and theoretical work. And finally, I would like to thank Las Des
Nestor and “Los Betos” for teaching me great mastery.

xvii
Introduction
Welcome to Beginning Mathematica and Wolfram for Data Science.
Why is data science important nowadays? Data science is an active topic that is
evolving daily; new methods, techniques, and data are created daily. Data science
is an interdisciplinary field involving scientific methods, algorithms, and systematic
procedures to extract data sets and thus better understand the data in its different
structures. It is a continuation of some theoretical data analysis fields such as statistics,
data mining, machine learning, and pattern analysis. With a unique objective, to extract
quantitative and qualitative information of value from the data being recollected from
various sources, and thus be able to objectively count an event for decision-making,
product development, pattern detection, or identification of new business areas.

Data Science Roadmap


Data science carries out a series of processes to solve a problem, which includes data
acquisition, data processing, model construction, communication of results, and
data monitoring or model improvement. The first step is to formalize an objective in
the investigation. From the object of the investigation, you can proceed to the data
acquisition sources. This step focuses on finding the right data sources. The product of
this path is usually raw data, which must be processed before it can be handled. Data
processing includes transforming the data from a raw form to a state in which it can
be reproduced to construct a mathematical model. Proceeding to the construction
of the model, a stage that intends to obtain the information by making predictions in
accordance with the conditions established in the early stages. Here, the appropriate
techniques and tools, which consist of different disciplines, are used. The objective is
to obtain a model that provides the best results. The next step is to present the outcome
of the study. Which consists of reporting the results obtained and whether they are
congruent with the established research objective. Finally, it comes to data monitoring,
with the intention of keeping the data updated because data can change constantly and
in different ways.

xix
Introduction

Data Science Techniques


Data science includes analysis techniques from different disciplines, such as
mathematics, statistics, computer science, and numerical analysis. The following are
some disciplines and techniques used.

• Statistics (linear, multiple regressions, least squares method,


hypothesis testing, analysis of variance (ANOVA), cross-validation,
resampling methods)
• Graph theory (network analysis, social network analysis)

• Artificial intelligence

• Machine learning

• Supervised learning (natural language processing, decision trees,


naive bayes, nearest neighbors. support vector machine)

• Unsupervised learning (cluster analysis, anomaly detection, K-means


cluster)

• Deep learning (artificial neural networks, deep neural networks)

• Stochastic processes (Monte Carlo methods, Markov chains, time


series analysis, nonlinear models)

Even though many techniques exist, this list only shows a part of it since research on
data science, machine learning, and artificial neural networks is constantly increasing.

Prerequisites
This book is intended for readers who want to learn about Mathematica / Wolfram
Language and implement it in data science; it focuses on the basic principles of data
science as well as for programmers outside of software development, that is, people who
write code for their academic and research projects, including students, researchers,
teachers, and many others. The general audience is not expected to be familiar with
Wolfram Language or with the front-end program Mathematica, but little or any
experience is welcome. Previous knowledge of the syntax would be an advantage in

xx
Introduction

understanding how the commands work in Mathematica. If this is not the case, the
book provides the basic concepts of the Wolfram Language syntax. The fundamental
structure of expressions in the Wolfram Language. Basic handling and understanding of
Mathematica notebooks.
Prior knowledge or some experience with programming, mathematical concepts
such as numbers, trigonometric functions, and basic statistics are useful, along
with some understanding of mathematical modeling, which is also helpful but not
compulsory.
Wolfram Language is different from many other languages but very intuitive and
user-friendly to learn.
The book aims to teach the general structure of the Wolfram Language, data
structures, objects, and rules for writing efficient code, and at the same time, teach data
management techniques that allow them to solve problems in a simple and effective
way. Provide the reader with the basic tools of the Wolfram Language, such as creating
structured data, to support the construction of future practical projects.
For this new version, all the programming was carried out on a MacBook Air M1
with Sonoma 14 environment with the installation of version 13.3.1.0 and 14 of Wolfram
Mathematica. Wolfram Mathematica is currently supported in other environments such
as Linux, Windows, and macOS. The code found in the book works with both the Pro and
Student versions.

Book Conventions
Throughout the book, you may come across different words written distinctly from
others. Throughout the book, the words command, built-in functions, and functions may
be used as synonyms that mean Wolfram Language commands written in Mathematica.
So, a function will be written in the form of the real name; for example, RandomInteger.
The evaluation of expressions appears in the Mathematica In/Out format; the same
applies to blocks of code.

In[#]:= “Hello World!”


Out[#]= “Hello World!”

xxi
Introduction

The Layout
The book is written in a compact and focused way to cover the basic ideas behind the
Wolfram Language and cover details on more complex topics. Some chapters have been
revised and redesigned in this new version to focus on novice and advanced topics.
Chapter 1 discusses the starting topics of the Wolfram Language, basic syntax,
and basic concepts with some example application areas, followed by an overview of
the basic operations and debugging techniques, and concludes by discussing security
measures within a Mathematica session.
Chapter 2 provides the key concepts and commands for data manipulation,
sampling, types of objects, and some concepts of linear algebra—the introduction to
lists, an important concept to understand in the Wolfram Language.
Chapter 3 discusses how to work properly with data and the initiation of the core
structures for creating a dataset object, introducing concepts like associations and
association rules are discussed with a conclusion remarking how associations and
dataset constructions can be interpreted as a generalization of a hash table aiming to
expose a better understanding of internal structures inside the Wolfram Language,
including an overview of performing operations on a list and between lists and then
discussing various techniques applied to dataset objects.
Chapter 4 exposes the main ideas behind importing and exporting data with
examples throughout the chapter with common and newly added file formats. It also
presents a very powerful command known as SemanticImport, which can import data
elements that are natural language.
Chapter 5 covers the topic areas for new data visualization, common data plots, data
colors, data markers, and how to customize a plot. Basic commands for 2D plots and 3D
plots are presented, too.
Chapter 6 introduces the statistical data analysis. Starting with random data
generation begins by introducing some standard statistical measures, followed
by a discussion on creating statistical charts and performing an ordinary least
square method.
Chapter 7 exposes the basis for data exploration and reviews a central discussion on
the Wolfram Data Repository. Performing descriptive statistics and data visualization
inside Fisher’s Irises dataset objects is also covered.

xxii
Introduction

Chapter 8 starts with machine learning concepts and techniques, such as gradient
descent, linear regression, logistic regression, and cluster analysis, including examples
from various datasets like the Boston and Titanic datasets and newly implemented
features.
Chapter 9 introduces the key ideas and the basic theory to understand the
construction of neural networks in the Wolfram Language, such as layers, containers,
and graphs. The MXNet framework in the Wolfram Language scheme is also discussed.
Chapter 10 concludes the book by discussing training neural networks in the
Wolfram Language. In addition, the Wolfram Neural Net Repository is discussed with
an example application, examining how to access data inside Mathematica and the
retrieval of information, such as credit risk modeling fraud detection, and concluding
with the example of the LeNet neural network, reviewing the idea behind this neural
network and exposing the main points on the architecture with the help of the MXNet
graph operations and a final road map on the creation, evaluation, and deployment of
predictive models with the Wolfram Language. In this new version, LLM (large language
model) features are introduced with the connection to GPT services, use of chat cells,
and presentation of the GPT-1 and GPT-2 models.

xxiii
CHAPTER 1

Introduction
to Mathematica
The chapter begins with a preliminary introduction to why Mathematica is a useful and
practical tool. It explores the core concepts of the Wolfram Language and its syntax.
It starts by explaining the internal structure of Mathematica and how to add code
effectively. The concept of a notebook is introduced, which is important to understand
the type of format that Mathematica handles. The chapter examines this interface class
and demonstrates how notebooks simultaneously support code and text. In this way,
a notebook is a computable text file. Next, you inspect various add-ons that can be
employed within a notebook to help the user maximize their code’s capabilities.
The next section demonstrates how to write expressions in Mathematica, examining
topics such as arithmetic, algebra, symbols, global and local variables, built-in functions,
date and time formats, plotting functions, logical operators, performance measures,
delayed expressions, and accessing Wolfram Alpha. You then look at how Mathematica
performs code computations, including its accepted varieties of inputs and the
evaluation of these inputs. This chapter concludes with tips for seeking support within
Mathematica, managing and handling errors, searching for solutions, and safely dealing
with security concerns in notebooks that incorporate dynamic content.

Why Mathematica?
Mathematica is a mathematical software package created by Stephen Wolfram more
than 35 years ago. Its first official version (Mathematica 1.0) emerged in 1988 and
was created as an algebraic computational system capable of handling symbolic
computations. However, Mathematica has established itself as a tool capable of
performing complex tasks efficiently, automatically, and intuitively. Mathematica is

1
© Jalil Villalobos Alva 2024
J. Villalobos Alva, Beginning Mathematica and Wolfram for Data Science,
https://doi.org/10.1007/979-8-8688-0348-2_1
Chapter 1 Introduction to Mathematica

widely used in many disciplines like engineering, optics, physics, graph theory, financial
engineering, game development, and software development.
Mathematica provides a complete, integrated platform to import, analyze, and
visualize data. Mathematica does not require plug-ins. It also has a mixed syntax,
performing both symbolic and numerical calculations. It provides an accessible way
to read the code with the implementation of notebooks as a standard format, which
also serves to create detailed reports of the processes carried out. Mathematica can
be characterized as a powerful platform enabling efficient and concise forms of work.
Among computer languages, the Wolfram Language falls into the group of programming
languages classified as a high-level, multi-paradigm interpreted language. Unlike
conventional programming languages, the Wolfram Language adheres to unique rules,
facilitating order and clear, compact code composition.

The Wolfram Language


Mathematica is powered by the Wolfram Language, an interpreted high-level
programming language that covers both symbolic and numeric capabilities. To
understand the Wolfram Language, it is necessary to remember that the language’s
core nature resembles a normal mathematical text, as opposed to other programming
languages’ syntax. The following describes some remarkable features of the Wolfram
Language.

• The first letter of a built-in function word is uppercase and is also


human-readable.
• Any element introduced in the language is taken as an expression.

• Expressions take values consisting of the Wolfram Language atomic


expressions.

–– A symbol made up of letters, numbers, or alphanumeric contents

–– Four types of numbers: integers, rational, real, and complex

–– The default character string is written within the quotation marks (“ ”)

2
Chapter 1 Introduction to Mathematica

• In Mathematica, there are three ways to group expressions.

–– Parentheses group terms within an expression (expr1 + expr2) + (expr3).

–– Command entries are enclosed by brackets [ ]. Also, square brackets enclose


the arguments of a built-in function, F[x].

–– Mathematica uses curly braces {} (e.g., {a, b, c}) to represent lists, arrays,
matrixes, and other collections.

Structure of Mathematica
Before entering code, you need to get the layout of Mathematica. To launch
Mathematica, go to your Applications folder and select the Mathematica icon. This
action brings up the new welcome screen, illustrated in Figure 1-1.

Figure 1-1. The default welcome screen for Mathematica’s latest version

3
Chapter 1 Introduction to Mathematica

Tip The startup window offers valuable information for new and adept users,
including the Mathematica version, access to documentation, resources, and the
Wolfram community, among other things.

After the startup screen appears, you can create a new notebook by selecting the New
Document button, and a blank page should appear like the one shown in Figure 1-2.
New documents can also be created by selecting File ➤ New ➤ Notebook or with the
⌘+N (macOS) or Ctrl+N (Win) keyboard shortcut command.

Figure 1-2. A blank notebook ready to receive input

The blank document that appears is called a notebook, and it’s the core interaction
between the user and Mathematica. Notebooks can be saved locally from the menu bar
by selecting File ➤ Save (or Save as). Initializing Mathematica always exhibits an untitled
notebook. Notebooks serve as the standard document format. They can be customized
to display text alongside computations. However, the key feature of Mathematica lies
in its capacity to perform computations, extending beyond numerical calculations,
regardless of the notebook’s purpose.

4
Chapter 1 Introduction to Mathematica

Note Mathematica version 13.1 introduced a new default assistant toolbar.

Mathematica’s notebooks are separated into input spaces called cells. Cells are
represented by the square brackets on the notebook’s right side. Each input and output
cell has its bracket. Brackets enclosed by larger brackets are related computations,
whether input or output. Grouped cells are represented by nested brackets that contain
the whole evaluation cell. Other cells can be grouped by selecting and grouping them
with the right-click option. Cells can also have the capability to show or hide input by
simply double-clicking the cells. To add a new cell, move the text cursor down, and a flat
line should appear, marking the new cell ready to receive input expressions. The plus
tab in the line is the assistant input tab, showing the various types of input supported by
Mathematica. Figure 1-3 displays grouped input (In[-]) and output (Out[-]) cells.

Figure 1-3. Expression cells are grouped by input and output

There are four main input types. The default input is the Wolfram Language code
input. Free-form input is involved with Wolfram knowledge-base servers, and the results
are shown in Wolfram Language syntax. Wolfram Alpha query is associated with results
explicitly shown on the Wolfram Alpha website. External Language Input is built-in
support for common external programming supported by Mathematica.
There are four main input types.
• Default input: Wolfram Language code input

• Free-form input: involved with Wolfram knowledge-base servers and


the results are shown in Wolfram Language syntax
• Wolfram Alpha query: associated with results explicitly shown on the
Wolfram Alpha website

• External language input: built-in support for common external


programming supported by Mathematica
These are illustrated in Figure 1-4.

5
Chapter 1 Introduction to Mathematica

Figure 1-4. Main input types in Mathematica

Tip Keyboard shortcuts for front-end instruction commands are shown on the
right or left side of each panel.

Design of Mathematica
Now that you have the lay of the land of Mathematica’s basic format, you can learn
the internal structure of how Mathematica works. Inside Mathematica, there are
two fundamental processes: the Mathematica kernel and the graphical interface.
The Mathematica kernel is the one that takes care of performing the programming
computations; it is where the Wolfram Language is interpreted and is associated with
each Mathematica session. The Mathematica interface allows the user to interact with the
Wolfram Language functions and, at the same time, document your progress.

6
Chapter 1 Introduction to Mathematica

Each notebook contains cells, where the commands that the Mathematica kernel
receives are written and then evaluated. Each cell has an associated number. There are
two types of cells: the Input cell and the Output cell. These are associated with each other
and have the following expressions: In[n]:= Expression and Out [n]: = Result or (“new
expr”). The evaluations are listed according to which cell is evaluated first and continue
in ascending order. When quitting the kernel session, all the information, computations
made, and stored variables are relinquished, and the kernel is restarted, including the
cell expressions. To quit a kernel session, select Evaluation ➤ Quit Kernel ➤ Local.

Tip To start a new kernel session, click Evaluation ➤ Start Kernel ➤ Local.

To begin, try typing the following computation.

In[1] := (11*17) + (4/2)


Out[1] = 189

The computation shows that In and Out have a number enclosed. This number is the
number associated with the evaluated expression.
A suggestion bar appears after every expression is evaluated (see Figure 1-5).
The suggestion bar in Mathematica is always visible unless the user hides it. But the
suggestion bar offers suggestions for possible new commands or functions to be applied
to the generated output. The suggestion bar can sometimes be helpful if you are unsure
what to code next; if used wisely, it might be helpful.

Figure 1-5. Suggestion bar for more possible evaluations

The input form of Mathematica is intuitive; to write in a Mathematica notebook,


you just have to put the cursor in a blank space, and the cursor indicates that you are
inside a cell that has not been evaluated. To evaluate a cell, click the keys [Shift + Enter],
instructing Mathematica kernel to evaluate the expression written. The next chapter
looks at the new form to evaluate expressions using the new toolbar.
To evaluate the whole notebook, go to the Evaluation tab on the toolbar and
select Evaluate Notebook. If the execution of calculations takes more time than
expected, you make a wrong execution of code, or if you want to seize a computation,
Mathematica provides several ways to stop calculations. To abort a computation, go to

7
Chapter 1 Introduction to Mathematica

Evaluation ➤ Abort Evaluation. Alternatively, use the keyboard shortcut in Windows


[Alt + .] or macOS [⌘ + .].
When a new notebook is created, the default settings are applied to every cell (input
style). Nevertheless, preferences can be edited in Mathematica with various options. To
access them, go to Edit ➤ Preferences. On macOS, the Preferences (settings) menu is
located in the application menu, go to Mathematica ➤ Settings.
Once opened, a pop-up window appears (see Figure 1-6) with multiple tabs
(Interface, Appearance, AI Settings, etc.). Basic customizations involve magnification,
language settings, and other general instructions. The Appearance tab is related to code
syntax color (i.e., symbols, strings, comments, errors, etc.). The AI Settings tab is the new
tab associated with the LLM (large language model) evaluator. Other options belong to
advanced settings that are not used in this book. Feel free to navigate each option.

Figure 1-6. Preferences window

8
Chapter 1 Introduction to Mathematica

Later, you learn about in-depth settings and customization options for the notebook
interface that allow you to tailor preferences.

Mathematica Environment
This section explores the user interface of Mathematica, with a focus on the notebook
interface, as well as the other user experience functionalities.

Notebook Interface
Mathematica is always on the quest to improve user experience and boost productivity.
In version 13.1, a big enhancement has been introduced—the seamless integration of a
default toolbar (see Figure 1-7) across all standard notebook user interfaces (UIs).

Figure 1-7. The new UI default toolbar showcases essential tools and
functionalities for efficient code development. Toolbar icons may vary by
Mathematica version

This new toolbar (described left to right) includes several new features to enhance
user experience. Evaluate allows users basic and costume code evaluation. Abort
lets users cancel queued cells and remove chosen ones; both options are shown
in Figure 1-8. These features can also be accessed via the keyboard, as previously
mentioned.

9
Chapter 1 Introduction to Mathematica

Figure 1-8. Extensive options for code evaluation and abort options in a notebook
interface; the double arrow-like shape hides the toolbar

The other options integrate text cell formatting, offering styling options like cell style
(title, subtitle, etc.) and cell color background. Users also benefit from the convenient
cell management functions, such as grouping, dividing, merging cells, and inserting
input/output of cells, all reduced to simple buttons. Continuing to options like extend
selection, convert natural language into Wolfram Language code, collapse cells, insert
comment, math form input, and LATEX rendering, users also have access to drawing
canvas and hyperlink features. Finally, the rightmost section of the toolbar includes
buttons for chat notebooks (utilizing LLM features), saving or publishing to the Wolfram
Cloud, accessing documentation (local or web-based), and searching within the
notebook.

Note Different buttons may appear based on the selected cell type where the
cursor resides, ranging from text to code formatting. Figure 1-7 shows for Wolfram
Language code input cell. Figure 1-9 shows for text display cell.

Figure 1-9. Text cell options for bold, italic, and underline and insert code text
evaluation and abort options in a notebook interface

10
Chapter 1 Introduction to Mathematica

This essential addition provides a coherent user experience and fosters a more
streamlined, productive programming environment within Mathematica. For example,
Figure 1-10 shows a code input cell with a colored background.

Figure 1-10. Light-green code input cell, with a 2pt black top margin

Besides the default toolbar, more improvements were made to the other toolbars,
Ruler, Formatting, Templating, and Testing, as Figure 1-11 shows. The last two are not
shown since they are more associated with a specific type of programmatic notebook,
which is beyond the scope of this book.

Figure 1-11. Notebook application toolbar menu showcasing three distinct


toolbars: formatting (upper), default (central), and ruler (lower)

Note To show or hide any toolbar, go to Window ➤ Toolbar. Toolbar availability


varies by version.

11
Chapter 1 Introduction to Mathematica

The prominent toolbar Ruler indicates and adjusts the text margins of specified cells
using draggable marks, offering control over the text format. The Formatting toolbar
brings advanced textual design options, while the Templating and Testing toolbars
(not shown in the image) facilitate the efficient creation of new templates and testing
programmatic notebooks.

Text Processing
Notebooks can include explanatory text, titles, sections, and subsections. The
Mathematica notebook resembles a computable document rather than a programming
command line. Text is useful for describing code and can be inserted into cells as text
cells, which often relate to the corresponding computations. Mathematica allows you to
work with multiple forms of text cells, including lines of text, chapters, formulas, items,
bullets, and more. Like a word-processing tool, notebooks can have titles, chapters,
sections, and subsections. By selecting Format ➤ Style, additional options become
available. For more control over style cells, use the formatting toolbar (see Figure 1-12)
found by navigating to Window ➤ Toolbar Formatting in the menu bar. The formatting
toolbar streamlines cell styling, allowing users to justify text left, center, right, or fully.

Figure 1-12. The Style Format toolbar has a user-friendly interface for
customizing text appearance

The cell types can be arranged in different forms, depending on the notebook’s
format. There are numerous forms to add text in a cell; the most straightforward is
to type the text in the input cell, and the Assistant tab input automatically suggests
converting it to text. Another alternative is to choose the cell type from the toolbars, with
the input chooser or the shortcut (⌘+7 or Ctrl+7).
Styled text can be created with the formatting toolbar or by selecting the desired style
in Format ➤ Style ➤ (title, chapter, text, code, input, etc.). In the Style menu, note the
keyboard shortcuts for all the available text styles. It can be used instead of going into
the menu bar every time. Plain text can also be converted into input text by formatting
the cell in the Input style. There is no restriction in converting text; text can be converted
into whatever style is supported in the format menu.

12
Chapter 1 Introduction to Mathematica

Note To convert text, highlight the text or select the cell that contains the text.

As shown in Figure 1-13, styled cells look different from others. Each style has
a unique order by which a notebook is organized into cell groups. A title cell has a
higher order in a notebook, so the other cells are anchored to the title cell, as shown
in Figure 1-13, but it does not mean that if another title cell is added, both titles are
grouped. If the title cell is collapsed, the title is the only displayed text.

Figure 1-13. A notebook with different format styles; this includes title, subtitle,
section, subsections, plain text, item list, and subitem list

Text can be given a particular style, changed, and different formats applied
throughout the notebook. By selecting Font or Show Fonts (macOS users) from the
Format menu, a pop-up window appears, allowing you to change the font, font style,
size, and other characteristics.

13
Chapter 1 Introduction to Mathematica

Tip To clear the format style of a cell, select the cell and then the right-click
button and choose Clear Formatting.

Palettes
Palettes show different ways to enter various commands into Mathematica. A
diverse quantity of special characters and typesetting symbols are used in the
Wolfram Language, which can be typed within expressions to more closely resemble
mathematical text. The best way to access these symbols is by using the pallets built
into Mathematica. To select a simple pallet, go to Pallets ➤Basic Math Assistant. Each
pallet has different tabs that stand for different categories with distinct commands and a
variety of characters or placeholders that can be inserted using the pallets. To enter the
symbol, type ESC followed by the name of the symbol, then ESC again. Try typing (ESC a
ESC) to type the lowercase alpha Greek letter. Figure 1-14 shows the basic math assistant
pallet in Mathematica.

14
Chapter 1 Introduction to Mathematica

Figure 1-14. The Basic Math Assistant palette

Note Hovering the mouse cursor over a symbol or character, an information tip


pops up, showing the keyboard shortcut. This also applies to placeholders.

Notebook Style and Features


In the new versions comprising version 13.0 and beyond, Mathematica has been
refining and polishing its notebook interface by adding new features for a smoother user
experience. One considerable enhancement involves the handling of extensive outputs
within the user interface. Users can efficiently manage and interpret sizable outputs
without overwhelming the notebook display or causing memory issues. The following

15
Chapter 1 Introduction to Mathematica

example generates a large amount of data, which can be suppressed, displayed, or even
stored in the notebook (see Figure 1-15).

In[2]:= Table[i^12,{i,1,10^4}]
Out[2]=

Figure 1-15. Large output menu displaying additional user control

Figure 1-15 shows that the input code returns a responsive output. Users can expand,
show, iconize, or select to store the whole data expression. Additionally, the data can
be fully stored in the notebook, preserving the entire output for future manipulation
and consuming 0.7MB of memory. If you iconize large outputs, a summary of the data
structure, length, and size is displayed. See Figure 1-16.

Figure 1-16. List structure with 10,000 items and a byte count of 682,696

Another aspect that has been renewed is the preference settings. The whole settings
display has undergone notable refreshment in terms of customization options, as
illustrated in Figure 1-6. Specifically, regarding the notebook front end, by selecting
the Appearance tab (see Figure 1-17), users can tailor their choices to optimize their
notebook code style, resulting in a more personalized experience.

16
Chapter 1 Introduction to Mathematica

Figure 1-17. Notebook settings customization

Figure 1-17 shows Appearance Settings window. The Syntax Coloring tab is related
to the visual representation of code elements (variables, errors, automatic coloring,
highlighting, etc.). The Debugger tab includes coloring options about debugger
highlights, breakpoints, and evaluation points. The Numbers tab offers multiple choices
based on formatting and configuration choices, a few mentions are digits control
numerical notation, among others. The Graphics tab allows you to choose the render of
2D and 3D graphics, from lowest to highest quality.

Note To change the colors of the code syntax options in the Appearance
windows. Select the variables checkbox and click the green square. A color wheel
pops up, allowing you to change the color. This process is the same for the three
code setting options. Also, as you can see, there are different tabs.

17
Chapter 1 Introduction to Mathematica

Expression in Mathematica
Basic arithmetic operations can be performed in Mathematica with a common,
intuitive form.

In[3]:= (3*3) + (4/2)


Out[3] = 11

Mathematica also provides the capability to use a traditional mathematical notation.


To insert a placeholder in the form, click [Ctrl + 6]. To indicate the product operation, use
a space between expressions or add an asterisk (*) between.

In[4]:= 1002 ∗ 10
Out[4]= 100000

In[5]:= 2 1
Out[5]= 2

The standard Mathematica format aims to deliver the value closest to its regular
form, so when dealing with decimal numbers or general math notation, Mathematica
always gives you the best precision (involving, in some circumstances, infinite
precision). However, it allows you to manipulate expressions numerically, to display
numeric values, you use the N function. To insert the square root, type [Ctrl + 2].

In[6]:= 1/2 + 2
Out[6]= 1/2 + 2

In[7]:= N[1/2+ 2 ]
Out[7]= 1.91421

You can manage the number precision of a numeric expression. In this case, you
establish 10 decimal places.

In[8]:= N[77/13,10]
Out[8]= 5.923076923

For a shortcut to work with the decimal point, just type a dot (.) anywhere in the
expression, and with this, you are telling Mathematica to calculate the value with
machine precision.

18
Chapter 1 Introduction to Mathematica

4. 2
In[9]:= +
2 13
Out[9]= 2.15385

Mathematica performs the sequence of operations from left to right, in line with the
written expression, while adhering to the standard order of mathematical operations. To
evaluate an expression without showing the result, you add a semicolon (;) after the end
of the first term. In the following example, the 11/7 is evaluated but not shown, and the
other term is displayed.

In[10]:= 11/7; Sqrt[4]


Out[10]= 2

The last form of code is called a compound expression. Expressions can be written in
a single line of code, and with compound expressions, they are evaluated in the intended
sequence. If you write the semicolon in each expression, Mathematica does not return
the values, but they are evaluated.

In[11]:= 3*4; 100*100; Sqrt[4];Power[2,2];


Out[11]=

There is no output, but all the expressions have been evaluated. Later, you use
compound expressions to understand the concept of delayed expressions. This basic
feature of the Wolfram Language makes it possible for expressions to be evaluated but
not displayed to save memory.

Assigning Values
In the Wolfram Language, each variable requires a unique identifier that distinguishes
it from the others. A variable in the Wolfram Language can be a union of more than one
letter and digits; it must also not coincide with protected words—reserved words that
refer to commands or built-in functions. Keep in mind that the Wolfram Language is
case-sensitive. User variables are advised to be lowercase to avoid confusion with built-
in symbols.

Note Mathematica supports assigning values to variables, which enables the


effective handling of algebraic variables.

19
Chapter 1 Introduction to Mathematica

Undefined variables or symbols appear in blue font, while defined or recognized


built-in functions appear in black. It is also true that the previously mentioned
characteristics can be changed in the preferences window.
Use the keyboard shortcut Esc pi Esc (pi number) to write special constants and
Greek letters. A symbol of a vertical ellipsis (⋮) should appear every time Esc is typed.
Another choice is to write the first letter of the name, and a sub-menu showing a list of
options should appear.

In[12]:= a=Pi
x=11
z+y
Out[12]= π
Out[13]= 11
Out[14]= y+z

In the previous example, Mathematica expresses each output with its cell, even
though the input cell is just one. That is because Mathematica gives each cell a unique
identifier. To access previous evaluations, the symbol (%) is used. Additionally,
Mathematica lets you retrieve previous values using the cell input/output information by
the % # command and the number of the cell or by explicitly writing the command with
In [# of cell] or Out [# of cell]. As demonstrated in the next example, Mathematica gives
the same value for each expression.

In[15]:=
%12
In[12]
Out[12]

Out[15]= π
Out[16]= π
Out[17]= π

To determine whether a word is reserved within the Wolfram Language, use the
Attributes command; this displays the attributes to the associated command. Attributes
are general aspects that define functions in the Wolfram Language. When the word
“Protected” appears in the attributes, it means that the word of the function is reserved.
The next example shows whether the word “Power” is reserved.

20
Chapter 1 Introduction to Mathematica

In[18]:= Attributes[Power]
Out[18]= {Listable,NumericFunction,OneIdentity,Protected}

As seen in the attributes, “Power” is a protected word. Importantly, most of the built-
in functions in Mathematica are listable—that is, the function is interleaved to the lists
that appear as arguments to the function.
Variables can be presented in a notebook in the following ways: (1) global variables,
or those that are defined and can be used throughout the notebook, like the ones in
the earlier examples; and (2) local variables, which are defined in only one block that
corresponds to what is known as a module, in which they are only defined within
a module. A module has the following form: Module [symbol1, symbol 2... body of
module].

In[19]:= Module[{l=1,k=2,h=3},h Sqrt[k+l] + k + l]


Out[19]= 3 + 3 3

Variables inside a module turn green by default; this is a handy feature for seeing the
code inside a module block. A local variable only exists inside the module, so if you try to
access them outside their module, the symbol is unassigned, as shown in the following
example.

In[20]:= {l,k,h}
Out[20]= {l,k,h}

Variables can be cleared with multiple commands, but the most suitable command
is the Clear[symbol], which removes assigned values from the specified variable or
variables. So, if you evaluate the variable after Clear, Mathematica treats it as a symbol,
and you can check it with the command Head; Head always gives you the head of the
expression, which is the type of object in the Wolfram Language.

In[21]:= Clear[a,x]

And if you check the head a, you see that “a” is a symbol.

In[22]:= Head[a]
Out[22]= Symbol

Symbols or variables assigned during a session remain in the memory unless they
are removed or the kernel session ends.

21
Chapter 1 Introduction to Mathematica

Note Remove is an alternative to Clear.

Built-in Functions
Built-in commands or functions are written in common English with the first letter
capitalized. Some functions have abbreviations, while others employ PascalCase
notation with two capital letters. Here, different examples of functions are presented.
Built-in functions and group expressions often require arguments, which are values that
the function needs to execute the correct operation. Functions may or may not accept
arguments; they are separated by commas.

In[23]:= RandomInteger[]
Out[23]= 0

Note RandomInteger, with no arguments, returns a random integer from the


interval of 0 to 1, so do not panic if the result is not the same.

In[24]:= Sin[90 Degree] + Cos[0 Degree]


Out[24]= 2

In[25]:= Power[2,2]
Out[25]= 4

Built-in functions can also be assigned symbols.

In[26]:= d=Power[2,2]
F=Sin[π] + Cos[π]
Out[26]= 4
Out[27]= -1

In[28]:= Clear[d,F]

Some commands or built-in functions in Mathematica have options that can be


specified in a particular expression. To see whether a built-in function has available

22
Chapter 1 Introduction to Mathematica

options, use Option. In the next example, the RandomReal function creates a pseudo-
random real number between an established interval.

In[29]:= Options[RandomReal]
Out[29]= {WorkingPrecision → MachinePrecision}

RandomReal has only one option for specifying specific instructions within the
WorkingPrecision command. The default value for this option is MachinePrecision.
WorkingPrecision defines the number of digits of precision for internal computations,
while MachinePrecision is the symbol used to approximate real numbers, denoted by
$MachinePrecision. To see the value of MachinePrecision, type $MachinePrecision. The
next example observes the difference between using default values for an option and
employing custom values.

In[30]:= RandomReal[{0,1},WorkingPrecision->MachinePrecision]
RandomReal[{0,1},WorkingPrecision->30]
Out[30]= 0.19858
Out[31]= 0.451259323577871140781571594337

Tip In the Wolfram Language, global constants, which can be considered


environmental variables, always start with a dollar sign (e.g., $MachinePrecision).

The first one returns a value with six digits after the decimal point, and the other
returns a value with 30 digits after the decimal point. However, some built-in functions,
such as Power, do not have any options associated with them.

In[32]:= Options[Power]
Out[32]= {}

Dates and Time


The DateObject command provides results for concretely manipulating dates and times
(see Figure 1-18). Date and time input and basic words are supported.

In[33]:=DateObject[]
Out[33]=

23
Chapter 1 Introduction to Mathematica

Figure 1-18. The date of Wed 13 Sept 2023 and time zone

DateObjects with no arguments give the current date, as shown in Figure 1-19.
Natural language is supported in Mathematica—for instance, getting the date after Wed
13 Sept 2023.

In[34]:= Tomorrow
Out[34]=

Figure 1-19. The date of Thu 14 Sep 2023

The date format is entered as year, month, and day. It also supports string date
formats and different calendars, as the next code dates show.

In[35]:= DateString[DateObject[{2020,6,10}]]
Out[35]= Wed 10 Jun 2020

In[36]:= DateString[DateObject[Today,CalendarType->"Julian"]]
DateString[DateObject[Today,CalendarType->"Jewish"]]
Out[36]= Wed 31 Aug 2023
Out[37]= Yom Revi'i 27 Elul 5783

The command also supports options that are related to a time zone.

In[38]:= DateString[DateObject[{2010,3,4},TimeZone->"America/Belize"]]
Out[38]= Thu 4 Mar 2010

Your current location’s sunrise and sunset times can be calculated (support data is
downloaded).

In[39]:= DateString[Sunset[Here,Now]]
DateString[Sunrise[Here,Yesterday]]

Out[39]= Wed 13 Sep 2023 18:41:27


Out[40]= Tue 12 Sep 2023 06:23:34

24
Chapter 1 Introduction to Mathematica

To get the current time, use TimeObject with zero arguments (see Figure 1-20). It can
be entered in the format of 24h or 12h. To introduce the time, enter the hour, minute,
and second.

In[41]:= TimeObject[]
Out[41]=

Figure 1-20. Wed 13 Sep GMT-6 time

Time zone conversion is supported; convert 5 p.m. from GMT-5 Cancun time to
Pacific Time Los Angeles. You can also use DatesString to use pure string objects.

In[42]:=
DateString[TimeZoneConvert[TimeObject[{17,0,0},TimeZone-> "America/
Cancun"],"America/Los_Angeles"]]
Out[42]= 15:00:00

Strings
Text can be useful when a description of the code is needed. Mathematica allows you to
input text into cells and create a text cell related to your computations. Mathematica has
different forms to work with text cells. Text cells can have lines of text, and depending on
the purpose of the text, you can work with different text formats, like creating chapters,
sections, or just general text. In contrast, to text cells, you can introduce comments to
expressions that need an explanation of their purpose or just a description. For that, you
simply write the comment within the symbols (* *). And the comments are shown with
different colors; comments also always remain as unevaluated expressions. Comments
can be single-line or multiline.
Mathematica can work with strings. To input a string, enclose the text in quotation
marks “text”; Mathematica knows that it is dealing with text. Characters can be whatever
you type or enter into the cells.

In[43]:= "Hello World" (*This is a comment*)


Out[43]= Hello World

25
Another Random Scribd Document
with Unrelated Content
The Project Gutenberg eBook of Sten Sture
nuorempi ja Kristiina Gyllenstjerna I: Ruotsin
Valkyria
This ebook is for the use of anyone anywhere in the United States
and most other parts of the world at no cost and with almost no
restrictions whatsoever. You may copy it, give it away or re-use it
under the terms of the Project Gutenberg License included with this
ebook or online at www.gutenberg.org. If you are not located in the
United States, you will have to check the laws of the country where
you are located before using this eBook.

Title: Sten Sture nuorempi ja Kristiina Gyllenstjerna I: Ruotsin


Valkyria

Author: Louise Stjernström

Translator: Lauri Soini

Release date: September 15, 2017 [eBook #55552]

Language: Finnish

Credits: E-text prepared by Juhani Kärkkäinen and Tapio Riikonen

*** START OF THE PROJECT GUTENBERG EBOOK STEN STURE


NUOREMPI JA KRISTIINA GYLLENSTJERNA I: RUOTSIN VALKYRIA
***
E-text prepared by Juhani Kärkkäinen and Tapio Riikonen

STEN STURE NUOREMPI JA


KRISTIINA GYLLENSTJERNA
I: RUOTSIN VALKYRIA
Historiallis-romanttinen kuvaus

Kirj.

CARL BLINK [Louise Stjernström]

Suomentanut Juho Ahava [Lauri Soini]

Helsingissä, Kustannusosakeyhtiö Otava, 1912.


SISÄLLYS:

1. Luostarimuurien sisällä.
2. Naisenryöstö.
3. Vaaralliset kirjeet.
4. Suomalaiset.
5. Synnin palkka täytyy hänen armonsakin pitää hyvänään.
6. Synnin palkka, millaisena se lankeaa jalosukuiselle rouvalle.
7. Pilvet vetäytyvät kokoon.

1.

LUOSTARIMUURIEN SISÄLLÄ.

Oli kylmä ja kuulas tammikuun päivä 1512; lumi narisi kävelijäin


jaloissa ja auringon säteet säkenöivät jäätyneillä ikkunaruuduilla,
sillä Vadstenassa oli jo ehditty sellaisia hankkia kaikkiin hyvävaraisiin
taloihin, ja useimmat talot olivat hyvissä varoissa, siitä sai kaupunki
kiittää luostarista koituvia suuria etuja.
Mutta kiittämättömyys on yhtä vanha kuin maailmakin, eikä
Vadstena tehnyt mitään poikkeusta säännöstä, varsinkin kun
kaupungilla oli suotuisammat ja paremmat olot kuin kaikilla muilla
kaupungeilla ja sentähden suuremmat vaatimukset.

Mainittuna päivänä kohtasivat toisensa raatimies Reinhardin


emäntä ja matami Elsa Olavintytär, juuri kun edellinen palasi torilta
ja jälkimäinen oli aikeissa sinne tekemään ostoksia viikon varalle.

"Herran siunausta, sisko!" virkkoi jälkimäinen hieman pisteliäästi,


harmissaan siitä, että tuli liian myöhään.

"Suuri kiitos, mutta tänään ei ole saatavissa mitusen mitään;


kaikki menee luostariin kuten tavallisesti."

"Minusta näyttää siskon kori olevan täysi."

"Lampaan puolikas vain, muutamia nauriita ja lohen palanen,


sellaista kyllä saa koko päivän."

"Mitäs vielä pitäisi!"

"Hyvänen aika, sellaisia makupaloja kuin luostariväelläkin on."

"Sellaisesta minä en välitä!"

"Kyllä minun vain täytyy sanoa, että aina kun Ingeborgini tulee
sieltä, on hänellä niin paljon kerrottavaa siitä, mitä niillä siunatuilla
sisarilla on pöydässään, ja kun kerran on varaa, miksei laittaisi yhtä
mainiota itselleen."

"Mutta kun nyt kaikki menee sinne?"


"Niin, sanos muuta. Voiko sisko ajatella, että tänään, paukkuvassa
talvipakkasessa, tuli puutarhuri kulettaen vihanneksia, yhtä tuoreita
kuin oltaisiin keskellä kesää."

"Eikö se ole Jumalan pilkkaamista?"

"Mitäs muuta sitten!"

"Miehelläni on ollut työtä luostarista. Kunnianarvoisat veljet olivat


sangen tyytyväiset siihen, ja niin kutsuttiin hänet eräänä päivänä
syömään päivällistä."

"No, sisko!" Raatimiehen emäntä teki samoja eleitä kuin kissa


ilmaistessaan tyytyväisyyttään.

"Kyllä se oli ollut mainiota!"

"Hienoa tietysti?"

"Kaikkea muuta!"

"Mitä nyt?"

"Mitä heillä oli ruokana? kysyin minä, kun hän tuli kotiin. Hän
ärähti vihaisesti: Kärvennettyä lampaanlapaa ja hapankaljaa
saadakseni ei minun tarvitse mennä luostariin!"

"Eikä saada kotonakaan!"

"Niin juuri minäkin sanoin, mutta siihen ei hän vastannut mitään,


niin hän oli poissa suunniltaan."

"No, mutta eikö sitten ollut muuta mitään?"


"Tavallista ruisleipää!"

"Ja sitten?"

"Ei Jumalan jyväistäkään enempää."

"Moista en ole kuullut koskaan!"

"Mutta mieheni kosti."

"Kuinka niin?"

"Hän kutsui muutamia kunnianarvoisista isistä vieraikseen."

"Sillille ja leivälle?"

"Ei, me laitoimme pöydän koreaksi!"

"No, mitä he sanoivat?"

"Söivät ja joivat vain!"

"Mutta totta kai he sanoivatkin jotakin?"

"Sanoivat, etteivät olleet koskaan voineet niin hyvin."

"Entä kaikki herkut, mitkä menevät luostariin?"

"Ne menevät abbedissalle ja sisarille."

"Voiko se olla mahdollista?"

"Sitä en usko."

"Niin, en minäkään."
"Vaikken tahdo sanoa mitään."

"En minäkään! Onhan Ingeborgini ja monet muut hänen


kanssansa oppineet luostarissa nypläyksen ja paljon muuta; nunnat
ovat aina valmiit neuvomaan, kun heitä pyytää; mutta abbedissa
pakottaa maan kantamaan hedelmiä, kun se tahtoo levätä, ja
hänellä on tuoksuvia ruusuja keskellä talvea."

"Kuinka ikinä se voisi olla mahdollista!"

"Se on silkkaa totta, rakas sisko, enkä suinkaan tahdo sanoa


sanaakaan siunattua abbedissaa ja siunattua luostaria vastaan,
mutta kyllä sentään ihmettelen itsekseni, onko oikein ja Jumalalle
otollista, että ihmiset pakottavat maan kasvamaan talvella sellaista,
minkä Jumala tahtoo kasvavan ainoastaan kesällä."

"Tuollaisesta kai eivät ymmärrä meikäläiset yksinkertaiset ihmiset


mitään", vastasi Elsa sisko. "Paljon on muutakin pulmallista."

"Mitä niin?"

"Oh, ei juuri mitään!"

"Kyllä, jotakin se on!"

"Täytyy lukita kieli hampaiden taa."

"Odotahan hieman; minä heitän vain korin ovesta sisään, sitten


tulen mukaan torille; olen unhottanut jauhot…" Ja raatimiehen
emäntä riensi tiehensä.

Seppämestari Eliaanpoikaa pidettiin kaupungissa suuressa arvossa,


ja hänen muijansa, Elsa Olavintytär, sai sentähden osakseen suurta
kunnioitusta ja luottamusta; tiedettiin hyvin, että hänellä oli paljon
tiedossaan.

Hän jatkoi verkkaan taivallustaan; hän näytti olevan yhtä kärkäs


puhumaan kuin toinen kuulemaan, eikä kestänyt monta minuuttia,
ennenkuin hänen ja raatimiehen emännän nähtiin, kummallakin kori
kainalossaan, käsikynkässä ja innokkaasti puhellen palaavan torille.

"Noo?" kysyi raatimiehen emäntä innokkaasti.

"En tiedä, onko minulla lupa…"

"Kenen tähden?"

"Se voi olla samantekevää!" Elsa tahtoi vapauttaa käsivartensa,


mutta raatimiehen emäntä piti sen kiinni.

"Mitä tämä merkitsee!" huudahti hän. "Enkö minä kertonut siskolle


nimismiehestä ja Pietari Räätälin leskestä, samoin riidasta
konfessorin ja abbedissan kesken? Mutta maailmassa ei ole mitään
kiitollisuutta!" Ja raatimiehen emäntä otti käsiliinansa taskustaan,
levitti sen ja kuivaili silmiään, jonka jälkeen hän sen laittoi
laskoksilleen ja pisti takaisin taskuun. "Jollei sisko tahdo sanoa
mitään, niin vaikene kernaasti minusta nähden!" lisäsi hän jättämättä
siltä toisen käsivartta.

"Lupaako sisko olla vaiti?"

"Niinkuin muuri."

"Veli Mathias…"

"Lasimestari?"
"Niin!"

"Hän on laittanut ruudut meillekin."

"Jollei häntä olisi ollut, emme kai olisi koskaan saaneet mitään
lasi-ikkunoita. Minun mieheni mielestä oli synti laittaa niin kovin
valoisaa, ja kun isillämmekin on ollut ainoastaan lyijyruutuja, niin
voimmehan mekin niihin tyytyä."

"Ihan kuten meilläkin!"

"Mutta veli Mathias sanoi…"

"Ja perheenäiti sanoi hänkin sanansa…?"

"Tietysti sekin vaikutti."

"Veli Mathias käy usein teillä?" Raatimiehen emännän katse oli


kiinnitettynä Elsaan.

"Kaarinallani on niin hyvä halu opetella latinaa, ja veli Mathias


lukee hänen kanssaan."

"Kaarina on sorja neito."

"Oh, herrapa hänet tiennee!"

"Kysy Mathiaalta!"

Elsa katsoi ällistyneenä raatimiehen rouvaan. "Mitä sanotte?" kysyi


hän. "Ettekö tiedä, että Kaarina on kunniallinen tyttö?"

"Se ei suinkaan estä, että veli voi mielistyä häneen."


"Kaikella siveydellä ja kunniallisuudella; Kaarina voi hyvin sietää
häntä."

"Sanotaan, että ensimäinen mestarisälli on kosinut Kaarinaa?"

"Herra paratkoon, hän ei tahdo ottaa häntä!" huokasi äiti.

"Kuka siihen on syypää?"

"Hän on niin nuori!"

"Kahdeksantoista; paras ikä!"

"Luuletteko, että Mathias…"

"Niin luulee koko kaupunki!"

Nyt tempasi Elsa käsivartensa irti. "Täälläkään ei siis anneta


raukan olla rauhassa!" huudahti hän.

"Vilpittömiä ystäviä arvostellaan väärin!"

"Mathias kyllä saa kuulla kunniansa…"

"Älä vain mainitse minua…"

"En, tietysti!… Mutta sanoa se juuri nyt, kun hän tahtoo tehdä
meille niin suuren palveluksen…"

"Minkä sitten?"

"Siitähän juuri piti kertoanikin…"

"No, kerro sitten…"


Tällävälin olivat molemmat juttelevat naiset ehtineet torille;
luostari näkyi sinne, ja molemmat huomasivat nyt erään munkin,
joka, kaapuunsa kääriytyneenä ja huppukaulus vedettynä pään
ylitse, hitaasti ratsasti torin poikki. Hevonen ja ratsastaja näyttivät
yhtä upiuupuneilta; edellinen ilmaisi hirnahtaen tyytyväisyytensä
luostarin nähdessään, ja jälkimäinen heitti huppukauluksen
taaksepäin ja katseli eräänlaisella uteliaisuudella ympärilleen.

"Isä Laurentius!" huudahtivat molemmat naiset.

Munkki käänsi päätänsä, tunsi heidät ja nyökäytti ystävällisesti


päätänsä.

Naiset niiasivat maahan asti.

"Vieraanne on tullut, Elsa muori!" sanoi munkki hiljaa ja jatkoi sen


jälkeen matkaansa.

"Pyhä Maria!" huudahti tämä ja riensi kotia kohden niin nopein


askelin, ettei raatimiehen emännän maksanut koettaakaan häntä
seurata.

Sillävälin oli munkki saapunut luostariin ja soittanut. Portti avattiin


hänelle ja hänen ratsulleen.

Luostaripiha oli melkein neliskulmainen. Kolmella reunalla oli


rakennuksia, neljänneltä, joka oli kadulle päin, teki asuinrakennusta
melkoista korkeampi kivimuuri mahdottomaksi nähdä
ulkomaailmaan. Siitä huolimatta eivät veljet eivätkä siskot olleet
suljetut maailmasta pois, vaan ainoastaan suojatut uteliailta katseilta
ja — kenties monetkin — vaaralliselta kiusaukselta ikävöidä ja
huoata menetettyä vapauttaan.
Vadstena oli kaksoisluostari, jossa oleskeli sekä miehiä että naisia.
Mainitun luostarirakennuksen toisella puolen oli puutarha, ja sen
päässä oli jälleen korkea muuri, joka oli naisten ja miesten alueen
rajana. Molemmilla luostareilla oli oma kappelinsa, mutta kirkko oli
välillä ja yhdisti molemmat. Sinne puutarhasta vievä sisäänkäytävä
oli muurilla aidattu kahtia, niin ettei veljillä ja sisarilla ollut mitään
yhteyttä keskenään.

Yleinen sisäänkäytävä kirkkoon oli kadulta, vastapäisellä puolella.


Täällä oli myös ruokasali, kokoussaleja ja muita huoneita.

Luostarin alue käsitti siis koko neljänneksen, ja sinne oli


sisäänkäytävät kaikilta neljältä puolelta.

Ylin johtaja oli abbedissa, hänen alapuolellaan oli konfessori, joka


oli veljien ylin valvoja, samoinkuin prioritar oli sisarten.
Viimeksimainittujen luku nousi nykyään kuuteenkymmeneen, mutta
vakinaisten veljien kolmeenkymmeneen.

Palaamme miesluostarin pihaan.

Kellonsoitto oli tehnyt vaikutuksen, jota saattoi odottaakin.


Kaikissa ikkunoissa näkyi päitä ja kyseltiin uteliaina toisiltaan:
"Kukahan tulija lienee?"

Munkki oli jälleen vetänyt huppukauluksen päänsä ylitse, joko


kylmän tähden tai muusta syystä. Nyt heitti hän sen nopeasti
taapäin ja silmäili ujostelematta ympärilleen.

"Veli Laurentius!" kajahti kaikkien suista.

"Niin, veljet, Laurentius, joka kiittää Jumalaa ja pyhää Birgittaa


siitä, että on täällä jälleen!" virkkoi munkki astuessaan alas ratsailta.
Mutta sen jälkeen oli hänen ilmeisesti vaikea seista jaloillaan.

"Pidä hyvä huoli elukka parasta!" sanoi hän palvelevalle veljelle,


joka tuli ottamaan vastaan hevosta. "Sen veroista ratsua saa kauan
etsiä!" Näin sanoen taputti hän hevosta lautasille ja määräsi, miten
sitä oli hoidettava.

"Veli Laurentius!"

Kun hän kääntyi, näki hän suurimman osan veljistä seisovan


ympärillään.

"Niin, nyt alan saada aikaa tervehtiä." Ja hän pudisti heidän


kaikkien kättä.

"Tervetuloa kotiin!"

"Niin, tervetuloa!" huusivat kaikki.

"Kiitos, kiitos!"

"Oletko kokenut kovia?"

"Sellaiset pakkaset!"

"Vaivalloiset tiet?"

"Monia ikävyyksiä taipaleella?"

Kysymykset satelivat hänen ylitseen.

"Kova nälkä saapuessa perille!" huudahti Laurentius tömistellen


jalkojaan. "Nälkä ja kylmä samalla kertaa, onko kukaan teistä sitä
kokenut?"
Kaikki nauroivat, ja veli vietiin heti ruokasaliin, missä takassa paloi
suuri loimotteleva valkea ja pöytään tuotiin hyvä ateria, jossa ei
suinkaan ollut vain kärvennettyä lampaanlapaa ja hapankaljaa.

Ja veli Laurentius söi ja joi kuten mies, joka ei ole moniin


viikkoihin astunut katetun pöydän ääreen; hänen utelias
ympäristönsä sai tyytyä yksitavuisiin vastauksiin, joihin hän sekoitti
kysymyksiä, niin että kun tahdottiin tietää, oliko hän koko ajan ollut
terve, tuli vastaukseksi:

"Jotakuinkin, mutta täällä?"

"Miten milloinkin."

"Abbedissa?"

"Heikko terveys, herra paratkoon!"

"Toivotaan, että kevät palauttaa hänen terveytensä. Ja


kunnianarvoisa äiti, prioritar?"

"Terve ja reipas kuten aina!"

"Pyhä Birgitta olkoon kiitetty! Ja kaikkien meidän isämme,


kunnianarvoisa konfessori?"

"Hänellä on juuri nyt neuvottelu abbedissan kanssa."

"Sitten tahdon sillävälin hieman levähtää. Veli Pentti kenties


herättää minut, kun aika tulee?"

Puhuteltu nyökäytti myöntävästi päätänsä; hän oli nuorin veljistä,


ainoastaan muutamia vuosia yli kahdenkymmenen, valkokiharainen
ja sinisilmä. Hän muistutti munkiksi pukeutunutta tyttöä, ja munkit
sanoivatkin häntä leikkisästi "sisareksi".

Mutta silloin leimahtivat lempeät sinisilmät todellisia


vihansalamoita ja hän pyysi vastaisuudessa päästä pilanteosta, jota
hän ei sanonut aikovansa sietää.

Veli Laurentius näytti ottavan hänet erityiseen huomaansa, ja


noustuaan pöydästä lähteäkseen selliinsä viittasi hän salavihkaan
nuorta veljeä seuraamaan.

"Mitä uutta?" kysyi hän heti kun he olivat ehtineet selliin.

"Ei mitään tärkeä."

"Mutta kuitenkin jotakin?" vastasi munkki terävästi tähystellen


nuorta veljeä.

Tämä seisoi maahan luoduin silmin.

"No, saanko vastauksen?"

"Se koskee ainoastaan minua!"

"Moista ei sinun tarvitse sanoa, näen sen, mutta tahdon tietää,


mitä se on."

"Säästäkää minua, kunnianarvoisa isä!"

"Silloin kutsutaan sinut ripille!"

"Miksi tahdotte repiä vertavuotavaa haavaa!" huudahti


nuorukainen.
"Katsokaa ja arvostelkaa, olenko ollut sääliväinen itseäni kohtaan!"
Ja hän avasi pukunsa ja näytti ruoskimalla hirveästi haavoitetun
ruumiin.

"Miksi kaikki tämä?" kysyi Laurentius hämmästyksissään.

"Karkoittaakseni pahat ajatukset."

"Sinä rakastat?"

"Niin, kovaksi onneksi!"

"Ketä?"

"Täytyykö minun sanoa se?"

"Käsken sen!"

"Erästä nuorta porvarin tytärtä."

"Hänen nimensä?"

"Kaarina Eliaantytär."

"Rikkaan seppämestarin tytär?"

"Juuri hän!"

"Sinä olet kohdannut hänet ainoastaan kadulla?"

"Minä käyn melkein joka päivä hänen isänsä talossa… Silloin


kohtaamme toisemme!"

"Mitä tekemistä sinulla siellä on?"

"Veli Mathias opettaa hänelle latinaa."


"No ja sitten?"

"Hän tahtoo aina minut mukaan!"

"Mitä varten?"

"Muuten ei hän saisi olla kahdenkesken Kaarinan kanssa."

"Sinusta ei hän siis välitä?"

"Ei, minun ollessani läsnä voi hän puhua rakkaudestaan Kaarinan


kanssa, ja Kaarina…"

"Se miellyttää häntä?"

"Kaarina rakastaa minua!"

"Onko hän sanonut niin?"

"Kerran sanoillakin, mutta joka päivä katseillaan. Ainoastaan


saadakseen nähdä minua kuuntelee hän veli Mathiaan viekkaita
sanoja."

"Eikö veli Mathiaan rakkaus ole yhtä oikeutettu kuin sinunkin?"

"Kyllä, ja yhtä rikollinen!… Minä pakenisin Kaarinan näkyvistä,


mutta kuitenkin pysyn siellä suojellakseni häntä… häntä uhkaa suuri
vaara."

"Mistä sen tiedät?"

"Veli Mathias on tehnyt minut uskotukseen."

"Onko hän sokea?"


"On, paitsi rakkaudelleen."

"Mikä on hänen aikeensa?"

"Ryöstää Kaarina pois."

"Hän uskaltaa?"

"Hän tahtoo, että minun on se tehtävä."

"Heh, panna pukki puutarhuriksi! Olet kai suostunut?"

"Omatuntoni on kieltänyt sen."

"Se on kunniaksi omalletunnollesi. Vaiti, joku tulee!"

Muuan palveleva veli ilmoitti, että konfessori oli palannut ja tahtoi


mielellään puhutella veli Laurentiusta ad privatum.

"Vastaa, että tulen hetimiten", vastasi tämä, "kunhan vain ensin


otan esiin muutamia kirjeitä."

"Milloin on sinun ensi kerran mentävä sinne?" kysyi hän Pentiltä,


heidän jäätyään kahden.

"Huomenna!"

"Se ei saa tapahtua!"

"Älkää kieltäkö minua!" huudahti Pentti epätoivoissaan.


"Mieluummin kadun kaksinkerroin, ennenkuin sallin hänen mennä
sinne yksin."

"Hän ei enää tule sinne menemään."


"Voitteko estää sen?" huudahti nuorukainen riemuiten.

"Voin estää hänet näkemästä enää tyttöä."

"Millä tavoin?"

"Sitä en vielä tiedä, mutta huomiseen on vielä aikaa. Jätä minut


nyt!"

Muutamia minuutteja myöhemmin tapaamme veli Laurentiuksen


jälleen istumassa pienen pöydän ääressä luostarin kirjastossa.
Vastapäätä häntä istuu konfessori, kunnianarvoisa maisteri Nikolaus
Ragvaldinpoika, ja kuuntelee tarkkaavaisesti toisen sanoja.

"Julius toinen ei ole meille erittäin suosiollinen", sanoi hän.


"Pietarinropo ei paisu meidän maassamme niin suureksi kuin pyhä
valtaistuin toivoisi."

"Kootaanhan kuitenkin suuria summia."

"Mutta tie on pitkä täältä Roomaan ja suuri osa ei pääse kuunaan


perille. Siitä huolimatta birgittiinikunta on suuressa arvossa ja
meidän hospitaalimme Roomassa on niin hyvin hänen pyhyytensä
kuin kardinaalienkin erityisessä suosiossa."

"Mutta se maksaa suuria summia."

"Tosin kyllä, mutta ei kunniakaan ole vähäinen."

"Emme ole vielä saaneet ketään ruotsalaista pyhimystä, paitsi


pyhää
Birgittaa."
"Minulla oli armo puhua siitä hänen pyhyydelleen, ja hän teki
minulle ymmärrettäväksi, että se riippuu pääasiallisesti siitä,
tahdommeko ja voimmeko maksaa."

"Pyhän Katarinan jäännösten juhlallisesta arkkuunkätkemisestä


maksoimme kaksi tuhatta tukaattia", puuttui konfessori vilkkaasti
puheeseen. "Pyhäksijulistus nousisi varmaankin vähintään kuuteen
tuhanteen; mutta sellainen juhla lisäisi niin suuressa määrin
toivioretkeläisten lukua, että me heiltä varsin pian saisimme kokoon,
mitä menettäisimme."

"On eräs toinen syy, joka kenties on vielä tärkeämpi ja


merkitsevämpi", virkkoi Laurentius erityisellä äänenpainolla.
"Tarkkaavalta katsojalta ei voi jäädä huomaamatta ajan
vieraantuminen kirkosta."

"Mitä sanotte?" puuskahti konfessori. "Saksassa oleskellessani


kuulin siitä yhtä ja toista. Toivokaamme ja uskokaamme, että pyhä
neitsyt ja kaikki pyhimykset iät kaiket suojelevat ja varjelevat ainoaa
autuaaksi tekevää uskoa, mutta meidän, hänen halpojen
palvelijainsa, asia on kaikin voimin tukea ja kannattaa, mitä ajan
pahuus tahtoo repiä maahan. Erittäinkin on meidän asiamme
lohduttaa ja tukea heikkoja ja epäileväisiä. Uudet pyhimykset
herättäisivät uutta eloisuutta, enkä minä ole säästänyt vaivojani
saavuttaakseni, mihin niin kauan olemme pyrkineet."

"Skaaran piispan, Brynolfin, täytyy ensin tulla kysymykseen!"


huudahti konfessori.

"Samaa kunniaa vaaditaan Linköpingin piispalle, Nikolaus


Hermanninpojalle."
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!

ebookultra.com

You might also like