0% found this document useful (0 votes)
4 views

CST, Calculus for Cognitive Scientists Partial Differential Equation Models

The document is a comprehensive text titled 'Calculus for Cognitive Scientists' by James K. Peterson, focusing on partial differential equation models relevant to cognitive science. It serves as a preparatory resource for students and researchers in fields such as biology, cognitive science, and neurobiology, emphasizing the importance of mathematics and computer science in understanding cognition. The book includes various mathematical tools and models, aiming to inspire interdisciplinary collaboration in cognitive research.

Uploaded by

David Olivera
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CST, Calculus for Cognitive Scientists Partial Differential Equation Models

The document is a comprehensive text titled 'Calculus for Cognitive Scientists' by James K. Peterson, focusing on partial differential equation models relevant to cognitive science. It serves as a preparatory resource for students and researchers in fields such as biology, cognitive science, and neurobiology, emphasizing the importance of mathematics and computer science in understanding cognition. The book includes various mathematical tools and models, aiming to inspire interdisciplinary collaboration in cognitive research.

Uploaded by

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

Cognitive Science and Technology

James K. Peterson

Calculus for
Cognitive
Scientists
Partial Differential Equation Models
Cognitive Science and Technology

Series editor
David M.W. Powers, Adelaide, Australia

More information about this series at http://www.springer.com/series/11554


Jim makes his first step toward developing cephalopod measure for his new class in comparative
cognition
James K. Peterson

Calculus for Cognitive


Scientists
Partial Differential Equation Models

123
James K. Peterson
Department of Mathematical Sciences
Clemson University
Clemson, SC
USA

ISSN 2195-3988 ISSN 2195-3996 (electronic)


Cognitive Science and Technology
ISBN 978-981-287-878-6 ISBN 978-981-287-880-9 (eBook)
DOI 10.1007/978-981-287-880-9

Library of Congress Control Number: 2015958343

© Springer Science+Business Media Singapore 2016


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.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this
publication does not imply, even in the absence of a specific statement, that such names are exempt from
the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this
book are believed to be true and accurate at the date of publication. Neither the publisher nor the
authors or the editors give a warranty, express or implied, with respect to the material contained herein or
for any errors or omissions that may have been made.

Printed on acid-free paper

This Springer imprint is published by SpringerNature


The registered company is Springer Science+Business Media Singapore Pte Ltd.
I dedicate this work to my students who have
learned this material in its various
preliminary versions, to my students who
interested in working out models of various
small creatures brains, have settled down and
devoted months of effort to learning about
excitable nerve cells in this abstract way and
to the practicing scientists from biology,
cognitive science, neurobiology and
computational cognitive science who have
helped an outsider think better in this very
interdisciplinary world. As always, I also
thank my family who have listened to my
ideas in the living room, over dinner, in my
study and on walks in the forest for many
years. I hope that this new text helps to
inspire all my students to consider
mathematics and computer science as
indispensable tools in their own work in the
trying to understand cognition. This is the
last preparatory text on the underlying
mathematics and computation to study
cognitive systems. In the next volume, the
study of neural systems begins!
Acknowledgments

We would like to thank all the students who have used the various iterations
of these notes as they have evolved from handwritten to the fully typed version
here. We particularly appreciate your interest as it is hard to find students who want
to learn how to wear so many hats! We have been pleased by the enthusiasm you
have brought to this interesting combination of ideas from many disciplines. These
ideas have been taught as an overload to small numbers of students over the last
10 years. We appreciate them very much!

vii
Contents

Part I Introductory Matter


1 Introduction. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Chapter Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Part II Quantitative Tools


2 Graham–Schmidt Orthogonalization . . . . . . . . . . . . . . . . . . . . . . . 13
2.1 Numerical Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.1 Evaluating Smk . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.1.2 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1.3 Matlab Implementation . . . . . . . . . . . . . . . . . . . . . 20
2.1.4 Run Time Output . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2 Linearly Independent Functions . . . . . . . . . . . . . . . . . . . . . . 22
2.2.1 Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
2.2.2 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.3 Vector Spaces and Basis . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.4 Inner Products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.5 Graham–Schmidt Orthogonalization . . . . . . . . . . . . . . . . . . . 32
2.5.1 Making It Formal . . . . . . . . . . . . . . . . . . . . . . . . . 41
2.5.2 General MatLab GSO . . . . . . . . . . . . . . . . . . . . . . 41
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
3 Numerical Differential Equations . . . . . . . . . . . . . . . . . . . . . . . . . 47
3.1 Approximating Solutions Numerically . . . . . . . . . . . . . . . . . . 47
3.1.1 Expansions of F . . . . . . . . . . . . . . . . . . . . . . . . . . 48
3.1.2 Minimizing Error . . . . . . . . . . . . . . . . . . . . . . . . . 50
3.1.3 The Matlab Implementation . . . . . . . . . . . . . . . . . . 52

ix
x Contents

3.2 Runge–Kutta Fehlberg Methods . . . . . . . . . . . . . . . . . . . . . . 53


3.2.1 The RKF5 Flowchart. . . . . . . . . . . . . . . . . . . . . . . 54
3.2.2 Runge–Kutta Fehlberg MatLab Implementation . . . . 56
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

Part III Deriving the Cable Model


4 Biological Molecules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.1 Molecular Bonds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.1.1 Bond Comparisons . . . . . . . . . . . . . . . . . . . . . . . . 68
4.2 Energy Considerations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
4.3 Hydrocarbons. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
4.4 Amino Acids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
4.5 Peptide Bonds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.6 Chains of Amino Acids. . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
4.7 Nucleic Acids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.7.1 Sugars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.7.2 Nucleotides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.7.3 Complementary Base Pairing . . . . . . . . . . . . . . . . . 91
4.8 Making Proteins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
5 Ion Movement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5.1 Membranes in Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
5.2 The Physical Laws of Ion Movement . . . . . . . . . . . . . . . . . . 99
5.2.1 Ficke’s Law of Diffusion . . . . . . . . . . . . . . . . . . . . 99
5.2.2 Ohm’s Law of Drift . . . . . . . . . . . . . . . . . . . . . . . 100
5.2.3 Einstein’s Relation . . . . . . . . . . . . . . . . . . . . . . . . 101
5.2.4 Space Charge Neutrality . . . . . . . . . . . . . . . . . . . . 101
5.2.5 Ions, Volts and a Simple Cell. . . . . . . . . . . . . . . . . 102
5.3 The Nernst–Planck Equation . . . . . . . . . . . . . . . . . . . . . . . . 103
5.4 Equilibrium Conditions: The Nernst Equation . . . . . . . . . . . . 105
5.4.1 An Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
5.5 One Ion Nernst Computations in MatLab . . . . . . . . . . . . . . . 108
5.5.1 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
5.6 Electrical Signaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
5.6.1 The Cell Prior to K Gates . . . . . . . . . . . . . . . . . . . 110
5.6.2 The Cell with K þ Gates . . . . . . . . . . . . . . . . . . . . . 111
5.6.3 The Cell with NaCl Inside and Outside Changes. . . . 112
5.6.4 The Cell with Na þ Gates . . . . . . . . . . . . . . . . . . . . 113
5.6.5 The Nernst Equation for Two Ions . . . . . . . . . . . . . 113
5.6.6 The Nernst Equation for More Than Two Ions . . . . . 115
5.6.7 Multiple Ion Nernst Computations in MatLab. . . . . . 117
Contents xi

5.7 Ion Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119


5.7.1 Transport Mechanisms. . . . . . . . . . . . . . . . . . . . . . 119
5.7.2 Ion Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
5.7.3 Active Transport Using Pumps . . . . . . . . . . . . . . . . 124
5.7.4 A Simple Compartment Model . . . . . . . . . . . . . . . . 125
5.8 Movement of Ions Across Biological Membranes . . . . . . . . . . 128
5.8.1 Membrane Permeability . . . . . . . . . . . . . . . . . . . . . 128
5.8.2 The Goldman–Hodgkin–Katz (GHK) Model. . . . . . . 132
5.8.3 The GHK Voltage Equation . . . . . . . . . . . . . . . . . . 136
5.8.4 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
5.8.5 The Effects of an Electrogenic Pump . . . . . . . . . . . . 140
5.9 Excitable Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
6 Lumped and Distributed Cell Models . . . . . . . . . . . . . . . . . . . . . . 149
6.1 Modeling Radial Current . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
6.2 Modeling Resistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6.3 Longitudinal Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
6.4 Current in a Cable with a Thin Wall . . . . . . . . . . . . . . . . . . . 153
6.5 The Cable Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
6.5.1 The Core Conductor Model Assumptions. . . . . . . . . 157
6.5.2 Building the Core Conductor Model . . . . . . . . . . . . 160
6.6 The Transient Cable Equations . . . . . . . . . . . . . . . . . . . . . . . 163
6.6.1 Deriving the Transient Cable Equation . . . . . . . . . . 164
6.6.2 The Space and Time Constant of a Cable . . . . . . . . 166
7 Time Independent Solutions to Infinite Cables . . . . . . . . . . . . . . . . 171
7.1 The Infinite Cable. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
7.2 Solving the Time Independent Infinite Cable Equation . . . . . . 172
7.2.1 Variation of Parameters . . . . . . . . . . . . . . . . . . . . . 173
7.3 Modeling Current Injections. . . . . . . . . . . . . . . . . . . . . . . . . 181
7.3.1 Continuity in the Solution . . . . . . . . . . . . . . . . . . . 182
7.3.2 Continuity in the Derivative . . . . . . . . . . . . . . . . . . 183
7.3.3 Forcing Continuity at the Boundaries . . . . . . . . . . . 183
7.4 Modeling Instantaneous Current Injections . . . . . . . . . . . . . . . 185
7.4.1 What Happens Away from 0? . . . . . . . . . . . . . . . . 186
7.4.2 What Happens at Zero? . . . . . . . . . . . . . . . . . . . . . 188
7.5 Idealized Impulse Currents. . . . . . . . . . . . . . . . . . . . . . . . . . 189
7.5.1 Integrals of Impulse Functions . . . . . . . . . . . . . . . . 192
7.6 The Inner and Outer Current Solutions . . . . . . . . . . . . . . . . . 192
7.7 The Inner and Outer Voltage Solutions . . . . . . . . . . . . . . . . . 195
7.8 Summarizing the Infinite Cable Solutions . . . . . . . . . . . . . . . 196
7.8.1 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
xii Contents

8 Time Independent Solutions to Finite and Half-Infinite


Space Cables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
8.1 The Half-Infinite Cable Solution . . . . . . . . . . . . . . . . . . . . . . 199
8.2 The Finite Cable Solution: Current Initialization . . . . . . . . . . . 202
8.2.1 Parametric Studies. . . . . . . . . . . . . . . . . . . . . . . . . 207
8.2.2 Some MatLab Implementations. . . . . . . . . . . . . . . . 207
8.2.3 Run-Time Results . . . . . . . . . . . . . . . . . . . . . . . . . 210
8.2.4 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
8.3 The Finite Cable: Voltage Initialization . . . . . . . . . . . . . . . . . 211
8.3.1 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
8.4 Synaptic Currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
8.4.1 A Single Impulse . . . . . . . . . . . . . . . . . . . . . . . . . 216
8.4.2 Forcing Continuity . . . . . . . . . . . . . . . . . . . . . . . . 218
8.4.3 The Limiting Solution . . . . . . . . . . . . . . . . . . . . . . 220
8.4.4 Satisfying Boundary Conditions . . . . . . . . . . . . . . . 221
8.4.5 Some Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222
8.5 Implications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

Part IV Excitable Neuron Models


9 A Primer on Series Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
9.1 The Separation of Variables Method . . . . . . . . . . . . . . . . . . . 229
9.1.1 Determining the Separation Constant . . . . . . . . . . . . 231
9.2 Infinite Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
9.2.1 Simple Limits from Calculus . . . . . . . . . . . . . . . . . 235
9.2.2 Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238
9.2.3 Series of Positive Terms . . . . . . . . . . . . . . . . . . . . 239
9.2.4 Series of Functions . . . . . . . . . . . . . . . . . . . . . . . . 241
9.2.5 Fourier Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
9.3 The Cable Model Infinite Series Solution. . . . . . . . . . . . . . . . 244
9.3.1 Homework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
9.4 The Membrane Voltage Cable Equation . . . . . . . . . . . . . . . . 246
9.5 Fourier Series Components . . . . . . . . . . . . . . . . . . . . . . . . . 248
9.5.1 Orthogonal Functions . . . . . . . . . . . . . . . . . . . . . . 248
9.6 The Convergence of Fourier Series . . . . . . . . . . . . . . . . . . . . 254
9.6.1 Rewriting SN ðxÞ . . . . . . . . . . . . . . . . . . . . . . . . . . 256
9.6.2 Rewriting SN  F . . . . . . . . . . . . . . . . . . . . . . . . . 258
9.6.3 Convergence . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
9.7 Fourier Sine Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
9.8 Fourier Cosine Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
9.9 MatLab Implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
9.9.1 Inner Products Revisited . . . . . . . . . . . . . . . . . . . . 265
9.9.2 Fourier Cosine and Sine Approximation. . . . . . . . . . 270
9.9.3 Testing the Approximations . . . . . . . . . . . . . . . . . . 273
9.9.4 Cable Membrane Approximations . . . . . . . . . . . . . . 277
Contents xiii

9.10 Convergence Analysis for the Cable Equation . . . . . . . . . . . . 282


9.10.1 Uniform Convergence Ideas . . . . . . . . . . . . . . . . . . 283
9.10.2 A Fourier Series Example . . . . . . . . . . . . . . . . . . . 286
9.10.3 Uniform Convergence for f . . . . . . . . . . . . . . . . . . 289
9.10.4 Extending to Fourier Sin and Fourier
Cosine Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
9.10.5 Back to Convergence of the Cable Solution . . . . . . . 300
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 308
10 Linear Partial Differential Equations. . . . . . . . . . . . . . . . . . . . . . . 309
10.1 The Separation of Variables Method Revisited . . . . . . . . . . . . 310
10.1.1 The Wave Equation . . . . . . . . . . . . . . . . . . . . . . . 310
10.1.2 Laplace’s Equation . . . . . . . . . . . . . . . . . . . . . . . . 318
10.1.3 The Heat/Diffusion Equation . . . . . . . . . . . . . . . . . 326
10.2 Fourier Series Approximate Methods . . . . . . . . . . . . . . . . . . 331
10.2.1 The Wave Equation . . . . . . . . . . . . . . . . . . . . . . . 331
10.2.2 Laplace’s Equation . . . . . . . . . . . . . . . . . . . . . . . . 342
10.2.3 The Heat Equation . . . . . . . . . . . . . . . . . . . . . . . . 350
Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
11 Simplified Dendrite—Soma—Axon Information Processing . . . . . . 361
11.1 A Simple Model of a Dendrite: The Core
Conductor Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
11.2 Time Independent Solutions to the Cable Model. . . . . . . . . . . 367
11.3 The Dendritic Voltage Model. . . . . . . . . . . . . . . . . . . . . . . . 369
11.4 The Ball and Stick Model . . . . . . . . . . . . . . . . . . . . . . . . . . 371
11.5 Ball-Stick MatLab Solutions . . . . . . . . . . . . . . . . . . . . . . . . 375
11.5.1 Approximating the Solution . . . . . . . . . . . . . . . . . . 376
11.5.2 Applied Voltage Pulses . . . . . . . . . . . . . . . . . . . . . 379
11.6 Ball and Stick Numerical Solutions. . . . . . . . . . . . . . . . . . . . 380
11.6.1 Root Finding and Simple Optimization . . . . . . . . . . 381
11.6.2 The Ball and Stick Matrix Construction . . . . . . . . . . 384
11.6.3 Solving for Impulse Voltage Sources. . . . . . . . . . . . 388
11.7 Ball Stick Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
12 The Basic Hodgkin–Huxley Model . . . . . . . . . . . . . . . . . . . . . . . . 401
12.1 Adding Ion Membrane Currents . . . . . . . . . . . . . . . . . . . . . . 405
12.2 The Hodgkin–Huxley Gates . . . . . . . . . . . . . . . . . . . . . . . . . 405
12.2.1 Activation and Inactivation Variables . . . . . . . . . . . 408
12.3 The Voltage Clamped Protocol. . . . . . . . . . . . . . . . . . . . . . . 408
12.4 The Hodgkin–Huxley Sodium and Potassium Model. . . . . . . . 409
12.4.1 Encoding the Dynamics . . . . . . . . . . . . . . . . . . . . . 411
12.5 Computing the Solution Numerically. . . . . . . . . . . . . . . . . . . 414
xiv Contents

12.6 The Simple MatLab Implementation . . . . . . . . . . . . . . . . . . . 415


12.6.1 Managing the Simulation: SolveSimpleHH.m . . . . . . 416
12.6.2 Gate Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
12.6.3 Setting Ion Currents to Zero: Rest.m . . . . . . . . . . . . 424
12.6.4 The Runge–Kutta Manager: HHFixedRK.m . . . . . . . 426
12.6.5 A Simple External Current: IE.m . . . . . . . . . . . . . . 427
12.6.6 Runtime Results . . . . . . . . . . . . . . . . . . . . . . . . . . 428
12.7 Printing Additional Variables . . . . . . . . . . . . . . . . . . . . . . . . 434
12.7.1 The New Dynamics Function: simpleHHnew.m . . . . 434
12.7.2 The New Manager: SolveSimpleHHnew.m. . . . . . . . 435
12.7.3 The New Runge–Kutta Manager:
HHFixedRKnew.m . . . . . . . . . . . . . . . . . . . . . . . . 437
12.7.4 Runtime Results . . . . . . . . . . . . . . . . . . . . . . . . . . 437
12.8 Initiation of the Action Potential. . . . . . . . . . . . . . . . . . . . . . 439
12.9 Homework. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
12.10 Another MatLab Implementation . . . . . . . . . . . . . . . . . . . . . 443
12.10.1 The Rewritten Dynamics . . . . . . . . . . . . . . . . . . . . 447
12.10.2 A New SolveSimpleHH.m . . . . . . . . . . . . . . . . . . . 451
12.11 More Action Potentials . . . . . . . . . . . . . . . . . . . . . . . . . . . . 453
12.11.1 Exercise. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
12.12 Action Potential Dynamics. . . . . . . . . . . . . . . . . . . . . . . . . . 462
12.12.1 Multiple Pulses. . . . . . . . . . . . . . . . . . . . . . . . . . . 468
12.12.2 Generating Action Potentials for Sequences
of Pulses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
12.12.3 Simulating Second Messenger Activity . . . . . . . . . . 482
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 484

Part V Summing It All Up


13 Final Thoughts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488

Part VI Advise to the Beginner


14 Background Reading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
14.1 Biology and Physiology . . . . . . . . . . . . . . . . . . . . . . . . . . . 491
14.2 Theoretical Biology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 492
14.3 Software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 493
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494

Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 497

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
List of Figures

Figure 2.1 Two linearly independent vectors in R2 . . . . . . . . . . . . . . 32


Figure 2.2 Two linearly independent vectors in R2 . . . . . . . . . . . . . . 33
Figure 2.3 Three linearly independent vectors in R3 . . . . . . . . . . . . . 40
Figure 3.1 The tunnel diode capacitor voltage versus time . . . . . . . . . 60
Figure 3.2 The tunnel diode inductor current versus time . . . . . . . . . . 60
Figure 3.3 Step size versus time . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Figure 4.1 Electrostatic attraction between two molecules:
one has a carboxyl group and the other an amide
group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Figure 4.2 Typical hydrogen bonds . . . . . . . . . . . . . . . . . . . . . . . . . 66
Figure 4.3 Typical hydrogen bonds in a helix structure . . . . . . . . . . . 67
Figure 4.4 Vanderwaals forces between molecules. . . . . . . . . . . . . . . 67
Figure 4.5 Special forces act on water . . . . . . . . . . . . . . . . . . . . . . . 69
Figure 4.6 The polarity of water induces cages to form.
a Polar bonding with water. b Ion water cages . . . ...... 70
Figure 4.7 It is more efficient to group non polar molecules
in cages. a Non polar molecule water cages.
b Non polar molecule group water cages . . . . . . . ...... 70
Figure 4.8 Methyl and ethyl can have side chains of arbitrary
complexity called residues . . . . . . . . . . . . . . . . . ...... 71
Figure 4.9 Methyl with carboxyl and amide residues
with electron shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Figure 4.10 A typical amino acid in normal and ionized forms . . . . . . . 75
Figure 4.11 The amino acids Glycine and Alanine . . . . . . . . . . . . . . . 75
Figure 4.12 The amino acids Valine and Leucine . . . . . . . . . . . . . . . . 75
Figure 4.13 The amino acids Isoleucine and Proline . . . . . . . . . . . . . . 76
Figure 4.14 The amino acids Phenylalanine and Tyrosine. . . . . . . . . . . 76
Figure 4.15 The amino acids Tryptophan and Cysteine . . . . . . . . . . . . 77
Figure 4.16 The amino acids Methionine and Serine . . . . . . . . . . . . . . 77
Figure 4.17 The amino acids Lysine and Threonine. . . . . . . . . . . . . . . 78
Figure 4.18 The amino acids Arganine and Histidine. . . . . . . . . . . . . . 78

xv
xvi List of Figures

Figure 4.19 The amino acids Asparate and Glutamate . . . . . . . . . . . .. 79


Figure 4.20 The amino acids Asparagine and Glutamine . . . . . . . . . .. 79
Figure 4.21 The bond between two amino acids . . . . . . . . . . . . . . . .. 80
Figure 4.22 The peptide bond between two amino acids
with the rotation possibilities indicated. Cα1 and Cα2
point up in the picture . . . . . . . . . . . . . . . . . . . . . . . . . . 81
Figure 4.23 Details of the peptide bonds in a chain . . . . . . . . . . . . . . . 82
Figure 4.24 A three amino acid chain . . . . . . . . . . . . . . . . . . . . . . . . 83
Figure 4.25 Molecular details of a chain . . . . . . . . . . . . . . . . . . . . . . 83
Figure 4.26 A first chain abstraction . . . . . . . . . . . . . . . . . . . . . . . . . 83
Figure 4.27 Disulfide insulin protein . . . . . . . . . . . . . . . . . . . . . . . . . 84
Figure 4.28 First and second order protein foldings.
a Primary structure of a protein. b Secondary
structure of a protein . . . . . . . . . . . . . . . . . . . . . . . . . .. 85
Figure 4.29 Third and fourth order protein foldings. a Tertiary
structure of a protein. b Quatenary structure
of a protein . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 85
Figure 4.30 The Pyran and Furan structures. a Details
of a cyclic hydrocarbon sugar: Pyran. b The schematic
for Pyran. c Details of a cyclic hydrocarbon sugar: Furan.
d The schematic for Furan . . . . . . . . . . . . . . . . . . . . . .. 86
Figure 4.31 Three dimensional Furan structures.
a The 3 C0 endo Furan. b The 2 C0 endo Furan . . . . . . . . .. 87
Figure 4.32 Oxygenated and de-oxygenated ribose sugars.
a The ribose sugar. b The deoxy ribose sugar . . . . . . . . .. 87
Figure 4.33 Forms of nitrogenous bases. a The generic Purine.
b The generic Pyrimidine . . . . . . . . . . . . . . . . . . . . . . .. 87
Figure 4.34 Purine and Pyrimidine nucleotides. a Adenine.
b Guanine. c Thymine. d Cytosine. . . . . . . . . . . . . . . . . . 88
Figure 4.35 Deoxy-adenoside . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Figure 4.36 Deoxy-adenotide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Figure 4.37 A general nucleotide . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 4.38 A nucleotide chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
Figure 4.39 An abstract nucleotide chain . . . . . . . . . . . . . . . . . . . . . . 90
Figure 4.40 The Tyrosine–Adenine bond . . . . . . . . . . . . . . . . . . . . . . 91
Figure 4.41 The Cytosine–Guanine bond . . . . . . . . . . . . . . . . . . . . . . 91
Figure 4.42 A cross-section of a nucleotide helix . . . . . . . . . . . . . . . . 92
Figure 4.43 The base–base pair rotation . . . . . . . . . . . . . . . . . . . . . . . 93
Figure 4.44 The nucleotide Uracil and Thymine . . . . . . . . . . . . . . . . . 93
Figure 4.45 The unzipped double helix . . . . . . . . . . . . . . . . . . . . . . . 94
Figure 5.1 The phospholipid membranes. a A typical phospholipid.
b An abstract lipid. c The hydrophobic phospholipid end
group. d The hydrophilic phospholipid end group . . . . . .. 98
List of Figures xvii

Figure 5.2 Membrane structures. a The self assembled lipid


sheet membrane structure. b The self assembled lipid
sphere membrane structure . . . . . . . . . . . . . . . . . . . . . .. 99
Figure 5.3 A simple cell. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 102
Figure 5.4 A simple membrane model . . . . . . . . . . . . . . . . . . . . . .. 116
Figure 5.5 Transport through water channels. a Osmosis. b Diffusion
and water channel transport. . . . . . . . . . . . . . . . . . . . . . . 120
Figure 5.6 A carrier moves a solute through the membrane . . . . . . . . 121
Figure 5.7 Molecular transport mechanisms . . . . . . . . . . . . . . . . . . . 121
Figure 5.8 Typical voltage channel . . . . . . . . . . . . . . . . . . . . . . . . . 122
Figure 5.9 The linear membrane concentration model . . . . . . . . . . . . 130
Figure 5.10 A typical action potential . . . . . . . . . . . . . . . . . . . . . . . . 143
Figure 5.11 A typical sodium channel . . . . . . . . . . . . . . . . . . . . . . . . 143
Figure 5.12 Spiking due to sodium ions. . . . . . . . . . . . . . . . . . . . . . . 145
Figure 6.1 A simple cell model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
Figure 6.2 Cable cylinders. a The cable cylinder model.
b 2D cross-section . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 150
Figure 6.3 Cable details. a The cable cylinder model
cross section. b Part of the cable bilipid membrane
structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
Figure 6.4 Longitudinal cable currents . . . . . . . . . . . . . . . . . . . . . . . 153
Figure 6.5 Cable membrane with wall thickness shown . . . . . . . . . . . 154
Figure 6.6 Potential difference versus position curves . . . . . . . . . . . . 157
Figure 6.7 Cylindrical cell details. a Current injection.
b Radial cross section. . . . . . . . . . . . . . . . . . . . . . . . . .. 158
Figure 6.8 Radial and longitudinal details. a Currents
and voltages in the radial cross section.
b A longitudinal slice of the cable . . . . . . . . . . . . . . . . . . 159
Figure 6.9 Longitudinal currents . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Figure 6.10 The two slice model. . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
Figure 6.11 The equivalent electrical network model . . . . . . . . . . . . . . 161
Figure 6.12 Inner cylinder currents . . . . . . . . . . . . . . . . . . . . . . . . . . 161
Figure 6.13 The RC membrane model . . . . . . . . . . . . . . . . . . . . . . . . 165
Figure 7.1 Current injection into a cable. . . . . . . . . . . . . . . . . . . . . . 172
Figure 7.2 Voltages due to two current impulses . . . . . . . . . . . . . . . . 191
Figure 8.1 A half-infinite dendrite or axon model . . . . . . . . . . . . . . . 200
Figure 8.2 Finite cable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
Figure 8.3 Attenuation increases with ρ . . . . . . . . . . . . . . . . . . . . . . 208
Figure 8.4 Finite cable input conductance study . . . . . . . . . . . . . . . . 208
Figure 8.5 Low end cap loads. a End cap load is 0.1, b End cap
load is 1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 211
Figure 8.6 High end cap loads. a End cap load is 5.0, b End cap
load is 50.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 211
Figure 8.7 Dendrite model with synaptic current injections . . . . . . . .. 215
xviii List of Figures

Figure 8.8 Finite cable initial endcap current. . . . . . . . . . . . . . . . . . . 223


Figure 8.9 Finite cable current initializations: strong impulses . . . . . . . 223
Figure 8.10 Finite cable current initializations: strong impulses . . . . . . . 224
Figure 8.11 Three finite cable current initializations. . . . . . . . . . . . . . . 224
Figure 9.1 Six term Fourier cosine series approximation
to a sawtooth: NIP ¼ 100 . . . . . . . . . . . . . . . . . . . . . . .. 274
Figure 9.2 Six term Fourier cosine series approximation to a square
wave: NIP ¼ 100 . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 274
Figure 9.3 Eleven term Fourier cosine series approximation
to a square wave: NIP ¼ 100 . . . . . . . . . . . . . . . . . . . .. 275
Figure 9.4 Twenty two term Fourier sine series approximation
to a square wave: NIP ¼ 100 . . . . . . . . . . . . . . . . . . . .. 277
Figure 9.5 Twenty term Fourier series approximation to the cable
equation with pulse data and Neumann boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 282
Figure 10.1 5 term Fourier series approximation to the wave equation
with sawtooth wave data and Dirichlet boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 335
Figure 10.2 5 term Fourier series approximation to the wave equation
with sawtooth wave data and Neumann boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 341
Figure 10.3 10 term Fourier series approximation to Laplace’s
equation with square wave data and Dirichlet boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 346
Figure 10.4 20 term Fourier series approximation to Laplace’s
equation with square wave data and Dirichlet boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 346
Figure 10.5 5 term Fourier series approximation to Laplace’s
equation with square wave data and Neumann
boundary conditions . . . . . . . . . . . . . . . . . . . . . . . . . . .. 349
Figure 10.6 10 term Fourier series approximation to the heat equation
with square wave data and Dirichlet boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 352
Figure 10.7 40 term Fourier series approximation to the heat equation
with pulse data and Dirichlet boundary conditions . . . . . .. 353
Figure 10.8 41 term Fourier series approximation for dual
pulse data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 357
Figure 10.9 41 term Fourier series approximation to the heat equation
with dual pulse data and Neumann boundary
conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Figure 11.1 The dendrite fiber model. . . . . . . . . . . . . . . . . . . . . . . . . 363
Figure 11.2 The ball and stick model . . . . . . . . . . . . . . . . . . . . . . . . 371
Figure 11.3 The ball and stick eigenvalue problem . . . . . . . . . . . . . . . 374
List of Figures xix

Figure 11.4 Initial axon hillock voltage for pulse of size


100 at location 2.0. This uses the t ¼ 0 values which
possess least square solution artifacts . . . . . . . . . . . . . . .. 390
Figure 11.5 Initial axon hillock voltage for pulse of size
100 at location 2.0. This starts at t ¼ 0:05 to lessen
the least square solution artifacts . . . . . . . . . . . . . . . . . .. 391
Figure 11.6 Model approximation to an impulse of size 100
at location 2.0: This starts with the voltage at t ¼ 0
so there are least squares solution artifacts . . . . . . . . . . .. 391
Figure 11.7 Model approximation to an impulse of size 100
at location 2.0. This starts at t ¼ 0:05 to lessen
the least squares solution artifacts . . . . . . . . . . . . . . . . .. 392
Figure 11.8 Axon hillock response to an impulse of size 100
at location 2.0; Q ¼ 40, 80 and 120: time starts at 0 . . . .. 394
Figure 11.9 Axon hillock response to an impulse of size 100
at location 2.0; Q ¼ 40, 80 and 120: t starts at 0.05. . . . .. 394
Figure 11.10 Model approximation to an impulse of size 100
at location 2.0; Q ¼ 40, 80 and 120 starting at time
zero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 395
Figure 11.11 Model approximation to an impulse of size 100
at location 2.0; Q ¼ 40, 80 and 120 starting
at time 0.05. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 395
Figure 11.12 Transient axon hillock voltage for pulse of size 300
at location 4.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 396
Figure 11.13 Model approximation to an impulse of size 300
at location 4.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 397
Figure 11.14 Axon hillock voltage for pulse of size 300
at location 4.5 and Size 100 at location 2.0 . . . . . . . . . . .. 397
Figure 11.15 Model approximation for pulse of size 300 at location
4.5 and size 100 at location 2.0 . . . . . . . . . . . . . . . . . . . . 398
Figure 12.1 The membrane and gate circuit model . . . . . . . . . . . . . . . 403
Figure 12.2 The equivalent electrical network model . . . . . . . . . . . . . . 403
Figure 12.3 The RC membrane model . . . . . . . . . . . . . . . . . . . . . . . . 404
Figure 12.4 The simple Hodgkin–Huxley membrane circuit model . . . . 406
Figure 12.5 Membrane voltage versus time: gL ¼ 0:0084170,
EL ¼ 50, gmax NA ¼ 120 and gK ¼ 36:0 . . . . . . . . . . . .
max
.. 430
Figure 12.6 Sodium and potassium conductances versus time
for gmax
NA ¼ 120 and gK ¼ 36 for impulse current . . . . .
max
. . 430
Figure 12.7 Sodium activation and inactivation versus time . . . . . . . . . 431
Figure 12.8 Potassium activation versus time . . . . . . . . . . . . . . . . . . . 431
Figure 12.9 Sodium and potassium currents versus time. . . . . . . . . . . . 432
Figure 12.10 Sodium conductance versus voltage . . . . . . . . . . . . . . . . . 433
Figure 12.11 Potassium conductance versus voltage . . . . . . . . . . . . . . . 433
Figure 12.12 m time constant and asymptotic value versus time . . . . . . . 438
xx List of Figures

Figure 12.13 m time constant and asymptotic value versus


membrane voltage . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 439
Figure 12.14 Action potentials generated by a series
of depolarizations starting from none to 10 mV . . . . . . . .. 440
Figure 12.15 Action potentials generated by a series
of depolarizations starting from none to 11 mV . . . . . . . . . 441
Figure 12.16 M α and β for sodium. a αMNA . b βMNA . . . . . . . . . . . . . . 447
Figure 12.17 H α and β for sodium. a αHNA . b βHNA . . . . . . . . . . . . . . 448
Figure 12.18 M α and β for potassium. a αMK . b βMK . . . . . . . . . . . . . 449
Figure 12.19 A voltage pulse 1100 at 3.0 . . . . . . . . . . . . . . . . . . . . . . 454
Figure 12.20 Action potential: pulse 200 at 3.0 . . . . . . . . . . . . . . . . . . 456
Figure 12.21 Sodium and potassium current during a pulse
1100 at 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 456
Figure 12.22 Absolute sodium and potassium current during
a pulse 1100 at 3.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Figure 12.23 Sodium activation MNA during a pulse . . . . . . . . . . . . . . . 458
Figure 12.24 Sodium inactivation HNA during a pulse . . . . . . . . . . . . . 458
Figure 12.25 Potassium activation MK during a pulse . . . . . . . . . . . . . . 459
Figure 12.26 The product MNA 3 HNA during a pulse 1100
at 3.0 scaled by the maximum sodium and potassium
conductance values . . . . . . . . . . . . . . . . . . . . . . . . . . .. 459
Figure 12.27 The product MK 4 during a pulse 1100 at 3.0 scaled
by the maximum sodium and potassium conductance
values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. 460
Figure 12.28 Dendritic voltage surface approximation due
to a spike of 300 mV at location 4.0 using 40 terms . . . . . 464
Figure 12.29 Voltage surface for one pulse . . . . . . . . . . . . . . . . . . . . . 472
Figure 12.30 Voltage surface for two pulses. . . . . . . . . . . . . . . . . . . . . 472
Figure 12.31 Approximation to pulse one on the dendritic cable . . . . . . . 473
Figure 12.32 Approximation to pulse two on the dendritic cable. . . . . . . 473
Figure 12.33 Axon hillock voltage for two pulses . . . . . . . . . . . . . . . . . 474
Figure 12.34 Generated action potential for pulses
200δðt  5; x  1:5Þ, 300δðt  10; x  2:0Þ and
400δðt  11; x  3:0Þ . . . . . . . . . . . . . . . . . . . . . . . . . .. 481
Figure 12.35 70 to 40 digitization of action potential for pulses
200δðt  5; x  1:5Þ, 300δðt  10; x  2:0Þ and
400δðt  11; x  3:0Þ . . . . . . . . . . . . . . . . . . . . . . . . . .. 481
Figure 12.36 0 to 1 digitization of action potential for pulses
200δðt  5; x  1:5Þ, 300δðt  10; x  2:0Þ and
400δðt  11; x  3:0Þ . . . . . . . . . . . . . . . . . . . . . . . . . .. 482
Figure 12.37 Generated action potential for pulses
200δðt  5; x  1:5Þ, 300δðt  10; x  2:0Þ and
400δðt  11; x  3:0Þ with increased gL . . . . . . . . . . . . .. 483
Figure 12.38 70 to 40 digitization of action potential for pulses
200δðt  5; x  1:5Þ, 300δðt  10; x  2:0Þ and
400δðt  11; x  3:0Þ with increased gL . . . . . . . . . . . . .. 483
List of Tables

Table 4.1 Hydrogen bond lengths . . . . . . . . . . . . . . . . . . . . . . . . . . . 66


Table 4.2 Maximum attraction distances. . . . . . . . . . . . . . . . . . . . . . . 67
Table 4.3 Bond distances by type . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Table 4.4 Energy sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Table 4.5 Abbreviations for the amino acids. . . . . . . . . . . . . . . . . . . . 80
Table 4.6 Abbreviations for the nitrogenous bases . . . . . . . . . . . . . . . . 88
Table 4.7 Two complimentary nucleotide chains . . . . . . . . . . . . . . . . . 92
Table 4.8 The Triplet code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Table 5.1 Typical inner and outer ion concentrations . . . . . . . . . . . . . . 108
Table 8.1 Typical cable constants . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Table 12.1 Hodgkin–Huxley variable units. . . . . . . . . . . . . . . . . . . . . . 402

xxi
List of Code Examples

Listing 1.1 How to add paths to Octave . . . . . . . . . . . . . . . . . . . . . 8


Listing 1.2 Set paths in octave . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Listing 2.1 Implementing the differences in Matlab. . . . . . . . . . . . . . 16
Listing 2.2 Storing Newton–Cotes Weight Vectors . . . . . . . . . . . . . . 20
Listing 2.3 Newton–Cotes Implementation. . . . . . . . . . . . . . . . . . . . 20
Listing 2.4 Numerical Integration Script . . . . . . . . . . . . . . . . . . . . . 21
Listing 2.5 Integrand Function I . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Listing 2.6 Integrand Function II . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Listing 2.7 Using quad . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Listing 2.8 A Newton–Cotes session . . . . . . . . . . . . . . . . . . . . . . . . 22
Listing 2.9 Setting two vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Listing 2.10 Draw2DGSO: drawing the vectors . . . . . . . . . . . . . . . . . 34
Listing 2.11 Graph the new basis vectors . . . . . . . . . . . . . . . . . . . . . 34
Listing 2.12 Setting the aspect ratio . . . . . . . . . . . . . . . . . . . . . . . . . 35
Listing 2.13 Drawing a two dimensional Graham–Schmidt
orthogonalization result: Draw2DGSO . . . . . . . . . . . . . . 35
Listing 2.14 A 2DGSO sample session . . . . . . . . . . . . . . . . . . . . . . . 36
Listing 2.15 Setting coordinates for a line plot . . . . . . . . . . . . . . . . . . 37
Listing 2.16 Plotting the lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Listing 2.17 Plotting all the lines . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Listing 2.18 Finding and plotting the new basis . . . . . . . . . . . . . . . . . 38
Listing 2.19 Drawing the plane between V1 and V2 . . . . . . . . . . . . . . 38
Listing 2.20 Drawing a three dimensional Graham–Schmidt
orthogonalization result: Draw3DGSO . . . . . . . . . . . . . . 39
Listing 2.21 A Draw3DGSO example . . . . . . . . . . . . . . . . . . . . . . . . 40
Listing 2.22 Generic Powers of t Function. . . . . . . . . . . . . . . . . . . . . 42
Listing 2.23 Constructing an anonymous function as a loop. . . . . . . . . 42
Listing 2.24 Nested inner product code . . . . . . . . . . . . . . . . . . . . . . . 43
Listing 2.25 A Newton–Cotes GSO Code . . . . . . . . . . . . . . . . . . . . . 43
Listing 2.26 GSO with Newton–Cotes Order 3 . . . . . . . . . . . . . . . . . 44
Listing 2.27 GSO with Newton–Cotes Order 4 . . . . . . . . . . . . . . . . . 44

xxiii
xxiv List of Code Examples

Listing 2.28 GSO with Newton–Cotes Order 6 . . . . . . . . . . . . . . . . . 45


Listing 2.29 Inner products using quad . . . . . . . . . . . . . . . . . . . . . . . 45
Listing 2.30 Graham–Schmidt Orthogonalization With quadl . . . . . . . . 45
Listing 2.31 GSO with quadl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
Listing 3.1 Runge–Kutta Codes . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Listing 3.2 The Runge–Kutta Solution . . . . . . . . . . . . . . . . . . . . . . 53
Listing 3.3 RKF5 function evaluations . . . . . . . . . . . . . . . . . . . . . . 54
Listing 3.4 Compute the error vector. . . . . . . . . . . . . . . . . . . . . . . . 55
Listing 3.5 See if step size is acceptable . . . . . . . . . . . . . . . . . . . . . 55
Listing 3.6 Is step size too small?. . . . . . . . . . . . . . . . . . . . . . . . . . 55
Listing 3.7 Is step too big? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Listing 3.8 Ending the loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Listing 3.9 RKF5 with No Parameters. . . . . . . . . . . . . . . . . . . . . . . 56
Listing 3.10 Tunnel Diode Dynamics With Parameters . . . . . . . . . . . . 58
Listing 3.11 RKF5 Algorithm With Parameters . . . . . . . . . . . . . . . . . 58
Listing 3.12 Solving a tunnel diode model . . . . . . . . . . . . . . . . . . . . 60
Listing 4.1 Amino acid string. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Listing 5.1 Computing The Nernst Voltage simply . . . . . . . . . . . . . . 108
Listing 5.2 Finding Potassium voltage . . . . . . . . . . . . . . . . . . . . . . . 109
Listing 5.3 Nernst Output for Potassium . . . . . . . . . . . . . . . . . . . . . 109
Listing 5.4 Calculating the Nernst voltage NernstMemVolt . . . . . . . . 118
Listing 5.5 Finding the membrane voltage using conduc-
tances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...... 118
Listing 5.6 Increasing the Sodium to Potassium Conductance
ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Listing 8.1 Computing The Infinite Cable Voltage . . . . . . . . . . . . . . 209
Listing 8.2 Computing The Finite Cable Voltage . . . . . . . . . . . . . . . 209
Listing 8.3 Sample Matlab session . . . . . . . . . . . . . . . . . . . . . . . . . 210
Listing 9.1 Riemann sum innerproduct . . . . . . . . . . . . . . . . . . . . . . 265
Listing 9.2 Using Riemann sums for GSOs: Graham–
SchmidtTwo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Listing 9.3 Sample GrahamSchmidtTwo run . . . . . . . . . . . . . . . . . . 266
Listing 9.4 GSO Orthogonality results first 3 powers of t . . . . . . . . . 266
Listing 9.5 Running GSO on the first 5 powers of t . . . . . . . . . . . . . 267
Listing 9.6 GSO Orthogonality results: first 5 powers of t . . . . . . . . . 267
Listing 9.7 SetUpCosines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Listing 9.8 SetUpSines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267
Listing 9.9 SetUpOrthogCos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Listing 9.10 SetUpOrthogSin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
Listing 9.11 Checking orthogonality of the GSO: CheckOrtho . . . . . . . 268
Listing 9.12 The code to check cos orthogonality. . . . . . . . . . . . . . . . 269
Listing 9.13 Checking Orthogonality for cosine functions:
NIP ¼ 50 . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...... 269
List of Code Examples xxv

Listing 9.14 Checking Orthogonality for cosine functions:


NIP ¼ 200 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Listing 9.15 FourierCosineApprox . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Listing 9.16 Splitfunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Listing 9.17 Sawtooth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Listing 9.18 Build a sawtooth and square wave . . . . . . . . . . . . . . . . . 273
Listing 9.19 The Fourier cosine approximation to a sawtooth. . . . . . . . 273
Listing 9.20 The Fourier cosine approximation to a square wave
with 6 terms . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... 274
Listing 9.21 Fourier cosine approximation to the square wave
with 11 terms . . . . . . . . . . . . . . . . . . . . . . . . . . ..... 275
Listing 9.22 FourierSineApprox . . . . . . . . . . . . . . . . . . . . . . . ..... 275
Listing 9.23 Fourier sine approximation to a square wave with 22
terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276
Listing 9.24 CableNeumannApprox arguments. . . . . . . . . . . . . . . . . . 278
Listing 9.25 Get Fourier cosine approximation to f. . . . . . . . . . . . . . . 278
Listing 9.26 Define the needed exponential functions . . . . . . . . . . . . . 279
Listing 9.27 Generate the approximation to the series solution . . . . . . . 279
Listing 9.28 Setup the time and space domain . . . . . . . . . . . . . . . . . . 279
Listing 9.29 Generate the plot and end . . . . . . . . . . . . . . . . . . . . . . . 279
Listing 9.30 Cable Neumann Data Fourier Series Approxima-
tion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Listing 9.31 pulsefunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
Listing 9.32 A cable solution for a pulse. . . . . . . . . . . . . . . . . . . . . . 281
Listing 10.1 Get Fourier sine coefficients . . . . . . . . . . . . . . . . . . . . . 333
Listing 10.2 Setup sine functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Listing 10.3 Setup cosine functions . . . . . . . . . . . . . . . . . . . . . . . . . 333
Listing 10.4 Construct the approximate solution . . . . . . . . . . . . . . . . . 333
Listing 10.5 Setup plot domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Listing 10.6 Plot approximate solution surface . . . . . . . . . . . . . . . . . . 334
Listing 10.7 WaveDirichletApprox . . . . . . . . . . . . . . . . . . . . . . . . . . 334
Listing 10.8 Sample Wave Equation Approximate solution . . . . . . . . . 334
Listing 10.9 Altering WaveDirichletApprox to return partials. . . . . . . . 336
Listing 10.10 Setting up partial derivative approximations. . . . . . . . . . . 336
Listing 10.11 The wave solution with dirichlet BC using saw
data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337
Listing 10.12 Testing the boundary conditions . . . . . . . . . . . . . . . . . . . 337
Listing 10.13 Get fourier cosine approximations . . . . . . . . . . . . . . . . . 338
Listing 10.14 Setup cosine functions . . . . . . . . . . . . . . . . . . . . . . . . . 339
Listing 10.15 Setup approximation solution . . . . . . . . . . . . . . . . . . . . . 339
Listing 10.16 WaveNeumannApprox . . . . . . . . . . . . . . . . . . . . . . . . . 339
Listing 10.17 Testing on saw data . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Listing 10.18 Altering WaveNeumannApprox to return partial
information . . . . . . . . . . . . . . . . . . . . . . . . . . . . ..... 340
xxvi List of Code Examples

Listing 10.19 Setting up the partial derivative approximations . . . . . . . . 341


Listing 10.20 Solving and returning the partial information . . . . . . . . . . 342
Listing 10.21 LaplaceDirichletApprox arguments . . . . . . . . . . . . . . . . . 343
Listing 10.22 Build approximation solution . . . . . . . . . . . . . . . . . . . . . 344
Listing 10.23 LaplaceDirichletApprox. . . . . . . . . . . . . . . . . . . . . . . . . 344
Listing 10.24 A sample solution with 10 terms . . . . . . . . . . . . . . . . . . 345
Listing 10.25 A sample solution with 20 terms . . . . . . . . . . . . . . . . . . 347
Listing 10.26 LaplaceNeumannApprox arguments . . . . . . . . . . . . . . . . 348
Listing 10.27 LaplaceNeumannApprox . . . . . . . . . . . . . . . . . . . . . . . . 348
Listing 10.28 Sample solution with 5 terms. . . . . . . . . . . . . . . . . . . . . 349
Listing 10.29 HeatDirichletApprox . . . . . . . . . . . . . . . . . . . . . . . . . . . 351
Listing 10.30 Sample solution with 10 terms . . . . . . . . . . . . . . . . . . . . 352
Listing 10.31 pulsefunc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Listing 10.32 Sample solution with 40 terms . . . . . . . . . . . . . . . . . . . . 353
Listing 10.33 HeatNeumannApprox . . . . . . . . . . . . . . . . . . . . . . . . . . 355
Listing 10.34 Two pulses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 356
Listing 10.35 Fourier cosine approximation to the double pulse . . . . . . . 356
Listing 10.36 Sample solution with 40 terms . . . . . . . . . . . . . . . . . . . . 356
Listing 10.37 Sample session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Listing 10.38 Sample session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Listing 10.39 Sample session. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Listing 11.1 M Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 379
Listing 11.2 Ball and Stick Eigenvalues . . . . . . . . . . . . . . . . . . . . . . 381
Listing 11.3 Modified Finite Difference Newton Method. . . . . . . . . . . 381
Listing 11.4 Finding Ball and Stick Eigenvalues . . . . . . . . . . . . . . . . 382
Listing 11.5 Finding Two Eigenvalues . . . . . . . . . . . . . . . . . . . . . . . 383
Listing 11.6 20 Eigenvalues. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384
Listing 11.7 Finding the Ball and Stick coefficient Matrix . . . . . . . . . . 384
Listing 11.8 Q ¼ 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Listing 11.9 M Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 386
Listing 11.10 Finding Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Listing 11.11 Finding the Minimal Q For a Resonable Orthogo-
nality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Listing 11.12 Finding the Ball and Stick Data Vector . . . . . . . . . . . . . . 388
Listing 11.13 Finding the Approximate Solution . . . . . . . . . . . . . . . . . 389
Listing 11.14 Finding the Axon Hillock Voltage . . . . . . . . . . . . . . . . . 389
Listing 11.15 Axon Hillock Voltage Computation . . . . . . . . . . . . . . . . 390
Listing 11.16 Plot Of Model Approximation To Pulse . . . . . . . . . . . . . 392
Listing 11.17 GetAxonHillock2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
Listing 11.18 Increasing Q . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Listing 11.19 Simple Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394
Listing 11.20 Two Pulses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Listing 11.21 Axon Hillock Responses . . . . . . . . . . . . . . . . . . . . . . . . 396
Listing 11.22 Adding Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . 396
List of Code Examples xxvii

Listing 12.1 Managing The MatLab Hodgkin–Huxley Simulation


One . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416
Listing 12.2 Calculating Ion Voltages: IonBatteryVoltages.m . . . . . . . . 417
Listing 12.3 simpleHH Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Listing 12.4 Set dimension of dynamics . . . . . . . . . . . . . . . . . . . . . . 418
Listing 12.5 Get Ion battery voltages . . . . . . . . . . . . . . . . . . . . . . . . 418
Listing 12.6 Calculate sodium current . . . . . . . . . . . . . . . . . . . . . . . . 418
Listing 12.7 Calculate Potassium current . . . . . . . . . . . . . . . . . . . . . . 419
Listing 12.8 Set leakage current . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
Listing 12.9 Set cell capacitance and cable dynamics . . . . . . . . . . . . . 420
Listing 12.10 Gate Dynamics Function . . . . . . . . . . . . . . . . . . . . . . . . 422
Listing 12.11 Classical HH Gate Model . . . . . . . . . . . . . . . . . . . . . . . 422
Listing 12.12 HH Dynamics: simpleHH.m . . . . . . . . . . . . . . . . . . . . . 423
Listing 12.13 Initializing The Simulation: rest.m . . . . . . . . . . . . . . . . . 425
Listing 12.14 The MatLab Fixed Runge–Kutta Method. . . . . . . . . . . . . 426
Listing 12.15 Adding Injection Current To The Runge–Kutta
Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Listing 12.16 The Injected Current Pulse . . . . . . . . . . . . . . . . . . . . . . 427
Listing 12.17 Finding Hodgkin–Huxley model initial conditions . . . . . . 428
Listing 12.18 Sample session to generate an action potential . . . . . . . . . 429
Listing 12.19 Calculating and plotting ion currents. . . . . . . . . . . . . . . . 432
Listing 12.20 Adding new variables to the dynamics to return
more information: simpleHHnew . . . . . . . . . . . . . ..... 434
Listing 12.21 A new HH dynamics function: SolveSim-
pleHHnew . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Listing 12.22 A new Runge–Kutta manager: HHFixedRKnew . . . . . . . . 437
Listing 12.23 A sample session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438
Listing 12.24 Sample session to generate action potentials . . . . . . . . . . 439
Listing 12.25 A more careful gates function: HHGates . . . . . . . . . . . . . 444
Listing 12.26 Handling indeterminacies in the α/β calculations:
HHGatesGraph. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Listing 12.27 Graphing the α/β functions: GatesNAKGraph . . . . . . . . . 445
Listing 12.28 Cleanup figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Listing 12.29 Removing plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Listing 12.30 Continuous Pulses: IE2.m . . . . . . . . . . . . . . . . . . . . . . . 448
Listing 12.31 p structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 450
Listing 12.32 A rewritten HH dynamic function using parameter
arguments HHdynamics.m . . . . . . . . . . . . . . . . . . . . . . . 450
Listing 12.33 Managing The Hodgkin–Huxley Simulation. . . . . . . . . . . 452
Listing 12.34 Generate An Axon Hillock Voltage Curve. . . . . . . . . . . . 453
Listing 12.35 Generating axon hillock voltage trace . . . . . . . . . . . . . . . 454
Listing 12.36 Calculating an action potential . . . . . . . . . . . . . . . . . . . . 455
Listing 12.37 Generating currents. . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
Listing 12.38 Plotting currents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 457
xxviii List of Code Examples

Listing 12.39 Generating the axon hillock function . . . . . . . . . . . . . . . 462


Listing 12.40 Drawing the surface . . . . . . . . . . . . . . . . . . . . . . . . . . . 462
Listing 12.41 GetAxonHillockThree . . . . . . . . . . . . . . . . . . . . . . . . . . 463
Listing 12.42 GetAxonHillockThree test . . . . . . . . . . . . . . . . . . . . . . . 464
Listing 12.43 Axon hillock voltage time dependence . . . . . . . . . . . . . . 464
Listing 12.44 Approximation to the dendritic pulse . . . . . . . . . . . . . . . 465
Listing 12.45 GetAxonHillockFour arguments . . . . . . . . . . . . . . . . . . . 465
Listing 12.46 Adding absolute values . . . . . . . . . . . . . . . . . . . . . . . . . 465
Listing 12.47 Setup the surface plot . . . . . . . . . . . . . . . . . . . . . . . . . . 465
Listing 12.48 Generating the plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Listing 12.49 GetAxonHillockFour. . . . . . . . . . . . . . . . . . . . . . . . . . . 466
Listing 12.50 SetUpPulses arguments . . . . . . . . . . . . . . . . . . . . . . . . . 468
Listing 12.51 Generating the response for an impulse sequence . . . . . . . 468
Listing 12.52 Constructing the summed dendritic pulse. . . . . . . . . . . . . 469
Listing 12.53 Generating plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 469
Listing 12.54 SetUpPulses. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 470
Listing 12.55 Setting up pulses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Listing 12.56 Getting handles for the plots . . . . . . . . . . . . . . . . . . . . . 471
Listing 12.57 Generating the plots . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Listing 12.58 Cleaning up the generated figures. . . . . . . . . . . . . . . . . . 472
Listing 12.59 The p.c field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 474
Listing 12.60 Extracting information from the p structure . . . . . . . . . . . 475
Listing 12.61 Evaluating the gates functions . . . . . . . . . . . . . . . . . . . . 475
Listing 12.62 Using incoming depolarizations: HHdynamicsVin. . . . . . . 475
Listing 12.63 ConvertToDigital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Listing 12.64 Calculating a dendritic pulse . . . . . . . . . . . . . . . . . . . . . 477
Listing 12.65 Setting up parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 477
Listing 12.66 Initialize the pp and q structures. . . . . . . . . . . . . . . . . . . 478
Listing 12.67 Plot the axon response . . . . . . . . . . . . . . . . . . . . . . . . . 478
Listing 12.68 The digital response . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Listing 12.69 SetUpHH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Listing 12.70 Clean up figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Listing 12.71 Setup for multiple pulses. . . . . . . . . . . . . . . . . . . . . . . . 480
Listing 12.72 Simulating second messenger activity . . . . . . . . . . . . . . . 482
Abstract

This book again tries to show cognitive scientists in training how mathematics,
computer science, and science can be usefully and pleasurably intertwined. This is a
follow-up text to our first two sets of notes on mathematics for cognitive scientists,
which are our companion volumes (J. Peterson, Calculus for Cognitive Scientists:
Derivatives, Integration and Modeling (Springer, Singapore, 2015 in press)) and
(J. Peterson, Calculus for Cognitive Scientists: Higher Order Models and Their
Analysis (Springer, Singapore, 2015 in press)). In these notes, we add the mathe-
matics and computational tools needed to understand how to compute the terms in
the Fourier Series expansions that solve the cable equation. We derive the cable
equation from the first principles by going back to cellular biology and the relevant
biophysics. We discuss carefully ion movement through cellular membranes and
then show how the equations that govern such ion movement lead to the standard
transient cable equation. Then we learn how to solve the cable model using sep-
aration of variables. We go over carefully why Fourier Series converge and
implement MATLAB tools to compute the solutions. We then discuss how to
solve linear PDE in general using these tools. Finally, we develop the standard
Hodgkin–Huxley model of an excitable neuron and solve it using MATLAB tools.
As always, our chosen models are used to illustrate how these three fields influence
each other in interesting and useful ways. We also stress our underlying motto:
always take the modeling results and go back to the scientists to make sure they
retain relevance.

xxix
History

Based On:
Research Notes: 1992–1998
Class Notes: MTHSC 982 Spring 1997
Research Notes: 1998–2000
Class Notes: MTHSC 860 Summer Session I 2000
Class Notes: MTHSC 450, MTHSC 827 Fall 2001
Research Notes: Fall 2007 and Spring 2008
Class Notes: MTHSC 450 Fall 2008
Class Notes: MTHSC 450 Fall 2009
Class Notes: MTHSC 450 Spring 2010 and Fall 2010
Class Notes: MTHSC 450 Spring 2011 and Fall 2011
Class Notes: MTHSC 450 Spring 2012
Class Notes: MTHSC 434 Summer Session II 2010 and 2011
Class Notes: MTHSC 450 Fall 2011 and Spring 2012
Class Notes: MTHSC 434 Summer Session II 2012
Class Notes: MTHSC 434 Summer Session II 2014

xxxi
Part I
Introductory Matter
Chapter 1
Introduction

In this book, we will continue to discuss how to blend mathematics, computational


tools and science into a cohesive point of view. Hence, this is a follow up text to our
books on mathematics for Cognitive Scientists, (Peterson 2015a, b). In these volumes,
we add the new science, mathematics and computational tools to get you to a good
understanding of how excitable neurons generate action potentials. Hence, we have
chapters on some of the basics of cellular processing and protein transcription and a
thorough discussion of how to solve the kinds of linear partial differential equation
models that arise. The equations we use to model how an action potential develops
are derived by making many assumptions about a great number of interactions inside
the cell. We firmly believe that we can do a better job understanding how to build fast
and accurate approximations for our simulations of neural systems if we know these
assumptions and fully understand why each was made and the domain of operation
in which assumptions are valid.
We also spend a lot more time discussing how to develop code with MatLab/Octave
to solve our problems numerically. As we have done in Peterson (2015a, b), we
continue to explain our coding choices in detail so that if you are a beginner in the
use of programming techniques, you continue to grow in understanding so that you
can better build simulations of your own. We always stress our underlying motto:
always take the modeling results and go back to the scientists to make sure they retain
relevance.
Our model of the excitable neuron is based on the cable equation which is a
standard equation in biological information processing. The cable equation is one
example of a linear model phrased in terms of partial derivatives: hence, it is a linear
partial differential equation model or Linear PDE. We begin by solving the time
independent version of the cable equation which uses standard tools from linear
differential equations in both the abstract infinite length and the finite cable version.
The time dependent solutions to this model are then found using the separation of
variables technique which requires us to discuss series of functions and Fourier series
carefully. Hence, we have to introduce new mathematical tools that are relevant to
solving linear partial differential equation models. We also discuss other standard

© Springer Science+Business Media Singapore 2016 3


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_1
4 1 Introduction

Linear PDE models such as the diffusion equation, wave equation and Laplace’s
equation to give you more experience with the separation of variables technique.
We then use the cable equation to develop a model of the input side of an excitable
neuron—the dendrite and then we build a model of the excitable neuron itself. This
consists of a dendrite, a cell body or soma and the axon along which the action
potential moves in the nervous system. In the process, we therefore use tools at the
interface between science, mathematics and computer science.
We are firm believers in trying to build models with explanatory power. Hence, we
abstract from biological complexity relationships which then are given mathemat-
ical form. This mathematical framework is usually not amenable to direct solution
using calculus and other such tools and hence part of our solution must include sim-
ulations of our model using some sort of computer language. In this text, we focus
on using MatLab/Octave as it is a point of view that is easy to get started with.
Even simple models that we build will usually have many parameters that must be
chosen. For example, in Peterson (2015b) we develop a cancer model based on a
singe tumor suppressor gene having two allele states. There are two basic types of
cell populations: those with no chromosomal instability and other cells that do have
some sort of chromosomal instability due to replication errors and so forth. The two
sets of populations are divided into three mutually exclusive sets: cells with both
alleles intact, cells having only one allele and cells that have lost both alleles. Once a
cell loses both alleles, cancer is inevitable. Hence, the question is which pathway to
cancer is most probable: the pathway where there is not chromosomal instability or
the pathway which does have chromosomal instabilities. The model therefore has 6
variables—one for each cell type in each pathway and a linear model is built which
shows how we think cell types turn into other cell types. The problem is all the two
dimensional graphical tools to help us understand such as phase plane analysis are
no longer useful because the full system is six dimensional. The model can be solved
by hand although it is very complicated and it can be solved using computational
tools for each choice of our model’s parameters. If you look at this model in Peterson
(2015b), you’ll see there are 4 parameters of interest. If we had 10 possible levels
for each parameter, we would have to solve the model computationally for the 104
parameter choices in order to explore this solution space. This is a formidable task
and it still doesn’t answer our question about which pathway to cancer is dominant.
In Peterson (2015b), we make quite a few reasonable assumptions about how this
model works to reduce the number of parameters to only 2 and then we approximate
the solutions using first order methods to find a relationship between these two para-
meters which tells us when each pathway is probably dominant. This is the answer
we seek: not a set of plots but a algebraic relationship between the parameters which
gives insight. Many times these types of questions are the ones we want to ask.
In this book, we are going to build a model of an excitable neuron and to do this we
will have to make many approximations. At this point, we will have a model which
generates action potentials but we still don’t know much about how to link such
excitable neuron models together or how to model second messenger systems and
1 Introduction 5

so forth. Our questions are much larger and more ill-formed than simply generating
a plot of membrane voltage versus time for one excitable neuron. Hence, this entire
book is just a starting point for learning how to model networks of neurons. In
Peterson (2015c), we develop our understanding further and develop MatLab/Octave
code to actually build neural circuit models. But that is another story.
The book (McElreath and Boyd 2007) also caution modelers to develop models
that are appropriately abstract yet simple. In McElreath and Boyd (2007, pp. 7–8),
we find a nice statement of this point of view. This book looks carefully at how to
build models to explain social evolution but their comments are highly relevant to us.
Simple models never come close to capturing all the details in a situation.... Models are like
maps – they are most useful when they contain details of interest and ignore others....Simple
models can aid our understanding of the world in several ways. There are ... a very large
number of possible accounts of any particular biological ... phenomenon. And since much of
the data needed to evaluate these accounts are ... impossible to collect, it can be challenging
to narrow down the field of possibilities. But models which formalize these accounts tell us
which are internally consistent and when conclusions follow from premises....Formalizing
our arguments helps us to understand which [models] are possible explanations. [Also]
formal models are much easier to present and explain. ...They give us the ability to clearly
communicate what we mean. [Further], simple models often lead to surprising results. If
such models always told us what we thought they would, there would be little point in
constructing them. ...They take our work in directions we would have missed had we stuck
to verbal reasoning, and they help us understand features of the system of study that were
previously mysterious.... Simple formal models can be used to make predictions about natural
phenomena.

Further, they make the same important points about the need for abstraction and the
study of the resulting formal models using abstract methods aided by simulations.
In McElreath and Boyd (2007, p. 8) we have
There is a growing number of modelers who know very little about analytic methods.
Instead these researchers focus on computer simulations of complex systems. When com-
puters were slow and memory was tight, simulation was not a realistic option. Without
analytic methods, it would have taken years to simulate even moderately complex systems.
With the rocketing ascent of computer speed and plummeting price of hardware,it has become
increasingly easy to simulate very complex systems. This makes it tempting to give up on
analytic methods, since most people find them difficult to learn and to understand.
There are several reasons why simulations are poor substitutes for analytic models. ...Equa-
tions – given the proper training – really do speak to you. They provide intuitions about the
reasons a ... system behaves as it does, and these reasons can be read from the expressions
that define the dynamics and resting states of the system. Analytic results tell us things that
we must infer, often with great difficulty, from simulation results.

This is our point with our comments about the cancer model. Simulation
approaches for the cancer model do not help us find the parameter relationships
we seek to estimate which pathway to cancer is the most likely for a given set of
parameter choices. The analytic reasoning we use based on our dynamic models helps
us do that. In the same way, simulation approaches alone will not give us insight into
the workings of neural systems that can begin to model portions of the brain cir-
cuitry humans and other animals have. The purpose of our modeling is always to
gain insight.
6 1 Introduction

1.1 Chapter Guide

This text covers the material in bioinformation processing in the following way.

Part I: Introductory Matter This is the material you are reading now.
Part II: Quantitative Tools In this part, we introduce computational tools based on
MatLab (although you can use the open source Octave just as easily. The students
we teach are not very comfortable with programming in other languages and
paradigms and so we have not used code based on C, C++ and so forth although
it is available. We discuss and provide code for

• Chapter 2: After introducing integration approximation routines in code, we move


on to more abstract discussion of vectors which leads to the idea of vector spaces,
linear independence and so forth. We finish with the Graham–Schmidt Orthogo-
nalization process in both theory and code.
• Chapter 3: We look again at Runge–Kutta methods for solving systems of differ-
ential equations. We look closely at how the general Runge–Kutta methods are
derived and finish with a discussion of an automatic step size changing method
called Runge–Kutta Fehlberg.

Part III: Deriving The Cable Model We now derive the basic cable equation so we
can study it. We start with a discussion of basic cell biology and the movement
of ions across cell membranes. Then, with the basic cable equation available for
study, we then turn to its solution in various contexts. We begin by removing time
dependence and discuss its solution in the three flavors: the infinite cable, the
half-infinite cable and the finite cable. To do the nonhomogeneous infinite cable
model, we introduce the method of variation of parameters and discuss what we
mean by linearly independent functions.

• Chapter 4: We go over the biophysics of how ions move inside cells and discuss
how proteins are made.
• Chapter 5: We discuss how ions move across biological membranes leading to
the derivation of the Nernst–Planck equation and the notion of Nernst equilibrium
voltages for different ions. We introduce the idea of signaling with multiple ion
species crossing a membrane at the same time.
• Chapter 6: We derive the basic cable model for the change in membrane voltage
with respect to space and time. We end with the transient membrane cable equation.
We are now need to study how to solve linear partial differential equations.
• Chapter 7: We solve the cable equation when there is no time independence. We
start with an infinite cable and finish with the half-infinite cable case.
• Chapter 8: We solve the cable equation when the cable has a finite length. This is
messy technically but it rewards your study with a deeper understanding of how
these solutions behave. Our method of choice is Variation of Parameters.
1.1 Chapter Guide 7

Part IV: Excitable Neuron Models The standard model of an excitable neuron then
glues together a dendrite model (a finite length cable) to an equipotential cell body
and an axon. The dendrite and cell body have a complicated interface where they
share a membrane and the resulting complicated cable equation plus boundary
conditions is known as the Ball and Stick Model. This model is solved using
the separation of variable technique and gives rise to a set of functions whose
properties must be examined. The numerical solutions we build then require new
tools in MatLab on root finding and the solution of linear equations. Once the
dendrite cable models have been solved, we use their solution as the input to
classical Hodgkin–Huxley models. Hence, we discuss the voltage dependent ion
gates and their usual Hodgkin–Huxley model in terms of activation and interaction
variables. Once the axon models are built, we then glue everything together and
generate action potentials using the dendrite–axon model we have built in this
part. The necessary MatLab scripts and code to implement these models are
fully described.

• Chapter 9: We learn how to solve the cable equation using a new technique called
separation of variables. To do this, we need to build what are called infinite series
solutions. Hence, once we find the infinite series solution to the cable equation,
we need to backtrack and describe some mathematical ideas involving series of
functions. We then include a discussion of Fourier series and their convergence. The
convergence of these series is a complicated topic and we include a fairly careful
explanation of most of the relevant ideas. We finish with a detailed development
of the way we would implement Fourier series computations in MatLab/Octave
code.
• Chapter 10: We then use separation of variables to solve a variety of additional
linear partial differential equations. We finish with an implementation of how to
build approximations to the series solutions in MatLab/Octave.
• Chapter 11: We build a primitive, although illuminating, model of an excitable
neuron which has a single dendritic cable, a body called the soma and a simplified
output cable called the axon. This model is the Ball Stick model and it is compli-
cated to solve. The usual method of separation of variables has some complications
which we must work around. We provide a full discussion of this and the relevant
MatLab/Octave code needed for approximating the solutions.
• Chapter 12: We finish this volume with a nice discussion of a classical Hodgkin–
Huxley model. We introduce the Hodgkin–Huxley ion gate model and add it to
the already developed Ball Stick model so that we have a full excitable nerve cell
model. We include our development of relevant code also.

Our style here is to assume you the reader are willing to go on this journey with
us. So we have worked hard at explaining in detail all of our steps. We develop
the mathematical tools you need to a large extent in house, so to speak. We also
try to present the algorithm design and the code behind our MatLab/Octave experi-
ments in a lot of detail. The interactive nature of the MatLab integrated development
8 1 Introduction

environment makes it ideal for doing the exploratory exercises we have given you in
these pages. If you work hard on this material, you will be ready for the later journeys
which begin to explain bioinformation processing in more detail along with more
advanced software techniques.

1.2 Code

All of the code we use in this book is available for download from the site Biologi-
cal Information Processing (http://www.ces.clemson.edu/~petersj/CognitiveModels.
html). The code samples can then be downloaded as the zipped tar ball Cognitive-
Code.tar.gz and unpacked where you wish. If you have access to MatLab, just add
this folder with its sub folders to your MatLab path. If you don’t have such access,
download and install Octave on your laptop. Now Octave is more of a command
line tool, so the process of adding paths is a bit more tedious. When we start up an
Octave session, we use the following trick. We write up our paths in a file we call
MyPath.m. For us, this code looks like this
Listing 1.1: How to add paths to Octave
f u n c t i o n MyPath ( )
%
s 1 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / : ’ ;
s 2 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /GSO : ’ ;
s 3 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /HH: ’ ;
s 4 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / I n t e g r a t i o n : ’ ;
s 5 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / I n t e r p o l a t i o n : ’ ;
s 6 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / L i n e a r A l g e b r a : ’ ;
s 7 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / N e r n s t : ’ ;
s 8 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /ODE : ’ ;
s 9 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / RootsOpt : ’ ;
s 1 0 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / L e t t e r s : ’ ;
s 1 1 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o / Graphs : ’ ;
s 1 2 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /PDE : ’ ;
s 1 3 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /FDPDE : ’ ;
s 1 4 = ’ / home/ p e t e r s j / M a t L a b F i l e s / B i o I n f o /3DCode ’ ;
s = [ s1 , s2 , s3 , s4 , s5 , s6 , s7 , s8 , s9 , s 1 2 ] ;
addpath ( s ) ;
end

The paths we want to add are setup as strings, here called s1 etc., and to use this, we
start up Octave like so. We copy MyPath.m into our working directory and then do
this
Listing 1.2: Set paths in octave
o c t a v e>> MyPath ( ) ;

We agree it is not as nice as working in MatLab, but it is free! You still have
to think a bit about how to do the paths. For example, in Peterson (2015c),
we develop two different ways to handle graphs in MatLab. The first is in the
1.2 Code 9

directory GraphsGlobal and the second is in the directory Graphs. They


are not to be used together. So if we wanted to use the setup of Graphs and
nothing else, we would edit the MyPath.m file to set s = [s11]; only. If
we wanted to use the GraphsGlobal code, we would edit MyPath.m so that
s11 = ’/home/petersj/MatLabFiles/BioInfo/GraphsGlobal:’;
and then set s = [s11];. Note the directories in the MyPath.m are ours:
the main directory is ’/home/petersj/MatLabFiles/BioInfo/ and of
course, you will have to edit this file to put your directory information in there instead
of ours.
All the code will work fine with Octave. So pull up a chair, grab a cup of coffee
or tea and let’s get started.

References

R. McElreath, R. Boyd, Mathematical Models of Social Evolution: A Guide for the Perplexed
(University of Chicago Press, Chicago, 2007)
J. Peterson, Calculus for Cognitive Scientists: Derivatives, Integration and Modeling, Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015a, in Press)
J. Peterson, Calculus for Cognitive Scientists: Higher Order Models and Their Analysis, Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015b, in Press)
J. Peterson, BioInformation Processing: A Primer On Computational Cognitive Science. Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015c, in press)
Part II
Quantitative Tools
Chapter 2
Graham–Schmidt Orthogonalization

In our work, we need to talk about vectors and functions using more advanced ideas.
In this chapter, we begin by discussing how to integrate functions numerically with
MatLab so that we can calculate the inner product of two functions in code. In
the second text, we introduced the ideas of vector spaces, linear dependence and
independence of vectors. Now we apply these ideas to vector spaces of functions and
finish with the Graham–Schmidt Orthogonalization process.

2.1 Numerical Integration


b
We now discuss how to approximate a f (x)dx on the interval [a, b]. These methods
generate the Newton–Cotes Formulae. Consider the problem of integrating the
function f on the finite interval [a, b]. Let’s assume that the interval [a, b] has been
subdivided into points {x1 , . . . , xm } which are uniformly spaced; we let the function
values at these points be given by fi = f (xi ). This gives

i−1
xi = a + (b − a)
m−1
x1 = a
m−1
x2 = a + 1 × h, where h =
b−a
··· = ···
xm = a + (m − 1) × h

The functions we use to build the interpolating polynomial for the m points x1 to xn
have the form

p0 (x) = 1
j
pj (x) = i=1 (x − xi ), 1 ≤ j ≤ m.

© Springer Science+Business Media Singapore 2016 13


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_2
14 2 Graham–Schmidt Orthogonalization

Thus,

p0 (x) = 1
p1 (x) = (x − x1 )
p2 (x) = (x − x1 )(x − x2 )
p3 (x) = (x − x1 )(x − x2 )(x − x3 )
..
.
pm−1 (x) = (x − x1 )(x − x2 ) · · · (x − xm−1 )

The Newton Interpolating polynomial to f for this partition is given by the polynomial
of degree m − 1

Pm−1 (x) = c1 p0 (x) + c2 p1 (x) + c3 p2 (x) + · · · + cm pm−1 (x)


= 1 + c2 p1 (x) + c3 p2 (x) + · · · + cm pm−1 (x)

where the numbers c1 through cm are chosen so that Pm−1 (xj ) = f (xj ). For conve-
nience, let’s look at a four point uniform partition of [a, b], {x1 , x2 , x3 , x4 } and figure
out how to find these numbers cj . Hence the uniform step size here is h = b−a 3
here.
The Newton interpolating polynomial in this case is given by

p3 (x) = c1 + c2 (x − x1 ) + c3 (x − x1 )(x − x2 ) + c4 (x − x1 )(x − x2 )(x − x3 )

Since we want p3 (xj ) = f (xj ) = fj , we have

p3 (x1 ) = f1 = c1
p3 (x2 ) = f2 = c1 + c2 (x2 − x1 )
p3 (x3 ) = f3 = c1 + c2 (x3 − x1 ) + c3 (x3 − x1 )(x3 − x2 )
p4 (x4 ) = f4 = c1 + c2 (x4 − x1 ) + c3 (x4 − x1 )(x4 − x2 )
+ c4 (x4 − x1 )(x4 − x2 )(x4 − x3 )

For convenience, let xij = xi − xj . Then we can rewrite the above as

f1 = c1
f2 = c1 + c2 x21
f3 = c1 + c2 x31 + c3 x31 x32
f4 = c1 + c2 x41 + c3 x41 x42 + c4 x41 x42 x43

This is the system of equations which is in lower triangular form and so it is easy to
solve.
2.1 Numerical Integration 15
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
1 0 0 0 c1 f1
⎢1 x21 0 0 ⎥ ⎢c2 ⎥ ⎢f 2 ⎥
⎢ ⎥ ⎢ ⎥= ⎢ ⎥
⎣1 x31 x31 x32 0 ⎦ ⎣c3 ⎦ ⎣ f3 ⎦
1 x41 x41 x42 x41 x42 x43 c4 f4

We find c1 = f1 . Then, c1 + c2 x21 = f2 and letting fij = fi − fj , we have c2 = f21 /x21 .


Next, we have

c1 + c2 x31 + c3 x31 x32 = f3

or

f21 /x21 x31 + c3 x31 x32 = f31

c3 x31 x32 = f31 − f21 /x21

c3 = f31 /x31 − f21 /x21 /x32 .

The final calculation is the worst. Again, for convenience, let gij = fij /xij . Then we
can rewrite c3 as

c3 = g31 − g21 /x32 .

We know

c1 + c2 x41 + c3 x41 x42 + c4 x41 x42 x43 = f4 .

Solving for x41 x42 x43 c4 , we obtain

c4 x41 x42 x43 = f4 − c1 − c2 x41 − c3 x41 x42

= f41 − f21 /x21 x41 − g31 − g21 /x32 x41 x42

Now divide through by x41 to find

c4 x42 x43 = f41 /x41 − f21 /x21 − g31 − g21 /x32 x42

= g41 − g21 − g31 − g21 /x32 x42 .


16 2 Graham–Schmidt Orthogonalization

Now divide by x42 to solve for x43 c4 :

c4 x43 = g41 − g21 /x42 − g31 − g21 /x32 .

which tells us (finally!) that

c4 = g41 − g21 /x42 − g31 − g21 /x32 /x43 .

Since all the differences xij = h, the uniform step size, these formulae can be then
be rewritten.

c1 = f1
f2 − f1
c2 =
h
f3 −f1
− f2 −f1

c3 = 2h h
h
f3 − 2f2 + f1
=
2h2
f4 − 3f3 + 3f2 − f1
c4 =
6h3
Although this is messy to do by hand, it is easy to do in MatLab. First, we set f to be
the vector of function values f (x1 ), . . . , f (xm ). If func is the function we are using
in MatLab for the function f , this is done with the lines f = func(x) where x
has already been setup with a linspace command.

Listing 2.1: Implementing the differences in Matlab


m = length (x) ;
f o r k = 1 :m−1;
f ( k +1:m) = ( f ( k +1:m) − f ( k ) ) . / ( x ( k +1:m) − x ( k ) ) ;
end
c = f;

For our example, m = 4 and so when k = 1, we find f(2:4) = ( f(2:4)


- f(1) )./(x(2:4) - x(1) ). This looks forbidding, but remember
f(2:4) is the vector f(2), f(3), f(4). So f(2:4) - f(1) becomes
f(2) - f(1), f(3) - f(1), f(4) - f(1) or the quantities
f21 , f31 , f41 . Then x(2:4) - x(1) is x(2) - x(1), x(3) - x(1),
x(4) - x(1) or x21 , x31 , x41 . Hence, when k = 1, we find f(2) = ( f(2)
- f(1) )/ (x(2) - x(1) or f21 /x21 f(3) = ( f(3) - f(1) )/
(x(3) - x(1) or f31 /x31 and f(4) = ( f(4) - f(1) )/ (x(4) -
x(1) or f41 /x41 . At this point the vector f contains the proper value of c1 in f(1)
2.1 Numerical Integration 17

and the right value of c2 in the component f(2). The values for c3 and c4 are
not yet right. The next pass through the loop will set c3 correctly. When k = 2,
the MatLab code becomes f(3:4) = ( f(3:4) - f(2) )./ (x(3:4)
- x(2) ) which is short for f(3) = ( f(3) - f(2) )/(x(3)-x(2)
and f(4) = ( f(4) - f(2) )/(x(4)-x(2). Now remember what f(2),
f(3) are at this point and plug them in. We find f(3) has become (f31 /x31 −
f21 /x21 )/x32 or (g31 − g21 )/x32 . This is the proper value c3 should have. We now have
f(4) is (f41 /x41 − f21 /x21 )/x42 or (g41 − g21 )/x42 . Finally, the last pass through the
loop uses k = 3 and results in the line f(4:4) = ( f(4:4) - f(3) )./
(x(4:4) - x(3) ) which is just f(4) = (f(4) - f(3) )/ (x(4) -
x(3) ). Now plug in what we have for f(3) to obtain

f4 = g41 − g21 /x42 − g31 − g21 /x32 /x43

which is exactly the value that c4 should be. This careful walk through the code is
what we all do when we are trying to see if our ideas actually work. We usually do
it on scratch paper to make sure everything is as we expect. Typing it out is much
harder!
These polynomials are called Newton interpolants and we can use these ideas
b b
to approximate a f (x)dx as follows. We approximate a f (x)ds by replacing f by a
Newton interpolant on the interval [a, b]. For an m point uniformly spaced partition,
we will use the m − 1 degree polynomial Pm−1 whose coefficients can be computed
recursively like we do above. We replace the integrand f by Pm−1 to find

b b
f (x)dx ≈ Pm−1 (x)dx
a a
b m−1
= c1 + ck+1 ki=1 (x − xi ) dx
a k=1
m−1 b
= c1 (b − a) + ck+1 ki=1 (x − xi ) dx
k=1 a

To figure out this approximation, we need to evaluate

b
ki=1 (x − xi )dx
a

Make the change of variable s defined by x = a + sh. Then at x = a, s = 0 and


at x = b, s = (b − a)/h = m − 1 (m points uniformly spaced means the common
interval is (b − a)/m). Further, x − xi becomes (s − i + 1)h. Thus, we have
b m−1
ki=1 (x − xi )dx = hk+1 ki=1 (s − i + 1)ds
a 0
18 2 Graham–Schmidt Orthogonalization

We will let

Sm1 = m − 1
m−1
Sm,k+1 = ki=1 (s − i + 1)ds, 1 ≤ k ≤ m − 1
0

Next, note c1 (b − a) = c1 h((b − a)/h) and since (b − a)/h = m − 1, we have


c1 (b − a) = c1 h(m − 1), which gives us the final form of our approximation:

b m−1
f (x)dx ≈ c1 (b − a) + ck+1 hk+1 Sm,k+1
a k=1
m−1
= c1 h(m − 1) + ck+1 hk+1 Sm,k+1
k=1

We can rewrite the sum above letting n = k + 1 to

b m m
f (x)dx ≈ c1 h(m − 1) + cn hn Smn = ck hk Smk .
a n=2 k=1

2.1.1 Evaluating Smk

The value of m we choose to use gives rise then to what is called an m point rule and
given m we can easily evaluate the needed coefficients Sm1 through Smm . Here are
some calculations:
m−1
Sm2 = sds
0
(m − 1)2
=
2
m−1
Sm3 = s(s − 1)ds
0
(m − 1)2
= (2m − 5)
6
m−1
Sm4 = s(s − 1)(s − 2)ds
0
(m − 1)2 (m − 3)2
=
4
2.1 Numerical Integration 19

We will denote this Newton Polynomial approximation to this integral using m points
by the symbol QNC(m) . Hence, for the case m = 4, we have

S41 = 3
9
S42 =
2
9
S43 =
2
9
S44 =
4
This leads to the approximation

b
f (x)dx ≈ c1 hS41 + c2 h2 S42 + c3 h3 S43 + c4 h4 S44
a
9 f2 − f1 2 9 f3 − 2f2 + f1 3 9 f4 − 3f3 + 3f2 − f1 4
= 3f1 h + h + h + h
2 h 2 h2 4 6h3
9 9 9
= 3f1 h + (f2 − f1 )h + (f3 − 2f2 + f1 )h + (f4 − 3f3 + 3f2 − f1 )h
2 4 24
9 9 3
= 3f1 h + (f2 − f1 )h + (f3 − 2f2 + f1 )h + (f4 − 3f3 + 3f2 − f1 )h
2 4 8
3h
= (8f1 + 12f2 − 12f1 6f3 − 12f2 + 6f1 f4 − 3f3 + 3f2 − f1 )
8
3h
= (f1 + 3f2 + 3f3 + f4 )
8

b−a
But h is 3
here, so our final 4 point formula is

b
b−a
f (x)dx ≈ (f1 + 3f2 + 3f3 + f4 )
a 8

2.1.2 Homework

Exercise 2.1.1 Show that for m = 2, we get the Trapezoidal Rule


b
1 1
f (x)dx ≈ (b − a) f1 + f2
a 2 2

Exercise 2.1.2 Show that for m = 3, we get the Simpson Rule


b
b−a
f (x)dx ≈ (f1 + 4f2 + f3 )
a 6
20 2 Graham–Schmidt Orthogonalization

2.1.3 Matlab Implementation

We store the Newton–Cotes Weight vectors in this short piece of Matlab code

Listing 2.2: Storing Newton–Cotes Weight Vectors


f u n c t i o n w = WNC(m)
%
% m an i n t e g e r from 2 t o 5
% w t h i s i s t h e Newton C o t e s W ei gh t V e c t o r
5 %
i f m==2
w = [1 1] ’/2;
e l s e i f m==3
w = [1 4 1] ’/6;
10 e l s e i f m==4
w = [1 3 3 1] ’/8;
e l s e i f m==5
w = [ 7 32 12 32 7 ] ’ / 9 0 ;
e l s e i f m==6
15 w = [ 1 9 75 50 50 75 1 9 ] ’ / 2 8 8 ;
e l s e i f m==7
w = [ 4 1 216 27 272 27 216 4 1 ] ’ / 8 4 0 ;
e l s e i f m==8
w = [ 7 5 1 3577 1323 2989 2989 1323 3577 7 5 1 ] ’ / 1 7 2 8 0 ;
20 e l s e i f m==9
w = [ 9 8 9 5888 −928 10496 −4540 10496 −928 5888 9 8 9 ] ’ / 2 8 3 5 0 ;
else
d i s p ( ’ You must use a value of m between 2 and 9 ’ ) ;
w = [0 0] ’;
25 end

The Newton–Cotes implementation is then given by

Listing 2.3: Newton–Cotes Implementation


f u n c t i o n numI = QNC( fname , a , b ,m)
%
% fname t h e name o f t h e f u n c t i o n w h i c h i s t o i n t e g r a t e d
% a,b the intergation i n t e r v a l is [ a , b ]
5 % m t h e o r d e r o f t h e Newton−C o t e s Method t o u s e
% t h i s i s t h e same a s t h e number o f p o i n t s i n
% the p a r t i t i o n of [ a , b ]
%
% numI t h e v a l u e o f t h e Newton−C o t e s a p p r o x i m a t i o n t o
10 % the i n t e g r a l
%
i f m>= 2 & m <= 9
w = WNC(m) ;
x = l i n s p a c e ( a , b ,m) ’ ;
15 f = f e v a l ( fname , x ) ;
numI = ( b−a ) ∗ (w’ ∗ f ) ;
else
d i s p ( ’ You need to use an order m between 2 and 9 ’ ) ;
end

and finally, a script to run the numerical integration routines is as follows:


2.1 Numerical Integration 21

Listing 2.4: Numerical Integration Script


1 w h i l e i n p u t ( ’ Another Example ? (1= yes , 0= no ) . ’ ) ;
fname = i n p u t ( ’ Enter function name : ’ ) ;
a = i n p u t ( ’ Enter left endpoint ’ ) ;
b = i n p u t ( ’ Enter right endpoint : ’ ) ;
s = [ ’ QNC ( ’ fname s p r i n t f ( ’ ,%6.3 f ,%6.3 f , m ) ’ , a , b ) ] ;
6 disp ( [ ’ m ’ s ])
disp ( ’ ’)
for m = 2:9
numI = QNC( fname , a , b ,m) ;
d i s p ( s p r i n t f ( ’ %2.0 f %20.16 f ’ ,m, numI ) )
11 end
end

2.1.4 Run Time Output

We use the functions defined in func1.m, f (x) = sin(x) , and func2.m,

f (x) = e−x
2
, which have matlab codes

Listing 2.5: Integrand Function I


function y = func1 ( x )
y = sin (x) ;

Listing 2.6: Integrand Function II


function y = func2 (u)
%
3 z = −u . ∗ u ;
y = exp ( z ) ;

π 2
Here is our runtime. The first example is 0 sin(x)dx = 1 and the second is 0 e−x dx
2

which can only be evaluated numerically and has the value approximately 0.882. You
can see this by using the built in MatLab numerical integration function quad. The
following session computes the integral using quad: here,we use the anonymous
function h to pass into quad.

Listing 2.7: Using quad


1 h = @( x ) exp (−x . ˆ 2 ) ;
c = quad ( h , 0 , 2 )
c = 0.8821

We then compare this to the Newton–Cotes methods in the session below.


22 2 Graham–Schmidt Orthogonalization

Listing 2.8: A Newton–Cotes session


ShowNC
2 Another Example ? (1= yes , 0=no ) . 1
E n t e r f u n c t i o n name : ’ func1 ’
Enter l e f t endpoint 0
E n t e r r i g h t e n d p o i n t : p i /2
m QNC( f u n c 1 , 0 . 0 0 0 , 1 . 5 7 1 ,m )
7

2 0.7853981633974483
3 1.0022798774922104
4 1.0010049233142790
5 0.9999915654729927
12 6 0.9999952613861668
7 1.0000000258372352
8 1.0000000158229039
9 0.9999999999408976
Another Example ? (1= yes , 0=no ) . 1
17 E n t e r f u n c t i o n name : ’ func2 ’
Enter l e f t endpoint 0
Enter r i g h t endpoint : 2 . 0
m QNC( f u n c 2 , 0 . 0 0 0 , 2 . 0 0 0 ,m )

22 2 1.0183156388887342
3 0.8299444678581678
4 0.8622241875991991
5 0.8852702891231793
6 0.8838030970892903
27 7 0.8819161924221999
8 0.8819818734329694
9 0.8820864256236417
Another Example ? (1= yes , 0=no ) . 0

2.2 Linearly Independent Functions

The ideas of linear independence and dependence are hard to grasp, so even though
we went through these ideas in Peterson (2015), it is a good idea to do a repeat
performance. So let’s go back and think about vectors in 2 . As you know, we think
of these as arrows with a tail fixed at the origin of the two dimensional coordinate
system we call the x–y plane. They also have a length or magnitude and this arrow
makes an angle with the positive x axis. Suppose we look at two such vectors,
E and F. Each vector has an x and a y component so that we can write
 
a c
E= , F=
b d

The cosine of the angle between them is proportional to the inner product < E, F >=
ac + bd. If this angle is 0 or π, the two vectors lie along the same line. In any case,
the angle associated with E is tan−1 ( ab ) and for F, tan−1 ( dc ). Hence, if the two vectors
lie on the same line, E must be a multiple of F. This means there is a number β so
that
2.2 Linearly Independent Functions 23

E = βF.

We can rewrite this as


 
a c
= β
b d

Now let the number 1 in front of E be called −α. Then the fact that E and F lie on
the same line implies there are 2 constants α and β, both not zero, so that

αE + βF = 0.

Note we could argue this way for vectors in 3 and even in n . Of course, our ability
to think of these things in terms of lying on the same line and so forth needs to be
extended to situations we can no longer draw, but the idea is essentially the same.
Instead of thinking of our two vectors as lying on the same line or not, we can rethink
what is happening here and try to identify what is happening in a more abstract
way. If our two vectors lie on the same line, they are not independent things in the
sense one is a multiple of the other. As we saw above, this implies there was a linear
equation connecting the two vectors which had to add up to 0. Hence, we might say
the vectors were not linearly independent or simply, they are linearly dependent.
Phrased this way, we are on to a way of stating this idea which can be used in many
more situations. We state this as a definition.

Definition 2.2.1 (Two Linearly Independent Objects)


Let E and F be two mathematical objects for which addition and scalar multiplication
is defined. We say E and F are linearly dependent if we can find non zero constants
α and β so that

αE + βF = 0.

Otherwise, we say they are linearly independent.

We can then easily extend this idea to any finite collection of such objects as follows.

Definition 2.2.2 (Finitely many Linearly Independent Objects)


Let {Ei : 1 ≤ i ≤ N} be N mathematical objects for which addition and scalar mul-
tiplication is defined. We say E and F are linearly dependent if we can find non
zero constants α1 to αN , not all 0, so that

α1 E1 + · · · + αN EN = 0.

Note we have changed the way we define the constants a bit. When there are more
than two objects involved, we can’t say, in general, that all of the constants must be
non zero.
24 2 Graham–Schmidt Orthogonalization

2.2.1 Functions

We can apply these ideas to functions f and g defined on some interval I. By this we
mean either
• I is all of , i.e. a = −∞ and b = ∞,
• I is half-infinite. This means a = −∞ and b is finite with I of the form (−∞, b)
or (−∞, b]. Similarly, I could have the form (a, ∞) or [a, ∞,
• I is an interval of the form (a, b), [a, b), (a, b] or [a, b] for finite a < b.
We would say f and g are linearly independent on the interval I if the equation

α1 f (t) + α2 g(t) = 0, for all t ∈ I.

implies α1 and α2 must both be zero. Here is an example. The functions sin(t) and
cos(t) are linearly independent on  because

α1 cos(t) + α2 sin(t) = 0, for all t,

also implies the above equation holds for the derivative of both sides giving

−α1 sin(t) + α2 cos(t) = 0, for all t,

This can be written as the system


  
cos(t) sin(t) α1 0
=
− sin(t) cos(t) α2 0

for all t. The determinant of the matrix here is cos2 (t) + sin2 (t) = 1 and so picking
any t we like, we find the unique solution is α1 = α2 = 0. Hence, these two functions
are linearly independent on . In fact, they are linearly independent on any interval I.
This leads to another important idea. Suppose f and g are linearly independent
differentiable functions on an interval I. Then, we know the system
  
f (t) g(t) α1 0
=
f  (t) g  (t) α2 0

only has the unique solution α1 = α2 = 0 for all t in I. This tells us



f (t) g(t)
det = 0
f  (t) g  (t)

for all t in I. This determinant comes up a lot and it is called the Wronskian of
the two functions f and g and it is denoted by the symbol W (f , g). Hence, we have
the implication: if f and g are linearly independent differentiable functions, then
2.2 Linearly Independent Functions 25

W (f , g) = 0 for all t in I. What about the converse? If the Wronskian is never zero
on I, then the system
  
f (t) g(t) α1 0
=
f  (t) g  (t) α2 0

must have the unique solution α1 = α2 = 0 at each t in I also. So the converse is


true: if the Wronskian is not zero on I, then the differentiable functions f and g are
linearly independent on I. We can state this formally as a theorem.

Theorem 2.2.1 (Two Functions are Linearly Independent if and only if their Wron-
skian is not zero)
If f and g are differentiable functions on I, the Wronskian of f and g is defined to
be

f (t) g(t)
W (f , g) = det .
f  (t) g  (t)

where W (f , g) is the symbol for the Wronskian of f and g. Sometimes, this is just
written as W , if the context is clear. Then f and g are linearly independent on I if
and only if W (f , g) is non zero on I.

Proof See the discussions above. 

If f , g and h are twice differentiable on I, the Wronskian uses a third row of second
derivatives and the statement that these three functions are linearly independent on
I if and only if their Wronskian is non zero on I is proved essentially the same way.
The appropriate theorem is

Theorem 2.2.2 (Three Functions are Linearly Independent if and only if their Wron-
skian is not zero)
If f , g and h are twice differentiable functions on I, the Wronskian of f , g and h is
defined to be
⎛⎡ ⎤⎞
f (t) g(t) h(t)
W (f , g, h) = det ⎝⎣ f  (t) g  (t) h (t) ⎦⎠ .
f  (t) g  (t) h (t)

where W (f , g, h) is the symbol for the Wronskian of f and g. Then f , g and h are
linearly independent on I if and only if W (f , g, h) is non zero on I.

Proof The arguments are similar, although messier. 

For example, to show the three functions f (t) = t, g(t) = sin(t) and h(t) = e2t are
linearly independent on , we could form their Wronskian
26 2 Graham–Schmidt Orthogonalization
⎛⎡ ⎤⎞
t sin(t) e2t  
⎝ ⎣ 2t ⎦⎠ cos(t) 2e2t sin(t) e2t
W (f , g, h) = det 1 cos(t) 2e = t −
− sin(t) 4e2t − sin(t) 4e2t
0 − sin(t) 4e2t

= t e2t (4 cos(t) + 2 sin(t) − e2t (4 sin(t) + sin(t)

= e2t 4t cos(t) + 2t sin(t) − 5 sin(t) .

Since, e2t is never zero, the question becomes is

4t cos(t) + 2t sin(t) − 5 sin(t)

zero for all t? If so, that would mean the functions t sin(t), t cos(t) and sin(t) are
linearly dependent. We could then form another Wronskian for these functions which
would be rather messy. To see these three new functions are linearly independent, it
is easier to just pick three points t from  and solve the resulting linearly dependence
equations. Since t = 0 does not give any information, let’s try t = −π, t = π4 and
t = π2 . This gives the system
⎡ ⎤⎡ ⎤ ⎡ ⎤
−4π 0√ 0√ α1 0
⎣ π 2 π 2 −5 2 ⎦ ⎣α2 ⎦ = ⎣0⎦
4 2 2
0 2 π2 −5 α3 0

in the unknowns α1 , α2 and α3 . We see √


immediately α − 1 = 0 and the remaining
two by two system has determinant 2 (−10 π4 ) + 10 π2 = 0. Hence, α2 = α3 = 0
2

too. This shows t sin(t), t cos(t) and sin(t) are linearly independent and show the
line 4t cos(t) + 2t sin(t) − 5 sin(t) is not zero for all t. Hence, the functions f (t) = t,
g(t) = sin(t) and h(t) = e2t are linearly independent. As you can see, these calcu-
lations become messy quickly. Usually, the Wronskian approach for more than two
functions is too hard and we use the pick three suitable points ti , from I approach
and solve the resulting linear system. If we can show the solution is always 0, then
the functions are linearly independent.

2.2.2 Homework

Exercise 2.2.1 Prove et and e−t are linearly independent on .

Exercise 2.2.2 Prove et and e2t are linearly independent on .

Exercise 2.2.3 Prove f (t) = 1 and g(t) = t 2 are linearly independent on .

Exercise 2.2.4 Prove et , e2t and e3t are linearly independent on . Use the pick
three points approach here.
2.2 Linearly Independent Functions 27

Exercise 2.2.5 Prove sin(t), sin(2t) and sin(3t) are linearly independent on . Use
the pick three points approach here.
Exercise 2.2.6 Prove 1, t and t 2 are linearly independent on . Use the pick three
points approach here.

2.3 Vector Spaces and Basis

We can make the ideas we have been talking about more formal. If we have a set
of objects u with a way to add them to create new objects in the set and a way to
scale them to make new objects, this is formally called a Vector Space with the set
denoted by V . For our purposes, we scale such objects with either real or complex
numbers. If the scalars are real numbers, we say V is a vector space over the reals;
otherwise, it is a vector space over the complex field.
Definition 2.3.1 (Vector Space)
Let V be a set of objects u with an additive operation ⊕ and a scaling method .
Formally, this means
1. Given any u and v, the operation of adding them together is written u ⊕ v and
results in the creation of a new object w in the vector space. This operation is
commutative which means the order of the operation is not important. Also, this
operation is associative as we can group any two objects together first, perform
this addition ⊕ and then do the others and the order of the grouping does not
matter.
2. Given any u and any number c (either real or complex, depending on the type
of vector space we have), the operation c u creates a new object. We call such
numbers scalars.
3. The scaling and additive operations are compatible in the sense that they satisfy
the distributive laws for scaling and addition.
4. There is a special object called o which functions as a zero so we always have
o ⊕ u = u ⊕ o = u.
5. There are additive inverses which means to each u there is a unique object u† so
that u ⊕ u† = o.

Comment 2.3.1 These laws imply

(0 + 0) u = (0 u) ⊕ (0 u)

which tells us 0 u = 0. A little further thought then tells us that since

0 = (1 − 1) u
= (1 u) ⊕ (−1 u)

we have the additive inverse u† = −1 u.


28 2 Graham–Schmidt Orthogonalization

Comment 2.3.2 We usually say this much simpler. The set of objects V is a vector
space over its scalar field if there are two operations which we denote by u + v and
cu which generate new objects in the vector space for any u, v and scalar c. We
then just add that these operations satisfy the usual commutative, associative and
distributive laws and there are unique additive inverses.
Comment 2.3.3 The objects are often called vectors and sometimes we denote them
by u although this notation is often too cumbersome.
Comment 2.3.4 To give examples of vector spaces, it is usually enough to specify
how the additive and scaling operations are done.
• Vectors in 2 , 3 and so forth are added and scaled by components.
• Matrices of the same size are added and scaled by components.
• A set of functions of similar characteristics uses as its additive operator, pointwise
addition. The new function (f ⊕ g) is defined pointwise by (f ⊕ g)(t) = f (t) +
g(t). Similarly, the new function c f is defined by c f is the function whose
value at t is (cf )(t) = cf (t). Classic examples are
1. C[a, b] is the set of all functions whose domain is [a, b] that are continuous on
the domain.
2. C 1 [a, b] is the set of all functions whose domain is [a, b] that are continuously
differentiable on the domain.
3. R[a, b] is the set of all functions whose domain is [a, b] that are Riemann inte-
grable on the domain.
There are many more, of course.
Vector spaces have two other important ideas associated with them. We have already
talked about linearly independent objects. Clearly, the kinds of objects we were
focusing on were from some vector space V . The first idea is that of the span of a
set.
Definition 2.3.2 (The Span Of A Set Of Vectors)
Given a finite set of vectors in a vector space V , W = {u1 , . . . , uN } for some
 positive
integer N, the span of W is the collection of all new vectors of the form Ni=1 ci ui for
any choices of scalars c1 , . . . , cN . It is easy to see W is a vector space itself and since
it is a subset of V , we call it a vector subspace. The span of the set W is denoted
by SpW . If the set of vectors W is not finite, the definition is similar but we say the
span of W is the set of all vectors which can be written as Ni=1 ci ui for some finite
set of vectors u1 , . . . uN from W .
Then there is the notion of a basis for a vector space. First, we need to extend the
idea of linear independence to sets that are not necessarily finite.
Definition 2.3.3 (Linear Independence For Non Finite Sets)
Given a set of vectors in a vector space V , W , we say W is a linearly independent
subset if every finite set of vectors from W is linearly independent in the usual
manner.
2.3 Vector Spaces and Basis 29

Definition 2.3.4 (A Basis For A Vector Space)


Given a set of vectors in a vector space V , W , we say W is a basis for V if the span
of W is all of V and if the vectors in W are linearly independent. Hence, a basis is
a linearly independent spanning set for V . The number of vectors in W is called the
dimension of V . If W is not finite is size, then we say V is an infinite dimensional
vector space.

Comment 2.3.5 In a vector space like n , the maximum size of a set of linearly
independent vectors is n, the dimension of the vector space.

Comment 2.3.6 Let’s look at the vector space C[0, 1], the set of all continuous
functions on [0, 1]. Let W be the set of all powers of t, {1, t, t 2 , t 3 , . . .}. We can
use the derivative technique to show this set is linearly independent even though
it is infinite in size. Take any finite subset from W . Label the resulting powers as
{n1 , n2 , . . . , np }. Write down the linear dependence equation

c1 t n1 + c2 t n2 + · · · + cp t np = 0.

Take np derivatives to find cp = 0 and then backtrack to find the other constants are
zero also. Hence C[0, 1] is an infinite dimensional vector space. It is also clear that
W does not span C[0, 1] as if this was true, every continuous function on [0, 1]
would be a polynomial of some finite degree. This is not true as sin(t), e−2t and many
others are not finite degree polynomials.

2.4 Inner Products

Now there is an important result that we use a lot in applied work. If we have an object
u in a Vector Space V , we often want to find to approximate u using an element from
a given subspace W of the vector space. To do this, we need to add another property
to the vector space. This is the notion of an inner product. We already know what
an inner product is in a simple vector space like n . Many vector spaces can have
an inner product structure added easily. For example, in C[a, b], since each object is
continuous, each object is Riemann integrable. Hence, given two functions f and g
b
from C[a, b], the real number given by a f (s)g(s)ds is well-defined. It satisfies all
the usual properties that the inner product for finite dimensional vectors in n does
also. These properties are so common we will codify them into a definition for what
an inner product for a vector space V should behave like.

Definition 2.4.1 (Real Inner Product)


Let V be a vector space with the reals as the scalar field. Then a mapping ω which
assigns a pair of objects to a real number is called an inner product on V if
1. ω(u, v) = ω(v, u); that is, the order is not important for any two objects.
2. ω(c u, v) = cω(u, v); that is, scalars in the first slot can be pulled out.
30 2 Graham–Schmidt Orthogonalization

3. ω(u ⊕ w, v) = ω(u, v) + ω(w, v), for any three objects.


4. ω(u, u) ≥ 0 and ω(u, u) = 0 if and only if u = 0.
These properties imply that ω(u, c v) = cω(u, v) as well. A vector space V with
an inner product is called an inner product space.

Comment 2.4.1 The inner product is usually denoted with the symbol < , > instead
of ω(,). We will use this notation from now on.

Comment 2.4.2 When we have an inner product, we can measure the size or mag-
nitude of an object, as follows. We define the analogue of the euclidean norm of an
object u using the usual || || symbol as

||u|| = < u, u >.

This is called the norm induced by the inner product of the object. In C[a, b], with
b
the inner product < f , g > = a f (s)g(s)ds, the norm of a function f is thus ||f || =

b 2
a f (s)ds. This is called the L2 norm of f .

It is possible to prove the Cauchy–Schwartz inequality in this more general setting


also.

Theorem 2.4.1 (General Cauchy–Schwartz Inequality)


If V is an inner product space with inner product < , > and induced norm || ||, then

| < u, v > | ≤ ||u|| ||v||

with equality occurring if and only if u and v are linearly dependent.

Proof The proof is different than the one you would see in a Calculus text for 2 ,
of course, and is covered in a typical course on beginning analysis. 

Comment 2.4.3 We can use the Cauchy–Schwartz inequality to define a notion of


angle between objects exactly like we would do in 2 . We define the angle θ between
u and v via its cosine as usual.
< u, v >
cos(θ) = .
||u|| ||v||

Hence, objects can be perpendicular or orthogonal even if we can not interpret them
as vectors in 2 . We see two objects are orthogonal if their inner product is 0.

Comment 2.4.4 If W is a finite dimensional subspace, a basis for W is said to


be an orthonormal basis if each object in the basis has L2 norm 1 and all of the
objects are mutually orthogonal. This means < ui , uj > is 1 if i = j and 0 otherwise.
We typically let the Kronecker delta symbol δij be defined by δij = 1 if i = j and 0
otherwise so that we can say this more succinctly as < ui , uj >= δij .
2.4 Inner Products 31

Now, let’s return to the idea of finding the best object in a subspace W to approximate
a given object u. This is an easy theorem to prove.

Theorem 2.4.2 (Best Finite Dimensional Approximation Theorem)


Let u be any object in the inner product space V with inner product <, > and
induced norm || ||. Let W be a finite dimensional subspace with an orthonormal
basis {w1 , . . . w N } where N is the dimension of the subspace. Then there is an unique
object p∗ in W which satisfies

||u − p∗ || = min ||u − p||


p∈W

with
N
p∗ = < u, w i > wi .
i=1

Further, p − p∗ is orthogonal to the subspace W .


N
Proof Any object in the subspace has the representation i=1 ai wi for some scalars
ai . Consider the function of N variables
 N N 
E(a1 , . . . , aN ) = u − ai wi , u − aj wj
i=1 j=1
N N N
= < u, u > −2 ai < u, w i > + ai aj < wi , w j > .
i=1 i=1 j=1

Simplifying using the orthonormality of the basis, we find

N N
E(a1 , . . . , aN ) = < u, u > −2 ai < u, w i > + ai2 .
i=1 i=1

This is a quadratic expression and setting the gradient of E to zero, we find the critical
points
aj =< u, w j > .

This is a global minimum for the function E. Hence, the optimal p∗ has the form

N

p = < u, w i > wi .
i=1
32 2 Graham–Schmidt Orthogonalization

Finally, we see

N

< p − p , wj > = < p, wj > − < p, wk >< wk , wj >
k=1
= < p, wj > − < p, wj >= 0,

and hence, p = p∗ is orthogonal of W . 

2.5 Graham–Schmidt Orthogonalization

Let’s assume we are given two linearly independent vectors in 2 . Fire up


MatLab/Octave and enter two such vectors.

Listing 2.9: Setting two vectors


V1 = [ 6 ; 2 ] ;
V2 = [ − 1 ; 4 ] ;

In Fig. 2.1 we see these two vectors.


Now project V2 to the vector V1 . The unit vector pointing in the direction of V1 is
E1 = V1 /||V1 || and the amount of V2 that lies in the direction of V1 is given by the

Fig. 2.1 Two linearly independent vectors in 2


2.5 Graham–Schmidt Orthogonalization 33

inner product < V1 , E1 >. Hence, the vector < V1 , E1 > E1 in the vector portion of
V2 which lies in the direction of V1 . Now subtract this from V2 . Hence, define W by

W = V2 − < V2 , E1 > E1 .

Note by construction W is perpendicular to V1 as

< W, E1 > = < V2 − < V2 , E1 > E1 , E1 > = < V2 , E1 > − < V2 , E1 >< E1 , E1 >
= < V2 , E1 > − < V2 , E1 > = 0,

since < E1 , E1 > = ||E1 ||2 = 1. Let E2 be the unit vector given by W/||W ||. Then
from the linearly independent vectors V1 and V2 , we have constructed two new
linearly independent vectors which are mutually orthogonal, E1 and E2 . We also see
both {V1 , V2 } and {E1 , E2 } are bases for 2 but the new one {E1 , E2 } is preferred as
the basis vectors are orthogonal. We can see the new vectors in Fig. 2.2.
You should be able to see that this procedure is easy to extend to three linearly
vectors in 3 and finite sets of linearly independent functions as well. This type
of procedure is called Graham–Schmidt Orthogonalization and we can see this
graphically in 2 . First we graph the vectors. This done with calls to plot. We start
with the function Draw2DGSO and add the vector drawing code first. We do all of
our drawing between a hold on and hold off so we keep drawing into the figure
until we are done.

Fig. 2.2 Two linearly independent vectors in 2


34 2 Graham–Schmidt Orthogonalization

Listing 2.10: Draw2DGSO: drawing the vectors


f u n c t i o n Draw2DGSO( V1 , V2)
%
T = linspace (0 ,1 ,2) ;
h o l d on
5 % find equation of l i n e for v e c t o r V1
i f V1 ( 1 ) == 0
f 1 = @( t ) t ;
else
f 1 = @( t ) (V1 ( 2 ) /V1 ( 1 ) ) ∗ t ;
10 end
T = [ 0 : V1 ( 1 ) : V1 ( 1 ) ] ;
p l o t (T , f 1 (T) ) ;
t e x t ( V1 ( 1 ) / 2 ,V1 ( 2 ) / 2 , ’V1 ’ ) ;
% find equation of l i n e for v e c t o r V2
15 i f V2 ( 1 ) == 0
f 2 = @( t ) t ;
else
f 2 = @( t ) (V2 ( 2 ) /V2 ( 1 ) ) ∗ t ;
end
20 p l o t (T , f 2 (T) ) ;
T = [ 0 : V2 ( 1 ) : V2 ( 1 ) ] ;
t e x t ( V2 ( 1 ) / 2 ,V2 ( 2 ) / 2 , ’V2 ’ ) ;
hold o f f
end

Note we also use the new text command to add text at desired points in the graph.
Next, we find the new basis vectors E1 and E2 and graph them.

Listing 2.11: Graph the new basis vectors


% Now p l o t e1
E1 = V1/norm ( V1) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r V1
i f E1 ( 1 ) == 0
5 e1 = @( t ) t ;
else
e1 = @( t ) ( E1 ( 2 ) /E1 ( 1 ) ) ∗ t ;
end
T = [ 0 : E1 ( 1 ) : E1 ( 1 ) ] ;
10 p l o t (T , e1 (T) , ’r ’ , ’ linewidth ’ , 4 ) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r e2
W = V2 − d o t ( V2 , E1 ) ∗E1
E2 = W/norm (W) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r e2
15 i f E2 ( 1 ) == 0
e2 = @( t ) t ;
else
e2 = @( t ) ( E2 ( 2 ) /E2 ( 1 ) ) ∗ t ;
end
20 T = [ 0 : E2 ( 1 ) : E2 ( 1 ) ] ;
p l o t (T , e2 (T) , ’r ’ , ’ linewidth ’ , 4 ) ;

Now if you just did this, you will probably see the E1 and E2 don’t necessarily
look perpendicular in the figure. This is because by itself, MatLab/Octave does not
necessarily use a square picture frame for our graph. So the x and y axes need not be
2.5 Graham–Schmidt Orthogonalization 35

the same size. If they are not this, will make us lose the appearance of orthogonality!
So to fix this, we make sure the x and y axes are the same size. This requires some
messy code as follows.

Listing 2.12: Setting the aspect ratio


% set axis limits
xmin = V1 ( 1 ) ;
i f (V2 ( 1 ) < xmin )
4 xmin = V2 ( 1 ) ;
xmax = V1 ( 1 ) ;
else
xmax = V2 ( 1 ) ;
end
9 ymin = V1 ( 2 ) ;
i f (V2 ( 2 ) < ymin )
ymin = V2 ( 2 ) ;
ymax = V2 ( 2 ) ;
else
14 ymax = V2 ( 1 ) ;
end
%
umin = xmin ;
i f ( ymin < umin )
19 umin = ymin ;
end
umax = xmax ;
i f ( ymax > umax )
umax = ymax ;
24 end
a x i s ( [ umin , umax , umin , umax ] ) ;

This sets the axes correctly, but we still need to make sure the figure is square. We do
this be setting the figure size with figure(’Position’,[0,0,600,600]);
at the top of the file. The full code to see what is happening in 2 is then given in
the function Draw2DGSO given below.

Listing 2.13: Drawing a two dimensional Graham–Schmidt orthogonalization result:


Draw2DGSO
f u n c t i o n Draw2DGSO( V1 , V2 )
%
T = linspace (0 ,1 ,2) ;
f i g u r e ( ’ Position ’ , [ 0 , 0 , 6 0 0 , 6 0 0 ] ) ;
5 h o l d on
% f i n d e q u a t i o n o f l i n e f o r v e c t o r V1
i f V1 ( 1 ) == 0
f 1 = @( t ) t ;
else
10 f 1 = @( t ) ( V1 ( 2 ) /V1 ( 1 ) ) ∗ t ;
end
T = [ 0 : V1 ( 1 ) : V1 ( 1 ) ] ;
p l o t (T , f 1 (T) ) ;
t e x t ( V1 ( 1 ) / 2 , V1 ( 2 ) / 2 , ’ V1 ’ ) ;
15 % f i n d e q u a t i o n o f l i n e f o r v e c t o r V1
i f V2 ( 1 ) == 0
f 2 = @( t ) t ;
else
f 2 = @( t ) ( V2 ( 2 ) /V2 ( 1 ) ) ∗ t ;
20 end
p l o t (T , f 2 (T) ) ;
36 2 Graham–Schmidt Orthogonalization

T = [ 0 : V2 ( 1 ) : V2 ( 1 ) ] ;
t e x t ( V2 ( 1 ) / 2 , V2 ( 2 ) / 2 , ’ V2 ’ ) ;
% Now p l o t e1
25 E1 = V1/norm ( V1 ) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r V1
i f E1 ( 1 ) == 0
e1 = @( t ) t ;
else
30 e1 = @( t ) ( E1 ( 2 ) /E1 ( 1 ) ) ∗ t ;
end
T = [ 0 : E1 ( 1 ) : E1 ( 1 ) ] ;
p l o t (T , e1 (T) , ’r ’ , ’ linewidth ’ , 4 ) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r e2
35 W = V2 − d o t ( V2 , E1 ) ∗E1
E2 = W/norm (W) ;
% f i n d e q u a t i o n o f l i n e f o r v e c t o r e2
i f E2 ( 1 ) == 0
e2 = @( t ) t ;
40 else
e2 = @( t ) ( E2 ( 2 ) /E2 ( 1 ) ) ∗ t ;
end
T = [ 0 : E2 ( 1 ) : E2 ( 1 ) ] ;
p l o t (T , e2 (T) , ’r ’ , ’ linewidth ’ , 4 , ) ;
45 % set axis limits
xmin = V1 ( 1 ) ;
i f ( V2 ( 1 ) < xmin )
xmin = V2 ( 1 ) ;
xmax = V1 ( 1 ) ;
50 else
xmax = V2 ( 1 ) ;
end
ymin = V1 ( 2 ) ;
i f ( V2 ( 2 ) < ymin )
55 ymin = V2 ( 2 ) ;
ymax = V2 ( 2 ) ;
else
ymax = V2 ( 1 ) ;
end
60 %
umin = xmin ;
i f ( ymin < umin )
umin = ymin ;
end
65 umax = xmax ;
i f ( ymax > umax )
umax = ymax ;
end
a x i s ( [ umin , umax , umin , umax ] ) ;
70 hold o f f
end

It is simple to use this code. The example we just worked out would be done this
way in MatLab/Octave.

Listing 2.14: A 2DGSO sample session


V1 = [ 6 ; 2 ] ;
V2 = [ − 1 ; 4 ] ;
Draw2DGSO( V1 , V2) ;
4 p r i n t −dpng ’2 DGSO . png ’
2.5 Graham–Schmidt Orthogonalization 37

We can certainly do this procedure for three linearly independent vectors in 3 . We


graph lines using the plot3 function. For example, to draw the line between V1 and
V2 , we set up vectors X, Y and Z as follows:

Listing 2.15: Setting coordinates for a line plot


X = [ 0 ; V1 ( 1 ) ] ;
Y = [ 0 ; V1 ( 2 ) ] ;
Z = [ 0 ; V1 ( 3 ) ] ;

The way to look at this is that the first column of these three vectors specifies the
start position [0, 0, 0]T and the second column is the end position coordinates V1T .
We then plot the line and add text with

Listing 2.16: Plotting the lines


p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
2 t e x t (V1 ( 1 ) / 2 ,V1 ( 2 ) / 2 ,V1 ( 3 ) / 2 , ’V1 ’ ) ;

Note we set the width of the plotted line to be of size 2 which is thicker than size 1.
Once this line is plotted, we do the others. So the code to plot the three vectors as
lines starting at the origin is as follows; note, we wrap this code between hold on
and hold off statements so that we draw into our figure repeatedly until we are
done.

Listing 2.17: Plotting all the lines


h o l d on
% p l o t V1
X = [ 0 ; V1 ( 1 ) ] ;
Y = [ 0 ; V1 ( 2 ) ] ;
5 Z = [ 0 ; V1 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V1 ( 1 ) / 2 ,V1 ( 2 ) / 2 ,V1 ( 3 ) / 2 , ’V1 ’ ) ;
% p l o t V2
X = [ 0 ; V2 ( 1 ) ] ;
10 Y = [ 0 ; V2 ( 2 ) ] ;
Z = [ 0 ; V2 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V2 ( 1 ) / 2 ,V2 ( 2 ) / 2 ,V2 ( 3 ) / 2 , ’V2 ’ ) ;
% p l o t V3
15 X = [ 0 ; V3 ( 1 ) ] ;
Y = [ 0 ; V3 ( 2 ) ] ;
Z = [ 0 ; V3 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V3 ( 1 ) / 2 ,V3 ( 2 ) / 2 ,V3 ( 3 ) / 2 , ’V3 ’ ) ;
20 hold o f f

We then do the steps of the Graham–Schmidt orthogonalization. First, we set up


E1 = V1 /||V1 || as usual. We then project V2 to V1 to obtain
38 2 Graham–Schmidt Orthogonalization

W = V2 − < V2 , E1 > E1

which by construction will be perpendicular to E1 . We then set E2 = W/||W ||.


Finally, we project V3 to the plane determined by V1 and V2 as follows:

W = V3 − < V3 , E1 > E1 − < V3 , E2 > E2

which by construction will be perpendicular to both E1 and E2 . Finally, we let E3 =


W/||W || and we have found a new mutually orthogonal basis for 3 {E1 , E2 , E3 }. It
is easy put this into code. We write

Listing 2.18: Finding and plotting the new basis


% Do GSO
E1 = V1/norm ( V1) ;
W = V2 − d o t ( V2 , E1 ) ∗E1 ;
E2 = W/norm (W) ;
5 W = V3 − d o t ( V3 , E1 ) ∗E1 − d o t ( V3 , E2 ) ∗E2 ;
E3 = W/norm (W) ;
% P l o t new b a s i s
% p l o t E1
X = [ 0 ; E1 ( 1 ) ] ;
10 Y = [ 0 ; E1 ( 2 ) ] ;
Z = [ 0 ; E1 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 ) ;
% p l o t E2
X = [ 0 ; E2 ( 1 ) ] ;
15 Y = [ 0 ; E2 ( 2 ) ] ;
Z = [ 0 ; E2 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 ) ;
% p l o t E3
X = [ 0 ; E3 ( 1 ) ] ;
20 Y = [ 0 ; E3 ( 2 ) ] ;
Z = [ 0 ; E3 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 ) ;

Then to make this show up nicely, we draw lines between V1 and V2 to make the
plane determined by these vectors stand out.

Listing 2.19: Drawing the plane between V1 and V2


% Draw p l a n e d e t e r m i n e d by V1 and V2
delt = 0.05;
3 for i = 1:10
p = i ∗ delt ;
X = [ p∗V1 ( 1 ) ; p∗V2 ( 1 ) ] ;
Y = [ p∗V1 ( 2 ) ; p∗V2 ( 2 ) ] ;
Z = [ p∗V1 ( 3 ) ; p∗V2 ( 3 ) ] ;
8 p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
end
t e x t ( (V1 ( 1 )+V2 ( 1 ) ) / 4 , (V1 ( 2 )+V2 ( 2 ) ) / 4 , ( V1 ( 3 )+V2 ( 3 ) ) / 4 , ’V1 -
V2 Plane ’ ) ;

The full code is then given in the function Draw3DGSO.


2.5 Graham–Schmidt Orthogonalization 39

Listing 2.20: Drawing a three dimensional Graham–Schmidt orthogonalization


result: Draw3DGSO
f u n c t i o n Draw3DGSO( V1 , V2 , V3 )
%
T = linspace (0 ,1 ,2) ;
f i g u r e ( ’ Position ’ , [ 0 , 0 , 6 0 0 , 6 0 0 ] ) ;
5 h o l d on
% p l o t V1
X = [ 0 ; V1 ( 1 ) ] ;
Y = [ 0 ; V1 ( 2 ) ] ;
Z = [ 0 ; V1 ( 3 ) ] ;
10 p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V1 ( 1 ) / 2 , V1 ( 2 ) / 2 , V1 ( 3 ) / 2 , ’ V1 ’ ) ;
% p l o t V2
X = [ 0 ; V2 ( 1 ) ] ;
Y = [ 0 ; V2 ( 2 ) ] ;
15 Z = [ 0 ; V2 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V2 ( 1 ) / 2 , V2 ( 2 ) / 2 , V2 ( 3 ) / 2 , ’ V2 ’ ) ;
% p l o t V3
X = [ 0 ; V3 ( 1 ) ] ;
20 Y = [ 0 ; V3 ( 2 ) ] ;
Z = [ 0 ; V3 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
t e x t ( V3 ( 1 ) / 2 , V3 ( 2 ) / 2 , V3 ( 3 ) / 2 , ’ V3 ’ ) ;
%
25 % Draw p l a n e d e t e r m i n e d b y V1 and V2
delt = 0.05;
for i = 1:10
p = i∗delt ;
X = [ p∗V1 ( 1 ) ; p∗V2 ( 1 ) ] ;
30 Y = [ p∗V1 ( 2 ) ; p∗V2 ( 2 ) ] ;
Z = [ p∗V1 ( 3 ) ; p∗V2 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’r ’ , ’ linewidth ’ , 2 ) ;
end
t e x t ( ( V1 ( 1 )+V2 ( 1 ) ) / 4 , ( V1 ( 2 )+V2 ( 2 ) ) / 4 , ( V1 ( 3 )+V2 ( 3 ) ) / 4 , ’ V1 - V2
Plane ’ ) ;
35 %
% Do GSO
E1 = V1/norm ( V1 ) ;
W = V2 − d o t ( V2 , E1 ) ∗E1 ;
E2 = W/norm (W) ;
40 W = V3 − d o t ( V3 , E1 ) ∗E1 − d o t ( V3 , E2 ) ∗E2 ;
E3 = W/norm (W) ;
% P l o t new b a s i s
% p l o t E1
X = [ 0 ; E1 ( 1 ) ] ;
45 Y = [ 0 ; E1 ( 2 ) ] ;
Z = [ 0 ; E1 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 , ) ;
% p l o t E2
X = [ 0 ; E2 ( 1 ) ] ;
50 Y = [ 0 ; E2 ( 2 ) ] ;
Z = [ 0 ; E2 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 , ) ;
% p l o t E3
X = [ 0 ; E3 ( 1 ) ] ;
55 Y = [ 0 ; E3 ( 2 ) ] ;
Z = [ 0 ; E3 ( 3 ) ] ;
p l o t 3 (X, Y, Z , ’b ’ , ’ linewidth ’ , 4 , ) ;
hold o f f
end

It is again easy to use this code. Here is a sample session. Since we make up our
vectors, we always set up a matrix A using the vectors as rows and then find the
40 2 Graham–Schmidt Orthogonalization

determinant of A. If that was 0, we would know our choice of vectors was not
linearly independent and we would have to make up new vectors for our example.

Listing 2.21: A Draw3DGSO example


1 V1 = [ 6 ; 2 ; 1 ] ;
V2 = [ − 1 ; 4 ; 3 ] ;
V3 = [ 8 ; 2 ; − 1 ] ;
A = [ V1 ’ ; V2 ’ ; V3 ’ ] ;
d e t (A)
6 a n s = −48.000
Draw3DGSO( V1 , V2 , V3 ) ;
p r i n t −dpng ’3 DGSO . png ’

We can use this code to generate a nice 3D plot of this procedure as shown in Fig. 2.3.
If you do this in MatLab/Octave yourself, you can grab the graph and rotate it around
to make sure you see it in the orientation that makes the best sense to you.

Fig. 2.3 Three linearly independent vectors in 3


2.5 Graham–Schmidt Orthogonalization 41

2.5.1 Making It Formal

If we had a finite number of linearly independent objects in an inner product space


V , then they form a basis for their span. There is a recursive procedure to find a
new orthonormal basis from these vectors for the subspace formed by their span.
This is called the Graham–Schmidt Orthogonalization process. It is easiest to show
it explicitly for three vectors. You can then easily generalize it to more objects. Let’s
assume we start with three linearly independent objects u, v and w. We will find
three orthogonal objects of length 1, g 1 , g 2 and g 3 to be the new basis as follows:
First Basis Object Set
u
g1 = .
||u||

Second Basis Object

• Subtract the part of v which lies along the object g 1 .

h = v − < v, g 1 > g 1 .

• Find the length of h and set the second new basis object as follows:

h
g2 = .
||h||

Third Basis Object

• Subtract the part of w which lies along the object g 1 and the object g 2 .

h = w − < v, g 1 > g 1 − < v, g 2 > g 2 .

• Find the length of h and set the third new basis object as follows:

h
g3 = .
||h||

It is easy to see how to generalize this to four or more objects. In fact, the procedure is
the same whether we are using vectors or functions as long as the objects are linearly
independent.

2.5.2 General MatLab GSO

To see how we could do GSO in computationally, we will now show some simple
MatLab code. We will use the numerical integration code presented in this chapter
42 2 Graham–Schmidt Orthogonalization

which uses Newton–Cotes formulae and also show you how to use the built-in quadra-
ture codes in MatLab itself. In general, doing GSO on functions is hard, as you will
see, due to numerical errors. The code we have shown you so far is hard-wired to
the number of linearly independent objects. Hence, we wrote 2D and 3D GSO code
separately. Now we’ll try to write more general code where the argument we send
into the function is a collection of linearly independent objects. The code ideas that
follow are specialized to functions, but it wouldn’t be hard to write similar code for
sets of independent vectors in n .
The first code is the one that uses Newton–Cotes ideas. This is written to perform
GSO on powers of t, but it could be easily generalized to more general functions.
Some word of explanation are in order. First, we use a generic powers of t function

Listing 2.22: Generic Powers of t Function


f u n c t i o n y = Powers ( t , n )
2 % t = independent v a r i a b l e
% n = power
y = t .ˆn ;
end

We then use extensively the idea of pointers to functions which in MatLab are called
function handles. We also use the idea of anonymous functions in MatLab. The
basic syntax for these is something like h = @(x)x.^2; which sets up h as
an anonymous function so that a session line like h(3) would be evaluated as 32 .
The letter h here is the function handle which allows us to refer to this function in
other code. We do the GSO using nested loops of anonymous functions using syntax
like

Listing 2.23: Constructing an anonymous function as a loop


f o r k=M+2:N+1
%compute n e x t o r t h o g o n a l p i e c e
p h i = @( x ) 0 ;
f o r j = M+1:k−1
5 c = i p ( f {k } , g { j } , a , b , r ) ;
p h i = @( x ) ( p h i ( x )+c ∗ g { j } ( x ) ) ;
end
p s i = @( x ) ( f {k } ( x ) − p h i ( x ) ) ;
nf = sqrt ( ip ( psi , psi , a , b , r ) ) ;
10 g {k} = @( x ) ( p s i ( x ) / n f ) ;

to calculate each of the new basis objects gk . We start with the zero anonymous
function phi and progressively add up the pieces we must subtract that lie along the
previous gj objects. Once this is done, we subtract this sum from the original object
and then divide by the length. This then creates the new object gk .
2.5 Graham–Schmidt Orthogonalization 43

We also use an inner product implementation nested inside this code as follows:

Listing 2.24: Nested inner product code


function c = ip ( f , g , a , b , r )
w = WNC( r ) ;
s = linspace (a ,b , r ) ’;
u = zeros (r ,1) ;
5 u = f ( s ) .∗ g( s ) ;
c = ( b−a ) ∗ (w’ ∗ u ) ;
end

which uses the function handles f and g we pass with the desired Newton–Cotes
b
order to approximate a f gds.

Listing 2.25: A Newton–Cotes GSO Code


f u n c t i o n [ t , z ] = GrahamSchmidtNC ( a , b , r ,M, N, NumPoints )
%
3 % Perform Graham − S c h m i d t O r t h o g o n a l i z a t i o n
% on a s e t o f f u n c t i o n s 1 , t , t ˆ 2 , . . . , t ˆN
%
% a = s t a r t of i n t e r v a l
% b = end o f i n t e r v a l
8 % r = Newton−C o t e s o r d e r −− can b e a s h i g h a s 9
% M = power o f t t o s t a r t a t
% N = power o f t t o end w i t h
% NumPoints = t h e number o f p o i n t s t o u s e i n t h e t
% v e c t o r we w i l l u s e f o r p l o t t i n g t h e g k ’ s
13 %
% s e t u p t a s 1 xNumPoints
t = l i n s p a c e ( a , b , NumPoints ) ;
% s e t u p x a s NumPoints rows x N+1 c o l u m n s
z = z e r o s ( NumPoints ,N+1) ;
18 %S e t u p f u n c t i o n h a n d l e s
f = c e l l (N+1 ,1) ;
g = c e l l (N+1 ,1) ;
f o r i =1:N+1
f { i } = @( x ) Powers ( x , i −1) ;
23 end
n f = s q r t ( i p ( f {M+1} , f {M+1} , a , b , r ) ) ;
g{M+1} = @( x ) f {M+1}(x ) / n f ;
y = z e r o s ( 1 , NumPoints ) ;
d = z e r o s (N+1 ,N+1) ;
28 y = g{M+1}( t ) ;
z ( : ,M+1) = y ’ ;
f o r k=M+2:N+1
%compute n e x t o r t h o g o n a l p i e c e
p h i = @( x ) 0 ;
33 f o r j = M+1: k−1
c = i p ( f {k } , g{ j } , a , b , r ) ;
p h i = @( x ) ( p h i ( x )+c ∗g{ j } ( x ) ) ;
end
p s i = @( x ) ( f {k } ( x ) − p h i ( x ) ) ;
38 nf = sqrt ( ip ( psi , psi , a , b , r ) ) ;
g{k} = @( x ) ( p s i ( x ) / n f ) ;
y = g{k } ( t ) ;
z (: , k) = y ’ ;
end
43 % fi nd the matrix of inner products
f o r i=M+1:N+1
f o r j=M+1:N+1
d ( i , j ) = i p ( g{ i } , g{ j } , a , b , r ) ;
end
48 end
44 2 Graham–Schmidt Orthogonalization

% Print out the matrix of inner products


d

function c = ip ( f , g , a , b , r )
53 w = WNC( r ) ;
s = linspace (a ,b , r ) ’;
u = zeros (r ,1) ;
u = f ( s ) .∗ g( s ) ;
c = ( b−a ) ∗ (w’ ∗ u ) ;
58 end

end

Here are some Newton–Cotes results. First, we try a low order 3 Newton–Cotes
method. There is too much error here. In the snippet below, d is the matrix of <
gi , gj > inner products which should be an identity matrix. Note the many off diagonal
terms which are close to 1 is absolute value. Much error here.

Listing 2.26: GSO with Newton–Cotes Order 3


[ t , z ] = GrahamSchmidtNC ( 0 , 1 , 3 , 0 , 5 , 1 0 1 ) ;

d =

5 1.0000 0 0.0000 −0.4003 −0.4003 −0.4003


0 1.0000 0.0000 −0.1387 −0.1387 −0.1387
0.0000 0.0000 1.0000 −0.9058 −0.9058 −0.9058
−0.4003 −0.1387 −0.9058 1.0000 1.0000 1.0000
−0.4003 −0.1387 −0.9058 1.0000 1.0000 1.0000
10 −0.4003 −0.1387 −0.9058 1.0000 1.0000 1.0000

Newton–Cotes of order 4 is somewhat better but still unacceptable.

Listing 2.27: GSO with Newton–Cotes Order 4


[ t , z ] = GrahamSchmidtNC ( 0 , 1 , 4 , 0 , 5 ,101) ;
d =
1.0000 −0.0000 0.0000 −0.0000 0.0112 −0.0112
−0.0000 1.0000 0.0000 −0.0000 0.0208 −0.0208
5 0.0000 0.0000 1.0000 −0.0000 0.1206 −0.1206
−0.0000 −0.0000 −0.0000 1.0000 0.9924 −0.9924
0.0112 0.0208 0.1206 0.9924 1.0000 −1.0000
−0.0112 −0.0208 −0.1206 −0.9924 −1.0000 1.0000

We must go to Newton–Cotes of order 6 to get proper orthogonality.


2.5 Graham–Schmidt Orthogonalization 45

Listing 2.28: GSO with Newton–Cotes Order 6


[ t , z ] = GrahamSchmidtNC ( 0 , 1 , 6 , 0 , 5 ,101) ;
2 d =
1.0000 0.0000 −0.0000 0.0000 0.0000 −0.0000
0.0000 1.0000 −0.0000 0.0000 −0.0000 0.0000
−0.0000 −0.0000 1.0000 0.0000 −0.0000 0.0000
0.0000 0.0000 0.0000 1.0000 −0.0000 0.0000
7 0.0000 −0.0000 −0.0000 −0.0000 1.0000 0.0000
−0.0000 0.0000 0.0000 0.0000 0.0000 1.0000

It is much harder also, if we want to apply GSO to more powers of t, say up to


t 20 . In general, we would need a Newton–Cotes order of about 20 which would be
numerically unstable itself.
Another approach is to replace the inner product calculations with the build in
quadrature codes in MatLab. Here we use the function quadl instead of quad. Do
a help quad and help quadl in MatLab/Octave to figure out how these two
functions differ! We will find we need to fiddle with the error tolerance to get good
results. This is analogous to what we had to do before by increasing the Newton–
Cotes order.

Listing 2.29: Inner products using quad


function c = ip ( f , g , a , b)
v = @( x ) ( f ( x ) . ∗ g ( x ) ) ;
t o l = 1 . 0 e −9;
c = quadl ( v , a , b , t o l ) ;
5 end

The new GSO code is as follows:

Listing 2.30: Graham–Schmidt Orthogonalization With quadl


f u n c t i o n [ t , z ] = GrahamSchmidt ( a , b ,M, N, NumPoints )
%
% Perform Graham − S c h m i d t O r t h o g o n a l i z a t i o n
% on a s e t o f f u n c t i o n s 1 , t , t ˆ 2 , . . . , t ˆN
5 %
% a = s t a r t of i n t e r v a l
% b = end o f i n t e r v a l
% M = f i r s t power o f t t o u s e
% N = l a s t power o f t t o u s e
10 % NumPoints = number o f t i m e p o i n t s t o u s e f o r t i m e
% for p l o t t i n g of the g k ’ s
%
% s e t u p t a s 1 xNumPoints
t = l i n s p a c e ( a , b , NumPoints ) ;
15 % s e t u p x a s NumPoints rows x N+1 c o l u m n s
z = z e r o s ( NumPoints ,N+1) ;
%S e t u p f u n c t i o n h a n d l e s
f = c e l l (N+1 ,1) ;
g = c e l l (N+1 ,1) ;
20 f o r i =1:N+1
f { i } = @( x ) Powers ( x , i −1) ;
end
46 2 Graham–Schmidt Orthogonalization

n f = s q r t ( i p ( f {M+1} , f {M+1} , a , b ) ) ;
g{M+1} = @( x ) f {M+1}(x ) / n f ;
25 y = z e r o s ( 1 , NumPoints ) ;
d = z e r o s (N+1 ,N+1) ;
y = g{M+1}( t ) ;
z ( : ,M+1) = y ’ ;
f o r k=M+2:N+1
30 %compute n e x t o r t h o g o n a l p i e c e
p h i = @( x ) 0 ;
f o r j = M+1: k−1
c = i p ( f {k } , g{ j } , a , b ) ;
p h i = @( x ) ( p h i ( x )+c ∗g{ j } ( x ) ) ;
35 end
p s i = @( x ) ( f {k } ( x ) − p h i ( x ) ) ;
nf = sqrt ( ip ( psi , psi , a , b) ) ;
g{k} = @( x ) ( p s i ( x ) / n f ) ;
y = g{k } ( t ) ;
40 z (: , k) = y ’ ;
end
f o r i=M+1:N+1
f o r j=M+1:N+1
d ( i , j ) = i p ( g{ i } , g{ j } , a , b ) ;
45 end
end
d

function c = ip ( f , g , a , b)
50 v = @( x ) ( f ( x ) . ∗ g ( x ) ) ;
t o l = 1 . 0 e −9;
c = quadl ( v , a , b , t o l ) ;
end

55 end

We then get similar results for the GSO.

Listing 2.31: GSO with quadl


[ t , z ] = GrahamSchmidt ( 0 , 1 , 0 , 5 , 1 0 1 ) ;
d =
1.0000 −0.0000 0 0.0000 −0.0000 0.0000
−0.0000 1.0000 0.0000 −0.0000 0.0000 −0.0000
5 0 0.0000 1.0000 −0.0000 0.0000 −0.0000
0.0000 −0.0000 −0.0000 1.0000 0.0000 −0.0000
−0.0000 0.0000 0.0000 0.0000 1.0000 −0.0000
0.0000 −0.0000 −0.0000 −0.0000 −0.0000 1.0000

There are other ways to do this too, but this should give the idea. The bottom line is
that it is straightforward to do theoretically, but devilishly hard to do in practice!

Reference

J. Peterson, Calculus for Cognitive Scientists: Higher Order Models and Their Analysis, Springer
Series on Cognitive Science and Technology. (Springer Science + Business Media, Singapore
2015 in press)
Chapter 3
Numerical Differential Equations

We have already discussed how to solve ordinary differential equations in Peterson


(2015a) and in Peterson (2015b) so if you want to review our discussion of the error
estimates for Euler’s algorithm, you can review that material in those volumes. Here,
we will revisit Runge–Kutta methods and add a new one: the Fehlberg variation.

3.1 Approximating Solutions Numerically

These methods extend the simple Euler method by essentially looking at Taylor
expansions of f (t0 + αh, x0 + βk) for various choices of α, β and k and then com-
bining them in interesting ways to estimate error. Hence, we say these methods are
based on differences of multiple function evaluations. The iteration scheme generates
a sequence {x̂n } starting at x̂0 = x0 using the following recursion equation:

x̂n+1 = x̂n + F(tn , x̂n , h, f ) h


x̂0 = x0

where h is the step size we use for our underlying partition of the time space giving

ti = t0 + i h

for appropriate indices and F is some function of the previous approximate solution,
the step size and the right hand side function f . For convenience of exposition, we
will switch to a different notation for the approximate values x̂n . We will now denote
them by yn and so we solve the recursion

yn+1 = yn + F(tn , yn , h, f ) h
y0 = x0

© Springer Science+Business Media Singapore 2016 47


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_3
48 3 Numerical Differential Equations

For our purposes, we will assume F has the form

F(t, x, h, f ) = γ1 f (t, x) + γ2 f (t + αh, x + βh f (t, x)), (3.1)

which tells us we are using βh f (t, x) as our generic k term and our basic difference
is an interpolation between our base point f (t, x) and the new point f (t + αh, x +
βh f (t, x)). The amount of interpolation is determined by the values of γ1 and γ2 .

3.1.1 Expansions of F

Let’s look at the error term

Tn+1 = xn+1 − xn − h F(tn , xn , h, f ).


Tn+1
Rewriting, we have for τn+1 = h
,

xn+1 = xn + h F(tn , xn , h, f )Tn+1 + h τn+1 .

To understand what to do with this expression, we need to expand various versions


of f as Taylor polynomials with remainder. We have

f (t + αh, x + βh f (t, x)) = f (t, x) + f t (αh) + f x (t, x)(βh f (t, x))


  
1   f tt (t, x) f xt (t, x) αh
+ αh, βh f (t, x)
2 f t x (t, x) f x x (t, x) βh f (t, x)
+ O(h 3 ),

where the term O(h 3 ) consists of the third order partial derivatives of f in various
combinations all evaluated at some point ξ between (t, x) and (t +αh, x +βh f (t, x))
and multiplied by h 3 . Hence, these terms go to zero like h 3 does. We can multiply
out the vectors and matrices involved and assuming f has continuous second order
partials, the terms f t x and f xt will match. Thus, we obtain

f (t + αh, x + βh f (t, x)) = f (t, x) + f t (t, x) (αh) + f x (t, x)(βh f (t, x))
 
1 2 1
+ h2 α f tt (t, x) + αβ f t x (t, x) f (t, x) + β 2 f x x (t, x) f (t, x)
2 2
+ O (h 3 ),

We know also

x = f
x  = f t + f x f
x  = f tt + 2 f t x f + f x x f 2 + f t f x + f x2 f.
3.1 Approximating Solutions Numerically 49

Now using the Taylor expansion for x, we have to fourth order


1 1
xn+1 − xn = h x  (tn ) + h 2 x  (tn ) + h 3 x  (tn ) + O(h 4 ).
2 6
We can then use these expressions in the Tn+1 expansion to give

Tn+1 = xn+1 − xn − h F(tn , xn , h, f )


1 1
= hx  (tn ) + h 2 x  (tn ) + h 3 x  (tn ) + O(h 4 ) − h F(tn , xn , h, f ).
2 6
But, we can replace the f (t + αh, x + βh f (t, x)) in F by its expansion to get

h F(tn , xn , h, f ) = hγ1 f (n) + hγ2 f (tn + αh, xn + βh f (n) )


= hγ1 f (n)

+ hγ2 f (n) + f t(n) (αh) + f x(n) (βh f (n) )

h2
+ (α2 f tt(n) + 2αβ f t(n)
x f
(n)
+ β 2 f x(n)
x (f
(n) 2
) + O(h 3 )
2

where for ease of exposition, the terms evaluated at (tn , xn ) are denoted with a
superscript (n). Now, plug all of this into the original expression for Tn+1 . Here, we
will use the fact that hO(h 3 ) = O(h 4 ) too. We find (you will need to do this with a
pad of paper in hand!)
 
 (n) (n)
Tn+1 = h x (tn ) − γ1 f − γ2 f
 
2 1  (n) (n) (n)
+h x (tn ) − αγ2 f t − βγ2 f f x
2
 
3 1  1 2 (n) (n) (n) 1 2 (n) (n) 2
+h x (tn ) − α γ2 f tt − αβγ2 f t x f − β γ2 f x x ( f )
6 2 2
+ O(h 4 )

where we combine all the order h 4 terms into one O(h 4 ). Now, plug in all the x  etc.
terms. This is indeed messy, so follow along on your paper. You will get

Tn+1
   (n) (n) 
f + f x f (n) (n) (n)
= h 1 − γ1 − γ2 f (n) + h 2 t − αγ2 f t − βγ2 f (n) f x
2
 (n) (n) (n) (n) (n) 2 (n) (n) (n)
f + 2 ft x f + f x x ( f ) + f t f x + ( f x )2 f (n)
+ h 3 tt
6

1 (n) (n) 1 (n)
− α f tt − αβ f t x f (n) − β 2 f x x ( f (n) )2
2 2
+ O(h 4 )
50 3 Numerical Differential Equations

Many of these terms can be combined. We obtain


      
1 (n) 1
Tn+1 = h 1 − γ1 − γ2 f (n) + h 2 − αγ2 f t + − βγ2 f (n) f x(n)
2 2
      
1 1 1 (n) (n) 1 1 2
+ h3 − α2 γ2 f x(n)
x ( f (n) 2
) + − αβγ2 f t f x + − β γ 2 f (n)
xx ( f (n) 2
)
6 2 3 6 2
+ O (h 4 )

3.1.2 Minimizing Error

From the above, we see we can make Tn+1 have zero error in the h and h 2 terms by
choosing

γ1 + γ2 = 1 (3.2)
2αγ2 = 2βγ2 = 1. (3.3)

There are many choices for α, β, γ1 and γ2 all of which give Runge–Kutta order two
methods.
• If we choose γ1 = 0 and γ2 = 1, we find α = β = 21 . This gives the numerical
method
yn+1 = yn + h f (tn + 0.5h, xn + 0.5h f (tn , xn ))

which is an average slope method.


• If we choose γ1 = 1 and γ2 = 0, we find α and β can be anything and the h 2
error is always 0.5 f t(n) + 0.5 f x (n) f (n) = β = 21 . This gives Euler’s method,
of course.

yn+1 = yn + h f (tn , xn ).

• If we choose γ1 = γ2 = 0.5, we find α = β = 0.25 and the method becomes


 
yn+1 = yn + h 0.25 f (n) + f (tn + 0.25h, xn + 0.25h f (n) ) .

which is a trapezoidal method.


Note all of the Runge–Kutta order two methods have a local error proportional to h 3
and use two f evaluations at each step to generate the next approximate value.
Comment 3.1.1 For example, using the average slope method, we build an approx-
imate solution x̂n+1 to the true solution xn+1 that uses the information starting from
tn with data xn to construct the approximation

x̂n+1 = xn + h f (tn + 0.5h, xn + 0.5h f (tn , xn )


3.1 Approximating Solutions Numerically 51

which has a local error proportional to h 3 . Since this error is due to the fact that
we truncate the Taylor series expansions for f earlier, this is known as truncation
error.
Finally, to build a method which has local error proportional to h 4 , we would need
to look at an additional evaluation for f . We would have

F(t, x, h, f ) = γ1 f (t, x) + γ2 f (t + α1 h, x + β1 h f (t, x)) + γ3 f (t + α2 h, x + β2 h f (t, x))

and follow the same sort of discussion. We would combine the various Taylor expan-
sions from the base point (t, x) and find how to zero the h, h 2 and h 3 error. This
would then be the family of Runge–Kutta order 3 methods. All of these methods
have error proportional to h 4 . Note, we do 3 function evaluations using f at various
places to generate this method.
Finally, if we solve a vector system, we basically apply the technique above to
each component of the vector solution. So if the problem is four dimensional, we are
getting a constant C and D for each component. This, of course, complicates our life
as one component might have such a fast growing error that the error for it is very
large compared to the others. To control this, we generally cut the step size h to bring
down the error. Hence, the component whose error grows the fastest controls how
big a step size we can use in this type of technique. Thus, the Runge–Kutta methods
are based on multiple function evaluations.
Now in the theory of the numerical solution of ordinary differential equations
(ODEs) we find that there a several sources of error in finding a numerical approxi-
mation to the solution of our model process.
1. As discussed earlier, usually we approximate the function f using a few terms of
the Taylor series expansion of f around the point (tn , yn ) at each iteration. This
truncation of the Taylor series expansion is not the same as the true function f
of course, so there is an error made. Depending on how many terms we use in
the Taylor series expansion, the error can be large or small. If we let h denote the
difference tn+1 − tn , a fourth order method is one where this error is of the form
C h 5 for some constant C. This means that is you use a step size which is one
half h, the error decreases by a factor of 32. For a Runge–Kutta method to have
a local truncation error of order 5, we would need to do 4 function evaluations.
Now this error is local to this time step, so if we solve over a very long interval
with say N being 100,000 or more, the global error can grow quite large due to
the addition of so many small errors. So the numerical solution of an ODE can be
very accurate locally but still have a lot of problems when we try to solve over a
long time interval. For example, if we want to track a voltage pulse over 1000 ms,
if we use a step size of 10−4 this amounts to 107 individual steps. Even a fifth
order method can begin to have problems. This error is called truncation error.
2. We can’t represent numbers with perfect precision on any computer system, so
there is an error due to that which is called round-off error which is significant
over long computations.
52 3 Numerical Differential Equations

3. There is usually a modeling error also. The model we use does not perfectly
represent the physics, biology and so forth of our problem and so this also intro-
duces a mismatch between our solution and the reality we might measure in a
laboratory.

3.1.3 The Matlab Implementation

The basic code to implement the Runge–Kutta methods is broken into two pieces.
We have discussed this in the earlier volumes, but for completeness, we’ll add it here
too. The first one, RKstep.m implements the evaluation of the next approximation
solution at point (tn , yn ) given the old approximation at (tn−1 .yn−1 ). Here is that code
for Runge–Kutta codes of orders one to four.

Listing 3.1: Runge–Kutta Codes


f u n c t i o n [ tnew , ynew , fnew ] = RKstep ( fname , t c , yc , f c , h , k )
%
% fname t h e name o f t h e r i g h t hand s i d e f u n c t i o n f ( t , y )
% t i s a s c a l a r u s u a l l y c a l l e d t i m e and
5 % y i s a vector of s i z e d
% yc a p p r o x i m a t e s o l u t i o n t o y ’ ( t ) = f ( t , y ( t ) ) a t t=t c
% fc f ( tc , yc )
% h The t i m e s t e p
% k The o r d e r o f t h e Runge−K u t t a Method 1<= k <= 4
10 %
% t ne w t c+h
% ynew a p p r o x i m a t e s o l u t i o n a t tne w
% fnew f ( tnew , ynew )
%
15 i f k==1
k1 = h∗ f c ;
ynew = yc+k1 ;
e l s e i f k==2
k1 = h∗ f c ;
20 k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) ) ;
ynew = yc + k2 ;
e l s e i f k==3
k1 = h∗ f c ;
k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) ) ;
25 k3 = h∗ f e v a l ( fname , t c+h , yc−k1+2∗k2 ) ;
ynew = yc +(k1+4∗k2+k3 ) / 6 ;
e l s e i f k==4
k1 = h∗ f c ;
k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) ) ;
30 k3 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k2 / 2 ) ) ;
k4 = h∗ f e v a l ( fname , t c+h , yc+k3 ) ;
ynew = yc +(k1+2∗k2+2∗k3+k4 ) / 6 ;
else
d i s p ( s p r i n t f ( ’ The RK method %2 d order is not allowed ! ’ , k ) ) ;
35 end
tnew = t c+h ;
fnew = f e v a l ( fname , tnew , ynew ) ;
end

Once the step is implemented, we solve the system using the RK steps like this:
3.2 Runge–Kutta Fehlberg Methods 53

Listing 3.2: The Runge–Kutta Solution


f u n c t i o n [ t v a l s , y v a l s , f c v a l s ] = FixedRK ( fname , t0 , y0 , h , k , n )
2 %
% Gives approximate s o l u t i o n to
% y ’( t ) = f (t , y( t ))
% y ( t 0 ) = y0
% u s i n g a k t h o r d e r RK method
7 %
% t0 i n i t i a l time
% y0 initial state
% h stepsize
% k RK o r d e r 1<= k <= 4
12 % n Number o f s t e p s t o t a k e
%
% tvals t i m e v a l u e s o f form
% t v a l s ( j ) = t 0 + ( j −1)∗h , 1 <= j <= n
% yvals approximate s o l u t i o n
17 % y v a l s ( : j ) = approximate s o l u t i o n at
% tvals ( j ) , 1 <= j <= n
%
tc = t0 ;
yc = y0 ;
22 tvals = tc ;
y v a l s = yc ;
f c = f e v a l ( fname , t c , yc ) ;
fcvals = fc ;
f o r j =1:n−1
27 [ t c , yc , f c ] = RKstep ( fname , t c , yc , f c , h , k ) ;
y v a l s = [ y v a l s yc ] ;
tvals = [ tvals tc ] ;
fcvals = [ fcvals fc ] ;
end
32 end

3.2 Runge–Kutta Fehlberg Methods

In general, the Runge–Kutta solution schemes generate a sequence {yn } starting at


y0 using some sort of recursion equation:

yn+1 = yn + h n × F(tn , yn , h n , f )
y0 = y0

where h n is the step size we use at time point tn and the function F is some function
of the previous approximate solution yn , the step size h n and the dynamics vector
f . We usually choose a numerical method which allows us to estimate what a good
step size would be at each step n and then alter the step size to that optimal choice.
Our order two method discussed earlier used
 
1 1
F(tn , yn , h n , f ) = f tn + h n , xn + h n f (tn , xn )
2 2

A typical numerical algorithm which will do this is the Runge–Kutta–Fehlberg 45


(RKF45) algorithm which works like this:
54 3 Numerical Differential Equations

• Use a Runge–Kutta order 4 method to generate a solution with local error propor-
tional to h 5 . This needs four function evaluations.
• Do one more function evaluation to obtain a Runge–Kutta order 5 method which
generates a solution with local error proportional to h 6 .
• We now have two ways to approximate the true solution x at t + h. This gives us a
way to compare the two approximations and to use one more function evaluation
to get an estimate of the error we are making. We can then use that error estimate
to see if our step size h is too large (that is the error is too big and we can compute
a new h using our information), just right (we keep h as it is) or too small (we
double the step size).
Finally, just to give you the flavor of what needs to be computed, here is a outline of the
standard Runge–Kutta method: in what follows K is a six dimensional vector which
we use to store intermediate results. If the system we want to solve is a vector system
(for example, the vector function f we use in our Hodgkin–Huxley model dynamics
discussed later is at least 4 dimensional and is also computationally complex) these
six function evaluations can really slow us down!!

3.2.1 The RKF5 Flowchart

First, we do the function evaluations.

Listing 3.3: RKF5 function evaluations


h ⇐ h0
t ⇐ t0
3 while (t i s l e s s than final t i m e tf ) {
Compute f (t, y)
K[0] ⇐ hf
z ⇐ y + 0.25K[0]

8 Compute f (t + 14 h, z)
K[1] ⇐ hf
1.0
z ⇐ y + 32.0 (3.0K[0] + 9.0K[1])

Compute f (t + 3.08.0
h, z)
13 K[2] ⇐ hf
1.0
z ⇐ y + 2197.0 (1932.0K[0] − 7200.0K[1] + 7296.0K[2])

Compute f (t + 12.0
13.0
h, z)
K[3] ⇐ h ∗ f
439.0 3680.0 845.0
18 z ⇐ y + 216.0 K[0] − 8.0K[1] + 513.0
K[2] − 4104.0
K[3]

Compute f (t + h, z)
K[4] ⇐ hf
8.0 3544.0 1859.0 11.0
z ⇐ y − 27.0 K[0] + 2.0K[1] − 2565.0
K[2] + 4104.0
K[3] − 40.0
K[4]
23
Compute f (t + 12 h, z)
K[5] ⇐ hf

Then, compute the error vector e for this step size h.


3.2 Runge–Kutta Fehlberg Methods 55

Listing 3.4: Compute the error vector


1.0 128.0 2197.0 1.0 2.0
e ⇐ 360.0 K[0] − 4275.0 K[2] − 75240.0
K[3] + 50.0
K[4] + 55.0
K[5]
||e||∞ ⇐ max{|ei |}
||y||∞ ⇐ max{|yi |}

See if this step size is acceptable. Given the tolerances 1 , the amount of error we are
willing to make in our discretization of the problem, and 2 , the amount of weight
we wish to place on the solution we previously computed y, compute local decision
parameters

Listing 3.5: See if step size is acceptable


η ⇐ 1 + 2 ||y||∞
i f ( ||e||∞ < η ) {
// t h i s s t e p s i z e i s a c c e p t a b l e ; u s e i t t o compute t h e next
4 // v a l u e o f y}
16.0 6656.0
δy ⇐ 135.0 K[0] + 12825.0 K[2] + 28561.0
56430.0
9.0
K[3] − 50.0 2.0
K[4] + 55.0 K[5]
y ⇐ y + δy
t ⇐ t + h

Now although this step size is acceptable, it might be smaller than necessary; deter-
mine if ||e||∞ is smaller than some fraction of η—heuristically, 0.3 is a reasonable
fraction to use.

Listing 3.6: Is step size too small?


if ( ||e||∞ < 0.3η ) {
\\ Double t h e s t e p size in this case
h ⇐ 2.0h
}
5 }

It is possible that the step size is too big which can be determined by checking the
local error

Listing 3.7: Is step too big?


if ( ||e||∞ ≥ η ) {
i f ( ||e||∞ > 1 ) {

The maximum error is larger than the discretization error. A reasonable way to reset
the step size to reset to 0.9h ||e||η ∞ . The rational behind this choice is that if the biggest
error in the new computed solution is 5 times the allowed tolerance sought—1 , then
1 +2 ||y||∞
51
⇐ 0.2(1 + 21 ||y||∞ ) Now if the tolerance 2 is r times 1 , the computation
above would reset h to be 0.18h(1 + r ||y||∞ ). Hence the maximum component size
of the solution y influences how the step size is reset. If ||y||∞ was 10, then for r
0.1, the new step size is 0.36h. Of course, the calculations are a bit more messy, as
the ||y||∞ term is constantly changing, but this should give you the idea.
56 3 Numerical Differential Equations

Listing 3.8: Ending the loops


η
h ⇐ 0.9h ||e||∞
}
3 }
}

Again, we stress that since this algorithm uses six function evaluations per time step
that is actually used, it is very costly. We also use 6 evaluations each time we reset
h even if we don’t use this time step. So we trade off the cost of these computations
for the ability to widen our time step choice as much as possible to save computation
time.

3.2.2 Runge–Kutta Fehlberg MatLab Implementation

The basic RKF5 code is implemented using some dynamics function f of the form
f (t, y).

Listing 3.9: RKF5 with No Parameters


1
f u n c t i o n [ t v a l s , y v a l s , f v a l s , h v a l s ] = RKF5NoP( e r r o r t o l , s t e p t o l , minstep
, maxstep , fname , h i n i t , t i n i t , tend , y i n i t )
%
% Runge−K u t t a F e h l b e r g Order 5
% Automatically s e l e c t s optimal step size
6 %
% fname t h e name o f t h e r i g h t hand s i d e f u n c t i o n f ( t , y )
% t i s time , y i s a v e c t o r
% yinit i n i t i a l y data
% hinit i n i t i a l time s t e p
11 % tinit = i n i t i a l time
%
% tvals time v e c t o r
% yvals approximate s o l u t i o n vector
% fvals dynamics v e c t o r
16 % hvals step history vector
%
h = hinit ;
t = tinit ;
y = yinit ;
21 f = f e v a l ( fname , t , y ) ;

hvals = h ;
tvals = t ;
yvals = y ;
3.2 Runge–Kutta Fehlberg Methods 57

26 fvals = f ;

w h i l e t < tend
k1 = h∗ f e v a l ( fname , t , y ) ;
z = y+k1 / 4 ;
31 k2 = h∗ f e v a l ( fname , t +(h / 4 ) , z ) ;
z = y + ( 3 . 0 / 3 2 . 0 ) ∗k1 + ( 9 . 0 / 3 2 . 0 ) ∗k2 ;
k3 = h∗ f e v a l ( fname , t +3.0∗ h / 8 , z ) ;
z = y + ( 1 9 3 2 . 0 / 2 1 9 7 . 0 ) ∗k1 − ( 7 2 0 0 . 0 / 2 1 9 7 . 0 ) ∗k2 + ( 7 2 9 6 . 0 / 2 1 9 7 . 0 ) ∗k3 ;
k4 = h∗ f e v a l ( fname , t +12.0∗ h / 1 3 . 0 , z ) ;
36 z = y + ( 4 3 9 . 0 / 2 1 6 . 0 ) ∗k1 −8.0∗ k2 + ( 3 6 8 0 . 0 / 5 1 3 . 0 ) ∗k3 − ( 8 4 5 . 0 / 4 1 0 4 . 0 ) ∗k4 ;
k5 = h∗ f e v a l ( fname , t+h , z ) ;
z = y − ( 8 . 0 / 2 7 . 0 ) ∗k1+2∗k2 − ( 3 5 4 4 . 0 / 2 5 6 5 . 0 ) ∗k3 + ( 1 8 5 9 . 0 / 4 1 0 4 . 0 ) ∗k4
− ( 1 1 . 0 / 4 0 . 0 ) ∗k5 ;
k6 = h∗ f e v a l ( fname , t+h / 2 , z ) ;
temp1 = a b s ( k1 / 3 6 0 . 0 − ( 1 2 8 . 0 / 4 2 7 5 . 0 ) ∗k3 − ( 2 1 9 7 . 0 / 7 5 2 4 0 . 0 ) ∗k4+k5
/ 5 0 . 0 + ( 2 . 0 / 5 5 . 0 ) ∗k6 ) ;
41 temp2 = a b s ( y ) ;
e r r o r 1 = max ( temp1 ) ;
e r r o r 2 = max ( temp2 ) ;
% a d j u s t i n g s t e p s i z e code
% e r r o r i s ok , s o u s e s t e p s i z e h
46 % k e e p new t , new y from h e r e
d e c i s i o n t o l = s t e p t o l+e r r o r t o l ∗ e r r o r 2 ;
i f error1 < decisiontol
y = y + ( 1 6 . 0 / 1 3 5 . 0 ) ∗k1 + ( 6 6 5 6 . 0 / 1 2 9 2 5 . 0 ) ∗k3 + ( 2 8 5 6 1 . 0 / 5 6 4 3 0 . 0 ) ∗k4
− ( 9 . 0 / 5 0 . 0 ) ∗k5 + ( 2 . 0 / 5 5 . 0 ) ∗k6 ;
t = t + h;
51 hvals = [ hvals h ] ;
tvals = [ tvals t ] ;
yvals = [ yvals y ] ;
fvals = [ fvals f ];
% we h a v e computed t h e new s t a t e . S h o u l d we k e e p
56 % the step s i z e ? I f error i s too small , double h
% b u t don ’ t e x c e e d m a x s t e p o r go p a s t f i n a l t i m e
i f e r r o r 1 <= . 3 ∗ d e c i s i o n t o l
h d o u b l e = 2∗h ;
htop = min ( hdouble , maxstep ) ;
61 h = min ( htop , tend −t ) ;
end
% p i c k i n g an o p t i m a l s t e p s i z e when e r r o r i s t o o l a r g e
else
i f e r r o r 1 >= s t e p t o l
66 hnew = . 9 ∗ h∗ d e c i s i o n t o l / e r r o r 1 ;
h c l i p p e d = max ( hnew , m i n s t e p ) ;
h = min ( h c l i p p e d , tend −t ) ;
end
end
71 end

However, many dynamics functions depend on parameters, so we also implement


RKF5 in the case where f depends on a parameter vector p also. For example, a
typical dynamics function with parameters would be something like this:
58 3 Numerical Differential Equations

Listing 3.10: Tunnel Diode Dynamics With Parameters


function f = tunneldiode (p , t , x)
%
% param v e c t o r i s p = [ R ; L ; C ; u ]
4 %
% dynamics :
% x1 ’ = (−h ( x1 ) + x2 ) /C ;
% x2 ’ = (− x1 −Rx2 +u ) /L ;
% f = tunneldiode (1.5 ,5.0 ,2 ,1.2 , x)
9 %
h = x ( 1 ) .∗(17.76+ x ( 1 ) .∗( −103.79+ x ( 1 ) .∗(229.62+ x ( 1 ) .∗( −226.31+83.72∗ x
(1) ) ) ) ) ;
f = [ ( − h+x ( 2 ) ) /p ( 3 ) ; ( − x ( 1 )−p ( 1 ) ∗x ( 2 )+p ( 4 ) ) /p ( 2 ) ] ;

So we will change the way we write our dynamics functions so that we can pass in
a parameter vector. Consider the dynamics for the tunnel diode model we discussed
previously. Instead of editing the dynamics file every time we want to change the
inductance, resistance, capacitance and incoming voltage values, we will now pass
them in as a parameter p. We alter the RKF5 algorithm to allow the function f to use
a parameter vector p. We will pass back the time vector, tvals, the solution vector,
yvals, the values of the dynamics, fvals and, just for educational purposes, the
vector of stepsize values, hvals. Since this is a step size adjustment method, the
time values are no longer uniformly spaced and it is interesting to see how the values
of the step size change over time. We need to pass in two tolerances, errortol
and steptol, that are used in determining how we adjust h, a minimum possible
step size, minstep, and maximum possible step size, maxstep, the name of the
dynamics function, fname, an initial step size guess, hinit, the initial and final
times, tinit and tend, and the vector of initial values, yinit.

Listing 3.11: RKF5 Algorithm With Parameters


f u n c t i o n [ t v a l s , y v a l s , f v a l s , h v a l s ] = RKF5( e r r o r t o l , s t e p t o l , minstep ,
maxstep , . . .
fname , params , h i n i t , t i n i t ,
tend , y i n i t )
%
% Runge–Kutta F e h l b e r g Order 5
5 % Automatically s e l e c t s optimal step size
%
% e r r o r t o l tolerance for step adjustment
% steptol tolerance for step adjustment
% minstep minimum s t e p s i z e a l l o w e d
10 % maxstep maximum s t e p s i z e a l l o w e d
% fname t h e name o f t h e r i g h t hand s i d e f u n c t i o n f ( t , y , p )
% t i s time , y i s a v e c t o r , p i s parameter
% params parameter v e c t o r f o r dynamics
% hinit i n i t i a l time s t e p
15 % tinit i n i t i a l time
% tend f i n a l time
% yinit i n i t i a l y data
%
% tvals time v e c t o r
20 % yvals approximate s o l u t i o n vector
% fvals dynamics v e c t o r
% hvals step history vector
%
h = hinit ;
3.2 Runge–Kutta Fehlberg Methods 59

25 t = tinit ;
y = yinit ;
f = f e v a l ( fname , params , t , y ) ;

hvals = h;
30 tvals = t;
yvals = y;
fvals = f;

w h i l e t < tend
35 k1 = h∗ f e v a l ( fname , params , t , y ) ;
z = y+k1 / 4 ;
k2 = h∗ f e v a l ( fname , params , t +(h / 4 ) , z ) ;
z = y + ( 3 . 0 / 3 2 . 0 ) ∗k1 + ( 9 . 0 / 3 2 . 0 ) ∗k2 ;
k3 = h∗ f e v a l ( fname , params , t +3.0∗ h / 8 , z ) ;
40 z = y + ( 1 9 3 2 . 0 / 2 1 9 7 . 0 ) ∗k1 − ( 7 2 0 0 . 0 / 2 1 9 7 . 0 ) ∗k2 + ( 7 2 9 6 . 0 / 2 1 9 7 . 0 ) ∗k3 ;
k4 = h∗ f e v a l ( fname , params , t +12.0∗ h / 1 3 . 0 , z ) ;
z = y + ( 4 3 9 . 0 / 2 1 6 . 0 ) ∗k1 −8.0∗ k2 + ( 3 6 8 0 . 0 / 5 1 3 . 0 ) ∗k3 − ( 8 4 5 . 0 / 4 1 0 4 . 0 ) ∗k4 ;
k5 = h∗ f e v a l ( fname , params , t+h , z ) ;
z = y − ( 8 . 0 / 2 7 . 0 ) ∗k1+2∗k2 − ( 3 5 4 4 . 0 / 2 5 6 5 . 0 ) ∗k3 + ( 1 8 5 9 . 0 / 4 1 0 4 . 0 ) ∗k4
− ( 1 1 . 0 / 4 0 . 0 ) ∗k5 ;
45 k6 = h∗ f e v a l ( fname , params , t+h / 2 , z ) ;
temp1 = a b s ( k1 / 3 6 0 . 0 − ( 1 2 8 . 0 / 4 2 7 5 . 0 ) ∗k3 − ( 2 1 9 7 . 0 / 7 5 2 4 0 . 0 ) ∗k4+k5
/ 5 0 . 0 + ( 2 . 0 / 5 5 . 0 ) ∗k6 ) ;
temp2 = a b s ( y ) ;
e r r o r 1 = max ( temp1 ) ;
e r r o r 2 = max ( temp2 ) ;
50 % a d j u s t i n g s t e p s i z e code
% e r r o r i s ok , s o u s e s t e p s i z e h
% k e e p new t , new y from h e r e
d e c i s i o n t o l = s t e p t o l+e r r o r t o l ∗ e r r o r 2 ;
i f error1 < decisiontol
55 y = y + ( 1 6 . 0 / 1 3 5 . 0 ) ∗k1 + ( 6 6 5 6 . 0 / 1 2 9 2 5 . 0 ) ∗k3 + ( 2 8 5 6 1 . 0 / 5 6 4 3 0 . 0 ) ∗k4
− ( 9 . 0 / 5 0 . 0 ) ∗k5 + ( 2 . 0 / 5 5 . 0 ) ∗k6 ;
t = t + h;
hvals = [ hvals h ] ;
tvals = [ tvals t ] ;
yvals = [ yvals y ] ;
60 fvals = [ fvals f ];
% we h a v e computed t h e new s t a t e . S h o u l d we k e e p
% the step s i z e ? I f error i s too small , double h
% b u t don ’ t e x c e e d m a x s t e p o r go p a s t f i n a l t i m e
i f e r r o r 1 <= . 3 ∗ d e c i s i o n t o l
65 h d o u b l e = 2∗h ;
htop = min ( hdouble , maxstep ) ;
h = min ( htop , tend −t ) ;
end
% p i c k i n g an o p t i m a l s t e p s i z e when e r r o r i s t o o l a r g e
70 else
i f e r r o r 1 >= s t e p t o l
hnew = . 9 ∗ h∗ d e c i s i o n t o l / e r r o r 1 ;
h c l i p p e d = max ( hnew , m i n s t e p ) ;
h = min ( h c l i p p e d , tend −t ) ;
75 end
end
end

Let’s try using this in some tests. We solve the tunnel diode model for L = 5 micro
henrys, C = 2 pico fahrads, R = 1.5 kilovolts and u = 1.2 Volts. We solve this with
the following lines in MatLab:
60 3 Numerical Differential Equations

Listing 3.12: Solving a tunnel diode model


[ t v a l s , y v a l s , f v a l s , h v a l s ] = RKF5 ( 1 . 0 e − 6 , 1 . 0 e − 8 , 1 . 0 e − 5 , 2 . 0 , . . .
’ tunneldiode ’ , [ 1 . 5 ; 5 ; 2 ; 1 . 2 ] ] , . . .
3 .3 ,0 ,10 ,[ −0.4 ,1.5]) ;
plot ( tvals , yvals (1 ,:) ) ;
x l a b e l ( ’ Time nanoseconds ’ ) ;
y l a b e l ( ’V_C Volts ’ ) ;
t i t l e ( ’V_C vs Time ’ ) ;
8 plot ( tvals , yvals (2 ,:) ) ;
x l a b e l ( ’ Time nanoseconds ’ ) ;
y l a b e l ( ’I_L mA ’ ) ;
t i t l e ( ’I_L vs Time ’ ) ;
plot ( tvals , hvals ) ;
13 x l a b e l ( ’ Time nanoseconds ’ ) ;
y l a b e l ( ’ Step size ’ ) ;
t i t l e ( ’h vs Time ’ ) ;

This generates the plot of Vc versus time in Fig. 3.1 and I L versus time in Fig. 3.2.
We can also see the step size history in Fig. 3.3. Note how the step size changes
throughout the course of the solution. The step size plot shows us that to obtain
reasonable error, we need the h to be as low as 0.01 sometimes. For 10 time units,
this would require 1000 calculations requiring 6 function evaluations each time step
for a total of 6000 separate calculations. The RKF5 code here generates 91 individual
steps. We don’t keep track, however, how many times we reject a step size and restart.
Ignoring that, we have 546 function evaluations here. Even with restarts, this is a
significant reduction in computation time.

Fig. 3.1 The tunnel diode


capacitor voltage versus time
References 61

Fig. 3.2 The tunnel diode


inductor current versus time

Fig. 3.3 Step size versus


time

References

J. Peterson, Calculus for Cognitive Scientists: Derivatives, Integration and Modeling, Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd, Singapore, 2015a, in press)
J. Peterson, Calculus for Cognitive Scientists: Higher Order Models and Their Analysis, Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd, Singapore, 2015b, in press)
Part III
Deriving the Cable Model
Chapter 4
Biological Molecules

We will begin by going through some background material on what might be called
the chemistry of life; we had a hard time getting all of these things straight, so
for all of those mathematician and computer scientist types out there, here is
the introduction we wished we had when we started out. Molecules depend on the
interplay of non covalent and covalent interactions. Recall covalent bonds share
electrons in a tightly coupled way. There are three fundamental covalent bonds:
• Electrostatic Bonds due to Coulomb’s Law
• Hydrogen Bonds
• Vanderwaals Bonds

4.1 Molecular Bonds

The force F between two molecules is called a molecular bond. Specifically, the
force between two charges is given by the formula:

1 q1 q2
F= (4.1)
4π0 r 2

where q1 and q2 are the charges on the bonding units, r is the distance between the
units and 0 is a basic constant which depends on the solution (air, water and so
forth) that the units live within. For example, in Fig. 4.1, we see a representation of
the electrostatic attraction between two common molecules; one with a carboxyl and
the other with an amide group on their ends.
Hydrogen bonds occur when a hydrogen atom is shared between two other atoms
as shown in Fig. 4.2: The atom to which the hydrogen is held more tightly is called the
hydrogen donor and the other one which is less tightly linked is called the hydrogen
acceptor. You can see this represented abstractly as follows:

© Springer Science+Business Media Singapore 2016 65


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_4
66 4 Biological Molecules

O H

CH2− C N H3+ C −

O− H

Negative charge Positive charge


The molecule on the left has a net negative charge and the one on the
right has a positive charge. Hence, there is an attraction due to the
charges.

Fig. 4.1 Electrostatic attraction between two molecules: one has a carboxyl group and the other
an amide group

O
O H O O H

Strong hydrogen bond Weak hydrogen bond

The molecule on the left has a net negative charge and the one on the
right has a positive charge. Hence, there is an attraction due to the
charges.

Fig. 4.2 Typical hydrogen bonds

Table 4.1 Hydrogen bond Example Bond length (Å)


lengths
O–H· · · O 2.70
O–H· · · O− 2.63
O–H· · · N 2.88
N–H· · · O 3.04
N+ –H· · · O 2.93
N–H· · · N 3.10

H Donor Length H Acceptor


−O − H− 2.88Å · · · − N−
−N − H− 3.04Å · · · − O−

Recall, one Angstrom, (1 Å), is 10−10 meters or 10−8 cm. Hydrogen bond lengths
vary as we can see in Table 4.1.
The donor in biological systems is an oxygen or nitrogen with a covalently attached
hydrogen. The acceptor is either oxygen or nitrogen. These bonds are highly direc-
tional. The strongest bonds occur when all the atoms line up or are collinear (think
alignment of the planets like in the Tomb Raider movie!). In Fig. 4.3, we see an
idealized helix structure with two attached carbon groups. The carbons are part of
the helix backbone and the rest of the molecular group spills out from the backbone.
4.1 Molecular Bonds 67

Fig. 4.3 Typical hydrogen


bonds in a helix structure

Fig. 4.4 Vanderwaals forces Force


between molecules + The horizontal axis mea-
sures the distance between
molecules while the verti-
Repulsion increases cal axis gives the force be-
tween them.

Energy 0
Distance

Repulsion decreases
Maximum attraction

Table 4.2 Maximum Atom Radius of maximum


attraction distances attraction (Å)
H 1.20
C 2.00
N 1.50
O 1.40
S 1.85
P 1.90

If the two groups are separated enough along the background, the oxygen of the top
one is close enough physically to the nitrogen of the bottom group to allow them
to share a hydrogen. As you might expect, this sort of hydrogen bonding stabilizes
helical structures. This sort of upward spiral occurs in some protein configurations.
There is also a nonspecific attractive force which occurs when any two atoms
are 3–4 Å apart which is called a Vanderwaals Bond. The basis of this bond is that
the charge distribution around an atom is time dependent and at any instant is not
perfectly symmetrical. This “transient” asymmetry in an atom encourages a similar
asymmetry in the electron distribution around its neighboring atoms. The standard
picture of this force is shown in Fig. 4.4. The distance for maximum attraction varies
with the atom involved as we can see in Table 4.2.
68 4 Biological Molecules

Table 4.3 Bond distances by Bond Interaction Bond energy


type distance (Å) (kcal/mole)
Electrostatic 2.80 3–7
Hydrogen 2.70–3.10 3–7
Vanderwaals 2.70–3.20 1
Covalent 1.00 80

Table 4.2 shows us the H–C has a 3.20 Å Vanderwaals interaction radius; H–N
has a 2.70 Å; and H–P has a 13.10 Å.

4.1.1 Bond Comparisons

These three different types of bonds are therefore ranked according to their interaction
distance as shown in Table 4.3 where although we haven’t really discussed it, it should
be easy to understand that to pull a bond apart you would have to exert a force or in
other words do some work.
The amount of work you do can be measure in many units, but a common one in
biology is the calorie which can be converted to the standard physics energy measure
of ergs. The abbreviation kcal refers to 103 calories and the term mole refers to a
collection of 6.02 × 1023 (Avogadro’s Number) of molecules. Note that the covalent
bond is far stronger than the other bonds we have discussed!

4.2 Energy Considerations

The ultimate source of energy for most life is the sun (we will neglect here those
wonderful Mid-Atlantic smokers with a sulfur based life chemistry that does not
require any oxygen or photosynthesis at all). Energy can be stored in various ways
for later use—kind of like a battery. Some common energy sources are given in
Table 4.4.

Table 4.4 Energy sources Source Energy stored


Green photon energy 57 kcal/mole
ATP (Adenine Triphostate) 12 kcal/mole
(universal currency of
biochemical energy)
Each vibrational degree of 0.6 kcal/mole at 25 ◦ C
freedom in a molecule
Covalent bond 80 kcal/mole
4.2 Energy Considerations 69


O 99Å
H 105◦ H N H O C
+

Polar Bonding Without Wa-


A Water Molecule
ter

The water molecule shown on the left has an asymmetric charge distri-
bution which has a profound effect on how molecules interact in liquid.
There is an attraction due to this asymmetry: the positive side of water
attracts the negative side of other molecules.

Fig. 4.5 Special forces act on water

Basically, energy is moved from one storage source or another via special helper
molecules so that a living thing can perform its daily tasks of eating, growing, repro-
ducing and so forth. Now for us, we are going to concentrate on what happens inside
a cell. Most of us already know that the inside of a cell is a liquid solution which is
mostly water but contains many ions. You probably have this picture in your head
of an ion, like Na+ sitting inside the water close to other such ions with which they
can interact. The reality is more complicated. Water is made up of two hydrogens
and one oxygen and is what is called a polar molecule. As you can see from the left
side of Fig. 4.5, the geometry of the molecule means that the minus and plus charges
are not equally balanced. Hence, there is a charge gradient which we show with the
vertical arrow in the figure. The asymmetrical distribution of charge in water implies
that water molecules have a high affinity for each other and so water will compete
with other ions for hydrogens to share in a hydrogen bond.
If we had two molecules, say NH3 and COH2 , shown on the right side of Fig. 4.5,
we would see a hydrogen bond from between the oxygen of COH2 and the central
hydrogen of NH3 due to the asymmetrical distribution of charge in these molecules.
However, in an environment with water, the polarized water molecules are attracted
to these asymmetrical charge distributions also and so each of these molecules will
actually be surrounded by a cage of water molecules as shown in Fig. 4.6a. This shield
of polar water molecules around the molecules markedly reduces the attraction
between the + and − sites of the molecules. The same thing is true for ionized
molecules. If we denote a minus ion by a triangle with a minus inside it and a plus
ion by a square with a plus inside it, then this caging effect would look something
like what is shown in Fig. 4.6b.
This reduction occurs because the electric field of the shield opposes the electric
field of the ion and so weakens it. Consider common table salt, NaCl. This salt
can ionize into Na+ and Cl − , the exact amount that ionizes being dependent on the
solution you drop the salt into. The minus side of NaCl is very attractive to the
positive side of a polar water molecule which in turn is attracted to the negative side
of another water molecule. The same thing can be said about the positive side of the
salt. The presence of the polar water molecules actively encourages the splitting or
disassociating of the salt into two charged pieces. Hence, water can dissolve many
70 4 Biological Molecules

Fig. 4.6 The polarity of water induces cages to form. a Polar bonding with water. b Ion water cages

polar molecules, like the salt mentioned above, that serve as fuels, building blocks,
catalysts and information carriers. This causes a problem because the caging of an
ion by water molecules also inhibits ion interactions. Biological systems have solved
this problem by creating water free micro environments where polar interactions
have maximal strength. A consequence of this is that non polar groups aren’t split
apart by water and so it is energetically more favorable for non polar molecules to be
placed into one cage rather that have a separate water cage for each one. If we denote
a non polar molecule by the symbol NP enclosed in a circle, as a thought experiment
we can add our non polar molecule to a water environment. A cavity in the water
is created because the non polar molecule disrupts some hydrogen bonds of water
to itself. We see a picture like the one in Fig. 4.7a. This means that the number of
ways to from hydrogen bonds in the cage around the non polar molecule is smaller
that the the number of ways to from hydrogen bonds without the non polar molecule
present. This implies a cost to caging NP as order is created. Now if a second non
polar molecule NP is added, where will it go? If a second cage is created, more
hydrogen bonds are used up than if both NP molecules clump together inside one
cage. Remember always that order is costly and disorder is energetically favored.
So two non polar molecules clump together to give the picture shown in Fig. 4.7b.

Fig. 4.7 It is more efficient to group non polar molecules in cages. a Non polar molecule water
cages. b Non polar molecule group water cages
4.3 Hydrocarbons 71

4.3 Hydrocarbons

We need to learn a bit about the interesting molecules we will see in our quest to
build interesting models of cell function. Any good organic chemistry book is good
to have as a general reference on your shelf if you really like this stuff. We will begin
with simple hydrocarbons.
The basic thing to remember is that carbon’s outer shell of electrons is four shy of
being filled up. The far right edge of the periodic table consists of the noble gases or
elements because their outer most electron shells are completely populated. Hence,
they are considered special or noble. For us, a quick way to understand hydrocarbons
is to think of a carbon as wanting to add four more electrons so that it can be like
a noble gas. Of course, there are less anthropomorphic ways to look at it and really
nice physical models but looking at it in terms of a want really helps! We typically
draw a carbon atom, denoted by C, surrounded by four lines. Each of the lines is
ninety degrees apart and the lines represent a covalent bond with something. On the
left side of Fig. 4.8, we see a carbon with three of its covalent bonds with hydrogen
(hence, these lines go from the central C to an H) and the last covalent bond on the
left goes to an unknown molecule we denote as R. The R is called a residue and must
supply an electron for this last covalent bond. The molecule CH4 is called methyl
and is the simplest hydrocarbon (note the residue here is just a hydrogen); here we
have the molecule by CH3 R; for example, a ionized phosphate group, PO3− , would
supply such an electron and we would have the molecule CH3 PO3 . The next simplest
hydrocarbon is one that is built from two carbons. If the two carbons bond with each
other, that will leave six bonds left over to fill. If all of these bonds are filled with
hydrogens, we get the molecule ethyl with chemical formulae C2 H6 . Usually, we
think of the left most hydrogen as being replaced by a residue R which we show on
the right side of Fig. 4.8.

H H H

R C H R C C H

H H H
Methyl with Residue R Ethyl with Residue R

Carbon is represented by the symbol C and it can form four simple bonds. In the methyl
molecule, three of the bonds are taken up by hydrogen (symbol H) and the last one is used
to attach the residue (symbol R). In the ethyl molecule, the right most carbon uses its last
available bond to connect to the right most carbon. The right most carbon then has one last
bond that can be used to add the residue. The residue group itself be quite complicated.

Fig. 4.8 Methyl and ethyl can have side chains of arbitrary complexity called residues
72 4 Biological Molecules

Clearly, these groupings can get complicated very quickly! We won’t show any
more specific molecules, but you can get the flavor of all this by looking at Fig. 4.8
which shows a few of the residues we will see attached to various hydrocarbons. Of
course, we can also use more than two carbons and if you think about it a bit, as the
number of carbons we use goes up, there is no particular reason to think our pictures
will always organize the carbons in a central chain like beads on a string. Instead,
the carbons may forms side chains or branches, from circular groupings where the
last carbon in a group bonds to the first carbon and so forth. Also our pictures are
just idealizations to help us think about things; these molecules live in solutions, so
there are water cages, there are three dimensional concerns—like which carbons are
in a particular plane—and so forth. We won’t really discuss those things in a lot of
detail. However, the next step is to look at a special class of molecules called amino
acids and we will see some of this complication show up in our discussions there.

4.4 Amino Acids

An α amino acid consists of the following things:


• an amide group NH2
• a carbonyl group COOH
• a hydrogen atom H
• a distinctive residue R
These groups are all attached to a central carbon atom which is called the α carbon.
There are many common residues. First, let’s look at a methyl molecule with some
common residues attached.

Methyl + residue hydroxyl: The chemical formula here is OH and since O needs
to add electrons so that its outer electron shell can be filled, we think of it as having
a polarity or charge of −2. Oxygen shares the single electron of hydrogen to add
one electron to oxygen’s outer shell bringing oxygen closer to a filled outer shell.
Hence, the hydrogen bond here brings the net charge of the hydroxyl group to
−1 as hydroxyl still needs one more electron. In fact, it is energetically favorable
for the hydroxyl group to accept an electron to fill the outermost shell. Hence,
hydroxyl can act as OH − in an ionic bond. Since carbon wants electrons to fill
its outer shell, it saves energy for the hydroxyl group and the carbon to share one
of carbon’s outer electrons in a covalent bond. If we use the hydroxyl group as
the residue for methyl, we replace one of the hydrogen’s in methyl with hydroxyl
giving CH3 –OH.
Methyl + residue amide: The chemical formula here is NH2 and since N needs
three electrons to fill its outer most electron shell, we think of it as having a
polarity or charge of −3. Here N forms a single bond with the two hydrogens.
This molecule can accept an electron and act as the ion NH2− or it can bond
covalently with carbon replacing one methyl’s hydrogens. The methyl plus amide
residue would then be written as CH3 –NH2 .
4.4 Amino Acids 73

Methyl + residue carbonyl: The hydroxyl OH can form a covalent bond with
carbon and an oxygen can form a double covalent bond with carbon to give
COOH. This molecule can accept an additional electron and function in an ionic
bond as COOH − or it can form a covalent bond giving the group OOH which can
add an electron and function in ionic bonds as OOH − . This group can then form a
double covalent bond with carbon and share two electrons. The carbon atom then
can share two more electrons with another oxygen in a double covalent bond. This
gives the molecule COOH. This molecule finds it favorable to add an electron
in the outer shell so that it can form ionic bonds. In this state, we would call it
COOH − . The carbonyl can also form a covalent bond with another carbon. The
methyl molecule plus carbonyl residue would then be written as CH3 –COOH.
Methyl + phosphate: The chemical formula here is PO4 . Phosphate, P, has three
covalent bonds that can be used to fill its outer most electron shell. It carries two
electrons in its 2s orbital and three in its 2p orbitals. Since oxygen needs two
electrons to fill its outermost shell, the 2s electrons of phosphorus can be shared
with one oxygen. This is still considered a single bond as only two electrons are
involved (it is actually called a coordinate covalent bond). However, this bond is
often drawn as a double bond in pictorial representations anyway. The remaining
three electrons carbon needs to fill its 2p orbitals are then obtained by covalent
sharing with oxygen. Each of these three oxygen’s sharing a 2p carbon orbital,
still needs an electron. Hence, phosphate can form the ionic bond using PO−3 4 .
The three oxygen covalently sharing 2p orbitals can then ionically bond with
hydrogens to create the molecule PO4 H3 which is usually written reversed as
H3 PO4 . If you leave off one of the hydrogens, we have H2 PO− 4 . which can form
a residue on methyl giving methyl phosphate H2 PO4 CH3 .
Phosphates in dilute water solutions exist in four forms. In a strongly basic solu-
tion, PO−34 predominates. However, in a weakly basic setting, HPO4 is more
−2

common. In a weakly acid water solution, the dominant form is H2 PO−1 4 and
finally, in a strongly acidic solution, H3 PO4 has the highest concentration.
Methyl + thiol: The chemical formula here is SH and since sulphur has two cova-
lent bonds that can be used to fill its outer most electron shell, we think of it as
having a polarity or charge of −2. Hence, the hydrogen bond here gives us an ion
with −1. So we can denote this group as SH − . A methyl molecule with a thiol
residue would thus have the formula SH–CH3 .

If we replace two of the hydrogens on the methyl group with an amide group
and a carboxyl group we obtain the molecule NH2 –COOH–CH2 . We can see how a
molecule of this type will be assembled using are simple pictorial representation of
covalent bonds in Fig. 4.9. As we mentioned earlier, we think of the central carbon as
the α carbon so that we distinguish it from any other carbons that are attached to it.
In fact, one way to look at all this is to think that since a carbon lacks four electrons
in its outer shell, it is energetically favorable to seek alliances with other molecules
so that it can fill these empty spots. This is, of course, a very anthropomorphic way
to look at it, but it helps you see what is going on at a gut level. So draw the α carbon
with four dots around it. These are the places in the outer shell that are not filled.
74 4 Biological Molecules

Fig. 4.9 Methyl with


carboxyl and amide residues
with electron shells

Chemical theory tells us that the outer shell of a carbon consists of four groupings
of two electrons each. So when we draw four groupings of just one electron per
group we are clearly indicating that one electron is missing in each group. Now the
amide molecule is handled in a similar way: the nitrogen is missing three electrons
in its outer shell which we indicate by three single dots placed around the nitrogen.
A hydrogen has only one electron as it has a very simple shell structure; hence it is
drawn as a single dot. So hydrogen would like one more electron to fill its outer shell
and the nitrogen would also like an additional electron to fill one of its groups. So
a good solution is for the two atoms to share an electron which we denote by a box
around the two single electrons. Continuing in this way, we can build an electron dot
diagram for the amide and its connection to the α carbon. The carbonyl is a little
more complicated. So far we have only looked at bonds between atoms where one
electron is shared. Another type of bond which is even stronger is one where two of
the outer shell electrons are shared between two atoms. The carbonyl group would
be written as C = OOH to reflect the fact the there is such a double bond between
the carbon and the first oxygen. Oxygen is missing only two electrons in its outer
shell and so this double bond which is indicated by the double bars = completely
fills the outer shell of the oxygen and half of the outer shell of the carbon. One of the
remaining two outer shell groups is then filled by a hydroxyl group, OH. Note the
hydroxyl group is an oxygen with one of its outer shell groups filled by a hydrogen
leaving one group to fill. It does this by sharing with one of the remaining two groups
that are open on the carbon of the carbonyl group. This leaves one opening left on
the carbon of the carbonyl which is used to make a shared bond with the α carbon
of the amino acid. The entire electron dot diagram is shown in Fig. 4.9 and it is very
complex. So we generally do not use this kind of explicit notation to draw an amino
acid. All of this detail is assumed in the simple skeleton formula we see on the left
4.4 Amino Acids 75

N H2 N H3+

H C COOH H C COO −

R R

Unionized Form Double Ionized Form

Here we see a typical amino acid. The common elements are the carboxyl and amide groups.
Each amino acid then has a different residue. The carbon atom in the middle is called the
central carbon and the elements attached to it can be ionized in a variety of ways. This
ionization can substantially effect how the amino acid reacts with other molecules. Also,
charge distribution in amino acids is not uniform and so one side of an amino acid may act
more positive than the other.

Fig. 4.10 A typical amino acid in normal and ionized forms

COO − H

+H +H
3N C H 3N C COO −

H CH3
Glycine Alanine

Glycine’s residue is H and alanine’s, is CH3 . Glycine is the simplest amino acid and is
optically inactive.

Fig. 4.11 The amino acids Glycine and Alanine

COO − H

+H +H
3N C H 3N C COO −

CH2
CH
CH
CH3 CH3
CH3 CH3

Valine Leucine

Valine’s residue is CH(CH3 )2 and Leucine’s is CH2 CH(CH3 )2 . Note Valine and Leucine
have a longer residue which makes them hydrophobic.

Fig. 4.12 The amino acids Valine and Leucine


76 4 Biological Molecules

COO − H

+H +H
3N C H 3N C COO −

H C CH3
CH2 CH2
CH2
CH2
CH3

Isoleucine Proline

Isoleucine’s residue is HCCH3 CH2 CH3 and Proline’s is a cyclic structure H2 CCH2 CH2
attaching to both the amide and the central carbon. Isoleucine is hydrophobic but Proline’s
cyclic residue is indifferent to water.

Fig. 4.13 The amino acids Isoleucine and Proline

COO − COO −

+H C H +H C H
3N 3N

CH2 CH2
C C
H −C C−H H −C C−H
H −C C−H H −C C−H

C−H C − OH
Phenylalanine Tyrosine

Phenylalanine has a very hydrophobic phenyl group as a residue. The ring structure of the
phenyl group creates a localized cloud of pi electrons which make it very reactive. Tyrosine
replaces the bottom C − H with C − OH. The addition of the hydroxyl group makes this
amino acid hydrophilic. It is also very reactive due to the localized pi electron cloud.

Fig. 4.14 The amino acids Phenylalanine and Tyrosine

hand side of Fig. 4.10 and in the notation CH2 NH2 COOH. The structure shown in
Fig. 4.9 is that of the amino acid glycine (G or Gly).
An amino acid can exist in ionized or non ionized forms as shown on the right
side of Fig. 4.10 and of course all we have said about water cages is still relevant.
Another important thing is the three dimensional (3D) configuration of an amino
acid. An amino acid occurs in two different 3D forms. To keep it simple, look at this
simple representation
4.4 Amino Acids 77

COO −
COO −
+H C H
3N
+H C H
CH2 3N
C C
H −C CH CH
CH2
H −C CH
SH
CH NH

Trytophan Cysteine

Tryptophan’s residue is fairly complicated with a phenyl group off to the left. It is very
hydrophobic. Cysteine plays a special role in biology because bonds similar to hydrogen
bonds can form between sulphur atoms occurring on different cysteine molecules. These
bonds are called disulfide links.

Fig. 4.15 The amino acids Tryptophan and Cysteine

COO −
COO −

+H C H
3N
+H C H
3N
CH2
H C OH
CH2
H
S
CH3

Methionine Serine

Methionine is hydrophobic. If you look at Alalanine on the right side of Figure 4.11, you’ll
see that Serine is formed by Adding a hydroxyl group to the methyl residue on Alalanine.
This is called hydroxylation.

Fig. 4.16 The amino acids Methionine and Serine

R + y axis

H ← Cα → NH2 + x axis

COOH

The R, H, NH2 and COOH are in the xy plane and the Cα carbon is along the positive
z axis above the side groups. The NH2 is on the positive x axis and the R is on the
positive y axis. This is the L form as if you take your right hand, line up the fingers
along the NH2 line and rotate your fingers left towards the residue R. Note your
78 4 Biological Molecules

COO −
COO −

+H C H
3N
+H C H
3N
CH2
H C OH
CH2
CH3
CH2
N H3+

Lysine Threonine

Lysine is very polar and hence, it is very hydrophobic. Threonine is a hydroxylated version
of Valine (see the left side of Figure 4.12).

Fig. 4.17 The amino acids Lysine and Threonine

COO −
COO −
+H
+H C H 3N C H
3N
CH2
(CH2 )3 C
NH C CH
NH NH
C N H2+
CH
N H2
Arganine Histidine

Arganine and Histidine are very polar, hydrophobic and are positive ions at neutral pH.
However, Histidine is a negative ion at physiological pH.

Fig. 4.18 The amino acids Arganine and Histidine

thumb points out of the page towards the positive z axis location of Cα . Also, it is
easy to visualize by just imaging grabbing the Cα and pulling it up out of the page
that the other groups lie in. The other form is called the R form and looks like this:

H

COOH ← Cα → NH2 + x axis

R − y axis
4.4 Amino Acids 79

H H

+H +H
3N C COO − 3N C COO −

CH2 (CH2 )2

C C
O O− O O−
Asparate Glutamate

Aspartate and Glutamate have similar residues.

Fig. 4.19 The amino acids Asparate and Glutamate

H H

+H +H
3N C COO − 3N C COO −

CH2 (CH2 )2

C C
O N H2 O N H2
Asparagine Glutamine

The oxygen ion in Aspartate and Glutamate is replaced by the amide group in both
Asparagine and Glutamine. This change makes these amino acids neutral in charge.

Fig. 4.20 The amino acids Asparagine and Glutamine

The R, NH2 , H and COOH are in the xy plane and the Cα carbon is along the negative
z axis below the side groups. Here the NH2 is on the positive x axis but the R is on the
negative y axis. This is the R form as if you take your right hand, line up the fingers
along the NH2 line and rotate your fingers right towards the residue R. Hence, we
pull the Cα down below the page determined by the other groups here. For unknown
reasons, only L-forms are used in life on earth. Now there are a total of twenty amino
acids: we list them in Fig. 4.11 (glycine and alanine), Fig. 4.12 (valine and leucine),
Fig. 4.13 (isoleucine and proline), Fig. 4.14 (phenylalanine and tyrosine), Fig. 4.15
(tryptophan and cysteine), Fig. 4.16 (methionine and serine), Fig. 4.17 (lysine and
threonine), Fig. 4.18 (arginine and histidine), Fig. 4.19 (aspartate and glutamate) and
Fig. 4.20 (asparagine and glutamine). We have organized all of these figures so that
the residues are underneath the central carbon. As you can see, all have the common
80 4 Biological Molecules

Table 4.5 Abbreviations for the amino acids


Amino acid Abbreviation Amino acid Abbreviation
Glycine G, Gly Methionine M, Met
Alanine A, Ala Serine S, Ser
Valine V, Val Lysine K, Lys
Leucine L, Leu Threonine T, Thr
Isoleucine I, Ile Arginine R, Arg
Proline P, Pro Histidine H, His
Phenylalanine F, Phe Aspartate D, Asp
Tyrosine Y, Tyr Glutamate E, Glu
Tryptophan W, Trp Asparagine N, Asn
Cysteine C, Cys Glutamine G, Gln

amino acid structure with different residues R attached. The type of residue R deter-
mines the chemical and optical reactivity of the amino acids. For convenience, we
list the standard abbreviations for the names of the amino acids in table form as well
as in the figures in Table 4.5.

4.5 Peptide Bonds

Amino acids can link up in chains because the COOH on one can bond with the NH2
on another as is seen in Fig. 4.21. In this figure, there is an outlined box that contains
the bond between the COOH and the NH2 ; this is called the peptide bond and is
shown in Fig. 4.21. The two amino acids that pair are connected by a rigid planar
bond. There is a Cα1 atom from amino acid one and another Cα2 from amino acid two
attached to this bond. The COOH and NH2 bond looks like this in block diagram
form. The COOH loses an OH and the NH2 loses an H to form the bond. Think of
bond as forming a rigid piece of cardboard and attached on the left is the amino acid
built around Cα1 and attached on the right is the amino acid build around Cα2 .

Fig. 4.21 The bond between


two amino acids
4.5 Peptide Bonds 81

O (+y local axis)



Cα1 →← C → N(+x local axis) →← Cα2

H

Now think of Cα1 as attached to a pencil which is plugged into the side of the peptide
bond. The Cα1 to CO bond is an axis that amino acid one is free to rotate about. Call
this angle of rotation 1 . We can do the same thing for the other side and talk about a
rotation angle 2 for the NH to Cα2 bond. In Fig. 4.21, R1 is the residue or side chain
for the first amino acid and R2 is the side chain for the other. Note amino acid one
starts with an N2 H group on the left and amino acid two ends with a COOH group
on the right

O (+y local axis)



Cα1 → 1 ← C → N(+x local axis) → 2 ← Cα2

H

The peptide bond allows amino acids to link into chains as we show in the next block
diagram.
O (+y local axis)

N2 H ← Cα1 → 1 ← C → N(+x local axis) → 2 ← Cα2 → COOH

H

We show the peptide bond with a bit more three dimensionality in Fig. 4.22. We can
also draw the chain with two peptide bonds as we indicate in Fig. 4.23. You can see
that the side chains, R1 , R2 and R3 , then hang off of this chain of linked peptide bonds.
In a longer chain, there are two rotational degrees of freedom at the central carbon of
any two peptide bonds; i.e. a rotation angle with the peptide bond on the right and on

Fig. 4.22 The peptide bond


between two amino acids
with the rotation possibilities
indicated. Cα1 and Cα2 point
up in the picture
82 4 Biological Molecules

Fig. 4.23 Details of the


peptide bonds in a chain

the left. This means that if we imagine the linked peptide bonds as beads on a string,
there is a great deal of flexibility possible in the three dimensional configuration of
these beads on the string. It isn’t hard to imagine that if the beads of string were long
enough, full loops could form and there could even be complicated repeated patterns
or motifs. Also, these beads on a string are molecular groupings that are inside a
solution that is full of various charged groups and the residues or side chains coming
off of the string are also potentially charged. Hence, there are many forces that act on
this string including hydrogen bonds between residues, Vanderwaals forces acting
on motifs and so forth.
Now the peptide bond is always the same, so let’s indicate it by a simple PP. Then
we have

N2 H ← Cα1 → 1 ← PP → 2 ← Cα2 → COOH

It is then easy to show a chain of three amino acids with three separate rotation
angles. We have simplified the picture by replacing → 1 ← with just 1 and so
forth giving the block diagram

N2 H Cα1 1 PP 2 Cα2 PP 3 Cα3 COOH

We also show this in Fig. 4.24. In this picture, we show the chain we just laid out in
block form above.
If we look at one three amino acid piece of a long chain, we would see the
following molecular form as represented in Fig. 4.25. As discussed above, as more
and more amino acids link up, we get a chain of peptide bonds whose geometry is
very complicated in solution. To get a handle on this kind of chain at a high level,
we need to abstract out of this a simpler representation.
In Fig. 4.26, we show how we can first drop most of the molecular detail and just
label the peptide bond planes using the letter P. We see we can now represent our chain
in the very compact form –NCCNCCNCCN–. This is called the backbone of the
chain. The molecules such as side chains and hydrogen atoms hang off the backbone
in the form that is most energetically favorable. Of course, this representation does
not show the particular amino acids in the chain, so another representation for a five
4.5 Peptide Bonds 83

Fig. 4.24 A three amino acid chain

Fig. 4.25 Molecular details of a chain

Fig. 4.26 A first chain abstraction


84 4 Biological Molecules

amino acid chain would be A1 A2 A3 A4 A5 where the symbol Ai for appropriate indices
i represents one of the twenty amino acids. The peptide bonds are not even mentioned
as it is assumed that they are there. Also, note that in these amino acid chains, the
left end is an amino group and the right end is a carbonyl group.

4.6 Chains of Amino Acids

We roughly classify chains of amino acids by their length. Hence, we say polypep-
tides are chains of amino acids less than or equal to 50 units long. Clearly, this naming
is a judgment call. Further, longer chains of amino acids are called proteins. As we
mentioned earlier, these long chains have side chains and other things that interact
via weak bonds or via other sorts of special bonds. For example, the amino acid
cysteine (see the right side of Fig. 4.15) has the residue CH2 SH and if the residues of
two cysteine’s in an amino acid chain can become physically close (this can happen
even if the two cysteines are very far apart on the chain because the chain twists and
bend in three dimensional space!), a S–S bond can form between the sulphur in the
SH groups. This is called a disulfide bond and it is yet another important bond for
amino acid chains. An example of this bond occurs in the protein insulin as shown
in Fig. 4.27. In Fig. 4.27, note we represent the amino acid chains by drawing them
as beads on a string: each bead is a circle containing the abbreviation of an amino
acid as we listed in Table 4.5. This is a very convenient representation even if much
detail is hidden.
In general, for a protein, there are four ways to look at its structure: The primary
structure is the sequence of amino acids in the chain as shown in Fig. 4.28a.
To know this, we need to know the order in which the amino acids occur in the
chain: this is called sequencing the protein. Due to amino acid interactions along the
chain, different regions of the full primary chain may form local three dimensional
structures. If we can determine these, we can say we know the secondary structure
of the protein. An example is a helix structure as shown in Fig. 4.28b. If we pack

Fig. 4.27 Disulfide insulin protein


4.6 Chains of Amino Acids 85

Fig. 4.28 First and second order protein foldings. a Primary structure of a protein. b Secondary
structure of a protein

Fig. 4.29 Third and fourth order protein foldings. a Tertiary structure of a protein. b Quatenary
structure of a protein

secondary structures into one or more compact globular units called domains, we
obtain the tertiary structure an example of which is shown in Fig. 4.29a. In this
figure, each rectangle represents secondary structural elements. Finally, the protein
my contain several tertiary elements which are organized into larger structures.
This way the amino acid far apart in the primary sequence structure can be brought
close enough together in three dimensions to interact. This is called the quatenary
structure of the protein. An example is shown in Fig. 4.29b

4.7 Nucleic Acids

Our genetic code is contained in linear chains of what are called nucleic acids in
combination with a particular type of sugar. These nucleic acid plus sugar groups are
used in a very specific way to code for each of the twenty amino acids we mentioned
in Sect. 4.4. So our next task is to discuss sugars and nucleic acids and the way these
things are used to code for the amino acids.

4.7.1 Sugars

Consider the cyclic hydrocarbon shown in Fig. 4.30a The ring you see in Fig. 4.30a
is formed from five carbons and one oxygen. For sugars, we label the carbons with
86 4 Biological Molecules

Fig. 4.30 The Pyran and


Furan structures. a Details of
a cyclic hydrocarbon sugar:
Pyran. b The schematic for
Pyran. c Details of a cyclic
hydrocarbon sugar: Furan. d
The schematic for Furan

primes as 1 C  to 6 C  because it will be important to remember which side chains


are attached to which carbons. This type of structure is called a pyran and can be
indicated more schematically as in Fig. 4.30b. Another common type of structure is
that shown in Fig. 4.30c which is formed from four carbons and one oxygen. We
label the carbons in a similar fashion to the way we labeled in the pyran molecule.
More symbolically, we would draw a furan as shown in Fig. 4.30d.
We will spend most of our time with the furan structures which have the very
particular three dimensional geometry shown in Fig. 4.31a. Note that 3 C  and 5 C  are
out of the plane formed by O–1 C  –2 C  –4 C  ; this is called the 3 C  endo form. Another
three dimensional version of the furan molecule is the 2 C  endo form shown in
Fig. 4.31b. Here, 2 C  and 5 C  are out of the plane formed by O–1 C  –3 C  –4 C  . Looking
ahead some, these three dimensional forms are important because only certain ones
are used in biologically relevant structures. Later, we will define the large molecules
DNA and RNA and we will find that DNA uses the 2 C  endo and RNA, the 3 C 
endo form. Now the particular sugar we are interested in is called ribose which will
come in an oxygenated and non-oxygenated (deoxy) form. Consider the formula for
a ribose sugar as shown in Fig. 4.32a. Note the 2 C  carbon has an hydroxyl group on
it. If we remove the oxygen from this hydroxyl, the resulting sugar is known as the
deoxy-ribose sugar (see Fig. 4.32b).
4.7 Nucleic Acids 87

Fig. 4.31 Three dimensional Furan structures. a The 3 C  endo Furan. b The 2 C  endo Furan

Fig. 4.32 Oxygenated and de-oxygenated ribose sugars. a The ribose sugar. b The deoxy ribose
sugar

Fig. 4.33 Forms of nitrogenous bases. a The generic Purine. b The generic Pyrimidine

4.7.2 Nucleotides

There are four special nitrogenous bases which are important. They come in two
flavors: purines and pyrimidines. The purines have the form shown in Fig. 4.33a
while the pyrimidines have the one shown in Fig. 4.33b. There are two purines and
two pyrimidines we need to know about: the purines adenine and guanine and the
pyrimidines thymine and cytosine. These are commonly abbreviated as shown in
Table 4.6.
88 4 Biological Molecules

Table 4.6 Abbreviations for Type Name Abbreviation


the nitrogenous bases
Purine Adenine A
Purine Guanine G
Pyrimidine Thymine T
Pyrimidine Cytosine C

Fig. 4.34 Purine and Pyrimidine nucleotides. a Adenine. b Guanine. c Thymine. d Cytosine

These chemical formulae are important, so we show their respective forms in


Fig. 4.34a (Adenine is a purine with an attached amide on 6 C  ), Fig. 4.34b (Guanine
is a purine with an attached oxygen on 6 C  ), Fig. 4.34d (Cytosine is a pyrimidine with
an attached amide on 4 C  ), and Fig. 4.34c (Thymine is a pyrimidine with an attached
oxygen on 4 C  ). These four nitrogenous bases can bond to the ribose or deoxyribose
sugars to create what are called nucleotides. For example, adenine plus deoxyribose
would give a compound called deoxy-adenoside as shown in Fig. 4.35. In general, a
sugar plus a purine or pyrimidine nitrogenous base give us a nucleoside. If we add
phosphate to the 5 C  of the sugar, we get a new molecule called a nucleotide (note
the change from side to tide!). In general, sugar plus phosphate plus nitrogenous base
gives nucleotide. An example is deoxy-adenotide as shown in Fig. 4.36.
This level of detail is far more complicated and messy than we typically wish to
show; hence, we generally draw this in the compact form shown in Fig. 4.37. There,
we have replaced the base with a simple shaded box and simply labeled the primed
carbons with the numerical ranking. In Fig. 4.38 we show how nucleotides can link
up into chains: bond the 5 C  of the ribose on one nucleotide to the 3 C  of the ribose
4.7 Nucleic Acids 89

Fig. 4.35 Deoxy-adenoside

Fig. 4.36 Deoxy-adenotide

on another nucleotide with a phosphate or PO3− bridge. Symbolically this looks like
Fig. 4.38. This chain of three nucleotides has a terminal OH on the 5 C  of the top
sugar and a terminal OH on the 3 C  of the bottom sugar. We often write this even
more abstractly as shown in Fig. 4.39 or just OH– Base 3 P Base 2 P Base 1
P –OH, where the P denotes a phosphate bridge. For example, for a chain with
bases adenine, adenine, cytosine and guanine, we would write OH–A–p–A–p–C–
p–G–OH or OHApApCpGOH. Even this is cumbersome, so we will leave out the
common phosphate bridges and terminal hydroxyl groups and simply write AACG. It
is thus understood the left end is an OH terminated 5 C  and the right end an hydroxyl
terminated 3 C  .
90 4 Biological Molecules

Fig. 4.37 A general


nucleotide

Fig. 4.38 A nucleotide


chain

Fig. 4.39 An abstract


nucleotide chain
4.7 Nucleic Acids 91

Fig. 4.40 The Tyrosine–Adenine bond

Fig. 4.41 The Cytosine–Guanine bond

4.7.3 Complementary Base Pairing

The last piece in this puzzle is the fact that the purine and pyrimidine nucleotides can
bond together in the following ways: A to T or T to A and C to G or G to C. We say that
adenine and thymine and cytosine and guanine are complementary nucleotides. This
bonding occurs because hydrogen bonds can form between the adjacent nitrogen or
between adjacent nitrogen and oxygen atoms. For example, look at the T –A bond
in Fig. 4.40. Note the bases are inside and the sugars outside. Finally, note how the
bonding is done for the cytosine and guanine components in Fig. 4.41. Now as we
have said, nucleotides can link into a long chain via the phosphate bond. Each base
in this chain is attracted to a complimentary base. It is energetically favorable for two
chains to form: chain one and its complement chain 2. In the following table, Table 4.7,
we see how this pairing is done for a short sequence of nucleotides. Note that the
5
pairs with a 3 and vice versa. Each pair of complimentary nucleotides is called
a complimentary base pair. The forces that act on the residues of the nucleotides
and between the nucleotides themselves coupled with the rigid nature of the peptide
bond between two nucleotides induce the two chains to form a double helix structure
under cellular conditions which in cross-section (see Fig. 4.42) has the bases inside
and the sugars outside.
92 4 Biological Molecules

Table 4.7 Two Chain one Chain two


complimentary nucleotide 5 3
chains end end
C G
T A
A T
C G
G C
G C
C G
T A
A T
T A
T A
C G
G C
3 end 5 end

Fig. 4.42 A cross-section of


a nucleotide helix

The complimentary nucleotides fit into the spiral most efficiently with 100 degrees
of rotation and 1.5 Angstroms of rise between each base pair. Thus, there are 3.6 base
pairs for every 360 degrees of rotation around the spiral with a rise of 3.6 × 1.5 = 5.4
Angstroms. This is, of course, hard to draw! If you were looking down at the spiral
from the top, you could imagine each base to base pair as a set of bricks. You would
see a lower set of bricks and then the next pair of bricks above that pair would be
rotated 100 degrees as shown in Fig. 4.43. To make it easier to see what is going on,
only the top pair of bases have the attached sugars drawn in. You can see that when
you look down at this spiral, all the sugars are sticking outwards. The double helix is
called DNA when deoxy-ribose sugars are used on the nucleotides in our alphabet.
The name DNA stands for deoxy-ribose nucleic acid. A chain structure closely related
to DNA is what is called RNA, where the R refers to the fact that oxy-ribose sugars or
simply ribose sugars are used on the nucleotides in the alphabet used to build RNA.
The RNA alphabet is slightly different as the nucleotide Thymine,T, in the DNA
alphabet is replaced by the similar nucleotide Uracil, U. The chemical structure of
uracil is shown in Fig. 4.44 right next to the formula for thymine. Note that the only
difference is that carbon 5 C  holds a methyl group in thymine and just a hydrogen in
4.7 Nucleic Acids 93

Fig. 4.43 The base–base


pair rotation

Fig. 4.44 The nucleotide


Uracil and Thymine

uracil. Despite these differences, uracil will still bond to adenine via a complimentary
bond. It is rare for the long string of oxygenated ribose nucleotides to form a double
helix, although within that long chain of nucleotides there can indeed be local hairpin
like structures and so forth. Amino acids are coded using nucleotides with what is
called the triplet code. This name came about because any set of three nucleotides
is used to construct one of the twenty amino acids through a complicated series of
steps. We will simply say that each triplet is mapped to an amino acid as a shorthand
for all of this detail. There are 20 amino acids and only 4 nucleotides. Hence, our
alphabet here is {A, C, T , G} The number of ways to take 3 things out of an alphabet
of 4 things is 64. To see this, think of a given triplet as a set of three empty slots;
there are 4 ways to fill slot 1, 4 independent ways to fill slot 2 (we know have 4 × 4
ways to fill the first two slots) and finally, 4 independent ways to fill slot 3. This gives
a total of 4 × 4 × 4 or 64 ways to fill the three slots independently. Since there are
only 20 amino acids, it is clear that more than one nucleotide triplet could be mapped
to a given amino acid! In a similar way, there are 64 different ways to form triplets
from the RNA alphabet {A, C, U, G}. We tend to identify these two sets of triplets
and the associated mapping to amino acids as it is just a matter of replacing the T in
one set with an U to obtain the other set.
94 4 Biological Molecules

4.8 Making Proteins

Organisms on earth have evolved to use this nucleotide triplet to amino acid mapping
(it is not clear why this is the mapping used over other possible choices!). Now
proteins are strings of amino acids. So each amino acid in this string can be thought
of as the output of a mapping from the triplet code we have been discussing. Hence,
associated to each protein of length N is a long chain of nucleotides of length 3N.
Even though the series of steps by which the triplets are mapped into a protein is
very complicated, we can still get a reasonable grasp how proteins are made from
the information stored in the nucleotide chain by looking at the process with the
right level of abstraction. Here is an overview of the process of protein transcription.
When a protein is built, certain biological machines are used to find the appropriate
place in the DNA double helix where a long string of nucleotides which contains the
information needed to build the protein is stored. This long chain of nucleotides which
encodes the information to build a protein is called a gene. Biological machinery
unzips the double helix at this special point into two chains as shown in Fig. 4.45. A
complimentary copy of a DNA single strand fragment is made using complimentary
pairing but this time adenine pairs to uracil to create a fragment of RNA. This
fragment of RNA serves to transfer information encoded in the DNA fragment
to other places in the cell where the actual protein can be assembled. Hence, this
RNA fragment is given a special name—Messenger RNA or mRNA for short. This
transfer process is called transcription.
For example, the DNA fragment 5 ACCGTTACCGT 3 has the DNA complement
3
TGGCAATGGCA5 although in the cell, the complimentary RNA fragment
3
UGGCAAUGGCA5

Fig. 4.45 The unzipped


double helix
4.8 Making Proteins 95

Table 4.8 The Triplet code


Amino acid DNA triplet RNA triplet
Alanine GCA, GCC, GCG, GCT GCA, GCC, GCG, GCU
Arginine AGA, AGG, CGA, CGC AGA, AGG, CGA, CGC
CGG, CGT CGG, CGU
Asparagine AAC, AAT AAC, AAU
Aspartic acid GAC, GAT GAC, GAU
Cysteine TAC, TAT UAC, UAU
Glutamic acid GAA, GAG GAA, GAG
Glutamine CAA, CAG CAA, CAG
Glycine GGA, GGC, GGG, GGT GGA, GGC, GGG, GGU
Histidine CAC, CAT CAC, CAU
Isoleucine ATA, ATC, ATT AUA, AUC, AUU
Leucine CTA, CTC, CTG, CTT CUA, CUC, CUG, CUU
TTA, TTG UUA, UUG
Lysine AAA, AAG AAA, AAG
Methionine (Start) ATG AUG
Phenylalanine TTC, TTT UUC, UUU
Proline CCA, CCC, CCG, CCT CCA, CCC, CCG, CCU
Serine AGC, AGT, TCA, TCC AGC, AGU, UCA, UCC
TCG, TCT UCG, UCU
Threonine ACA, ACC, ACG, ACT ACA, ACC, ACG, ACU
Tryptophan TGG UGG
Tyrosine TAC, TAT UAC, UAU
Valine GTA, GTC, GTG, GTT GUA, GUC, GUG, GUU
Stop TAA, TAG, TGA UAA, UAG, UGA

is produced instead. Note again that the 5 pairs with a 3 and vice versa. There are many
details of course that we are leaving out. For example, there must be a special chunk
of nucleotides in the original DNA string that the specialized biological machines
can locate as the place to begin the unzipping process. The mRNA is transferred to a
special protein manufacturing facility called the ribosome where three nucleotides
at a time from the mRNA string are mapped into their corresponding amino acid.
From what we said earlier, there are 64 different triplets that can be made from the
alphabet {A, C, U, G} and it is this mapping that is used to assemble the protein chain
a little at a time. For each chain that is unzipped, a complimentary chain is attracted
to it in the fashion shown by Table 4.7. This complimentary chain will however be
built from the oxygenated deoxy-ribose or simply ribose nucleotides. Hence, this
complimentary chain is part of a complimentary RNA helix. As the amino acids
encoded by mRNA are built and exit from the ribosome into the fluid inside the
cell, the chain of amino acids or polypeptides begins to twist and curl into its three
96 4 Biological Molecules

dimensional shape based on all the forces acting on it. We can write this whole
process symbolically as DNA → mRNA → ribosome → Protein. This is known
as the Central Dogma of Molecular Biology.
Hence to decode a particular gene stored in DNA which has been translated to its
complimentary mRNA form all we need to know are which triplets are associated
with which amino acids. These triplets are called DNA Codons. The DNA alphabet
form of this mapping is given in Table 4.8; remember, the RNA form is the same, we
just replace the thymine’s (T’s) by uracil’s (U’s).
For example, the DNA sequence,

TAC|TAT|GTG|CTT|ACC|TCG|ATT

is translated into the mRNA sequence

AUG|AUA|CAC|GAA|UGG|AGC|UAA

which corresponds to the amino acid string

Listing 4.1: Amino acid string


S t a r t | I s o l e u c i n e | H i s t i d i n e | Glutamic Acid | Tryptophan | S e r i n e | Stop

Note that shifting the reading by one base to the right or left changes completely
which triplets we read for coding into amino acids. This is called a frame shift and it
can certainly lead to a very different decoded protein. Changing one base in a given
triplet is a very local change and is a good example of a mutation or a kind of damage
produced by the environment or by aging or disease. Since the triplet code is quite
redundant, this may or may not result in a amino acid change. Even if it does, it
corresponds to altering one amino acid in a potentially long chain.
Chapter 5
Ion Movement

We are now in a position to discuss how ions move in and out of the membranes that
surround individual cells. This background will eventually enable us to understand
how an excitable cell can generate an action potential.

5.1 Membranes in Cells

The functions carried out by membranes are essential to life. Membranes are highly
selective permeability barriers instead of impervious containers because they contain
specific pumps and gates as we have mentioned. Membranes control flow of infor-
mation between cells and their environment because they contain specific receptors
for external stimuli and they have mechanism by which they can generate chemical
or electrical signals.
Membranes have several important common attributes. They are sheet like struc-
tures a few molecules thick (60–100 Å). They are built from specialized molecules
called lipids together with proteins. The weight ratio of proteins to lipids is about
4 : 1. They also contain specialized molecules called carbohydrates (we haven’t
yet discussed these) that are linked to the lipids and proteins. Membrane lipids are
small molecules with a hydrophilic (i.e. attracted to water) and a hydrophobic (i.e.
repelled by water) part. These lipids spontaneously assemble or form into closed
bimolecular sheets in aqueous medium. Essentially, it is energetically most favor-
able for the hydrophilic parts to be on the outside near the water and the hydrophobic
parts to be inside away from the water. If you think about it a bit, it is not hard to see
that forming a sphere is a great way to get the water hating parts away from the water
by placing them inside the sphere and to get the water loving parts near the water by
placing them on the outside of the sphere. This lipid sheet is of course a barrier to the
flow of various kinds of molecules. Specific proteins mediate distinctive functions of
these membranes. Proteins serve many functions: as pumps, pumps, gates, receptors,
energy transducers and enzymes among others.

© Springer Science+Business Media Singapore 2016 97


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_5
98 5 Ion Movement

Fig. 5.1 The phospholipid membranes. a A typical phospholipid. b An abstract lipid. c The hy-
drophobic phospholipid end group. d The hydrophilic phospholipid end group

Membranes are thus structures or assemblies, whose constituent protein and lipid
molecules are held together by many non-covalent interactions which are coopera-
tive. Since the two faces of the membrane are different, they are called asymmetric
fluid structures which can be regarded as 2-D solutions of oriented proteins and
lipids. A typical membrane is built from what are called phospholipids which have
the generic appearance shown in Fig. 5.1a. Note the group shown in Fig. 5.1d is polar
and water soluble—i.e. hydrophilic and the other side, Fig. 5.1c, is water phobic. In
these drawings, we are depicting the phosphate bond as a double one.
Of course, this is way too much detail to draw; hence, we use the abstraction shown
in Fig. 5.1b using the term head for the hydrophilic part and tail for the hydrophobic
part. Thus, these lipids will spontaneously assemble so that the heads point out and
the tails point in allowing us to draw the self assembled membrane as in Fig. 5.2a.
We see the heads orient towards the water and the tails away from the water
spontaneously into this sheet structure. The assembly can also form a sphere rather
than a sheet as shown in Fig. 5.2b. A typical mammalian cell is 25 µm in radius where
a µm is 10−6 meter. Since 1 Å is 10−10 meter or 10−4 µm, we see a cell’s radius is
around 250,000 Å. Since the membrane is only 60 Å or so in thickness, we can see
the percentage of real estate of the cell concentrated in the membrane is very small.
So a molecule only has to go a small distance to get through the membrane but to
move through the interior of the cell (say to get to the nucleus) is a very long journey!
Another way of looking at this is that the cell has room in it for a lot of things!
5.2 The Physical Laws of Ion Movement 99

Fig. 5.2 Membrane structures. a The self assembled lipid sheet membrane structure. b The self
assembled lipid sphere membrane structure

5.2 The Physical Laws of Ion Movement

We have relied on the wonderful books of Johnston and Wu (1995) and Weiss (1996)
in developing this discussion. They provide even more details and you should feel free
to look at these books. However, the amount of detail in them can be overwhelming,
so we are trying to offer a short version with just enough detail for our mathemati-
cal/biological engineer and computer scientist audience! An ion c can move across
a membrane due to several forces.

5.2.1 Ficke’s Law of Diffusion

First, let’s talk about what concentration of a molecule means. For an molecule b,
the concentration of the ion is denoted by the symbol [b] and is measured in molecules
liter
.
Now, we hardly ever measure concentration in molecules per unit volume; instead
we use the fact that there are 6.02 × 1023 molecules in a Mole and usually measure
concentration in the units Moles
cm3
= M where for simplicity, the symbol M denotes the
concentration in Moles per cm3 . This special number is called Avogadro’s Number
and we will denote it by N A . In the discussions that follow, we will at first write all
of our concentrations in terms of molecules, but remember what we have said about
Moles as we will eventually switch to those units as they are more convenient.
The force that arises from the rate of change of the concentration of molecule b
acts on the molecules in the membrane to help move them across. The amount of
molecules that move across per unit area due to this force is labeled the diffusion
flux as flux is defined to a rate of transfer ( something
second
) per unit area. Now look at a
cross section of the membrane and draw a perpendicular line through it. We can then
measure position of molecules in the membrane with the variable x: the membrane
100 5 Ion Movement

of thickness  starts at some value x0 , and ends at x0 + . Hence, below x0 we are


inside the membrane and above x0 + , we are outside the membrane.
Ficke’s Law of Diffusion is an empirical law which says the rate of change of
the concentration of molecule b is proportional to the diffusion flux and is written in
mathematical form as follows:
∂ [b]
Jdiff = −D (5.1)
∂x
where
• Jdiff is diffusion flux which has units of molecules
cm2 −second
.
cm2
• D is the diffusion coefficient which has units of second .
• [b] is the concentration of molecule b which has units of molecules
cm3
.
The minus sign implies that flow is from high to low concentration; hence diffu-
sion takes place down the concentration gradient. Note that D is the proportionality
constant in this law.

5.2.2 Ohm’s Law of Drift

Ohm’s Law of Drift relates the electrical field due to an charged molecule, i.e. an
ion, c, across a membrane to the drift of the ion across the membrane where drift is
the amount of ions that moves across the membrane per unit area. In mathematical
form

Jdrift = − ∂el E (5.2)

where it is important to define our variables and units very carefully. We have:
• Jdrift is the drift of the ion which has units of cmmolecules
2 −second .

• ∂el is electrical conductivity which has units of volt−cm−second


molecules
.
We know from basic physics that an electrical field is the negative gradient of
the potential so if V is the potential across the membrane and x is the variable that
measures our position on the membrane, we have

∂V
E=−
∂x
Now the valence of ion c is the charge on the ion as an integer; i.e. the valence of
Cl − is −1 and the valence of Ca +2 is +2. We let the valence of the ion c be denoted
by z. It is possible to derive the following relation between concentration [c] and the
electrical conductivity ∂el :
5.2 The Physical Laws of Ion Movement 101

∂el = μ z [c]

where dimensional analysis shows us that the proportionality constant μ, called the
cm2
mobility of ion c, has units volt−second . Hence, we can rewrite Ohm’s Law of Drift as

∂V
Jdri f t = −μz[c] (5.3)
∂x
We see that the drift of charged particles goes against the electrical gradient.

5.2.3 Einstein’s Relation

There is a relation between the diffusion coefficient D and the mobility μ of an ion
which is called Einstein’s Relation. It says

κT
D= μ (5.4)
q

where
• κ is Boltzmann’s constant which is 1.38 × 10−23 joule
◦K .

• T is the temperature in degrees Kelvin.


• q is the charge of the ion c which has units of coulombs.
To
 see that the units work out, we have to recall some basic physics. Electrical work is
F · d where F is the Coulomb force. Hence, coulomb force times distance it acts
which has units of newton − meters or joules. However, we also know the electrical
field E is the coulomb force over charge, F/q0 and hence, we can rewrite F = q0 E.
We can thus use the units of coulombs − volt/meter for the Coulomb force. Thus,
electrical work has units of (coulombs − volt/meter) * meter or coulombs − volts.
Thus, we know that electrical work is measured in volt − coulombs or joules. Hence,

we see κT cm2 2

q
μ has units volt−coulomb
◦K
K
coulombs volt−second
= cm
sec
which reduces to the units
of D.
Further, we see that Einstein’s Law says that diffusion and drift processes are addi-
tive because Ohm’s Law of Drift says Jdri f t is proportional to μ which by Einstein’s
Law is proportional to D and hence Jdiff c.

5.2.4 Space Charge Neutrality

When we look at a given volume element enclosed by a non permeable membrane, we


also know that the total charge due to positively charged ions, cations, and negatively
charged ions, anions is the same. If we have N cations ci with valences z i+ and M
102 5 Ion Movement

anions a j with valences z −j , we have the charge due to an ion is its valence times the
charge due to an electron e giving


N 
M
z i+ e [ci ] = |z −j | e [c j ] (5.5)
i=1 j=1

Of course, in a living cell, the membrane is permeable, so Eq. 5.5 is not valid!

5.2.5 Ions, Volts and a Simple Cell

The membrane capacitance of a typical cell is one micro fahrad per unit area. Typi-
cally, we use F to denote the unit fahrads and the unit of area is cm2 . Also, recall that
µF
1F = 1 coulomb
volt
. Thus, the typical capacitance is 1.0 cm 2 . Now our simple cell will be

a sphere of radius 25 µM with the inside and outside filled with a fluid. Let’s assume
the ion c is in the extracellular fluid with concentration [c] = 0.5 M and is inside the
cell with concentration [c] = 0.5 M. The inside and outside of the cell are separated
by a biological membrane of the type we have discussed. We show our simple cell
model in Fig. 5.3.
Right now in our picture, the number of ions on both sides of the membrane are the
same. What if one side had more or less ions than the other? These uncompensated
ions would produce a voltage difference across the membrane because charge is
capacitance times voltage (q = cV ). Hence, if we wanted to produce a one volt
potential difference across the membrane, we can compute how many uncompensated
ions, δ[c] would be needed:

10−6 F coulombs
δ[c] = × 1.0 V = 10−6
cm2 cm2

Fig. 5.3 A simple cell


5.2 The Physical Laws of Ion Movement 103

Now the typical voltage difference across a biological membrane is on the order of
100 millivolts or less (1 millivolt is 10−3 V and is abbreviated mV). The capacitance
of the membrane per cm2 multiplied by the desired voltage difference of 100 mV
will give the uncompensated charge, n, per cm2 we need. Thus, we find

10−6 coulombs coulombs


n= 2
× 10−1 V = 10−7
cm cm2
For convenience, let’s assume our ion c has a valence of −1. Now one electron has
a charge of e of 1.6 × 10−19 coulombs, so the ratio ne tells us that 6.3 × 1011 ions
cm2
are
needed. We know the surface area, S A, and volume, V ol, of our simple cell of radius r
are S A = 4πr 2 = 7.854 × 10−5 cm2 and V ol = 43 πr 3 = 6.545 × 10−8 cm3 . Thus,
the number of uncompensated ions per cell to get this voltage difference is m = n S A
giving
n
m= S A = 4.95 × 107 ions
e
This is a very tiny fraction of the total number of ions inside or outside the cell as
for a 0.5 M solution, inside the cell, there are

ions Mole
0.5 × N A × V ol = 1.97 × 1016 ions
Mole cm3
implying the percentage of uncompensated ions to give rise to a voltage difference
of 100 mV is only 2.51 × 10−7 %.

5.3 The Nernst–Planck Equation

Under physiological conditions, ion movement across the membrane is influenced


by both electric fields and concentration gradients. Let J denote the total flux, then
we will assume that we can add linearly the diffusion due to the molecule c and the
drift due to the ion c giving

J = Jdrift + Jdiff

Thus, applying Ohm’s Law 5.3 and Ficke’s Law 5.1, we have

∂V ∂[c]
J = −μ z [c] −D
∂x ∂x
Next, we use Einstein’s Relation 5.4 to replace the diffusion constant D to obtain
what is called the Nernst Planck equation.
104 5 Ion Movement

∂V κT ∂[c]
J = −μ z [c] − μ
∂x q ∂x
 
∂V κT ∂[c]
= −μ z [c] + (5.6)
∂x q ∂x

We can rewrite this result by moving to units that are cm2moles


−second
. To do this, note that
J
NA
has the proper units and using the Nernst–Planck equation 5.6 we obtain
 
J μ ∂V κT ∂[c]
=− z [c] + (5.7)
NA NA ∂x q ∂x

The relationship between charge and moles is given by Faraday’s Constant, F,


which has the value F = 96,480 coulombs
mole
. Hence, the total charge in a mole of ions
is the valence of the ion times Faraday’s constant F, z F. Multiply Eq. 5.7 by z F on
both sides to obtain
 
J μ zF ∂V κT ∂[c]
zF = − z [c] + (5.8)
NA NA ∂x q ∂x

This equation has the units of current per unit area because

J moles coulombs coulombs


zF = =
NA cm − second mole
2 cm2 − sec
amps
=
cm2
We can measure energy in two different units: joules (we use these in Boltzmann’s
constant κ) or calories. One calorie is the amount of energy needed to raise one gram
of water from 25 degrees Centigrade to 26 degrees Centigrade. So it is certainly
not obvious how to convert from joules to calories. An argument that is based on
low level principles from physics gives us the following conversion One Calorie is
4.184 joules. From introductory level physics, there is another fundamental physical
constant called the Gas Constant which is traditionally denoted by R. The constant
can be expressed in terms of calories or joules as follows:

1.98 calories 8.31 joules


R= ◦ K Mole
= ◦
K Mole
Hence, if we let q be the charge on one electron, e, we have for T is one degree
Kelvin
5.3 The Nernst–Planck Equation 105

κ (T = 1) 1.38 × 10−23 joules


◦K joules
= (1◦ K) −19
= 8.614 × 10−5
q=e 1.6 × 10 coulombs coulomb
R (T = 1) 8.31 ◦ Kjoules joules
= Mole
= 8.614 × 10−5
F 96,480 coulomb
Mole
coulomb

For later purposes, we will need to remember that

R(T = 1) joules
= 8.614 × 10−5 (5.9)
F coulomb
κT RT
Thus, since q
is the same as F
, they are interchangeable in Eq. 5.8 giving
 
J μ ∂V ∂[c]
I = zF = − z F [c]
2
+ z RT (5.10)
NA NA ∂x ∂x

where the symbol I denotes this current density amps


cm2
that we obtain with this equation.
The current I is the ion current that flows across the membrane per unit area due to
the forces acting on the ion c. Clearly, the next question to ask is what happens when
this system is at equilibrium and the net current is zero?

5.4 Equilibrium Conditions: The Nernst Equation

The current form of the Nernst–Planck equation given in Eq. 5.10 describes ionic
current flow driven by electro-chemical potentials (concentration gradients and elec-
tric fields). We know that the current I is opposite to ∂V
∂x
, with ∂[c]
∂x
if the valence z
∂[c]
is negative and against ∂x if the valence z is positive. When the net current due to
all of these contributions is zero, we have I = 0 and by the Nernst–Planck Current
Equation 5.10, we have
 
μ ∂V ∂[c]
0=− z F [c]
2
+ z RT
NA ∂x ∂x

implying

∂V ∂[c]
z 2 F [c] = −z RT
∂x ∂x
or since there is only one independent variable x

dV RT 1 d[c]
=−
dx z F [c] d x
106 5 Ion Movement

Now let x1 and x2 be the start and end position of the membrane, respectively.
Now, integrate between positions x1 and x2 :
 x2  x2
dV RT d[c]
dx = − dx
x1 dx zF x1 [c]

Now assume that the membrane voltage and the concentration [c] are functions of
the position x in the membrane and hence can be written as V (x) and [c](x); we
will then let V (x1 ) = V1 , V (x2 ) = V2 , [c](x1 ) = [c]1 and [c](x2 ) = [c]2 . Then, upon
integrating, we find
 V2  [c]2
RT d[c]
dV = −
V1 z F [c]1 [c]
RT [c]2
V2 − V1 = − ln
zF [c]1

It is traditional to define the membrane potential Vm of a cell to be the difference


between the inside (Vin ) and outside potential (Vout ); hence we say

Vm = Vin − Vout

For a given ion c, the equilibrium potential of the ion is denoted by E c and is defined
as the potential across the membrane which gives a zero Nernst–Planck current. We
will let the position x1 be the place where the membrane starts and x2 , the place where
the membrane ends. Here, the thickness of the membrane is not really important. So
the potential at x1 will be considered the inner potential Vin and the potential at x2 will
be considered the inner potential Vout . From our discussions above, we see that the
assumption that I is zero implies that the difference V1 − V2 is −E c and so labeling
[c]2 and [c]1 as [c]out and [c]in respectively, we arrive at the following equation:

RT [c]out
Ec = ln (5.11)
zF [c]in

This important equation is called the Nernst equation and is an explicit expression
for the equilibrium potential of an ion species in terms of its concentrations inside
and outside of the cell membrane.

5.4.1 An Example

Let’s compute some equilibrium potentials. In Table 5.1, we see some typical inner
and outer ion concentrations and the corresponding equilibrium voltages. Unless
otherwise noted, we will assume a temperature of 70 degrees Fahrenheit—about
5.4 Equilibrium Conditions: The Nernst Equation 107

normal room temperature—which is 21.11 Celsius and 294.11 Kelvin as Kelvin is


273 plus Celsius. Since the factor FR is always a constant here, note

R 8.31 joules mV
= = 0.0861 (5.12)
F 96,480 coulomb − degrees Kelvin degrees Kelvin

Let’s look at some examples of this sort of calculation. While it is not hard to do
this calculation, we have found that all the different units are confusing to students
coming from the mixed background we see. Now at a temperature of 294.11 Kelvin,
RT
F
becomes 25.32 mV. Hence, all of our equilibrium voltage calculations take the
form
1 [c]out
Ec = 25.32 ln mV
z [c]in

where all we have to do is to use the correct valence of our ion c. Also, remember
that the symbol ln means we should use a natural logarithm! Here are some explicit
examples for this temperature:
1. For frog muscle, typical inner and outer concentrations for potassium are [K + ]out
is 2.25 mM (the unit mM means milliMoles) with [K + ]in at 124.0 mM. Then,
since z is +1, we have

2.25
E K + = 25.32 ln mV = 25.32 × (−4.0094) mV = −101.5168 mV
124.0

2. For frog muscle, typical inner and outer concentrations for chlorine are [Cl − ]out
is 77.5 mM with [Cl − ]in at 1.5 mM. Then, since z is −1, we have

77.5
E Cl − = −25.32 ln mV = −25.32 × (3.944) mV = −99.88 mV
1.5

3. For frog muscle, typical inner and outer concentrations for Calcium are [Ca +2 ]out
is 2.1 mM (the unit mM means milliMoles) with [Ca +2 ]in at 10−4 mM. Then, since
z is +2, we have

2.1
E Ca + = 0.5 × 25.32 ln mV = 12.66 × (9.9523) mV = 126.00 mV
10−4
We summarize the results above as well as two other sets of calculations in Table 5.1.
In the first two parts of the table we use a temperature of 294.11 Kelvin and the
conversion RT F
is 25.32 mV. In the last part, the temperature is higher (310 Kelvin)
and so RTF
becomes 26.69 mV. All concentrations are given in mM.
108 5 Ion Movement

Table 5.1 Typical inner and outer ion concentrations


[c]in [c]out Ec
Frog muscle (Conway 1957)
K+ 124.0 2.25 −101.52
Na+ 10.4 109.0 59.30
Cl− 1.5 77.5 −99.88
Ca+2 10−4 2.1 126.00
Squid axon (Hodgkin 1964)
K+ 400.0 20.0 −75.85
Na+ 50.0 440.0 55.06
Cl− 40.0–150.0 560.0 −66.82−33.35
Ca+2 10−4 10.0 145.75
Mammalian cell
K+ 140.0 5.0 −88.94
Na + 5.0–15.0 145.0 89.87−60.55
Cl− 4.0 110.0 −88.46
Ca+2 10−4 2.5–5.0 135.13−144.39

5.5 One Ion Nernst Computations in MatLab

Now let’s do some calculations using MatLab for various ions. First, we will write a
MatLab function to compute the Nernst voltage. Here is a simple MatLab function
to do this.

Listing 5.1: Computing The Nernst Voltage simply


f u n c t i o n v o l t a g e = N e r n s t ( v a l e n c e , Temperature , InConc , OutConc )
%
% compute N e r n s t v o l t a g e f o r a g i v e n i o n
4 %
R = 8.31;
T = Temperature + 2 7 3 . 0 ;
F = 96480.0;
P r e f i x = (R∗T) / ( v a l e n c e ∗F ) ;
9 %
% output v o l t a g e in m i l l i v o l t s
%
v o l t a g e = 1 0 0 0 . 0 ∗ ( P r e f i x ∗ l o g ( OutConc / InConc ) ) ;
end

It is then straightforward to compute a Nernst potential. We are computing the Nernst


potential for a potassium ion. The valence is thus 1. We will use a temperature in
5.5 One Ion Nernst Computations in MatLab 109

Centigrade of 37 degrees C (quite hot!) and the inside concentration is 124 milliMoles
with the outside concentration 2.5 milliMoles.

Listing 5.2: Finding Potassium voltage


% Our f u n c t i o n e x p e c t s t h e a rg m ents t o b e
2 % e n t e r e d as f o l l o w s :
%
% v a r i a b l e v a l e n c e t e m p e r a t u r e (C) I n s i d e C o n c OutsideConc
% | | | | |
% v v v v v
7 % E K = Nernst ( 1 , 37.0 , 124 , 2.5)
%
% so h e r e i s our l i n e
E K = Nernst ( 1 , 3 7 . 0 , 1 2 4 , 2 . 5 )

This function call produces the following output (edited to remove extra blank lines).

Listing 5.3: Nernst Output for Potassium


valence =
1
Temperature =
37
5 OutConc =
2.5000
InConc =
124.5000
T =
10 310
F =
96480
Prefix =
0.0267
15 E K =
−104.2400

5.5.1 Homework

Exercise 5.5.1 Use the MatLab functions we have written above to generate a
plot of the Nernst potential versus inside concentration for the Sodium ion at
T = 20 degrees C. Assume the outside concentration is always 440 milliMoles and
let the inner concentration vary from 2 to 120 in 200 uniformly spaced steps.

Exercise 5.5.2 Rewrite our Nernst and NernstMemVolt functions to accept temper-
ature arguments in degrees Fahrenheit.

Exercise 5.5.3 Rewrite our NernstMemVolt function for just Sodium and Potassium
ions.
110 5 Ion Movement

Exercise 5.5.4 For the following outside and inside ion concentrations, calculate
the Nernst voltages at equilibrium for the temperatures 45, 55, 65 and 72 ◦ F.

[c]in [c]out
K+ 130.0 5.25
Na+ 15.4 129.0
Cl− 1.8 77.5
Ca+2 10−5 3.1

5.6 Electrical Signaling

The electrical potential across the membrane is determined by how well molecules
get through the membrane (its permeability) and the concentration gradients for the
ions of interest. To get a handle on this let’s look at an imaginary cell which we
will visualize as an array. The two vertical sides you see on each side of the array
represent the cell membrane. There is cell membrane on the top and bottom of this
array also, but we don’t show it. We will label the part outside the box as the Outside
and the part inside as Inside. If we wish to add a way for a specific type of ion to
enter the cell, we will label this entry port as gates on the bottom of the array. We
will assume our temperature is 70 ◦ F which is 21.11 ◦ C and 294.11 ◦ K.

5.6.1 The Cell Prior to K Gates

To get started, let’s assume no potential difference across the membrane and add
100 mM of KCl to both the inside and outside of the cell as shown.

Inside
Outside
100 mM 100 mM
K Cl
K Cl

The KCl promptly disassociates into an equal amount of K + and Cl − in both the
inside and outside of the cell as shown below:
5.6 Electrical Signaling 111

Inside
Outside
100 mM K + 100 mM K +
100 mM Cl −
100 mM Cl −

5.6.2 The Cell with K + Gates

Now, we add to the cell channels that are selectively permeable to the ion K + .
These gates allow K + to flow back and forth across the membrane until there is a
balance between the chemical diffusion force and the electric force. We don’t expect
a nonzero equilibrium potential because there is charge and concentration balance
already. Using Nernst’s Equation 5.11 we see since z is 1 that for our temperature,
RT
zF
is 25.32 mV and

RT [K + ]out 100
EK = ln −
= 25.32 ln =0
F [K ]in 100

Inside
(K + Gates)
Outside
100 mM K + 100 mM K +
100 mM Cl −
100 mM Cl −

5.6.2.1 The Cell with Outer KCl Reduced

Now reduce the outside KCl to 10 mM giving the following cell:

Inside
(K + Gates)
Outside
10 mM K + 100 mM K +
10 mM Cl −
100 mM Cl −
112 5 Ion Movement

This set up a concentration gradient with an implied chemical and electrical force.
We see
10
E K = 25.32 ln
100
= −58.30

Hence, Vin − Vout is −58.30 mV and so the outside potential is 58.30 more than
the inside; more commonly, we say the inside is 58.30 mV more negative than the
outside.
Homework
Exercise 5.6.1 Consider a cell permeable to K + with the following concentrations
on ions:

Inside
(K + Gates)
Outside
90 mM K + 120 mM K +
90 mM Cl −
120 mM Cl −

Find the equilibrium Potassium voltage at temperature 69 ◦ F.

5.6.3 The Cell with NaCl Inside and Outside Changes

Now add 100 mM NaCl to the outside and 10 mM to the inside of the cell. We then
have

Inside
(K + Gates)
Outside
10 mM K + 100 mM N a + 100 mM K + 10 mM N a +
10 mM Cl − 100 mM Cl −
100 mM Cl − 10 mM Cl −

Note there is charge balance inside and outside but since the membrane is permeable
to K + , there is still a concentration gradient for K + . There is no concentration
gradient for Cl − . Since the membrane wall is not permeable to N a + , the N a +
5.6 Electrical Signaling 113

concentration gradient has no effect. The K + concentration gradient is still the same
as our previous example, the equilibrium voltage for potassium remains the same.

5.6.4 The Cell with N a+ Gates

Next replace the potassium gates with sodium gates as shown below. We can then
use the Nernst equation to calculate the equilibrium voltage for N a + :

100
E N a = 25.32 ln
10
= 58.30

which is the exact opposite of the equilibrium voltage for potassium.

Inside
(N a + Gates)
Outside
10 mM K + 100 mM N a + 100 mM K + 10 mM N a +
10 mM Cl − 100 mM Cl −
100 mM Cl − 10 mM Cl −

5.6.5 The Nernst Equation for Two Ions

Let’s look at what happens if the cell has two types of gates. The cell now looks like
this:

Inside
(K + Gates)
Outside (N a + Gates)
10 mM K + 100 mM N a +

10 mM Cl − 100 mM Cl − 100 mM K + 10 mM N a +

100 mM Cl − 10 mM Cl −

There are now two currents: K + is leaving the cell because there is more K + inside
than outside and N a + is going into the cell because there is more N a + outside. What
determines the resting potential now?
114 5 Ion Movement

Recall Ohm’s Law for a simple circuit: the current across a resistor is the voltage
across the resistor divided by the resistance; in familiar terms I = VR using time
honored symbols for current, voltage and resistance. It is easy to see how this idea
fits here: there is resistance to the movement of an ion through the membrane. Since
I = R1 V , we see that the ion current through the membrane is proportional to the
resistance to that flow. The term R1 seems to be a nice measure of how well ions
flow or conduct through the membrane. We will call R1 the conductance of the ion
through the membrane. Conductance is generally denoted by the symbol g. Clearly,
the resistance and conductance associated to a given ion are things that will require
very complex modeling even if they are pretty straightforward concepts. We will
develop some very sophisticated models in future chapters, but for now, for an ion
c, we will use

Ic = gc (Vm − E c )

where E c is the equilibrium voltage for the ion c that comes from the Nernst Equation,
Ic is the ionic current for ion c and gc is the conductance. Finally, we denote the voltage
across the membrane to be Vm . Note the difference between the membrane voltage
and the equilibrium ion voltage provides the electromotive force or emf that drives
the ion. In our cell, we have both potassium and sodium ions, so we have

i K = g K (Vm − E K ), i N a = g N a (Vm − E N a ).

At steady state, the current flows due to the two ions should sum to zero; hence

iK + iNa = 0

implying

0 = g K (Vm − E K ) + g N a (Vm − E N a )

which we can solve for the membrane voltage at equilibrium:


gK gN a
Vm = EK + ENa
gK + gN a gK + gN a

You will note that although we have already calculated E K and E N a here, we are not
able to compute Vm because we do not know the particular ionic conductances.

5.6.5.1 Homework

Let’s look at what happens if the cell has K + and N a + gates. The cell now looks
like this:
5.6 Electrical Signaling 115

Inside
(K + Gates)
Outside (N a + Gates)
20 mM K + 130 mM N a +

20 mM Cl − 130 mM Cl − 80 mM K + 10 mM N a +

15 mM Cl − 15 mM Cl −

Exercise 5.6.2 Compute E K and E N a at temperature 71 ◦ F .

Exercise 5.6.3 Compute the equilibrium membrane voltage for a g K to g N a ratio


of 5.0.

Exercise 5.6.4 Compute the equilibrium membrane voltage for a g K to g N a ratio


of 3.0.

Exercise 5.6.5 Compute the equilibrium membrane voltage for a g K to g N a ratio


of 2.0.

5.6.6 The Nernst Equation for More Than Two Ions

Consider Fig. 5.4. We see we are thinking of a patch of membrane as a parallel


circuit with one branch for each of the three ions K + , N a + and Cl − and a branch for
the capacitance of the membrane. We think of this patch of membrane as having a
voltage difference of Vm across it. In general, there will current that flows through each
branch. We label these currents as I K , I N a , ICl and Ic where Ic denotes the capacitative
current. The conductances for each ion are labeled with resistance symbols with a
line through them to indicate that these conductances might be variable in a real
model. For right now, we will assume all of these conductances are constant.
Each of our ionic currents have the form

i ion = gc (Vm − E c )

where Vm , as mentioned, is the actual membrane voltage, c denotes our ion, gc is the
conductance associated with ion c and E c is the Nernst equilibrium voltage. Hence
for three ions, potassium (K + ), sodium (N a + ) and chlorine (Cl − ), we have

i K = g K (Vm − E K ), i N a = g N a (Vm − E N a ), i Cl = gCl (Vm − E Cl )

There is also a capacitative current. We know the voltage drop across the capacitor
Cm is given by Vqmm ; hence, the charge across the capacitor is Cm Vm implying the
capacitative current is
116 5 Ion Movement

Fig. 5.4 A simple membrane model

d Vm
i m = Cm
dt
At steady state, i m is zero and the ionic currents must sum to zero giving

i K + i N a + i Cl = 0

Hence,

0 = g K (Vm − E K ) + g N a (Vm − E N a ) + gCl (Vm − E Cl )

leading to a Nernst Voltage equation for the equilibrium membrane voltage Vm of a


membrane permeable to several ions:
gK gN a gCl
Vm = EK + ENa + E Cl
g K + g N a + gCl g K + g N a + gCl g K + g N a + gCl

We usually rewrite this in terms of conductance ratios: r N a is the g N a to g K ratio and


rCl is the gCl to g K ratio:

1 rNa rCl
Vm = EK + ENa + E Cl
1 + r N a + rCl 1 + r N a + rCl 1 + r N a + rCl

Hence, if we are given the needed conductance ratios, we can compute the membrane
voltage at equilibrium for multiple ions. Some comments are in order:
• By convention, we set Vout to be 0 so that Vm = Vin − Vout is −58.3 mV in our
first K + gate example.
5.6 Electrical Signaling 117

• These equations are only approximately true, but still of great importance in guid-
ing our understanding.
• Ion currents flowing through a channel try to move the membrane potential toward
the equilibrium potential value for that ion.
• If several different ion channels are open, the summed currents drive the membrane
potential to a value determined by the relative conductances of the ions.
• Since an ion channel is open briefly, the membrane potentials can’t stabilize and
so there will always be transient ion currents. For example, if N a + channels pop
open briefly, there will be transient N a + currents.
Finally, let’s do a simple example: assume there are just sodium and potassium gates
and the relative conductances of N a + and K + are 4 : 1. Then r N a is 4 and for the
concentrations in our examples above:

1 4
Vm = (−58.3) mV + (58.3) mV = 34.98 mV
5 5

5.6.6.1 Homework

Exercise 5.6.6 Assume we know


• The temperature is 67 degrees Fahrenheit.
• The ratio g N a to g K is 0.08.
• The ratio of gCl to g K is 0.12.
• The inside and outside concentrations for potassium are 410 and 35 milliMoles
respectively.
• The inside and outside concentrations for sodium are 89 and 407 milliMoles
respectively.
• The inside and outside concentrations for chlorine are 124 and 450 milliMoles
respectively.
Calculate the equilibrium membrane voltage.

5.6.7 Multiple Ion Nernst Computations in MatLab

Now let’s do some calculations using MatLab for this situation. First, we will write
a MatLab function to compute the Nernst voltage across the membrane using our
conductance model. Here is a simple MatLab function to do this which uses our
previous Nernst function. We will build a function which assumes the membrane is
permeable to using potassium, sodium and chlorine ions.
118 5 Ion Movement

Listing 5.4: Calculating the Nernst voltage: NernstMemVolt


f u n c t i o n v o l t a g e = NernstMemVolt (T , gNa2gK , gCl2gK , InK , OutK , InNa , OutNa ,
InCl , OutCl )
%
% We assume t h r e e i o n s and compute t h e membrane v o l t a g e
4 %
% T i s the temperature in degrees Celsius
% gNa2gK i s t h e gNa t o gK c o n d u c t a n c e r a t i o
% gCl2GK i s t h e g C l t o gK c o n d u c t a n c e r a t i o
% InK and OutK a r e t h e i n s i d e and o u t s i d e p o t a s s i u m i o n
concentrations
9 % InNa and OutNa a r e t h e i n s i d e and o u t s i d e sodium i o n c o n c e n t r a t i o n s
% I n C l and OutCl a r e t h e i n s i d e and o u t s i d e c h l o r i n e i o n
concentrations
%
% F i n d e q u i l i b r i u m membrane v o l t a g e s f o r e a c h i o n
%
14 E K = N e r n s t ( 1 , T , InK , OutK ) ;
E Na = N e r n s t ( 1 , T , InNa , OutNa ) ;
E Cl = N e r n s t ( −1 ,T , InCl , OutCl ) ;
%
% F i n d membrane v o l t a g e f o r c e l l
19 %
denom = 1 . 0 + gNa2gK + gCl2gK ;
v o l t a g e = ( E K + gNa2gK ∗ E Na + gCl2gK ∗ E Cl ) /denom ;
end

Let’s try this out for the following example: we assume we know
• The temperature is 20 degrees Celsius.
• The ratio g N a to g K is 0.03.
• The ratio of gC to g K is 0.1.
• The inside and outside concentrations for potassium are 400 and 20 milliMoles
respectively.
• The inside and outside concentrations for sodium are 50 and 440 milliMoles
respectively.
• The inside and outside concentrations for chlorine are 40 and 560 milliMoles
respectively.
We then enter the function call into MatLab like this:

Listing 5.5: Finding the membrane voltage using conductances


NernstMemVolt ( 2 0 , 0 . 0 3 , 0 . 1 , 4 0 0 , 2 0 , 5 0 , 4 4 0 , 4 0 , 5 6 0 )
ans =
3 −71.3414

If there was a explosive change in the g N a to g K ratio (this happens in a typical


axonal pulse which we will discuss in later chapters), we see a large swing of the
equilibrium membrane voltage from the previous −71.34 to 46.02 mV. The code
below resets this ratio to 15 from its previous value of 0.03:
5.7 Ion Flow 119

Listing 5.6: Increasing the Sodium to Potassium Conductance ratio


NernstMemVolt ( 2 0 , 1 5 . 0 , 0 . 1 , 4 0 0 , 2 0 , 5 0 , 4 4 0 , 4 0 , 5 6 0 )
2 ans =
46.0241

5.7 Ion Flow

Our abstract cell is a spherical ball which encloses a fluid called cytoplasm. The
surface of the ball is actually a membrane with an inner and outer part. Outside
the cell there is a solution called the extracellular fluid. Both the cytoplasm and
extracellular fluid contain many molecules, polypeptides and proteins disassociated
into ions as well as sequestered into storage units. In this chapter, we will be interested
in what this biological membrane is and how we can model the flow of ionized species
through it. This modeling is difficult because some of the ions we are interested in
can diffuse or drift across the membrane and others must be allowed entry through
specialized holes in the membrane called gates or even escorted, i.e. transported or
pumped, through the membrane by specialized helper molecules.

5.7.1 Transport Mechanisms

There are five general mechanisms by which molecules are moved across biological
membranes. All of these methods operate simultaneously so we should know a little
about all of them.

• Diffusion: here dissolved substances are transported because of concentration gra-


dient. These substances can go right through the membrane. Some examples are
water, certain molecules known as anesthetics and other large proteins which are
soluble in the lipids which comprise the membrane such as the hormones known
as steroids.
• Transport Through Water Channels: water will flow from a region in which a
dissolved substance is at high concentration in order to equalize a high–low con-
centration gradient. This process is called osmosis and the force associated with it
is called osmotic pressure. The biological membranes are thus semi-permeable to
water and there are channels or pores in the membrane which selectively allow the
passage of water molecules. In Fig. 5.5b, we see an abstract picture of the process
of diffusion (part a) and the water channels (part b). The movement of water from
a high to low concentration environment of the ion c is shown in Fig. 5.5a.
• Transport Through Gated Channels: some ion species are able to move through a
membrane because there are special proteins embedded in the membrane which
can be visualized as a cylinder whose throat can be open or blocked depending on
some external signal. This external signal can be the voltage across the membrane
120 5 Ion Movement

Fig. 5.5 Transport through water channels. a Osmosis. b Diffusion and water channel transport

or a molecule called a trigger. If the external signal is voltage, we call these channels
voltage gates. When the gate is open, the ion is able to physically move through
the opening.
• Carrier Mediated Transport: in this case, the dissolved substance combines with
a carrier molecule on the one side of the membrane. The resulting complex that
is formed moves through the membrane. At the opposite end of the membrane,
the solute is released from the complex. A probable abstraction of this process is
shown in Fig. 5.6.
• Ion Pumps: ions can also be transported by a mechanism which is linked to the
addition of an OH group to the molecule adenine triphosphate. This process is
called hydrolysis and this common molecule is abbreviated ATP. The addition
of the hydroxyl group to ATP liberates energy. This energy is used to move ions
against their concentration gradient.

In Fig. 5.7, parts c through e, we see abstractions of the remaining types of transport
embedded in a membrane.

5.7.2 Ion Channels

In Fig. 5.8, we see a schematic of a typical voltage gate. Note that the inside of the
gate shows a structure which can be in an open or closed position. The outside of
the gate has a variety of molecules with sugar residues which physically extend into
the extracellular fluid and carry negative charges on their tips. At the outer edge of
the gate, you see a narrowing of the channel opening which is called the selectivity
filter. As we have discussed, proteins can take on very complex three dimensional
shapes. Often, their actual physical shape can switch from one form to another due
to some external signal such as voltage. This is called a conformational change. In
a voltage gate, the molecule which can block the inner throat of the gate moves from
5.7 Ion Flow 121

Fig. 5.6 A carrier moves a solute through the membrane

Fig. 5.7 Molecular transport mechanisms

its blocking position to its open position due to such a conformational change. In
fact, this molecule can also be in between open and closed as well. The voltage gated
channel is actually a protein macromolecule which is inserted into an opening in the
membrane called a pore. We note that this macromolecule is quite big (1800–4000
amino acids) with one or more polypeptide chains and 100’s of sugar residues hang
off the extracellular face. When open, the channel is a water filled pore with a fairly
122 5 Ion Movement

Fig. 5.8 Typical voltage channel

large inner diameter which would allow the passage of many things except that there
is one narrow stretch of the channel called a selectivity filter which inhibits access.
The inside of the pore is lined with hydrophilic amino acids which therefore like
being near the water in the pore and the outside of the pore is lined with hydrophobic
amino acids which therefore dislike water contact. These therefore lie next to the lipid
bilayer. Ion concentration gradients can be maintained by selective permeabilities of
the membrane to various ions. Most membranes are permeable to K + , maybe Cl −
and much less permeable to N a + and Ca +2 . This type of passage of ions through
the membrane requires no energy and so it is called the passive distribution of the
5.7 Ion Flow 123

ions. If there is no other way to transport ions, a cell membrane permeable to several
ion species will reach an equilibrium potential determined by the Nernst equation.
Let c+n denote a cation of valence n and a −m be an anion of valence −n. Then the
Nernst equilibrium potentials for these ions are given by

RT [c+n ]out RT [a −m ]out


Ec = ln +n Ea = ln −m
nF [c ]in −m F [a ]in

At equilibrium, the ionic currents must sum to zero forcing these two potentials to
be the same. Hence, E c is the same as E a and we find

RT [c+n ]out RT [a −m ]out


ln +n = ln −m
nF [c ]in −m F [a ]in

implying

m [c+n ]out [a −m ]in


ln +n = ln −m
n [c ]in [a ]out

Exponentiating these expressions, we find that the ion concentrations must satisfy
the following expression which is known as Donnan’s Law of Equilibrium.
1 1
[c+n ]out m
[a −m ]in n
= −m
[c+n ]in [a ]out

5.7.2.1 K + and Cl − Donnan Equilibrium

For example, for the ions K + and Cl − ,

Inside
Outside
[K + ]out [K + ]in
[Cl − ]out
[Cl − ]in

and we would have that at Donnan equilibrium, the inner and outer ion concentrations
would satisfy

[K + ]out [Cl − ]in


=
[K + ]in [Cl − ]out
124 5 Ion Movement

or

[K + ]out [Cl − ]out = [K + ]in [Cl − ]in

5.7.2.2 K + , Cl − and A−m Donnan Equilibrium

Now assume that there are other negative ions in the cell, say A−m . Then, [A−m ]out
is zero and we have

Inside
Outside
[K + ]out [K + ]in
[Cl − ]out
[Cl − ]in [A−m ]in

Then because there must be charge neutrality, [K + ]in = [Cl − ]in + [A−m ]in and
[K + ]out = [Cl − ]out . Also, we must have the usual Donnan Equilibrium state (re-
member the ion A−m does not play a role in this):

[K + ]out [Cl − ]out = [K + ]in [Cl − ]in

Thus,

[K + ]in
2
= [K + ]in ([Cl − ]in + [A−m ]in )
= [K + ]in [Cl − ]in + [K + ]in [A−m ]in
= [K + ]out [Cl − ]out + [K + ]in [A−m ]in
= [K + ]2out + [K + ]in [A−m ]in
> [K + ]2out

Hence, if we can only use passive transport mechanisms, we must have

[K + ]in > [K + ]out

5.7.3 Active Transport Using Pumps

There are many pumps within a cell that move substances in or out of a cell with or
against a concentration gradient.
• N a + K + Pump: this is a transport mechanism driven by the energy derived from
the hydrolysis of ATP. Here 3 N a + ions are pumped out and 2 K + ions are pumped
5.7 Ion Flow 125

in. So this pump gives us sodium and potassium currents which raise [N a + ]out and
[K + ]in and decrease [N a + ]in and [K + ]out . From Table 5.1, we see that [N a + ]out
is typically bigger, so this pump is pushing N a + out against its concentration
gradient and so it costs energy.
• N a + Ca +2 Pump: this pump drives out 3 N a + ions inside the cell for every Ca +2
ion that is moved out. Hence, this pump gives us sodium and calcium currents
which raise [N a + ]in and [Ca +2 ]out and decrease [N a + ]out and [Ca +2 ]in . Here,
the N a + movement is with its concentration gradient and so there is no energy
cost.
• Plasma membrane Ca +2 Pump: this pump is also driven by the hydrolysis of ATP.
Here, Ca +2 is pumped into a storage facility inside the cell called the endoplasmic
reticulum which therefore takes Ca + 2 out of the cytoplasm and so brings down
[Ca +2 ]in .
• H C O3− Cl − Exchange: this is driven by the N a + concentration gradient and
pumps H C O3− into the cell and Cl − out of the cell.
• Cl − N a + K + Co transport: This is driven by the influx of N a + into the cell. For
every one N a + and K + that are pumped into the cell via this mechanism, 2 Cl −
are driven out.

5.7.4 A Simple Compartment Model

Consider a system which has two compartments filled with ions and a membrane
with K + and Cl − gates between the two compartments as shown below:

Compartment One Compartment Two


(Cl − Gates) (Cl − Gates)
(K + Gates) (K + Gates)

100 mM A− 0 mM A−

150 mM K + 150 mM K +

50 mM Cl − 150 mM Cl −

We will assume the system is held at the temperature of 70 degree Fahrenheit—


about normal room temperature—which is 21.11 Celsius and 294.11 Kelvin. This
implies our Nernst conversion factor is 25.32 mV for K + and −25.32 for Cl − . Is this
system in electrochemical equilibrium or ECE? In each compartment, we do have
space charge neutrality as in Compartment One, 150 mM of K + balances 100 mM of
A− and 50 mM of Cl − ; and in Compartment Two, 150 mM of K + balances 150 mM
of Cl − . However, Cl − is not concentration balanced and so Cl − is not at ECE
implying that Cl − will diffuse into Compartment Two from Compartment One. This
diffusion shifts ions in the compartments to the new values
126 5 Ion Movement

Compartment One Compartment Two


(Cl − Gates) (Cl − Gates)
(K + Gates) (K + Gates)

100 mM A− 0 mM A−

150 mM K + 150 mM K +

100 mM Cl − 100 mM Cl −

So to get concentration balance, 50 Cl − moves Compartment Two to Compartment


One. Now counting ion charges in each compartment, we see that we have lost space
charge neutrality. We can regain this by shifting 50 mM of K + from Compartment
Two to Compartment One to give:

Compartment One Compartment Two


(Cl − Gates) (Cl − Gates)
(K + Gates) (K + Gates)

100 mM A− 0 mM A−

200 mM K + 100 mM K +

100 mM Cl − 100 mM Cl −

Now we see that there is a concentration imbalance in K + ! The point here is that
this kind of analysis, while interesting, is so qualitative that it doesn’t give us the
final answer quickly! To get to the final punch line, we just need to find the Donnan
Equilibrium point. This is where

[K + ] One [Cl − ] One = [K + ]T wo [Cl − ]T wo

From our discussion above, we know that the number of mM’s of K + and Cl − that
move from Compartment Two to Compartment One will always be the same in order
to satisfy space charge neutrality. Let x denote this amount. Then we must have

[K + ] One = 150 + x
[K + ]T wo = 150 − x
[Cl − ]T wo = 150 − x
[Cl − ] One = 50 + x
5.7 Ion Flow 127

yielding after a little algebra:

(150 + x) (50 + x) = (150 − x) (150 − x)


7500 + 200x + x 2 = 22,500 − 300x + x 2
500x = 15,000
x = 30

So at ECE, we have

Compartment One Compartment Two


(Cl − Gates) (Cl − Gates)
(K + Gates) (K + Gates)

100 mM A− 0 mM A−

180 mM K + 120 mM K +

80 mM Cl − 120 mM Cl −

What are the membrane voltages? Of course, they should match! Recall, in the
derivation of the Nernst equation, the voltage difference for ion c between side 2 and
1 was
RT [c]2
E c = V1 − V2 = ln
zF [c]1

Here, Compartment One plays the role of side 1 and Compartment Two plays the
role of side 2. So for K + , we have

[K + ]T wo 120
E K = VOne − VT wo = 25.32 ln +
= 25.32 ln = −10.27 mV
[K ] One 180

and for Cl − ,

[Cl − ]T wo 120
E Cl = VOne − VT wo = −25.32 ln −
= −25.32 ln = −10.27 mV
[Cl ] One 80

Are we at osmotic equilibrium? To see this, we need to add up how many ions are in
each compartment. In Compartment One, there are 360 ions and in Compartment Two
there are 240 ions. Since there are more ions in Compartment One than Compartment
Two, water will flow from Compartment One to Compartment Two to try to dilute
the ionic strength in Compartment One. We are ignoring this effect here.
128 5 Ion Movement

5.7.4.1 Homework

Exercise 5.7.1 Consider a system which has two compartments filled with ions and
a membrane with K + and Cl − gates between the two compartments as shown below:

Compartment One Compartment Two


(Cl − Gates) (Cl − Gates)
(K + Gates) (K + Gates)

80 mM A− 30 mM A−

160 mM K + 50 mM K +

80 mM Cl − 20 mM Cl −

Note the ion A can’t pass between compartments. Assume the system is held at the
temperature of 70 degree Fahrenheit.

1. Find the concentrations of ions that this system has at ECE.


2. For the ECE ion concentrations, calculate E Cl and E K .

5.8 Movement of Ions Across Biological Membranes

We now will work our way through another way to view the movement of ions across
biological membranes that was developed by Goldman in 1943 and Hodgkin and Katz
in 1949. This is the Goldman–Hodgkin–Katz or GHK model. Going through all
of this will give you an increased appreciation for both the kind of modeling we
need to do: what to keep from the science, what to throw away and what tools to
use for the model itself . We start with defining carefully what we mean by the word
permeability. We have used this word before but always in a qualitative sense. Now
we will be quantitative.

5.8.1 Membrane Permeability

Let’s consider a substance c moving across a biological membrane. We will assume


that the relationship between the number of moles of c moving across the membrane
in unit time and unit area is proportional to the change in concentration of c. This
gives

Jmolar = −P [c] (5.13)


5.8 Movement of Ions Across Biological Membranes 129

where
• Jmolar is the molar flux which is in the units cm2moles
−second
.
• P is the membrane permeability of the ion c which has units of cm
second
.
• [] is the change in the concentration of c measured in the units moles
cm 3 .
Ficke’s Law of diffusion gives Jdiff = −D ∂∂x[c] where Jdiff is measured in cmmolecules
2 −second .

Hence, we can convert to cm2moles


−second
by dividing by Avogadro’s number N A . This
gives (remember, partial differentiation becomes regular differentiation when there
is just one variable)

Jdiff Dm d[c]
=−
NA NA dx

where we now explicitly label the diffusion constant as belonging to the membrane.
These two fluxes should be the same; hence

Dm d[c]
Jmolar = −P [c] = − (5.14)
NA dx

We will want to use the above equation for the concentration of c that is in
the membrane itself. So we need to distinguish from the concentration of c inside
and outside the cell and the concentration in the membrane. We will let [c] denote
the concentration inside and outside the cell and [cm ], the concentration inside the
membrane. Hence, we have

Dm d[cm ]
Jmolar = −P [c] = − (5.15)
NA dx

Now a substance will probably dissolve differently in the cellular solution and in the
biological membrane, let’s model this quantitatively as follows: Let [c]in denote the
concentration of c inside the cell, and [c]out denote the concentration of c outside the
cell. The membrane has two sides; the side facing into the cell and the side facing
to the outside of the cell. If we took a slice through the cell, we would see a straight
line along which we can measure our position in the cell by the variable x. We have
x is 0 when we are at the center of our spherical cell and x is x0 when we reach the
inside wall of the membrane (i.e. x0 is the radius of the cell for this slice). We will
assume that the thickness of the membrane is a uniform . Hence, we are at position
x0 +  when we come to the outer boundary of the membrane. Inside the membrane,
we will let [cm ] denote the concentration of c. We know the membrane concentration
will be some fraction of the cell concentration. So

[cm ](x0 + ) = βo [c]out


[cm ](x0 ) = βi [c]in
130 5 Ion Movement

for some constants βi and βo . The ratio of the boundary concentrations of c and the
membrane concentrations is an important parameter. From the above discussions,
we see these critical ratios are given by:

[cm ]x0 +
βo =
[c]out
[cm ]x0
βi =
[c]in

For this model, we will assume that these ratios are the same: i.e. βo = βi ; this com-
mon value will be denoted by β. The parameter β is called the partition coefficient
between the solution and the membrane. We will also assume that the membrane
concentration [cm ] varies linearly across the membrane from [c]in at x0 to [c]out at
x0 + . This model is shown in Fig. 5.9: Thus, since we assume the concentration
inside the membrane is linear, we have for some constants a and b:

[cm ](x) = a x + b
[cm ](x0 ) = [cm ]in = β[c]in
[cm ](x0 + ) = [cm ]out = β[c]out

This implies that

[cm ]in = a x0 + b
[cm ]out = a (x0 + ) + b
 
= a x0 + b + a

= [cm ]in + a

Thus, letting C denote [c]out − [c]in , we have

Fig. 5.9 The linear membrane concentration model


5.8 Movement of Ions Across Biological Membranes 131

[cm ]out − [cm ]in


a=

β
= ([c]out − [c]in )

β
= C

We can also solve for the value of b:

b = [cm ]in − ax0


 
β
= [cm ]in − x0 ([c]out − [c]in )

 x0  x0
= β 1+ [c]in − β [c]out
 
Hence,

d[cm ] β β
= ([c]out − [c]in ) = C
dx  
Now recall that

Jmolar = −P [c]
Dm d[cm ]
=−
NA dx
Dm β
=− ([c]out − [c]in )
NA 

Thus, we have a way to express the permeability P in terms of low level fundamental
constants:
Dm β
P=
NA 

Finally, letting μm be the mobility within the membrane, we note that Einstein’s
relation tells us that Dm = κT μ = RT
q m
μ , so we conclude
F m

β RT μm
P= (5.16)
F N A
132 5 Ion Movement

5.8.2 The Goldman–Hodgkin–Katz (GHK) Model

The Goldman–Hodgkin–Huxley model is based on several assumptions about how


the substance c behaves in the membrane:
1. [cm ] varies linearly across the membrane as discussed in the previous subsection.
2. The electric field in the membrane is constant.
3. The Nernst–Planck equation holds inside the membrane.
We let V m (x) denote the voltage or potential and E m (x), the electrical field, in the
membrane at position x. By assumption (2), we know that E m (x) is a constant we
will call E m in the membrane for all x. Now we also know from standard physics
that an electric field is the negative of the derivative of the potential so

dV m
Em = −
dx
implying
 x0 +  x0 +
dV m
−E d x =
m
=⇒ −E m dx = d V m =⇒ −E m  = Vout
m
− Vinm
dx x0 x0

The Nernst equation will hold across the membrane, so we have that the voltage due
to c across the membrane is Vcm with

RT [c]out
E c = Vcm = Vinm − Vout
m
= ln
zF [c]in

Further, by assumption (3), the Nernst–Planck equation holds across the membrane,
so the ion current in the membrane, Im is given by
 
μm dV m d[cm ]
I m
=− z F [c ]
2 m
+ z RT
NA dx dx

Also, since

dV m V m − Vinm −Vcm
= −E m = out =
dx  
we have
 
μm m −Vc
m
d[cm ]
I m
=− z F [c ]
2
+ z RT
NA  dx
μm 2 V m
μ m d[c m
]
= z F [cm ] c − z RT
NA  NA dx
5.8 Movement of Ions Across Biological Membranes 133

We then see that

μm z 2 F [cm ] m μm d[cm ]
Im − Vc = − z RT (5.17)
NA  NA dx

To make sense out of this complicated looking equation, we will make a change of
variable: define y m as follows:

μm z 2 F [cm ] m
ym = I m − Vc (5.18)
NA 

Thus,

dy m dIm μm z 2 F m d[cm ]
= − Vc
dx dx NA  dx
dIm
We know that at equilibrium, the current flow will be zero and so dx
= 0. Hence,
at steady state, we have

dy m μm z 2 F m d[cm ]
=− Vc
dx NA  dx
or
 dy m μm z d[cm ]
− =
z F Vcm d x NA dx

] m
This gives us an expression for the term d[c
dx
in Eq. 5.17. Using our change of variable
y m and substituting for the concentration derivative, we find
   
μm z d[cm ]  dy m
y = −RT
m
= −RT −
NA dx z F Vcm d x

We have thus obtained the simpler differential equation

RT  dy m
ym = (5.19)
z F Vcm d x

This equation can be integrated easily:

RT  dy m
dx =
z F Vcm y m
 x0 +  x0 +
RT  dy m
dx = m
x0 z F Vc x0 ym
134 5 Ion Movement

which gives
RT  y m (x0 + )
= ln (5.20)
z F Vcm y m (x0 )

To simplify this further, we must go back to the definition of the change of variable
y m . From Eq. 5.18, we see

μm z 2 F [cm ](x0 + ) m
y m (x0 + ) = I m (x0 + ) − Vc
NA 
μm z 2 F [cm ](x0 ) m
y m (x0 ) = I m (x0 ) − Vc
NA 

At steady state the currents I m (x0 + ) and I m (x0 ) are the same value. Call this
constant steady state value I0m . Then we have

μm z 2 F [cm ](x0 + ) m
y m (x0 + ) = I0m − Vc
NA 
μm z 2 F [cm ](x0 ) m
y m (x0 ) = I0m − Vc
NA 

Finally, remember how we set up the concentration terms. We used the symbols
[cm ]out to represent [cm ](x0 + ) and [cm ]in to represent [cm ](x0 ). Thus, we have

μm z 2 F [cm ]out m
y m (x0 + ) = I0m − Vc
NA 
μm z 2 F [cm ]in m
y m (x0 ) = I0m − Vc
NA 

Now, to finish our derivation, let’s introduce an additional parameter ξ defined by

z F Vcm
ξ= (5.21)
RT
Recall that we defined the permeability by

Dm β
P=
NA 

and this also equals

β RT μm
P=
F N A
5.8 Movement of Ions Across Biological Membranes 135

Now from the definition of ξ and P, we find that Eq. 5.20 gives
 m 
 y (x0 + )
 = ln
ξ y m (x0 )

Thus, after canceling  from both sides, we obtain


 
y m (x0 + )
ξ = ln
y m (x0 )

Now, plug in the expressions for the y m terms evaluated at x0 +  and x0 to find
⎛ ⎞ 
μm z 2 F [cm ]out
I0m − NA 
Vcm I0m − zμm
NA
z F Vcm [cm ]out
ξ = ln ⎝ ⎠ = ln
I0m − μm z 2 F [cm ](x0 )
Vcm I0m − NzμAm z F Vcm [cm ]in
NA 
 μm ξ RT

I0m − zμm
NA
ξ RT [cm ]out I0m − NA
z

[cm ]out
= ln = ln
I0m − N Am ξ RT [cm ]in I0m − μmNξ ART
zμ z

[cm ]in

But we also know that by assumption

[cm ]out = β[c]out , [cm ]in = β[c]in

and so
μm ξ RT z m β RT μm
[c ]out = ξz [c]out
NA  N A

But we know from the definition of P that the fractional expression is just P F and
so we have
μm ξ RT z m
[c ]out = zP F ξ [c]out
NA 

In a similar fashion, we can derive that

μm ξ RT z m
[c ]in = zP F ξ [c]in
NA 

Substituting these identities into expression for ξ we derived earlier, we find


 
I0m − zP F ξ [c]out
ξ = ln
I0m − zP F ξ [c]in
136 5 Ion Movement

Now exponentiate these expressions to get

I0m − zP F ξ [c]out
eξ =
I0m − zP F ξ [c]in
(I0m − zP F ξ [c]in )eξ = I0m − zP F ξ [c]out

leading to

I0m (eξ − 1) = zP F ξ([c]in eξ − [c]out )

We can solve the above equation for the steady state current term I0m . This gives
 
[c]in eξ − [c]out
I0m = zP F ξ
eξ − 1

When we replace ξ by its definition and reorganize the resulting expression, we


obtain the GHK current equation for the ion c.
z F Vcm

z 2 P F 2 Vcm [c]in − [c]out e− RT
I0m = z F Vcm
(5.22)
RT 1 − e− RT

5.8.3 The GHK Voltage Equation

Consider a cell that is permeable to K + , Cl − and N a + ions with no active pumping.


Let’s calculate the resting potential of the cell. For each ion, we can apply our GHK
theory to obtain an ionic current, I K , I N a and ICl . At equilibrium, the current through
the membrane should be zero and so all of the ionic currents should sum to zero.
Thus

I K + I N a + ICl = 0

Further, the associated Nernst potentials for the ions should all match because oth-
erwise there would be current flow:

V0m = VKm+ = VN a + = VCl


m

where we denote this common potential by V0m . From the GHK current equation, we
have (note the valences for potassium and sodium are +1 and for chlorine is −1)
5.8 Movement of Ions Across Biological Membranes 137
⎛ F V0m

P K F 2 V0m ⎝ [K + ]in − [K + ]out e− RT ⎠
IK = F V0m
RT 1 − e− RT
⎛ F V0m

P N a F 2 V0m ⎝ [N a + ]in − [N a + ]out e− RT ⎠
IN a = F V0m
RT 1 − e− RT
⎛ −F V0m

PCl F 2 V0m ⎝ [Cl − ]in − [Cl − ]out e− RT ⎠
ICl = −F V0m
RT 1 − e− RT

F V0m
For convenience, let ξ0 denote the common term RT
. Then we have
 
[K + ]in − [K + ]out e−ξ0 [N a + ]in − [N a + ]out e−ξ0
I K = P K Fξ0 , I N a = P N a Fξ0
1 − e−ξ0 1 − e−ξ0

[Cl − ]in − [Cl − ]out eξ0
ICl = PCl Fξ0
1 − eξ0

Now sum these ionic currents to obtain


 +   
[K ]in − [K + ]out e−ξ0 [N a + ]in − [N a + ]out e−ξ0
0 = P K Fξ0 + P Na Fξ0
1 − e−ξ0 1 − e−ξ0
 
[Cl − ]in e−ξ0 − [Cl − ]out
−PCl Fξ0
1 − e−ξ0
or
Fξ0  
0= −ξ
P K [K + ]in + P N a [N a + ]in + PCl [Cl − ]out
1−e 0

  F ξ0 e−ξ0
− P K [K + ]out + P N a [N a + ]out + PCl [Cl ]in .
1 − e−ξ0

Rewriting, we obtain
 
eξ0 P K [K + ]in + P N a [N a + ]in + PCl [Cl − ]out
 
= P K [K + ]out + P N a [N a + ]out + PCl [Cl ]in

Hence, solving for eξ0 , we find

P K [K + ]out + P N a [N a + ]out + PCl [Cl ]in


eξ0 =
P K [K + ]in + P N a [N a + ]in + PCl [Cl − ]out
138 5 Ion Movement

Finally, taking logarithms, we obtain the GHK Voltage equation for these ions:
 
RT P K [K + ]out + P N a [N a + ]out + PCl [Cl ]in
V0m = ln (5.23)
F P K [K + ]in + P N a [N a + ]in + PCl [Cl − ]out

Now to actually compute the GHK voltage, we will need the values of the three
permeabilities. It is common to rewrite this equation in terms of permeability ratios.
We choose one of the permeabilities as the reference, say P N a , and compute the
ratios

PK PCl
rK = , rCl =
PN a PN a

We can then rewrite the GHK voltage equation as


 
RT [N a + ]out + r K [K + ]out + rCl [Cl ]in
V0m = ln (5.24)
F [N a + ]in + r K [K + ]in + rCl [Cl − ]out

5.8.4 Examples

Now let’s use the GHK voltage equation for a few sample calculations.

5.8.4.1 A First Example

Consider a squid giant axon. Typically, the axon at rest has the following permeability
ratios:

P K : P N a : PCl = 1.0 : 0.03 : 0.1

where we interpret this string of ratios as

PK 1.0
= = 33.33
PN a 0.03
PN a 0.03
= = 0.3
PCl 0.1

Thus, we have

PK
rK = = 33.33
PN a
PCl
rCl = : 3.33
PN a
5.8 Movement of Ions Across Biological Membranes 139

Now look at the part of Table 5.1 which shows the ion concentrations for the squid
axon. we will use a temperature of 294.11◦ Kelvin and the conversion RT
F
is 25.32 mV.
Also, recall that all concentrations are given in mM. Thus, the GHK voltage equation
for the squid axon gives
 
RT [N a + ]out + r K [K + ]out + rCl [Cl ]in
V0m = ln
F [N a + ]in + r K [K + ]in + rCl [Cl − ]out
 
440.0 + 33.33 × 20.0 + 3.333 × 40.0
= 25.32 (mV) ln
50.0 + 33.33 × 400.0 + 3.333 × 560.0
 
1239.9
= 25.32 (mV) ln
15248.48
= −63.54 mV

5.8.4.2 A Second Example

Now assume there is a drastic change in these permeability ratios: we now have:

P K : P N a : PCl = 1.0 : 15.0 : 0.1

where we interpret this string of ratios as

PK 1.0
rK = = = 0.0667
PN a 15.0
PCl 0.1
rCl = = = 0.00667
PN a 15.0

The GHK voltage equation now gives


 
440.0 + 0.0667 × 20.0 + 0.00667 × 40.0
V0m = 25.32 (mV) ln
50.0 + 0.0667 × 400.0 + 0.00667 × 560.0
 
441.60
= 25.32 (mV) ln
80.4152
= 43.12 mV

We see that this large change in the permeability ratio between potassium and
sodium triggers a huge change in the equilibrium voltage across the membrane. It is
actually far easier to see this effect when we use permeabilities than when we use
conductances. So as usual, insight is often improved by looking at a situation using
different parameters! Later, we will begin to understand how this explosive switch
from a negative membrane voltage to a positive membrane voltage is achieved. That’s
for a later chapter!
140 5 Ion Movement

5.8.5 The Effects of an Electrogenic Pump

We haven’t talked much about how the pumps work in our model yet, so just to give
the flavor of such calculations, let’s look at a hypothetical pump for an ion c. Let Ic
denote the passive current for the ion which means no energy is required for the ion
flow (see Sect. 5.7.1 for further discussion). The ion current due to a pump requires
p
energy and we will let Ic denote the ion current due to the pump. At steady state,
we would have
p
I N a+ + I N a+ = 0
p
IK + + IK + = 0

Let the parameter r be the number of N a + ions pumped out for each K + ion pumped
in. This then implies that
p p
r I K + + I N a+ = 0

From the GHK current equation, we know


 
[K + ]in − [K + ]out e−ξ0
I K + = P K F ξ0
1 − e−ξ0
 
[N a + ]in − [N a + ]out e−ξ0
I N a+ = P N a F ξ0
1 − e−ξ0

and thus from our steady state assumptions, we find


p p
I N a + = −I N a + , I K + = −I K +

and so

r I K + + I N a+ = 0 (5.25)

Substituting the GHK current expressions into Eq. 5.25, we have

Fξ0     
−ξ
r P K [K + ]in − [K + ]out e−ξ0 + P N a [N a + ]in − [N a + ]out e−ξ0 = 0
1−e 0

giving
   
r P K [K + ]in − [K + ]out e−ξ0 − P N a [N a + ]in − [N a + ]out e−ξ0 = 0
   
r P K [K + ]in + P N a [N a + ]in − r P K [K + ]out + P N a [N a + ]out e−ξ0 = 0
5.8 Movement of Ions Across Biological Membranes 141

We can manipulate this equation a bit to get


 
r P K [K + ]in + P N a [N a + ]in = r P K [K + ]out + P N a [N a + ]out e−ξ0

or

r P K [K + ]out + P N a [N a + ]out
eξ0 =
r P K [K + ]in + P N a [N a + ]in

Since we know that


F V0m
ξ0 =
RT
we can solve for V0m and obtain
 
RT r P K [K + ]out + P N a [N a + ]out
V0m =
F r P K [K + ]in + P N a [N a + ]in

The N a + − K + pump moves out 3N a + ions for every 2K + ions that go in. Hence
the pumping ratio is r is 1.5. Thus for our usual squid axon using only potassium
and sodium ions and neglecting chlorine, we find for a permeability ratio of

P K : P N a = 1.0 : 0.03

that
 
1.5 · 33.33 · 20.0 + 440.0
V0m = 25.32 (mV) ln
1.5 · 33.33 · 400.0 + 50.0
1439.90
= 25.32 (mV) ln
200480.0
= −66.68 mV

Without a pump, r will be 1 and the calculation becomes


 
33.33 · 20.0 + 440.0
V0m = 25.32 (mV) ln
33.33 · 400.0 + 50.0
1106.60
= 25.32 (mV) ln
13382.0
= −63.11 mV

Our sample calculation thus shows that the pump contributes −66.68 to −63.11 or
−3.57 mV to the rest voltage. This is only 66.68
3.57
or 5.35 percent!
142 5 Ion Movement

5.9 Excitable Cells

There are specialized cells in most living creatures called neurons which are adapted
for generating signals which are used for the transmission of sensory data, control of
movement and cognition through mechanisms we don’t fully understand. A neuron
is an example of what is called an excitable cell and its membrane is studded with
many voltage gated sodium and potassium channels. In terms of ionic permeabilities,
the GHK voltage equation for the usual sodium, potassium and chlorine ions gives
 
P K [K + ]out + P N a [N a + ]out + PCl [Cl ]in
V0m = 25.32 (mV) ln
P K [K + ]in + P N a [N a + ]in + PCl [Cl − ]out

which is about −60 mV at rest but which we have already seen can rapidly increase to
+40 mV upon a large shift in the sodium and potassium permeability ratio. Recalling
our discussion in Sect. 5.6, we can write the rest voltage in terms of conductances as
gK gN a gCl
V0m = EK + ENa + E Cl
g K + g N a + gCl g K + g N a + gCl g K + g N a + gCl

Either the conductance or the permeability model allows us to understand this sudden
increase in voltage across the membrane in terms of either sodium to potassium per-
meability or conductance ratio shifts. We will study all of this in a lot of detail later,
but for right now, let’s just say that under certain circumstances, the rest potential
across the membrane can be stimulated just right to cause a rapid rise in the equilib-
rium potential of the cell, followed by a sudden drop below the equilibrium voltage
and then ended by a slow increase back up to the rest potential. The shape of this
wave form is very characteristic and is shown in Fig. 5.10. This type of wave form is
called an action potential and is a fundamental characteristic of excitable cells. In the
figure, we draw the voltage across the membrane and simultaneously we draw the
conductance curves for the sodium and potassium ions. Recall that conductance is
reciprocal resistance, so a spike in sodium conductance, for example, is proportional
to a spike in sodium ion current. So in the figure we see that sodium current spikes
first and potassium second.
Now that we have discussed so many aspects of cellular membranes, we are at
a point where we can develop a qualitative understanding of how this behavior is
generated. We can’t really understand the dynamic nature of this pulse yet (that is
it’s time and spatial dependence) but we can explain in a descriptive fashion how
the potassium and sodium gates physical characteristics cause the behavior we see
in Fig. 5.10. The changes in the sodium and potassium conductances that we see
in the action potential can be explained by molecular properties of the sodium and
potassium channels. As in the example we worked through for the resting potential for
the squid nerve cells, for this explanation, we will assume the chlorine conductance
does not change. So all the qualitative features of the action potential will be explained
solely in terms of relative sodium to potassium conductance ratios. We have already
seen that if we allow a huge increase in the sodium to potassium conductance ratio,
5.9 Excitable Cells 143

Fig. 5.10 A typical action potential

Fig. 5.11 A typical sodium channel

we generate a massive depolarization of the membrane. So now, we will try to explain


how this happens. Let’s look at a typical sodium channel as shown in Fig. 5.11 which
is an example of a typical voltage dependent gate. The drawing of a potassium
channel will be virtually identical. When you look at the drawing of the sodium
channel, you’ll see it is drawn in three parts. Our idealized channel has a hinged
cap which can cover the part of the gate that opens into the cell. We call this the
inactivation gate. It also has a smaller flap inside the gate which can close off the
throat of the channel. This is called the activation gate. As you see in the drawing,
these two pieces can be in one of three positions: resting (activation gate is closed
and the inactivation gate is open); open (activation gate is open and the inactivation
gate is open); and closed (activation gate is closed or closed and the inactivation gate
is closed). Since this is a voltage activated gate, the transition from resting to open
144 5 Ion Movement

depends on the voltage across the cell membrane. We typically use the following
terminology:
• When the voltage across the membrane is above the resting membrane voltage,
we say the cell is depolarized.
• When the voltage across the membrane is below the resting membrane voltage,
we say the cell is hyperpolarized.
These gates transition from resting to open when the membrane depolarizes. In
detail, the probability that the gate opens increases upon membrane depolarization.
However, the probability that the gate transitions from open to closed is NOT voltage
dependent. Hence, no matter what the membrane voltage, once a gate opens, there
is a fixed probability it will close again.
Hence, an action potential can be described as follows: when the cell membrane is
sufficiently depolarized, there is an explosive increase in the opening of the sodium
gates which causes a huge influx on sodium ions which produces a short lived rapid
increase in the voltage across the membrane followed by a rapid return to the rest
voltage with a typical overshoot phase which temporarily keeps the cell membrane
hyperpolarized. We can explain much of this qualitatively as follows: The voltage
gated channels move randomly back and forth between their open and closed states.
At rest potential, the probability that a channel will move to the open position is
small and hence, most channels are in the closed position. When the membrane is
depolarized from some mechanism, the probability that a channel will transition to
the open position increases. If the depolarization of the membrane lasts long enough
or is large enough, then there is an explosive increase in the cell membrane potential
fueled by
Explosive Depolarization of the Membrane The depolarization causes a few N a +
channels to open. This opening allows N a + to move into the cell through the channel
which increase the inside N a + concentration. Now our previous attempts to explain
the voltage across the membrane were all based on equilibrium or steady state ar-
guments; here, we want to think about what happens in that brief moment when
the N a + ions flood into the cell. This is not a steady state analysis. Here, the best
way to think of it is that the number of plus ions in the cell has gone up. So since
the electrical field is based on minus to plus gradients, we would anticipate that the
electrical field temporarily increases. We also know from basic physics that

dV
E =−
dx
implying since the membrane starts at x0 and ends at x0 +  that

E = −V (x0 + ) + V (x0 ) = Vin − Vout .

where, as usual, we have labeled the voltage at the inside, V (x0 ) as Vin and the other
as Vout . Hence, since we define the membrane voltage V0m as
5.9 Excitable Cells 145

V0m = Vin − Vout ,

we see that

E = V0m

Thus if N a + ions come in, the electric field goes up and so does the potential across the
membrane. Hence, the initial depolarizing event further depolarizes the membrane.
This additional depolarization of the membrane increases the probability that the
sodium gates open. Hence, more sodium gates transition from resting to closed and
more N a + ions move into the cell causing further depolarization as outlined above.
We see depolarization induces further depolarization which is known as positive
feedback. Roughly speaking, the membrane voltage begins to drive towards E N a as
determined by the Nernst voltage equation. For biological cells, this is in the range
of 70 mV. Qualitatively, this is the portion of the voltage curve that is rising from rest
towards the maximum in Fig. 5.10.
Sodium Inactivation The probability that a sodium gate will move from open to
closed is independent of the membrane voltage. Hence, as soon as sodium gates
begin to open, there is a fixed probability they will then begin to move towards closed.
Thus, even as the membrane begins its rapid depolarization phase, the sodium gates
whose opening provided the trigger begin to close. This is most properly described
in terms of competing rates in which one rate is highly voltage dependent, but we
can easily see that essentially , the membrane continues to depolarize until the rate
of gate closing exceeds the rate of opening and the net flow of sodium ions is out of
the cell rather than into the cell. At this point, the membrane voltage begins to fall.
The sodium gate therefore does not remain open for long. It’s action provides a brief
spike in sodium conductance as shown in Fig. 5.12.
Potassium Channel Effects The potassium gate is also a voltage dependent channel
whose graphical abstraction is similar to that shown in Fig. 5.11. These channels
respond much slower to the membrane depolarization induced by the sodium channel
activations. As the K + channels open, K + inside the cell flows outward and thereby
begins to restore the imbalance caused by increased N a + in the cytoplasm. The
explanation for this uses the same electrical field and potential connection we invoked
earlier to show why the membrane depolarizes. This outward flow, however, moves

Fig. 5.12 Spiking due to


sodium ions
146 5 Ion Movement

the membrane voltage the other way and counteracts the depolarization and tries to
move the membrane voltage back to rest potential. The K + channels stay open a
long time compared to the N a + channels. Since the sodium channels essentially pop
open and then shut again quickly, this long open time of the potassium channel means
the potassium conductance, g K falls very slowly to zero. As the potassium outward
current overpowers the diminishing sodium inward current, the potential accelerates
its drop towards rest which can be interpreted as a drive towards the Nernst potential
E K which for biological cells is around −80 mV.
Chlorine Ion Movement The rest potential is somewhere in between the sodium
and potassium Nernst potentials and the drive to reach it is also fueled by several
other effects. There is also a chlorine current which is caused by the movement of
chlorine through the membrane without gating. The movement of negative ions into
the cell is qualitatively the same as the movement of positive potassium ions out
of the cell—the membrane voltage goes down. Thus, chlorine current in the cell is
always acting to bring the cell back to rest. We see the cell would return to its rest
voltage even without the potassium channels, but the potassium channels accelerate
the movement. One good way to think about it is this: the potassium channels shorten
the length of time the membrane stays depolarizes by reducing the maximum height
and the width of the pulse we see in Fig. 5.10.
The Na+ −K + Pump There is also an active sodium–potassium pump that moves 3
sodium ions out of the cell for each 2 potassium ions that are moved in. This means
that the cell’s interior plus charge goes down by one. This means the membrane
voltage goes down. Hence, this pump acts to bring the membrane potential back to
rest also.
The Hyperpolarization Phase In Fig. 5.10, you can see that after the downward
voltage pulse crosses the rest potential line, the voltage continues to fall before it
bottoms out and slowly rises in an asymptotic fashion back up to the rest potential.
This is called the hyperpolarization phase and the length of time a cell spends in
this phase and the shape of the this phase of the curve are important to how this
potential change from this cell can be used by other cells for communication. As the
potassium channels begin to close, the K + outward current drops and the voltage
goes up towards rest.
The Refractory Period During the hyperpolarization phase, many sodium channels
are inactivated. The probability a channel will reopen simultaneously is small and
most sodium gates are closed. So for a short time, even if there is an initial depo-
larizing impulse event, only a small number of sodium channels are in a position to
move to open. However, if the magnitude of the depolarization event is increased,
more channels will open in response to it. So it is possible that with a large enough
event, a new positive feedback loop of depolarization could begin and generate a new
action potential. However, without such an event, the membrane is hyperpolarized,
the probability of opening is a function of membrane voltage and so is very low, and
hence most gates remain closed. The membrane is continuing to move towards rest
though and the closer this potential is to the rest value, the higher the probability of
5.9 Excitable Cells 147

opening for the sodium gates. Typically, this period where the cell has a hard time
initiating a new action potential is on the order of 1–2 mS. This period is called the
refractory period of the cell.
With all this said, let’s go back to the initial depolarizing event. If this event is a
small pulse of N a + current that is injected into a resting cell, there will be a small
depolarization which does not activate the sodium channels and so the ECE force
acting on the K + and Cl − ions increase. K + goes out of the cell and Cl − comes
in. This balances the inward N a + ion jet and the cell membrane voltage returns to
rest. If the initial depolarization is larger, some N a + channels open but if the K +
and Cl − net current due to the resulting ECE forces is larger than the inward N a +
current due to the jet and the sodium channels that are open, the membrane potential
still goes back to rest. However, if the depolarization is sufficiently large, the ECE
derived currents can not balance the inward N a + current due to the open sodium
gates and the explosive depolarization begins.

References

D. Johnston, S. Miao-Sin Wu, Foundations of Cellular Neurophysiology (MIT Press, Cambridge,


1995)
T. Weiss, Cellular Biophysics: Volume 2, Electrical Properties, chapter The Hodgkin–Huxley model
(MIT Press, Cambridge, 1996), pp. 163–292
Chapter 6
Lumped and Distributed Cell Models

We can now begin to model a simple biological cell. We can think of a cell as having
an input line (this models the dendritic tree), a cell body (this models the soma)
and an output line (this models the axon). We could model all these elements with
cables—thin ones for the dendrite and axon and a fat one for the soma. To make our
model useful, we need to understand how current injected into the dendritic cable
propagates a change in the membrane voltage to the soma and then out across the
axon. Our simple model is very abstract and looks like that of Fig. 6.1.
Note that the dendrite in Fig. 6.1 is of length L and its position variable is w and
the soma also has length L and its position variable is w. Note that each of these
cables has two endcaps—the right and left caps on the individual cylinders—and
we eventually will have to understand the boundary conditions we need to impose
at these endcaps when current is injected into one of these cylinders. We could also
model the soma as a spherical cell, but for the moment let’s think of everything as
the cylinders you see here. So to make progress on the full model, we first need to
understand a general cable model.

6.1 Modeling Radial Current

Now a fiber or cable can be modeled by some sort of cylinder framework. In Fig. 6.2a,
we show the cylinder model. In our cylinder, we will first look at currents that run
out of the cylinder walls and ignore currents that run parallel or longitudinally down
the cylinder axis. We label the interesting variables as follows:
• The inner cylinder has radius a.
• L is the length of the wire.
• V is the voltage across the wall or membrane.
• Ir is the radial current flow through the cylinder. This means the current is flowing
through the walls. This is measured in amps.

© Springer Science+Business Media Singapore 2016 149


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_6
150 6 Lumped and Distributed Cell Models

Fig. 6.1 A simple cell


model

Fig. 6.2 Cable cylinders.


a The cable cylinder model.
b 2D cross-section

• Jr is the radial current flow density which has units of amps per unit area—for
example, amps
cm2
.
• K r is the radial current per unit length—typical units would be amps
cm
.
The 2D cross-section, shown in Fig. 6.2b, further illustrates that the radial current
Jr moves out of the cylinder. Clearly, since the total surface area of our cylinder is
2πa L, we have the following conversions between the various current variables.

Ir = 2πa L Jr
Ir
Kr = = 2πa Jr
L
Now, imagine our right circular cylinder as being hollow with a very thin skin filled
with some conducting solution, as shown in Fig. 6.3a. Further, imagine the wall is
actually a bilipid layer membrane as shown in Fig. 6.3b. We now have a simple model
of a biological cable we can use for our models. This is called the annular model of
a cable. In other words, if we take a piece of dendritic or axonal fiber, we can model
it as two long concentric cylinders. The outer cylinder is filled with a fluid which
is usually considered to be the extracellular fluid outside the nerve fiber itself. The
outer cylinder walls are idealized to be extremely thin and indeed we don’t usually
think about them much. In fact, the outer cylinder is actually just a way for us to
6.1 Modeling Radial Current 151

Fig. 6.3 Cable details. a The cable cylinder model cross section. b Part of the cable bilipid mem-
brane structure

handle the fact that the dendrite or axon lives in an extracellular fluid bath. The inner
cylinder has a thin membrane wall wrapped around an inner core of fluid. This inner
fluid is the intracellular fluid and the membrane wall around it is the usual membrane
we have discussed already. The real difference here is that we are now looking at a
specific geometry for our membrane structure.

6.2 Modeling Resistance

We also will think of these cables as much as possible in terms of simple circuits.
Hence, our finite piece of cable should have some sort of resistance associated with
it. We assume from standard physics that the current density per unit surface area,
Jr , is proportional to the electrical field density per length E . The proportionality
constant is called conductivity and is denoted by σe . The resulting equation is thus

Jr = σe E

Another traditional parameter is called the resistivity which is reciprocal conductivity


and is labeled ρ.

1
ρ=
σe

The units here are


• E is measured in Volts
cm
.
• σe is measured in ohm−cm
1
.
• ρ is measured in ohm − cm.
152 6 Lumped and Distributed Cell Models

Volts amps
This gives us the units of ohm−cm 2 or cm2 for the current density Jr which is what

we expect them to be! The parameters ρ and σe measure properties that tell us what
to do for one cm of our cable but do not require us to know the radius. Hence, these
parameters are material properties.

6.3 Longitudinal Properties

Now let’s look at currents that run parallel to the axis of the cable. These are called
longitudinal currents which we will denote by the symbol Ia . Now that we want to
look at currents down the fiber, we need to locate at what position we are on the
fiber. We will let the variable z denote the cable position and we will assume to cable
has length L. We show this situation in Fig. 6.4. The surface area of each endcap of
the cable cylinder is πa 2 . This implies that if we cut the cable perpendicular to its
longitudinal axis, the resulting slice will have cross-sectional area πa 2 . Our currents
are thus:
• Ia is the longitudinal current flow which has units of amps.
• Ja is the longitudinal current flow density which has units of amps per unit area—
amps
cm2
.
with the usual conversion

Ia = πa 2 Ja

Since the inside of the cable is filled with the same conducting fluid we used in our
radial current discussions, we know

Ja = σe E

and so

πa 2 E
Ia = πa 2 σe E =
ρ

using the definition of resistivity. From standard physics, it follows that

d
E =−
dz

where  is the potential in the conductor. Hence, we have

ρIa d
=−
πa 2 dz
6.3 Longitudinal Properties 153

Fig. 6.4 Longitudinal cable currents

implying

ρIa
V = (0) − (L) = L
πa 2
Now if we use Ohm’s law to relate potential, current and resistance as usual, we
would expect a relationship of the form

ρL
V = Resistance Ia = Ia
πa 2
This suggests that the term in front of Ia plays the role of a resistance. Hence, we
will define R to be the resistance of the cable by

ρL
R=
πa 2

The resistance per unit length would then be r = R L


which is πaρ 2 . This notation is
a bit unfortunate as we usually use the symbol r in other contexts to be a resistance
measured in ohms; here it is a resistance per unit length measured in ohms cm
. Note that
the resistance per unit length here is of the form Aρ .

6.4 Current in a Cable with a Thin Wall

So far, we haven’t actually thought of the cable wall as having a thickness. Now
let’s let the wall thickness be  and consider the picture shown in Fig. 6.5. We let the
variable s indicate where we are at inside the membrane wall. Hence, s is a variable
which ranges from a value of a (the inner side of the membrane) to the value a + 
(the outer side of the membrane). Let Ir (s) denote the radial current at s; then the
radial current density is defined by
154 6 Lumped and Distributed Cell Models

Fig. 6.5 Cable membrane


with wall thickness shown

Ir (s)
Jr (s) =
2πs L
We will assume the radial current is constant; i.e. Ir is independent of s. Thus, we
have
Ir
Jr (s) = .
2πs L
Now following the arguments we used before, we assume the current density is still
proportional to the electric field density and that the electrical field density E is
constant. Thus, we have Jr (s) = σe E . Hence

Jr (s) d
E = =−
σe ds

This implies

Ir d
= −σe
2πs L ds
Integrating, we find
 a+  (a+)
Ir d
= −σe
a 2πs L (a) ds
 
Ir a+
ln = −σe ((a + ) − (a))
2πL a

Now (a + ) is the voltage outside the cable at the end of the cell wall (Vout ) and
(a) is the voltage inside the cable at the start of the cell wall (Vin ). As usual, we
represent the potential difference Vin − Vout by Vr . Thus, using the definition of ρ,
we have
 
a+ 2πLσe Vr 2πL Vr
ln = =
a Ir ρIr
6.4 Current in a Cable with a Thin Wall 155

We conclude
 
ρIr 
Vr = ln 1 +
2πL a

Recall that  is the thickness of the cell wall which in general is very small compared
to the radius a. Hence the ratio of  to a is usually quite small. Recall from basic
calculus that for a twice differentiable function f defined near the base point x0 that
we can replace f near x0 as follows:

1 
f (x) = f (x0 ) + f  (x0 )(x − x0 ) + f (c)(x − x0 )2
2
where the number c lies in the interval (x0 , x). Unfortunately, this number c depends
on the choice of x, so this equality is not very helpful in general. The straight line
L(x, x0 ) given by

L(x, x0 ) = f (x0 ) + f  (x0 )(x − x0 )

is called the tangent line approximation or first order approximation to the function
f near x0 . Hence, we can say

1 
f (x) = L(x, x0 ) + f (c)(x − x0 )2
2
This tells us the error we make in replacing f by its first order approximation,
e(x, x0 ), can be defined by

1 
e(x, x0 ) = | f (x) − L(x, x0 )| = | f (c)|(x − x0 )2
2
Now ln(1 + x) is two times differentiable on (0, ∞) so we have the first order
approximation to ln(1 + x) near the base point 0 is given by

1 
L(x, x0 ) = ln(1) + (x − 0) = x
1 + x x=0

with error
1 1
e(x, 0) = | ln(1 + x) − x| = x2
2 (1 + c)2

where c is some number between 0 and x. Even though we can’t say for certain
where c is in this interval, we can say that

1
≤1
(1 + c)2
156 6 Lumped and Distributed Cell Models

no matter what x is! Hence, the error in making the first order approximation on the
interval [0, x] is always bounded above. We have shown

1 2
e(x, 0) ≤ x
2

Now for our purposes, let’s replace ln(1 + a ) with a first order approximation on the
interval (0, a ). Then the x above is just a and we see that the error we make is
 2
1 
e(x, 0) ≤
2 a

If the ratio of the cell membrane to radius is small, the error we make is negligible.
For example, a biological membrane is about 70 nM thick and the cell is about 20,000
nM in radius. Hence the membrane to radius ratio is 3.5e − 3 implying the error is on
the order of 10−5 which is relatively small. Since in biological situations, this ratio is
small enough to permit a reasonable first order approximation with negligible error,
we replace ln(1 + a ) by a . Thus, we have to first order

ρIr  Vr ρ
Vr = =⇒ R = =
2πL a Ir 2πLa

We know R is measured in ohms and so the resistance R of the entire cable at the
inner wall is R times the inner surface area of the cable which is 2πLa. Hence,
R = ρ which has units of ohms−cm2 . We know the wall has an inner and an outer
surface area. The outer surface area is 2πa(1 + a )L which is a bit bigger. In order to
define the resistance of a unit surface area, we need to know which surfaced area we
are talking about. So here, since we have already approximated the logarithm term
around the base point 0 (which means the inside wall as 1 + 0 corresponds to the
inside wall!) we choose to use the surface area of the inside wall. Note how there
are many approximating ideas going on here behind the scenes if you will. We must
always remember these assumptions in the models we build! The upshot of all of
this discussion is that for a cable model with a thin membrane, the resistance per unit
length, r , with units ohms
cm
, should be defined to be

R ρ
r = =
 2πLa

6.5 The Cable Model

In a uniform isolated cell, the potential difference across the membrane depends
on where you are on the cell surface. For example, we could inject current into a
cylindrical cell at position z 0 as shown in Fig. 6.7a. In fact, in the laboratory, we
6.5 The Cable Model 157

Fig. 6.6 Potential difference versus position curves

could measure the difference between V m (the membrane potential) and V0m (the
rest potential) that results from the current injection at z = 0 at various positions z
downstream and we would see potential difference curves versus position that have
the appearance of Fig. 6.6. The z = 0 curve is what we would measure at the site of
the current injection; the z = 21 and z = 2 curves are what we would measure 21 or
2 units downstream from the injection site respectively. Note the spike in potential
we see is quite localized to the point of injection and falls rapidly off as we move to
the right or left away from the site. Our simple cylindrical model gave us

ρIr 
Vr =
2πLa
as the voltage across the membrane or cell wall due to a radial current Ir flowing
uniformly radially across the membrane along the entire length of cable. So far our
model do not allow us to handle dependence on position so we can’t reproduce
voltage versus position curves as shown in Fig. 6.6. We also currently can’t model
explicit time dependence in our models!
Now we wish to find a way to model V m as a function of the distance downstream
from the current injection site and the time elapsed since the injection of the current.
This model will be called the Core Conductor Model.

6.5.1 The Core Conductor Model Assumptions

Let’s start by imagining our cable as a long cylinder with another cylinder inside
it. The inner cylinder has a membrane wall of some thickness small compared to
158 6 Lumped and Distributed Cell Models

Fig. 6.7 Cylindrical cell details. a Current injection. b Radial cross section

the radius of the inner cylinder. The outer cylinder simply has a skin of negligible
thickness. If we take a radial cross section as shown in Fig. 6.7b we see in this radial
cross section, let’s label the important currents and voltages as shown in Fig. 6.8a.
As you can see, we are using the following conventions:
• t is time usually measured in milli-seconds or mS.
• z is position usually measured in cm.
• (r, θ) are the usual polar coordinates we could use to label points in any given
radial cross section.
• K e (z, t) is the current per unit length across the outer cylinder due to external
sources applied in a cylindrically symmetric fashion. This will allow us to represent
current applied to the surface through external electrodes. This is usually measured
in amp
cm
• K m (z, t) is the membrane current per unit length from the inner to outer cylinder
through the membrane. This is also measure in amp cm
.
• Vi (z, t) is the potential in the inner conductor measured in milli-volts or mV.
• Vm (z, t) is the membrane potential measured in milli-volts or mV.
• Vo (z, t) is the potential in the outer conductor measured in milli-volts or mV.
We can also look at a longitudinal slice of the cable as shown in Fig. 6.8b. The
longitudinal slice allows us to see the two main currents of interest, Ii and Io as
shown in Fig. 6.9, we see
where
• Io (z, t) is the total longitudinal current flowing in the +z direction in the outer
conductor measured in amps.
• Ii (z, t) is the total longitudinal current flowing in the +z direction in the inner
conductor measured in amps.
The Core Conductor Model is built on the following assumptions:
1. The cell membrane is a cylindrical boundary separating two conductors of current
called the intracellular and extracellular solutions. We assume these solutions are
homogeneous, isotropic and obey Ohm’s Law.
2. All electrical variables have cylindrical symmetry which means the variables do
not depend on the polar coordinate variable θ.
6.5 The Cable Model 159

Fig. 6.8 Radial and longitudinal details. a Currents and voltages in the radial cross section. b A
longitudinal slice of the cable

Fig. 6.9 Longitudinal


currents

3. A circuit theory description of currents and voltages is adequate for our model.
4. Inner and outer currents are axial or longitudinal only. Membrane currents are
radial only.
5. At any given position longitudinally (i.e. along the cylinder) the inner and outer
conductors are equipotential. Hence, potential in the inner and outer conductors
is constant radially. The only radial potential variation occurs in the membrane.
Finally, we assume the following geometric parameters:
• r0 is the resistance per unit length in the outer conductor measured in ohm
cm
.
• ri is the resistance per unit length in the inner conductor measured in ohm
cm
.
• a is the radius of the inner cylinder measured in cm.
It is also convenient to define the current per unit area variable Jm :
amp
• Jm (z, t) is the membrane current density per unit area measured in cm2
.
160 6 Lumped and Distributed Cell Models

Outer Membrane

Ii (z, t) Vi (z, t) Ii (z + Δz, t) Vi (z + Δz, t) Outer Conductor

Inner Membrane

Inner Conductor

Km (z, t) Vm (z, t) Km (z + Δz, t) Vm (z + Δz, t) Inner Membrane

I0 (z, t) V0 (z, t) I0 (z + Δz, t) V0 (z + Δz, t) Outer Conductor

Outer Membrane
z z + Δz

A Δz slice of the cable model.

Fig. 6.10 The two slice model

6.5.2 Building the Core Conductor Model

Now let’s look at a slice of the model between positions z and z + z. In Fig. 6.10,
we see an abstraction of this. The vertical lines represent the circular cross sections
through the cable at the positions z and z + z. We cut through the outer shell first
giving two horizontal lines labeled outer membrane at the bottom of the figure. Then
as we move upward, we encounter the outer conductor. We then move through the
inner cable which has a bottom membrane, an inner conductor and a top membrane.
Finally, we enter the outer conductor again and exit through the outer membrane. At
each position z, there are values of Ii , Io , Vi , Vo , K m and Vm that are shown. Between
z and z + z, we thus have a cylinder of inner and outer cable of length z.
From the z slice in Fig. 6.10, we can abstract the electrical network model we
see in Fig. 6.11: Now in the inner conductor, we have current Ii (z, t) entering the face
of the inner cylinder. At that point the inner cylinder is at voltage Vi (z, t). A distance
z away, we see current I (z + z, t) leaving the cylinder and we note the voltage
of the cylinder is now at V (z + z, t). Finally, there is a radial membrane current
coming out of the cylinder uniformly all through this piece of cable. We illustrate this
in Fig. 6.12: Now we know that the total current I through the membrane is given by

I (z, t) = 2πa Jm (z, t) z = K m (z, t) z


6.5 The Cable Model 161

Ii (z, t) Ii (z + Δz, t)
Vi (z, t) Vi (z + Δz, t)
ri Δz Ω ri Δz Ω ri Δz Ω
a b

Km (z, t) Δz Km (z + Δz, t) Δz

Vm (z, t) Membrane Membrane Vm (z + Δz, t)

ro Δz Ω ro Δz Ω ro Δz Ω
d c
Vo (z, t) Vo (z + Δz, t)
Io (z, t) Io (z + Δz, t)

Ke (z, t) Δz Ke (z + Δz, t) Δz

Fig. 6.11 The equivalent electrical network model

Fig. 6.12 Inner cylinder currents

and at Node d, the currents going into the node should match the currents coming
out of the node:

Io (z, t) + K m (z, t) z = Io (z + z, t) + K e (z, t) z

Also, the voltage drop across the resistance ri z between Node a and Node b satisfies

ri z Ii (z + z, t) = Vi (z, t) − Vi (z + z, t)


162 6 Lumped and Distributed Cell Models

Similarly, between Node d and Node c we find the voltage drop satisfies

ro z Io (z + z, t) = Vo (z, t) − Vo (z + z, t)

Also at Node a, we find

Ii (z, t) = Ii (z + z, t) + K m (z, t) z

Next, note that Vm is Vi − Vo . Rearranging the relationships we have found, we


summarize as follows:
Ii (z + z, t) − Ii (z, t)
= −K m (z, t) (current balance at Node a)
z
Io (z + z, t) − Io (z, t)
= K m (z, t) − K e (z, t) (current balance at Node d)
z
Vi (z + z, t) − Vi (z, t)
= −ri Ii (z + z, t) (voltage drop between Nodes a and b)
z
Vo (z + z, t) − Vo (z, t)
= −ro Io (z + z, t) (voltage drop between Nodes c and d)
z

Now from standard multivariable calculus, we know that is a function f (z, t) has a
partial derivative at the point (z, t), then the following limit exists

f (z + z, t) − f (z, t)
lim
z→0 z

and the value of this limit is denoted by the symbol ∂∂zf . Now the equations above
apply for any choice of z. Physically, we expect the voltages and currents we see
here to be smooth differentiable functions of z and t. Hence, we expect that if we let
z go to zero, we will obtain the equations:

∂ Ii
= −K m (z, t) (6.1)
∂z
∂ Io
= K m (z, t) − K e (z, t) (6.2)
∂z
∂Vi
= lim (−ri Ii (z + z, t) = −ri Ii (z, t) (6.3)
∂z z→0
∂Vo
= lim (−ro Io (z + z, t)) = −ro Io (z, t) (6.4)
∂z z→0
Vm = Vi − V0 (6.5)

We call Eqs. 6.1 and 6.2 the Core Equations. Note we can manipulate these equations
as follows: Eq. 6.4 implies that
6.5 The Cable Model 163

∂Vm ∂Vi ∂V0


= −
∂z ∂z ∂z

From Eqs. 6.3 and 6.4, it then follows that

∂Vm
= −ri Ii + ro Io
∂z

Thus, using Eqs. 6.1 and 6.2, we find

∂ 2 Vm ∂ Ii ∂ I0
= −ri + ro = ri K m + ro K m − ro K e
∂z 2 ∂z ∂z

Thus, the core equations imply that the membrane voltage satisfies the partial differ-
ential equation

∂ 2 Vm
= (ri + ro )K m − ro K e (6.6)
∂z 2

Note that the units here do work out. The second partial derivative of Vm with respect
to z involves ratios of first order partials of Vm with respect to z. The first order terms,
by the definition of the partial derivative, have units of volt cm
; hence, the second order
volt ohm
terms have units of cm 2 . Each of the r i or r o terms have units cm
and the K m or K e
are current per length terms with units cm . Thus the products have units amp−ohm
amps
cm2
or
volt
cm
. This partial differential equation is known as the Core Conductor Equation.

6.6 The Transient Cable Equations

Normally, we find it useful to model stuff that is happening in terms of how far things
deviate or move away from what are called nominal values. We can use this idea to
derive a new form of the Core Conductor Equation which we will call the Transient
Cable Equation. Let’s denote the rest values of voltage and current in our model by
• Vm0 is the rest value of the membrane potential.
• K m0 is the rest value of the membrane current per length density.
• K e0 is the rest value of the externally applied current per length density.
• Ii0 is the rest value of the inner current.
• Io0 is the rest value of the inner current.
• Vi0 is the rest value of the inner voltage.
• Vo0 is the rest value of the inner voltage.
It is then traditional to define the transient variables as perturbations from these rest
values using the same variables but with lower case letters:
164 6 Lumped and Distributed Cell Models

• vm is the deviation of the membrane potential from rest.


• i i is the deviation of the current in the inner fluid from rest.
• i o is the deviation of the current in the outer fluid from rest.
• vi is the deviation of the voltage in the inner fluid from rest.
• vo is the deviation of the voltage in the outer fluid from rest.
• km is the deviation of the membrane current density from rest.
These variables are defined by

vm (z, t) = Vm (z, t) − Vm0


vi (z, t) = Vi (z, t) − Vi0
vo (z, t) = Vo (z, t) − Vo0
km (z, t) = K m (z, t) − K m0
i i (z, t) = Ii (z, t) − Ii0
i o (z, t) = Io (z, t) − Io0

6.6.1 Deriving the Transient Cable Equation

Now in our core conductor model so far, we have not modeled the membrane at all.
For this transient version, we need to think more carefully about the membrane boxes
we showed in Fig. 6.11. We will replace our empty membrane box by a parallel circuit
model. Now this box is really a chunk of membrane that is z wide. We will assume
our membrane has a constant resistance and capacitance. We know that conductance
is reciprocal resistance, so our model will consist to a two branch circuit: one branch
is contains a capacitor and the other, the conductance element. We will let cm denote
the membrane capacitance density per unit length (measured in fahrad cm
). Hence, in
our membrane box, since the box is z wide, we see the value of capacitance is
cm z. Similarly, we let gm be the conductance per unit length (measured in ohm−cm 1
)
for the membrane. The amount of conductance for the box element is thus gmz.
In Fig. 6.13, we illustrate our new membrane model. Since this is a resistance—
capacitance parallel circuit, it is traditional to call this an RC membrane model.
In Fig. 6.13, the current going into the element is K m (z, t)z and we draw the rest
voltage for the membrane as a battery of value Vm0 . What happens when the membrane
is at rest? At rest, all of the transients must be zero. At rest, there can be no capacitative
current and so all the current flows through the conductance branch. Thus applying
Ohm’s law,

K m0 (z, t) z = gm z Vm0 (6.7)

On the other hand, when we are not in a rest position, we have current through both
branches. Recall that for a capacitor C, the charge q held in a capacitor due to a
6.6 The Transient Cable Equations 165

Fig. 6.13 The RC


membrane model Km (z, t) Δz

1
gm Δz
S
cm Δz F
0
Vm V

voltage V is q = C V which implies that the current through the capacitor due to a
time varying voltage is i = dq
dt
given by

∂V
i =C
∂t
From Kirchhoff’s current law, we see
 
    ∂
K m0 + km (z, t) z = gm z Vm0 + vm (z, t) + V + vm (z, t) cm z
0
∂t m

Using Eq. 6.7 and taking the indicated partial derivative, we simplify this to

∂vm
km (z, t) z = gm z vm (z, t) + cm z
∂t
Upon canceling the common z term, we find the fundamental identity

∂vm
km (z, t) = gm vm (z, t) + cm (6.8)
∂t
Now the core conductor equation in terms of our general variables is

∂ 2 Vm
= (ri + ro )K m − ro K e
∂z 2
∂2  0     
Vm + vm (z, t) = (ri + ro ) K m0 + km (z, t) − ro K e0 + ke (z, t)
∂z 2

Thus, in terms of transient variables, we have

∂ 2 vm
= (ri + ro )K m0 − ro K e0 + (ri + ro )km − ro ke
∂z 2
166 6 Lumped and Distributed Cell Models

This leads to

∂ 2 vm
− (ri + ro )km + ro ke = (ri + ro )K m0 − ro K e0
∂z 2

Now at steady state, both sides of the above equation must be zero. This gives us the
identities:

∂ 2 vm
= (ri + ro )km − ro ke
∂z 2
(ri + ro )K m0 = ro K e0

However, Eq. 6.8, allows us to replace km by an equivalent relationship. We obtain


 
∂ 2 vm ∂vm
= (ri + ro ) gm vm + cm − ro ke
∂z 2 ∂t
(ri + ro )K m0 = ro K e0

The Transient Cable Equation or just Cable Equation is then

∂ 2 vm ∂vm
− (ri + ro )cm − (ri + ro )gm vm = −ro ke (6.9)
∂z 2 ∂t

6.6.2 The Space and Time Constant of a Cable

The Cable Eq. 6.9 can be further rewritten in terms of two new constants, the space
constant of the cable, λc , and the time constant, τm . Note, we can rewrite 6.9 as

1 ∂ 2 vm cm ∂vm ro
− − vm = − ke
(ri + ro )gm ∂z 2 gm ∂t (ri + ro )gm

Define the new constants



1
λc =
(ri + ro )gm
cm
τm =
gm

Then
ro
= ro λ2c
(ri + ro )gm
6.6 The Transient Cable Equations 167

and the Cable Eq. 6.9 can be written in a new form as

∂ 2 vm ∂vm
λ2c − τm − vm = −ro λ2c ke (6.10)
∂z 2 ∂t

The new constants τm and λc are very important to understanding how the solutions
to this equation will behave. We call τm the time constant and λc the space constant
of our cable.

6.6.2.1 The Time Constant

Consider the ratio gcmm . Note that the units of this ratio are fahrad − ohm. Recall that
charge deposited on a capacitor of value C fahrads is q = C V where V is the voltage
across the capacitor. Hence, a dimensional analysis shows us that coulombs equal
fahrad-volts. But we also know from Ohm’s law that voltage is current times resis-
tance; hence, dimensional analysis tells us that volts equal coulomb−ohm
sec
. We conclude
that fahrad − ohm equals coulombvolt
times ohm. But a coulomb
volt
is a sec
ohm
by Ohm’s law
as discussed above. Hence, simplifying, we see the ration gcmm has unit of seconds.
Hence, this ratio is a time variable. This is why we define this constant to be the
time constant of the cable, τm . Note that τm is a constant whose value is independent
of the size of the cell; hence it is a membrane property. Also, if we let G m be the
1 2
conductance of a square centimeter of cell membrane. Then G m has units of ohm−cm .
The conductance of our z box of membrane in our model was gm z and the total
conductance of the box is also G m times the surface area of the box or G m 2πa z.
Equating expressions, we see that

gm = 2πa G m

In a similar manner, if Cm is the membrane capacitance per unit area, we have

cm = 2πa Cm
Cm
We see the time constant can thus be expressed as Gm
also.

6.6.2.2 The Space Constant

Next, consider the dimensional analysis of the term (ri +r1o )gm . The sum of the resis-
tances per length have units ohmcm
and gm has units ohm−cm
1
. Hence, the denominator
ohm 1 −2
of this fraction has units cm times ohm−cm or cm . Hence, this ratio has units of
cm2 . This is why the square root of the ratio functions as a length parameter. We can
look at this more closely. Consider again our approximate model where we divide
the cable up into pieces of length z. We know the inner current per unit area density
168 6 Lumped and Distributed Cell Models

is Ji and it is defined by

Ii (z, t) d
Ji (z, t) = = σi Ei = −σi
πa 2 dz

where z is the position in the inner cylinder, σi is the conductivity and Ei is the
electrical field density per length of the inner solution, respectively and  is the
potential at position z in the inner cylinder. It then follows that

Ii (z, t) d
=−
πa 2 σi dz

Now let’s assume the inner longitudinal current from position z to position z + z
is constant with value I (z, t). Then, integrating we obtain
 z+z
Ii (z, t) d
z = − dz
πa 2 σi z dz
= (z) − (z + z).

But this change in potential from z to z+z can be approximated by the inner cylinder
voltage at z at time t, Vi (z, t). Thus, noting the resistivity of the inner solution, ρi , is
the reciprocal of the conductivity, our approximation allows us to say

ρi Ii (z, t)
z = Vi (z, t)
πa 2
This implies that resistance of this piece of cable can be modeled by

Vi (z, t) ρi z
Ri (z, t) = =
Ii (z, t) πa 2

and so we conclude that since Ri must be the same as ri z, we have


ρi
ri =
πa 2
Now in biological settings, we typically have that ri is very large compared to ro .
Hence, the term ri + ro is nicely approximated by just ri . In this case, since gm is
2πa G m , we see

1
λc =
ri gm

1
= ρi
πa 2
2πaG m
6.6 The Transient Cable Equations 169

a
=
2ρi G m

Now ρi and G m are membrane constants independent of cell geometry. So we see


that the space constant is proportional to the square root of the fiber radius. Note also
that the space constant decreases as the fiber radius shrinks.
Chapter 7
Time Independent Solutions to Infinite
Cables

In Fig. 7.1, we see a small piece of cable as described in Chap. 6. We are injecting
current Ie into the cable via an external current source at z = 0. We assume the
current that is injected in uniformly distributed around the cable membrane. We will
begin by assuming that the cable extends to infinity both to the right and to the left of
the current injection site. This is actually easier to handle mathematically, although
you will probably find it plenty challenging! The picture we see in Fig. 7.1 is thus
just a short piece of this infinitely long cable. Now if a dendrite or axon was really
long, this would probably not be a bad model, so there is a lot of utility in examining
this case as an approximation to reality. We also assume the other end of the line
that delivers the current Ie is attached some place so far away it has no effect on our
cable. We now begin our discussion of how to solve this problem.

7.1 The Infinite Cable

The time dependent cable equation is just the full cable Eq. 6.10 from Sect. 6.6.
Recall that ke is the external current per unit length. Hence, λc ke is a current which
is measured in amps. We also know that λc ro is a resistance measured in ohms.
Hence, the product ro λc times λc ke is a voltage as from Ohm’s law, resistance times
current is voltage. Thus, the right hand side of the cable equation is the voltage due
to the current injection. On the left hand side, a similar analysis shows that each term
represents a voltage.
• λ2c ∂∂zv2m is measured in cm2 times cm
2
volt
2 or volts.
∂vm
• τm ∂t is measured in seconds times secondvolt
or volts.
• vm is measured volts.
Now if we were interested only in solutions that did not depend on time, then the term
∂vm
∂t
would be zero. Also, we could write all of our variables as position dependent

© Springer Science+Business Media Singapore 2016 171


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_7
172 7 Time Independent Solutions to Infinite Cables

Fig. 7.1 Current injection


into a cable

only; i.e. vm (z, t) as just vm (z) and so on. In this case, the partial derivatives are not
necessary and we obtain an ordinary differential equation:

d 2 vm
λ2c − vm (z) = −ro λ2c ke (z) (7.1)
dz 2

7.2 Solving the Time Independent Infinite Cable Equation

Equation 7.1 as written does not impose any boundary or initial conditions on the
solution. Eventually, we will have to make a decision about these conditions, but
for the moment, let’s solve this general differential equation as it stands. The typical
solution to such an equation is written in two parts: the homogeneous part and the
particular part. The homogeneous part or solution is the function φh that solves

d 2 vm
λ2c − vm (z) = 0 (7.2)
dz 2

This means that if we plug φh into 7.2, we would find

d 2 φh
λ2c − φh (z) = 0
dz 2

The particular part or solution is any function φ p that satisfies the full Eq. 7.1; i.e.

d 2φ p
λ2c − φ p (z) = −ro λ2c ke (z)
dz 2

It is implied in the above discussions that φh and φ p must be functions that have two
derivatives for all values of z that are interesting. Since this first case concerns a cable
of infinite length, this means here that φh and φ p must be twice differentiable on the
7.2 Solving the Time Independent Infinite Cable Equation 173

entire z axis. We can also clearly see that adding the homogeneous and particular
part together will always satisfy the full time dependent cable equation. Let φ denote
the general solution. Then

φ(z) = φh (z) + φ p (z)

and φ will satisfy the time independent cable equation. If the external current ke is
continuous in z, then since the right hand side must equal the left hand side, the
continuity of the right hand side will force the left hand side to be continuous also.
This will force the solution φ we seek to be continuous in the second derivative. So
usually we are looking for solutions that are very nice: they are continuous in the
second derivative. This means that there are no corners in the second derivative of
voltage.

7.2.1 Variation of Parameters

Since we don’t know the explicit function ke we wish to use in the non-homogeneous
equation, the common technique to use to find the particular solution is the one called
Variation of Parameters. We use the fact that the solutions to our model are linearly
independent. Here the vector space is C 2 [a, b] for some interval [a, b] and we use
the linear independence of the two solutions of the homogeneous linear second order
model to build a solution to the nonhomogeneous model. Rather than doing this in
general, we will focus on a specific model:

d2x
β2 − x(t) = f (t)
dt 2
x(0) = −1
x(5) = 4.

where β is a nonzero number and we have switched to using the independent variable
t instead of z for convenience. Our cable models without time dependence will give
us equations to solve with the independent variable being space, z, but other models
can use time, t. The homogeneous solution x h here solves

d2x
β2 − x(t) = 0
dt 2
and has the form

x h (t) = Ae− β + Be β
t t
174 7 Time Independent Solutions to Infinite Cables

We want to find a particular solution, called x p , to the model. Hence, we want x p to


satisfy

β 2 x p (t) − x p (t) = f (t)

Since we don’t know the explicit function f we wish to use in the nonhomogeneous
equation, a common technique to find the particular solution is the one called Varia-
tion of Parameters. In this technique, we take the homogeneous solution and replace
the constants A and B by unknown functions u 1 (t) and u 2 (t). Then we see if we
can derive conditions that the unknown functions u 1 and u 2 must satisfy in order to
work. So we start by assuming

x p (t) = u 1 (t)e− β + u 2 (t)e β


t t

Using the chain and product rule for differentiation, the first derivative of x thus gives
(we use the prime notation for derivatives with respect to t to clean up the notation):

1 t 1 t
x p = u 1 (t)e− β − u 1 (t) e− β + u 2 (t)e β + u 2 (t) e β
t t

β β
 
= u 1 (t)e− β + u 2 (t)e β
t t

1 t 1 t
−u 1 (t) e− β + u 2 (t) e β
β β

We know there are two solutions to the model, e− β and e β which are linearly inde-
t t

pendent functions. Hence, there associated Wronskian is never zero for all s. Letting
x1 (t) = e− β and x2 (t) = etβ , consider the system
t

    
x1 (t) x2 (t) φ(t) 0
=
x1 (t) x2 (t) ψ(t) g(t)

for any appropriately nice function g. For each fixed t, the determinant of this system
is the value of the Wronskian which is not zero. Hence, there is a unique solution
for the value of φ(t) and ψ(t) for each t. In particular, we can use this idea with
the functions φ(t) = u 1 (t) and ψ(t) = u 2 (t) so the first row gives us a condition we
must impose on our unknown functions u 1 (t) and u 2 (t). We must have

u 1 (t)e− β + u 2 (t)e β = 0
t t

This simplifies the first derivative of x p to be


7.2 Solving the Time Independent Infinite Cable Equation 175

1 t 1 t
x p (t) = −u 1 (t) e− β + u 2 (t) e β
β β

Now take the second derivative to get

1 t 1 t 1 1 t
x p (t) = −u 1 (t) e− β + u 2 (t) e β + u 1 (t) 2 e− β + u 2 (t) 2 e β
t

β β β β

Now plug these derivative expressions into the nonhomogeneous equation to find
 
 1 βt  1 − βt 1 βt 1 − βt
f (t) = β u 2 (t) e − u 1 (t) e + u 2 (t) 2 e + u 1 (t) 2 e
2
β β β β
 
− u 2 (t)e β + u 1 (t)e− β
t t

Now factor out the common u 1 (t) and u 2 (t) terms to find after a bit of simplifying
that
 
1 t 1 t
f (t) = β 2 u 2 (t) e β − u 1 (t) e− β + u 2 (t)(e β − e β ) + u 1 (t)(e− β − e− β )
t t t t

β β

We see the functions u 1 and u 2 must satisfy

f (t) 1 t 1 t
= u 2 (t) e β − u 1 (t) e− β
β2 β β

This gives us a second condition on the unknown functions u 1 and u 2 . Combining


we have

u 1 (t)e− β + u 2 (t)e β = 0
t t

1 t 1 t f (t)
−u 1 (t) e− β + u 2 (t) e β = 2
β β β

This can be rewritten in a matrix form:


 t     
e− β
t
eβ u 1 (t) 0
= f (t)
− β1 e− β β1 e β u 2 (t)
t t
β2

We then use Cramer’s Rule to solve for the unknown functions u 1 and u 2 . Let W
denote the matrix
 t 
e− β
t

W =
− β1 e− β β1 e β
t t
176 7 Time Independent Solutions to Infinite Cables

Then the determinant of W is det (W ) = 2


β
and by Cramer’s Rule
 t

0 eβ
f (t) 1 βt
β2 β
e 1 t
u 1 (t) = =− f (t)e β
det (W ) 2β

and
 
e− β
t
0
1 − βt f (t)
−βe β2 1
f (t)e− β
t
u 2 (t) = =
det (W ) 2β

Thus, integrating, we have


 t
1 u
u 1 (t) = − f (u) e β du
2β 0
 t
1
f (u) e− β du
u
u 2 (t) =
2β 0

where 0 is a convenient starting point for our integration. Hence, the particular
solution to the nonhomogeneous time independent equation is

x p (t) = u 1 (t) e− β + u 2 (t) e β


t t

  t    t 
1 1
f (u) e β du e− β + f (u) e− β du e β .
u t u t
= −
2β 0 β 0

The general solution is thus

x(t) = x h (t) + x p (t)


 t  t
1 − βt 1 βt
= A1 e− β + A2 e β − f (u) e− β du
t t u u
e f (u) e β du + e
2β 0 2β 0

for any real constants A1 and A2 . Finally, note we can rewrite these equations as
 t  t
− βt 1 1
f (u) e−
t u−t u−t
x(t) = A1 e + A2 e − β f (u) e β du + β du
2β 0 2β 0

or
  
− e−
u−t u−t
t
− βt 1t e β β
x(t) = A1 e + A2 e − β f (u) du
β 0 2
7.2 Solving the Time Independent Infinite Cable Equation 177

w −w
In applied modeling work, the function e −e 2
arises frequently enough to be given a
name. It is called the hyperbolic sine function and is denoted by the symbol sinh(w).
Hence, we can write once more to see
  
1 t
u−t
x(t) = A1 e− β + A2 e β −
t t
f (u) sinh du.
β 0 β

Finally, sinh is an odd function, so we can pull the minus side inside by reversing
the argument into the sinh function. This gives
  
1 t
t −u
x(t) = A1 e− β + A2 e β +
t t
f (u) sinh du
β 0 β

Now let’s use the initial conditions x(0) = −1 and x(5) = 4. Hence,

−1 = x(0) = A1 + A2
  
− β5 15
5
5−u
4 = x(5) = A1 e + A2 e + β f (u) sinh du
β 0 β

which is solvable (albeit with an forbidding algebraic struggle!) for A1 and A2 . We


can use this technique on lots of models and generate similar solutions. If we have
boundary conditions involving derivatives at a point, we will need a result called
Leibnitz’s Rule. We will only state a specific version of this; there are other more
general versions.

Theorem 7.2.1 (Leibnitz’s Rule)


Let f (s, t) be continuous on the rectangle [a, b] × [c, d] and let u and v be continu-
ous functions on some intervals whose range is a subset of [a, b]. This means u(t) is
in [a, b] for each t in its domain and v(t) is in [a, b] for each t in its domain. Then,
define F on the interval [c, d] by
 v(t)
F(t) = f (s, t) ds.
u(t)

Note that because of our assumptions, the lower and upper limit of integration always
give points in the interval [a, b] where f (s, t) is defined and so the Riemann integral
makes sense to calculate. Then, we have
 v(t)
 ∂f
F (t) = (s, t) ds + f (v(t), t) v  (t) − f (u(t), t) u  (t).
u(t) ∂t

Proof The proof of this is essentially similar to the proof of the Cauchy Fundamental
Theorem of Calculus. It is found in a good book on analysis (you can ask for our
notes on these matters if you are adventuresome!). 
178 7 Time Independent Solutions to Infinite Cables

The first example below has an initial condition on the derivative of the solution at
0; hence, Leibnitz’s rule will be needed.

7.2.1.1 Examples

Example 7.2.1 Solve

u  (t) + 9u(t) = 2t
u(0) = 1
u  (3) = −1

Solution The characteristic equation is r 2 + 9 = 0 which has the complex roots


±3i. Hence, the two linearly independent solutions to the homogeneous equation
are cos(3t) and sin(3t). We set the homogeneous solution to be

u h (t) = A cos(3t) + B sin(3t)

where A and B are arbitrary constants. The nonhomogeneous solution is of the form

u p (t) = φ(t) cos(3t) + ψ(t) sin(3t).

where this time the functions φ and ψ play the role of the functions u 1 and u 2 we
used earlier. Since the solution we seek is u(t) it is confusing to have the extra u 1
and u 2 and so we switch to the variables φ and ψ. We know the functions φ and ψ
must then satisfy
    
cos(3t) sin(3t) φ (t) 0
=
−3 sin(3t) 3 cos(3t) ψ  (t) 2t

Applying Cramer’s rule, we have since the Wronskian here is 3 that


 
1 0 sin(3t) 2
φ (t) = = − t sin(3t)
3 2t 3 cos(3t) 3

and
 
 1 cos(3t) 0 2
ψ (t) = = t cos(3t)
3 −3 sin(3t) 2t 3

Thus, integrating, we have


 t
2
φ(t) = − u sin(3u) du
3 0
7.2 Solving the Time Independent Infinite Cable Equation 179
 t
2
ψ(t) = u cos(3u) du.
3 0

The general solution is therefore


  t 
2
u(t) = A cos(3t) + B sin(3t) − u sin(3u) du cos(3t)
0 3
  t 
2
+ u cos(3u) du sin(3t).
3 0

This can be simplified to


 t
2
u(t) = A cos(3t) + B sin(3t) + u{sin(3t) cos(3u) − sin(3u) cos(3t)} du
3 0
 t
2
= A cos(3t) + B sin(3t) + u sin(3t − 3u) du.
3 0

Applying Leibnitz’s rule, we find


 t
2
u  (t) = −3A sin(3t) + 3B cos(3t) + t sin(3t − 3t) + 2u cos(3t − 3u) du
3 0
 t
= −3A sin(3t) + 3B cos(3t) + 2u cos(3t − 3u) du
0

Applying the boundary conditions, we find

1 = u(0) = A
 3
−1 = u  (3) = −3A sin(9) + 3B cos(9) + 2u cos(9 − 3u) du
0

Hence, A = 1 and
3
−1 + 3 sin(9) − 0 2u cos(9 − 3u) du
B= .
3 cos(9)

We can then assemble the solution using these constants.

Example 7.2.2 Solve

u  (t) + 9u(t) = 2t
u(0) = 1
u(4) = −1
180 7 Time Independent Solutions to Infinite Cables

Solution The model is the same as the previous example except for the boundary
conditions. We have

1 = u(0) = A
 4
2
−1 = u(4) = A cos(12) + B sin(12) + u sin(12 − 3u) du.
3 0

Thus, since A = 1, we have


 4
2
B sin(12) = −1 − cos(12) − u sin(12 − 3u) du.
3 0

and so
4
1 + cos(12) + 2
u sin(12 − 3u) du
B=− 3 0
.
sin(12)

As usual, we can then assemble the solution using these constants.

7.2.1.2 Homework

Exercise 7.2.1 Solve

u  (t) + 4u(t) = 2t
u(0) = 2
u(4) = −6

expressing the particular solution in integral form. Note, if you are brave, you can
calculate this integral, but be warned it needs integration by parts.

Exercise 7.2.2 Solve

u  (t) − u  (t) − 6u(t) = 2t


u(0) = 10
u(4) = −5

expressing the particular solution in integral form.


7.2 Solving the Time Independent Infinite Cable Equation 181

Exercise 7.2.3 Solve

u  (t) − 4u(t) = 2t
u(0) = 2
u  (0) = −1

expressing the particular solution in integral form.

7.3 Modeling Current Injections

The time independent Cable equation has the form

d 2 vm
λ2c − vm (z) = −ro λ2c ke (z)
dz 2

and we solve this model using Variation of Parameters. We find the general
solution is
 z  
− λzc z s−z
φ(z) = A1 e + A 2 e c + r 0 λc
λ ke (s) sinh ds.
0 λc

We are interested in understanding what the membrane voltage solution should look
like in the event of a current injection at say z = 0 for a very short period of time. We
could then use this idealized solution to understand the response of the cable model
to current injections occurring over very brief time periods of various magnitudes at
various spatial locations. Now let’s specialize as follows: we assume
• The current injection ke is symmetric about 0.
• The current ke (z) is zero on (−∞, −C) ∪ (C, ∞) for some nonzero C.
• The current smoothly varies to zero at C and −C; i.e. ke is at least differentiable
on the z axis.
• The area under the curve, which is the current applied to the membrane,
C
−C ke (s)ds is I.

Given this type of current injection, we see we are looking for a solution to the
problem

⎨0 z < −C
d 2
vm
λ2c − vm = −r o λ 2
k e −C ≤z≤C
dz 2 ⎩ c
0 C<z

This amounts to solving three differential equations and then recognizing that the
total solution is the sum of the three solutions with the condition that the full solution
is smooth, i.e. continuous, at the points −C and C where the solutions must connect.
182 7 Time Independent Solutions to Infinite Cables

Now we know that membrane voltages are finite. In the first and third region we
seek a solution, we are simply solving the homogeneous equation. We know then the
solution is of the form Ae−w + Bew in both of these regions where w(z) = z/λc .
However, in the (−∞, −C) region, the finiteness of the potential means that the
Bew solution is the only one possible and in the (C, ∞) region, the only solution is
therefore of the form Ae−w . In the middle region, the solution is given by the general
solution we found from the Variation of Parameters method. Thus, for each choice
of positive C, we seek a solution of the form


⎪ Bew(z) z < −C

⎨ A e−w(z) + A ew(z)
1 2
φC (z) = r0 λc −w(z) z s
− λsc
⎪ + λc ds − r0 λc ew(z) z

⎪ 2
⎩ −w(z)
e 0 ke (s) e 2 0 ke (s) e ds −C ≤ z ≤ C
Ae C<z

Our solution and its derivative should be continuous at −C and C. Between −C and
C, we compute the derivative of the solution to be

A1 −w(z) A2 w(z)
φC (z) = − e + e
λc λc

r 0 λc r0 −w(z) z
ke (z) e−w(z) ew(z) −
s
+ e ke (s) e λc ds
2 2
 0
r 0 λc r0 w(z) z
ke (z) e−w(z) ew(z) − ke (s) e− λc ds
s
− e
2 2 0

This simplifies to

A1 −w(z) A2 w(z)
φC (z) = − e + e
λc λ
 z c
r0
− e−w(z) ke (s) ew(s) ds
2
 z0
r0
− ew(z) ke (s) e−w(s) ds (7.3)
2 0

7.3.1 Continuity in the Solution

Now, let ω = C
λc
. Continuity in the solution at the point −C gives:
 −C  −C
r 0 λc ω r0 λc −ω
Be−ω = A1 eω + A2 e−ω + e ke (s) ew(s) ds − e ke (s) e−w(s) ds
2 0 2 0
7.3 Modeling Current Injections 183

This can be rewritten as


 
r 0 λc ω 0 r0 λc −ω 0
Be−ω = A1 eω + A2 e−ω − e ke (s) ews) ds + e ke (s) e−w(s) ds
2 −C 2 −C

Then, the continuity condition at C gives


 
r0 λc −ω C r 0 λc ω C
Ae−ω = A1 e−ω + A2 eω + e ke (s) ew(s) ds − e ke (s) e−w(s) ds.
2 0 2 0

7.3.2 Continuity in the Derivative

Continuity in the derivative at −C gives:


 −C  −C
B −ω A1 A2 −ω r0 ω r0 −ω
e = − eω + e − e ke (s) ew(s) ds − e ke (s) e−w(s) ds
λc λc λc 2 0 2 0

This simplifies to
 0  0
B −ω A1 A2 −ω r0 ω r0 −ω
e = − eω + e + e ke (s) ew(s) ds + e ke (s) e−w(s) ds
λc λc λc 2 −C 2 −C

Finally, the continuity condition in the derivative at the point C gives


 C  C
A −ω A1 A2 ω r0 −ω r0 ω
− e = − e−ω + e − e ke (s) ew(s) ds − e ke (s) e−w(s) ds
λc λc λc 2 0 2 0

7.3.3 Forcing Continuity at the Boundaries

To simplify the exposition, define


 C
J1+ = ke (s) ew(s) ds
0
 0
J1− = ke (s) ew(s) ds
−C
 C
J2+ = ke (s) e−w(s) ds
0
 0
J2− = ke (s) e−w(s) ds
−C
184 7 Time Independent Solutions to Infinite Cables

r 0 λc
and M = 2
. We can then rewrite our continuity conditions as
 
r 0 λc ω 0 r0 λc −ω 0
Be−ω = A1 eω + A2 e−ω − e ke (s) ew(s) ds + e ke (s) e−w(s) ds
2 −C 2 −C
 C  C
r0 λc −ω r 0 λc ω
Ae−ω = A1 e−ω + A2 eω + e ke (s) ew(s) ds − e ke (s) e−w(s) ds
2 0 2 0
 0 
B −ω A1 A2 −ω r0 r0 −ω 0
e = − eω + e + eω ke (s) ew(s) ds + e ke (s) e−w(s) ds
λc λc λc 2 −C 2 −C
 C 
A −ω A1 A2 ω r0 r0 ω C
− e = − e−ω + e − e−ω ke (s) ew(s) ds − e ke (s) e−w(s) ds
λc λc λc 2 0 2 0

With a little manipulation, we then have

Be−ω = A1 eω + A2 e−ω − M eω J1− + M e−ω J2−


Ae−ω = A1 e−ω + A2 eω + M e−ω J1+ − M eω J2+
B −ω A1 A2 −ω r0 ω − r0 −ω −
e = − eω + e + e J1 + e J2
λc λc λc 2 2
A A1 −ω A2 ω r0 −ω + r0 ω +
− e−ω =− e + e − e J1 − e J2
λc λc λc 2 2

Multiplying the third and fourth equation by λc , we obtain our final form:

Be−ω = A1 eω + A2 e−ω − M eω J1− + M e−ω J2−


Ae−ω = A1 e−ω + A2 eω + M e−ω J1+ − M eω J2+
Be−ω = −A1 eω + A2 e−ω + M eω J1− + M e−ω J2−
−Ae−ω = −A1 e−ω + A2 eω − M e−ω J1+ − M eω J2+

This gives us the equations:

(B − A2 − M J2− )e−w + (−A1 + M J1− )ew = 0 (7.4)


(A − A1 − M J1+ )e−w + (−A2 + M J2+ )ew = 0 (7.5)
(B − A2 − M J2− )e−w + (A1 − M J1− )ew = 0 (7.6)
(−A + A1 + M J1+ )e−w + (−A2 + M J2+ )ew = 0 (7.7)

Solving the four new Eqs. (7.4) − (7.6), (7.4) + (7.6), (7.5) − (7.7) and (7.5) + (7.7),
we find

(−2 A1 + 2M J1− )ew = 0


(2B − 2 A2 − 2M J2− )e−w = 0
(2 A − 2 A1 − 2M J1+ )e−w = 0
(−2 A2 + 2M J2+ )ew = 0
7.3 Modeling Current Injections 185

Since the exponentials can never be zero, we have

−2 A1 + 2M J1− = 0
2B − 2 A2 − 2M J2− = 0
2 A − 2 A1 − 2M J1+ = 0
−2 A2 + 2M J2+ = 0

Hence, the solution we seek is

A1 = M J1−
A2 = M J2+
A = A1 + M J1+ = M J1− + M J1+ = M(J1+ + J1− )
B = A2 + M J2− = M J2+ + M J2− = M(J2+ + J2− )

Next note that


 C
J1− + J1+ = ke (s) ew(s) ds
−C
 C
J2− + J2+ = ke (s) e−w(s) ds
−C

Then the solution to this sort of current injection is thus



Mew −C ke (s) e−w(s) ds
C

⎪   z < −C

φC (z) = M(J1− e−w + J2+ ew ) + 2M
z
ke (s) sinh s−z
λc
ds −C ≤ z ≤ C


0

Me−w −C ke (s) ew(s) ds
C
C < z.

7.4 Modeling Instantaneous Current Injections

We can perform the analysis we did in the previous section for any pulse of that form.
What happens as the parameter C approaches 0? As before, we look at pulses which
have these properties for each positive C:
• The current injection keC is symmetric about 0.
• The current keC (z) is zero on (−∞, −C) ∪ (C, ∞)
• The current smoothly varies to zero at ±C so that keC is differentiable on the z axis.
• The area under the curve, which is the current applied to the membrane,
C
−C ke (s)ds is I for all C. This means that as the width of the symmetric pulse
C

goes to zero, the height of the pulse goes to infinity but in a controlled way: the
186 7 Time Independent Solutions to Infinite Cables

area under the pulses is always the same number I . So no matter what the base of
the pulse, the same amount of current is delivered to the membrane.
The solution is

Mew −C keC (s) e−w(s) ds
C

⎪   z < −C

− −w + w z
φC (z) = M(J1C e + J2C e ) + 2M keC (s) sinh s−z
λc
ds −C ≤ z ≤ C


0

Me−w −C keC (s) ew(s) ds
C
C < z.

where we now use


 C
+
J1C = keC (s) ew(s) ds
0
 0

J1C = keC (s) ew(s) ds
−C
 C
+
J2C = keC (s) e−w(s) ds
0
 0

J2C = keC (s) e−w(s) ds
−C

Let’s look at the limit as C goes to 0.

7.4.1 What Happens Away from 0?

Pick a point z 0 that is not zero. Since z 0 is not zero, there is a value of positive number
C ∗ so that z 0 is not inside the interval (−C ∗ , C ∗ ). This means that z 0 is outside of
(−C, C) for all C smaller that C ∗ . Hence, either the first part or the third part of
the definition of φC applies. We will argue the case for z 0 is positive which implies
that the third part of the definition is the one that is applicable. The case where z 0 is
negative would be handled in a similar fashion. Since we assume that z 0 is positive,
we have for all C smaller than C ∗ :
 C
−w0
φC (z 0 ) = Me keC (s) ew(s) ds
−C

where w0 = z0
λc
. Next, we can prove as C goes to 0, we obtain

Lemma 7.4.1 (Limiting Current Densities)

+ I
lim J1C =
C→0 2
7.4 Modeling Instantaneous Current Injections 187

− I
lim J1C =−
C→0 2
+ I
lim J2C =
C→0 2
− I
lim J2C =−
C→0 2

Proof It suffices to show this for just one of these four cases. We will show the first
+
one. In mathematics, if the limit as C goes to 0 of J1C exists and equals 2I , this means
that given any positive number , we can find a C ∗∗ so that if C < C ∗∗ , then
 
 + 
J − I  <
 1C 2 

whenever C < C ∗∗ . We will show how to do this argument below. Consider


   
 +   C
I 
J − I  =  keC (s) e
s
λc ds − 
 1C 2   2
0

However, we know that the area under the curve is always I ; hence for any C,
 C
I = keC (s)ds
−C

Since our pulse is symmetric, this implies that


 C
I
= keC (s)ds
2 0

Substituting into our original expression, we find


   C  C 
 +   
J − I  =  k C
(s) e − λsc
ds − k C
(s)ds 
 1C 2   e e 
0 0
 C
keC (s) |e− λc − 1|ds
s

0

2
Now we know that this exponential function is continuous at 0; hence, given I
, there
is a δ so that
2
|e− λc − 1| <
s
if |s| < δ
I
Since, C goes to zero, we see that there is a positive number C ∗∗ , which we can
choose smaller than our original C ∗ , so that C ∗∗ < δ. Thus, if we integrate over
188 7 Time Independent Solutions to Infinite Cables

[0, C] for any C < C ∗∗ , all the s values inside the integral are less than δ. So we can
conclude
 C 
+ I 2
|J1C − |< keC (s) ds = .
2 0 I
+
This shows that the limit as C goes to 0 of J1C is 2I . 

Hence, for z 0 positive, we find


 C
lim φC (z 0 ) = Me−w0 lim keC (s) eω(s) ds
C→0 C→0 −C
 
− +
= Me−w0 lim J1C + J1C
C→0
r0 λc I −z0
= Me−w0 I = e λc .
2
In a similar fashion, for z 0 negative, we find

r o λc I z 0
lim φC (z 0 ) = e λc .
C→0 2

7.4.2 What Happens at Zero?

When we are at zero, since 0 is in (−C, C) for all C, we must use the middle part of
the definition of φC always. Now at 0, we see
  
− −0 + 0
0
s−0
φC (0) = M(J1C e + J2C e ) + 2M keC (s) sinh ds
0 λc
− +
= M(J1C + J2C )

From Lemma 7.4.1, we then find that

r o λc I
lim φC (0) = M I = .
C→0 2

Combining all of the above parts, we see we have shown that as C goes to 0, the
solutions φC converge at each point z (mathematicians say this sequence of functions
converges pointwise on (−∞, ∞)) to the limiting solution φ defined by

ro λc −| z |
φ(z) = I e λc
2
7.4 Modeling Instantaneous Current Injections 189

Now if the symmetric pulse sequence was centered at z 0 with pulse width C, we
can do a similar analysis (it is yucky though and tedious!) to show that the limiting
solution would be
ro λc − |z−z0 |
φ(z) = I e λc .
2

7.5 Idealized Impulse Currents

Now as C gets small, our symmetric pulses have very narrow base but very large
magnitudes. Clearly, these pulses are not defined in the limit as C goes to 0 as the
limit process leads to a current Iδ (z) which is the limit of the base pulses we have
described:

Iδ (z) = lim keC (z).


C→0

Note, in the limit as C gets small, we can think of this process as delivering an
instantaneous current value. This idealized current thus delivers a fixed amount I at
z = 0 instantly! Effectively, this means that the value of the current density keeps
getting larger while its spatial window gets smaller. A good example (though not
quite right as this example is not continuous at ±1/n) is a current density of size
n I which on the spatial window [−1/n, 1/n]. The current for any n that is applied
is the product of the current density and the distance it is applied: n I × 1/n = I .
From a certain point of view, we can view the limiting current density as depositing
an “infinite” amount of current in zero time: crazy, but easy to remember! Hence, we
can use the definition below as a short hand reminder of what is going on:

0 z = 0
Iδ (z) =
∞z=0

In fact, since the total current deposited over the whole cable is I , and integration can
be interpreted as giving the area under a curve, we can use the integration symbol

−∞ to denote that the total current applied over the cable is always I and write

 ∞
Iδ (z)dz = I.
−∞

Again, this is simply a mnemonic to help us remember complicated limiting current


density behavior! Again, think of Iδ as an amount of current I which is delivered
instantaneously at z is 0. Of course, the only way to really understand this idea is to
do what we have done and consider a sequence of constant current density pulses keC .
190 7 Time Independent Solutions to Infinite Cables

Summarizing, it is convenient to think of a unit idealized impulse called δ functions


defined by

0 z = 0
δ(z − 0) =
∞z=0
 ∞
δ(u − 0)du = 1
−∞

Then using this notation, we see our idealized current Iδ can be written as

Iδ (z − 0) = I δ(z − 0).

Moreover, if an idealized pulse is applied at z 0 rather than 0, we can abuse this


notation to define

0 z = z 0
δ(z − z 0 ) =
∞ z = z0
 ∞
δ(u − z 0 )du = 1
−∞

and hence I δ(z − z 0 ) is a idealized pulse applied at z 0 . Note that the notion of an
idealized pulse allows us to write the infinite cable model for an idealized pulse
applied at z 0 of magnitude I in a compact form. We let the applied current density
be ke (z) = I δ(z − z 0 ) giving us the differential equation

d 2 vm
λ2c − vm (z) = −ro λ2c I δ(z − z 0 )
dz 2

which we know has solution


r 0 λc z−z 0
φ(z) = I e−| λc |
2
In all of our analysis, we use a linear ordinary differential equation as our model.
Hence, the linear superposition principle applies and hence for N idealized pulses
applied at differing centers and with different magnitudes, the underlying differential
equation is

d 2 vm N
λ2c − vm (z) = −r o λ 2
c Ii δ(z − z i )
dz 2 i=0
7.5 Idealized Impulse Currents 191

with solution

r 0 λc 
N
z−z i
φ(z) = Ii e−| λc |
2 i=0

Note that the membrane voltage solution is a nonlinear summation of the applied
idealized current injections. For example, let’s inject current of magnitudes I at 0
and 2I at λc respectively. The solution to the current injection at 0 is vm1 and at λc ,
vm2 . Thus,

r o λc |z|
vm1 (z) = I e − λc
2
r o λc |z−λc |
vm2 (z) = 2I e− λc
2
We get a lot of information by looking at these two solutions in terms of units of
the space constant λc . If you look at Fig. 7.2, you’ll see the two membrane voltages
plotted together on the same access. Now the actual membrane voltage is, of course,
vm1 added to vm2 which we don’t show. However, you can clearly see how quickly the
peak voltages fall off as you move away from the injection site.
Note that one space constant away from an injection site z 0 , the voltage falls by
a factor of 1e or 37 %. This is familiar exponential decay behavior.

Fig. 7.2 Voltages due to two current impulses


192 7 Time Independent Solutions to Infinite Cables

7.5.1 Integrals of Impulse Functions

b
We often need to evaluate integrals of the form a δ(x − x0 )g(x)d x where x0 is in
the interval [a, b]. Let keC be our usual set of pulses which we use to approximate the
impulse function except this time we center the pulses at x0 . Then, we have
 b  C+x0
keC (x)g(x)d x = keC g(x)d x.
a C−x0

Now as long as g is continuous on [a, b], g has a minimum and maximum value on
the interval [C − x0 , C + x0 ]; call these gmC and g CM . Then we have the inequalities
 C+x0  C+x0  C+x0
gmC keC (x)d x ≤ keC (x)g(x)d x ≤ g CM keC (x)d x.
C−x0 C−x0 C−x0

C+x0
But the C−x0 keC (x)d x = 1 so we have
 C+x0
gmC ≤ keC (x)g(x)d x ≤ g CM .
C−x0

Finally, as C → 0, gmC → g(x0 ) and g CM → g(x0 ) because g is continuous on [a, b].


We conclude
 b
lim keC (x)g(x)d x = g(x0 ).
C→0 a

b
This limit is what we mean by the integral a δ(x − x0 )g(x)d x and so we have shown
b
that a δ(x − x0 )g(x)d x = g(x0 ).

7.6 The Inner and Outer Current Solutions

Recall that the membrane current density km satisfies

∂vm
km (z, t) = gm vm (z, t) + cm
∂t
Here, we are interested in time independent solutions, so we have the simpler
equation

km (z) = gm vm (z)
7.6 The Inner and Outer Current Solutions 193

Thus, we have for an idealized current impulse injection at 0

r o λc |z|
km (z) = gm I e − λc
2
From our core conductor equations, we know that

∂ Ii
= −K m (z)
∂z

and thus, using our transient variables

Io (z) = Io0 + i 0 (z), Ii (z) = Ii0 + i i (z), K m (z) = K m0 + km (z)

we see that
∂i i
= −K m0 − km (z)
∂z

Integrating, we see
 z
i i (z) = − (K m0 + km (u))du
−∞

We expect that the internal current is finite and this implies that the initial current
density K m0 must be zero as otherwise we obtain unbounded current. We thus have

∂i i
= − km (z) (7.8)
∂z

and so
 z  z
i i (z) − i i (−∞) = − km (u)du = − gm vm (u)du
−∞ −∞
 z u
r o λc −∞ e u
λc z<0
=− gm I 0 z − λu
2 c du + c du z ≥ 0
−∞ e 0 e
λ

Also, for an impulse current applied at zero, we would expect that the inner current
vanish at both ends of the infinite cable. Hence, i i (−∞) must be zero. We conclude
 u 
λc e λc −∞
z
r o λc z
= λ c e λc  z<0
i i (z) = − gm I
λc e λc 0−∞ − λc e− λc 0z = λc (2 − e− λc ) z ≥ 0
u u z
2
194 7 Time Independent Solutions to Infinite Cables

Using the definition of the space constant λc , we note the identity


ro
λ2c gm =
ri + ro

allowing us to rewrite the inner current solution as


 z
ro I e λc z<0
i i (z) = −
(2 − e− λc ) z ≥ 0
z
ri + ro 2

Now, from Sect. 6.5, Eqs. 6.1 and 6.2, we know in our time independent case

∂ Ii ∂ Io
= −K m (z), = K m (z) − K e (z)
∂z ∂z

which implies

∂i i ∂i o
+ = −K e (z) = −K e0 − ke (z)
∂z ∂z

Integrating, we have
  
z
∂i i z
∂i o z
du + du = − (K e0 + ke (u))du
−∞ ∂z −∞ ∂z −∞

In order for this integration to give us finite currents, we see the constant K e0 must
be zero implying
 z
i i (z) − i i (−∞) + i o (z) − i o (−∞) = − ke (u)du
−∞

We already know that i i is zero at z = −∞ for our idealized current impulse ke =


I δ(u). Further, we know from our lengthy analysis of sequences of current pulses
of constant area I , ken , that integrating from −∞ to z > 0 gives I and 0 if z ≤ 0.
Hence, the inner and outer transient currents for an idealized pulse must satisfy

−I z > 0
i i (z) + i o (z) − i o (−∞) =
0 z≤0

The argument to see this can be sketched as follows. If z is positive, for small enough
C, the impulse current keC is active on the interval [−C, C] with C less than z. For
such values of C, the integral becomes
 C
keC (u)du = I
−C
7.6 The Inner and Outer Current Solutions 195

On the other hand, if z is negative, eventually the interval where keC is non zero lies
outside the region on integration and so we get the value of the integral must be zero.
Physically, since we are using an idealized injected current, we expect that the outer
current satisfies i o (−∞) is zero giving

−I z > 0
i i (z) + i o (z) =
0 z≤0

We can rewrite our current solutions more compactly by defining the signum function
sgn and the unit step function u as follows:
 
−1 z < 0 0 z<0
sgn(z) = , u(z) =
+1 z ≥ 0 1 z≥0

Then we have
ro I  |z| 
i i (z) = e− λc sgn(z) − 2u(z)
2(ri + ro )

Next, we can solve for i o to obtain

i o (z) = −I u(z) − i i (z)


ro I  |z| 
= −I u(z) − e− λc sgn(z) − 2u(z)
2(ri + ro )
 
ro ro I |z|
= −u(z) 1 − I− e− λc sgn(z)
2(ri + ro ) 2(ri + ro )
ri ro I |z|
= −u(z) I− e− λc sgn(z)
ri + ro 2(ri + ro )

This further simplifies to the final forms


 
ro I |z| ri
i o (z) = − e− λc sgn(z) − 2 u(z)
2(ri + ro ) ro
 
ro λ2c gm I |z| r
e− λc sgn(z) − 2 u(z)
i
=−
2 ro

7.7 The Inner and Outer Voltage Solutions

From Sect. 6.5, Eqs. (6.3) and (6.4), we see that for our time independent case

∂Vi ∂Vo
= −ri Ii (z), = −ro Io (z)
∂z ∂z
196 7 Time Independent Solutions to Infinite Cables

Rewriting in terms of transient variables, we have

∂vi ∂vo
= −ri [Ii0 + i i (z)], = −ro [Io0 + i 0 (z)]
∂z ∂z

We expect our voltages to remain bounded and so we must conclude that Ii0 and Io0
are zero, giving
 z
vi (z) − vi (−∞) = −ri i i (u)du
−∞
 z
vo (z) − vo (−∞) = −ro i o (u)du
−∞

To finish this step of our work, we must perform these messy integrations. They are
not hard, but are messy! After a bit of arithmetic, we find
 
r i r o I λc − λ|z|c z
vi (z) − vi (−∞) = e +2 u(z)
2(ri + ro ) λc
 
ro2 I λc − λ|z|c ri z
vo (z) − vo (−∞) = −e +2 u(z)
2(ri + ro ) r o λc

Finally, note that after a bit of algebraic magic

ro I λc − |z|
vi (z) − vo (z) = vi (−∞) − vo (−∞) + e λc
2
Recall that vm is precisely the last term in the equation above; hence we have

vi (z) − vo (z) = vi (−∞) − vo (−∞) + vm (z)

The usual convention is that the voltages at infinity vanish; hence vi (−∞) and
vo (−∞) are zero and we have the membrane voltage solution we expect:

vi (z) − vo (z) = vm (z)

7.8 Summarizing the Infinite Cable Solutions

We have shown that the solutions here are


ro λc I − |z|
vm (z) = e λc
2
ro λ2c gm I −|z|
i i (z) = (e λc sgn(z) − 2u(z))
2
7.8 Summarizing the Infinite Cable Solutions 197

ro λ2c gm I −|z| ri
i o (z) = − (e λc sgn(z) + 2 u(z))
2 ro
ri ro λ3c gm I −|z| z
vi (z) = − (e λc + 2 u(z))
2 λc
r 2 λ3 gm I −|z| ri z
vo (z) = − o c (− e λc + 2 u(z))
2 r o λc
vm (z) = vi (z) − vo (z)

where we assume vi and vo are zero at negative infinity. Since λ2c can be expressed
in terms of ri and ro , we have also shown that

ro λc I − |z|
vm (z) = e λc
2
ro I −|z|
i i (z) = (e λc sgn(z) − 2u(z))
2 (ri + ro )
ro I −|z| ri
i o (z) = − (e λc sgn(z) + 2 u(z))
2 (ri + ro ) ro
ri ro I −|z| z
vi (z) = − (e λc + 2 u(z))
2 (ri + ro ) λc
ro2 I −|z| ri z
vo (z) = − (− e λc + 2 u(z))
2 (ri + ro ) r o λc

7.8.1 Homework

Exercise 7.8.1 Write Matlab functions to implement all the infinite cable transient
variable solutions using as many arguments to the functions as are needed.
1. vm
2. ii
3. io
4. vi
5. vo .

Exercise 7.8.2 Generate a parametric plot of each of these variables versus the
space variable z on a reasonable size range of z for the parameters λc and Ie∗ .
1. vm
2. ii
3. io
4. vi
5. vo .
Chapter 8
Time Independent Solutions to Finite
and Half-Infinite Space Cables

We are actually interested in a model of information processing that includes a


dendrite, a cell body and an axon. Now we know that the cables that make up
dendrites and axons are not infinite in extent. So although we understand the currents
and voltages change in our infinite cable model, we still need to figure out how these
solutions change when the cable in only finite in extent. A first step in this direction is
to consider a half-infinite cable such as shown in Fig. 8.1 and then a finite length cable
like in Fig. 8.2. In both figures, we think of a real biological dendrite or axon as an
inner cable surrounded by a thin cylindrical sheath of seawater. So the outer resistance
ro will be the resistance of seawater. At first, we think of the cable as extending to
the right forever; i.e. the soma is infinitely far from the front end cap of the cable.
This is of course not realistic, but we can use this thought experiment as a vehicle
towards understanding how to handle a finite cable attached to a soma. Before we had
an impulse current of magnitude I injected at some point on the outer cylinder and
uniformly distributed around the outer cylinder wall. Now we inject current directly
into the front face of our cables. In the finite length L cable case, there will also
be a back end cap at z = L. This back endcap will be attached to the soma. Then,
although we could have the membrane properties of the cable endcap and the soma
itself be different, a reasonable assumption is to make them identical. Hence the back
endcap of the cable is a portion of the cell soma. At any rate, in both situations, the
front endcap of the cable is a logical place to think of current as being injected.
We will begin our modeling with a half-infinite cable. Once we know how to
model the front endcap current injection in this case, we will move directly to the
finite cable model.

8.1 The Half-Infinite Cable Solution

Earlier, we injected an idealized pulse of current into the inner cable at z = 0 but
now we will inject into the current into the front face of the cable. Since the cable
is of radius a, this means we are injecting current into a membrane cap of surface
© Springer Science+Business Media Singapore 2016 199
J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_8
200 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Fig. 8.1 A half-infinite dendrite or axon model

Fig. 8.2 Finite cable

area π a 2 . Note there is no external current source here and hence ke is zero. The
underlying cable equation is

d 2 vm
λ2c − vm = 0, z ≥ 0
dz 2

with solution

vm (z) = A e− λc , z ≥ 0
z
8.1 The Half-Infinite Cable Solution 201

for some value of A which we will determine in a moment. We know that the mem-
brane current density is given by

km (z) = gm vm (z)

and further, from Eq. 7.8, the time independent transient inner current satisfies

di i
= −km (z) = −gm vm (z)
dz

Since the cable starts at z = 0 and moves off to infinity, let’s integrate this differential
equation from z to R for progressively large values of R and see what happens in the
limit as R → ∞. We find
 R  R
di i
e− λc ds
s
dz = −gm A
z dz z
 
i i (R) − i i (z) = gm λc A e− λc − e− λc
R z

Thus,

lim i i (R) = i i (z) − gm λc Ae− λc


z

R→∞

However, we would expect the inner current to become negligible as we move to the
end of the cable. Hence, lim R→∞ i i (R) = 0 and we have

i i (z) = gm λc Ae− λc
z

We also know that current of magnitude I is being injected into the front face of the
inner cable; hence i i (0) must be I . This tells us that

i i (0) = gm λc A = I

Combining, we have for positive z:

I
e− λc , i i (z) = I e− λc
z z
vm (z) =
gm λc

From Ohm’s Law, we know that the ratio of current to voltage is conductance. The
work above suggests that we can define the conductance of the inner cable at z = 0
by the ratio vimi (0)
(0)
. Therefore the ratio of this current to voltage at z = 0, defines an
idealized conductance for the end cap of the cable. This conductance is called the
202 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Th‘evenin Equivalent Conductance of the half-infinite cable. It is denoted by G∞ .


The ratio is easy to compute

i i (0)
G∞ = = gm λc
vm (0)

We can show that G∞ is dependent on the geometry of the cable; indeed, G∞ is


proportional to a to the three-halves power when ri is much bigger than ro . To see
this, recall that the definition of λc gives us that

gm
G∞ =
(ri + ro )

and so if ri is much bigger than ro , we find that



gm
G∞ ≈
ri

For a cylindrical cell of radius a, we know


ρi
ri = , gm = 2πaG m
πa 2
and so

2G m 3
G∞ ≈ π a2
ρi

which tells us that G∞ is proportional to the 3/2 power of a. Thus, larger fibers have
larger characteristic conductances!
If a cable is many space constants long (remember the space constant is propor-
tional to the square root of a, then the half-infinite model we discuss here may be
appropriate. We will be able to show this is a reasonable thing to do after we handle
the true finite cable model. Once that is done, we will see that the solutions there
approach the half-infinite model solutions as L goes to infinity.

8.2 The Finite Cable Solution: Current Initialization

If the cable becomes a piece of length L as shown in Fig. 8.2, then there are now
two faces to deal with; the input face through which a current pulse of size I is
delivered into some conductance and an output face at z is L which has a output
load conductance of Ge . Ge represents either the conductance of the membrane that
caps the cable or the conductance of another cable or cell soma attached at this point.
8.2 The Finite Cable Solution: Current Initialization 203

We again have no external source and so the cable equation is

d 2 vm
λ2c − vm (z) = 0, 0 ≤ z ≤ L
dz 2

The general solution to this homogeneous equation has been discussed before. The
solution we seek will also need two boundary conditions to be fully specified. The
general form of the membrane potential solution is

vm (z) = A1 e λc + A2 e− λc , 0 ≤ z ≤ L
z z

We will rewrite this in terms of the new functions hyperbolic sine and hyperbolic
cosine defined as follows:
   
e λc + e − λc e λc − e − λc
z z z z
z z
cosh = , sinh =
λc 2 λc 2

leading to the new form of the homogeneous solution


   
z z
vm (z) = A1 cosh + A2 sinh , 0≤z≤L
λc λc

It is convenient to reorganize this yet again and rewrite in another equivalent


form as
   
L−z L−z
vm (z) = A1 cosh + A2 sinh , 0≤z≤L
λc λc

Now the membrane current density satisfies


   
L−z L−z
km (z) = gm vm (z) = gm A1 cosh + gm A2 sinh
λc λc

Further, since

d d
cosh(z) = sinh(z), sinh(z) = cosh(z)
dz dz

we can use the internal current equation to find


   
di i L−z L−z
= −km (z) = −gm A1 cosh − gm A2 sinh
dz λc λc
204 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Using the simplest possible antiderivative (i.e. the integration constant is 0), upon
integrating, we find an inner current solution to be
   
L−z L−z
i i (z) = gm λc A1 sinh + gm λc A2 cosh
λc λc

Since the conductance at z = L is Ge , the current at L must be i i (L) = Ge vm (L) or


    
0 0
i i (L) = Ge vm (L) = Ge A1 cosh + A2 sinh = Ge A1 .
λc λc

Next, we have
   
L L
i i (0) = gm λc A1 sinh + gm λc A2 cosh
λc λc
   
0 0
i i (L) = gm λc A1 sinh + gm λc A2 cosh = A2 gm λc .
λc λc

Combining, since i i (0) = I , we have


    
L L
I = gm λc A1 sinh + A2 cosh , A1 Ge = A2 gm λc
λc λc

This implies using the definition of G∞


    
L L
I = G∞ A1 sinh + A2 cosh , A1 Ge = A2 G∞
λc λc

Thus,
    
L Ge L
I = A1 G∞ sinh + cosh
λc G∞ λc

giving us
⎛ ⎞
I ⎜
⎜ 1 ⎟
A1 =    ⎟
G∞ ⎝ Ge

sinh L
λc
+ G∞
cosh L
λc
⎛ ⎞
I Ge ⎜
⎜ 1 ⎟
A2 = 2 ⎝
   ⎟

G∞ Ge
sinh L
λc
+ G∞
cosh L
λc
8.2 The Finite Cable Solution: Current Initialization 205

This leads to the solution we are looking for


⎛    ⎞
Ge
cosh L−z
+ sinh L−z
I ⎜

λc G∞ ⎟λc
vm (z) =     ⎟
G∞ ⎝ Ge

sinh L
λc
+ G∞
cosh L
λc

⎛    ⎞
G∞ sinh + Ge cosh
L−z L−z
I ⎜

λc λc ⎟

i i (z) =    
G∞ ⎝ ⎠
sinh λLc + GG∞e cosh λLc

Note that at 0, we find


⎛    ⎞
Ge
cosh + L
sinh λLc
I ⎜

λc ⎟G∞
vm (0) =    ⎟
G∞ ⎝ ⎠
sinh λLc + GG∞e cosh λLc

From Ohm’s Law, the conductance we see at 0 is given by vimi (0)(0)


. We will call
this the Th‘evenin Equivalent Conductance looking into the cable of length L at 0
or simply the Th‘evenin Input Conductance of the Finite Cable and denote it by the
symbol GT (L) since its value clearly depends on L. It is given by
⎛    ⎞
Ge
sinh L
+ cosh L
⎜ λc G∞ ⎟ λc
GT (L) = G∞ ⎜    ⎟
⎝ ⎠
Ge
cosh L
λc
+ G∞
sinh L
λc

The hyperbolic function tanh is defined by

sinh(u)
tanh(u) =
cosh(u)

and it is easy to show that as u goes to infinity, tanh(u) goes to 1. We can rewrite the
formula for GT (L) to be
⎛   ⎞
Ge
+ tanh λLc
⎜ G∞ ⎟
GT (L) = G∞ ⎜   ⎟
⎝ ⎠
Ge
G∞
tanh λc + 1
L
206 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

and so as L goes to infinity, we find

Ge
G∞
+1
lim GT (L) = G∞ Ge
= G∞
L→∞
G∞
+1

Hence, the Th‘evenin input conductance of the cable approaches the idealized
Th‘evenin input conductance of the half-infinite cable. There are several interest-
ing cases: for convenience of exposition, let’s define

L−z Ge
Z = , H= ,
λc G∞
L
L = , D = sinh(L ) + H cosh(L )
λc

These symbols allow us to rewrite our solutions more compactly as

I cosh(Z ) + H sinh(Z )
vm (z) =
G∞ sinh(L ) + H cosh(L )
I cosh(Z ) + H sinh(Z )
=
G∞ D
I G∞ sinh(Z ) + Ge cosh(Z )
i i (z) =
G∞ sinh(L ) + H cosh(L )
I G∞ sinh(Z ) + Ge cosh(Z )
=
G∞ D
sinh(L ) + H cosh(L )
GT (L) = G∞
cosh(L ) + H sinh(L )

Ge = 0 If the conductance of the end cap is zero, then H is zero and no current
flows through the endcap. We see

sinh(L )
GT (L) = G∞ = G∞ tanh(L )
cosh(L )

Ge = G∞ If the conductance of the end cap is G∞ , then H is one and we see the
finite cable acts like the half-infinite cable:

sinh(L ) + cosh(L )
GT (L) = G∞ = G∞
cosh(L ) + sinh(L )

Ge = ∞ If the conductance of the end cap is ∞, the end of the cable acts like it is
short-circuited, H is infinity. Divide our original conductance solution by H top
and bottom and letting K denote the reciprocal of H , we see:
8.2 The Finite Cable Solution: Current Initialization 207

K sinh(L ) + cosh(L )
GT (L) = G∞
K cosh(L ) + sinh(L )

Now K is zero here so we get

cosh(L )
GT (L) = G∞ = G∞ coth(L )
sinh(L )

8.2.1 Parametric Studies

We can calculate that


vm (L) 1
=  
vm (0) cosh L
+ Ge
sinh L
λc G∞ λc

For convenience, let’s think of L as λLc and ρ as GG∞e . Then the ratio of the voltage at
the end of the cable to the voltage at the beginning can be expressed as

vm (L) 1
=
vm (0) cosh(L ) + ρ sinh(L )

This ratio measures the attenuation of the initial voltage as we move down the cable
toward the end. We can plot a series of these attenuations for a variety of values of ρ.
In Fig. 8.3, the highest ρ value is associated with the bottom most plot and the lowest
value is associated with the top plot. Note as ρ increases, there is more conductivity
through the end cap and the voltage drops faster. The top plot is for ρ is zero which is
the case of no current flow through the end cap. We can also look how the Th‘evenin
equivalent conductance varies with the value of ρ. We can easily show that

GT (L) tanh(L ) + ρ
GT∗ (L) = =
G∞ 1 + ρ tanh(L )

In Fig. 8.4, we see that the ρ is one is the plot to which the other choices approach.
When ρ is above one, the input conductance ratio curve starts above the ρ is one
curve; when ρ is below one, the ratio curve approaches from below.

8.2.2 Some MatLab Implementations

We want to compare the membrane voltages we see in the infinite cable case to
the ones we see in the finite cable case. Now in the infinite cable case, I current is
deposited at z = 0 and the current injection spreads out uniformly to both sides of 0
208 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Fig. 8.3 Attenuation increases with ρ

Fig. 8.4 Finite cable input conductance study


8.2 The Finite Cable Solution: Current Initialization 209

leading to the solution

r0 I λc −|z|
vm (z) = e λc
2
where the finite cable case is missing the division by 2 because in a sense, the current
is not allowed to spread backwards. Hence to compare solutions, we will inject 2 I
into the infinite cable at 0 and I into the finite cable. Now at z = 0, the finite cable
solution gives

I cosh(L ) + H sinh(L ) I 1 + H tanh(L )


vm (0) = =
G∞ sinh(L ) + H cosh(L ) G∞ H + tanh(L )

In the examples below, we set G∞ , λc and r0 are one and set the cable length to 3.
Hence, since for L = 3, tanh(L ) is very close to one, we have

1+ H
vm (0) ≈ I ≈ I
H +1

So for these parameters, we should be able to compare the infinite and finite cable
solutions nicely.
MatLab code to implement the infinite cable voltage solution is given below:

Listing 8.1: Computing The Infinite Cable Voltage


f u n c t i o n t = I n i n i t e M e m b r a n e V o l t a g e ( I e h a t , r0 , lambda c , z )
2 %
% compute membrane v o l t a g e i n s i d e a f i n i t e f i b e r
%
P r e f i x = ( I e h a t ∗ r0 ∗lambda c ) / 2 . 0 ;
t = P r e f i x ∗ exp ( − 1 . 0 ∗ a b s ( z ) / l a m b d a c ) ;

It is straightforward to modify the code above to handle the finite cable case:

Listing 8.2: Computing The Finite Cable Voltage


f u n c t i o n t = FiniteMembraneVoltage ( Iehat , G i n f i n i t y , . . .
Ge , L , lambda c , z )
%
4 % compute membrane v o l t a g e i n s i d e a f i n i t e f i b e r
%
Prefix = Iehat / Ginfinity ;
FixedArg = L/ l a m b d a c ;
R a t i o = Ge/ G i n f i n i t y ;
9 Denominator = s i n h ( FixedArg )+R a t i o ∗ c o s h ( FixedArg ) ;
Arg = ( L−z ) / l a m b d a c ;
Numerator = c o s h ( Arg )+ R a t i o ∗ s i n h ( Arg ) ;
t = ( I e h a t / G i n f i n i t y ) ∗ ( Numerator / Denominator ) ;
end
210 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

8.2.3 Run-Time Results

We try out these new functions in the following MatLab sessions:

Listing 8.3: Sample Matlab session


Ge = 0 . 1 ;
2 Iehat = 1 . 0 ;
Ginfinity = 1.0;
L = 3.0;
lambda c = 1 . 0 ;
r0 = 1 . 0 ;
7 Z = linspace (0 ,L,200) ;
% Find V o l t a g e f o r i n f i n i t e c a b l e f o r 2∗ I e h a t
V m i n f i n i t y = I n f i n i t e M e m b r a n e V o l t a g e ( 2 ∗ I e h a t , r0 , lambda c , Z ) ;
% Find V o l t a g e f o r f i n i t e c a b l e f o r I e h a t , Ge = 0 . 1
V m0 = F i n i t e M e m b r a n e V o l t a g e ( I e h a t , G i n f i n i t y , Ge , L , lambda c , Z ) ;
12 % Find V o l t a g e f o r f i n i t e c a b l e f o r I e h a t , Ge = 1 . 0
V m8 = F i n i t e M e m b r a n e V o l t a g e ( I e h a t , G i n f i n i t y , 1 . 0 , L , lambda c , Z ) ;
% Find V o l t a g e f o r f i n i t e c a b l e f o r I e h a t , Ge = 5 . 0
V m6 = F i n i t e M e m b r a n e V o l t a g e ( I e h a t , G i n f i n i t y , 5 . 0 , L , lambda c , Z ) ;
% Find V o l t a g e f o r f i n i t e c a b l e f o r I e h a t , Ge = 5 0 . 0
17 V m7 = F i n i t e M e m b r a n e V o l t a g e ( I e h a t , G i n f i n i t y , 5 0 . 0 , L , lambda c , Z ) ;
% P l o t I n f i n i t e c a b l e and f i n i t e c a b l e V o l t a g e s f o r I e h a t , Ge =
0.1
p l o t ( Z , V m i n f i n i t y , ’g - ’ , Z , V m0 , ’r - ’ ) ;
% P l o t I n f i n i t e c a b l e and f i n i t e c a b l e V o l t a g e s f o r I e h a t , Ge =
1.0
p l o t ( Z , V m i n f i n i t y , ’g - ’ , Z , V m8 , ’r -. ’ ) ;
22 % P l o t I n f i n i t e c a b l e and f i n i t e c a b l e V o l t a g e s f o r I e h a t , Ge =
5.0
p l o t ( Z , V m i n f i n i t y , ’g - ’ , Z , V m6 , ’r - ’ ) ;
% P l o t I n f i n i t e c a b l e and f i n i t e c a b l e V o l t a g e s f o r I e h a t , Ge =
50.0
p l o t ( Z , V m i n f i n i t y , ’g - ’ , Z , V m7 , ’r -. ’ ) ;

We are choosing to look at these solutions for a cable length of 3 with all the
other parameters set to 1 for convenience except for the cable length which will be 3
and the endcap load conductance Ge which we will vary. We are also injecting 2 Ie∗
into the infinite cable as we mentioned we would do. Note the finite cable response
attenuated more quickly than the infinite cable unless Ge is G∞ ! You can see a variety
of results in Figs. 8.5a, b and 8.6a, b.

8.2.4 Homework

Exercise 8.2.1 Write Matlab functions to implement the finite cable transient vari-
able solutions using as many arguments to the functions as are needed.
1. vm
2. i i
8.2 The Finite Cable Solution: Current Initialization 211

Fig. 8.5 Low end cap loads. a End cap load is 0.1, b End cap load is 1.0

Fig. 8.6 High end cap loads. a End cap load is 5.0, b End cap load is 50.0

Exercise 8.2.2 Generate a parametric plot of each of these variables versus the
space variable z on a reasonable size range of z for the parameters λc , Ie∗ , cable
length L and Ge . The ratio of Ge to G∞ is a very reasonable parameter to use.
1. vm
2. i i

Exercise 8.2.3 Plot GT (L) versus L and the horizontal line G∞ on the same plot
and discuss what is happening.

8.3 The Finite Cable: Voltage Initialization

We can redo what we have discussed in the above using a different initial condition.
Instead of specifying initial current, we will specify initial voltage. As you might
expect, this will generate slightly different solutions. We use the same start:
212 8 Time Independent Solutions to Finite and Half-Infinite Space Cables
   
L−z L−z
vm (z) = A1 cosh + A2 sinh
λc λc
   
L−z L−z
i i (z) = A1 G∞ sinh + A2 G∞ cosh
λc λc

Our boundary conditions are now vm (0) = V0 and i i (L) = Ge vm (L). Also, we will
use the abbreviations from before: H , Z and L but change D to

E = cosh(L ) + H sinh(L )

Now let VL denote vm (L). Then it follows that A1 = VL . If we set B L = A2


VL
, then
    
L−z L−z
vm (z) = VL cosh + B L sinh
λc λc
    
L−z L−z
i i (z) = VL G∞ sinh + B L cosh
λc λc

We know that i i (L) = Ge VL and so


    
0 0
i i (L) = VL G∞ sinh + B L cosh
λc λc
Ge VL = VL B L G∞

The above implies B L = H . Finally, note that


    
L L
vm (0) = VLcosh + H sinh
λc λc
    
= VL sinh L + H cosh L = VL E

Hence, V0
E
= VL and from this we obtain our final expression for the solution:
 
V0
vm (z) = cosh(Z ) + H sinh(Z )
E
 
V0
i i (z) = G∞ sinh(Z ) + H cosh(Z )
E

We will find that the Th‘evenin equivalent conductance at the end cap is still the
same. We have the same calculation as before

i i (0) sinh(L ) + H cosh(L )


GT (L) = = G∞
vm (0) cosh(L ) + H sinh(L )
8.3 The Finite Cable: Voltage Initialization 213

Finally, it is easy to see that the relationship between the current and voltage initial-
ization condition is given by

V0 GT (L) = i i (0)

We can then find voltage and current equations for various interesting end cap con-
ductance loads:
Ge = 0: If the conductance of the end cap is zero, then H is zero and no current
flows through the endcap. We see

cosh(Z ) sinh(Z )
vm (z) = V0 , i i (z) = V0 G∞ , GT (L) = G∞ tanh(L ).
cosh(L ) cosh(L )

Ge = G∞ : If the conductance of the end cap is G∞ , then H is one and we see the
finite cable acts like the half-infinite cable:
cosh(Z ) + sinh(Z ) −z
vm (z) = V0 = V0 e λc ,
cosh(L ) + sinh(L )
sinh(Z ) + cosh(Z ) −z
i i (z) = V0 G∞ = V0 G∞ e λc
cosh(L ) + sinh(L )
GT (L) = G∞ .

Ge = ∞: If the conductance of the end cap is ∞, the end of the cable acts like it
is short-circuited, H is infinity. We see

sinh(Z ) cosh(Z )
vm (z) = V0 , i i (z) = V0 G∞ , GT (L) = G∞ coth(L )
sinh(L ) sinh(L )

8.3.1 Homework

Exercise 8.3.1 Write Matlab functions to implement vm , i i and GT (L) using as many
arguments to the functions as are needed. The arguments will be L, λc , z, V0 , G∞
and Ge .

Exercise 8.3.2 Using V0 = 1, λc = 5, L = 10, and G∞ = 2.0 and generate a


parametric plot of each of these variables versus the space variable z on [0, 10] for
a reasonable size range of Ge . Discuss how the special conductance cases above fit
into these plots.

Exercise 8.3.3 Assume L = 1 and λc = 1 also. Suppose sufficient current is injected


to give V0 = 10 mV. Let G∞ = 2.0.
1. Let Ge = 0.5
214 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

(a) Compute vm at z = 0.6 and 1.0. Compute vm for the infinite cable model too
at these points.
2. Let Ge = 2.0
(a) Compute vm at z = 0.6 and 1.0. Compute vm for the infinite cable model too
at these points.
3. Let Ge = 50.0
(a) Compute vm at z = 0.6 and 1.0. Compute vm for the infinite cable model too
at these points.
4. Discuss the results.

8.4 Synaptic Currents

We can have two types of current injection. The first is injected through the outer
membrane and is modeled by the pulses ke . We know the outer cylinder is a theoretical
abstraction and so there is really no such physical membrane. The second is injected
into the front face of the cable in either a finite or half-infinite case. This current is
modeled as an initialization of the inner current i i . So consider the model we see in
Fig. 8.7. The differential equation we would solve here would be

d 2 vm
λ2c − vm = −ro λ2c I0 δ(z − z 0 ) − ro λ2c I1 δ(z − z 1 ), 0 ≤ z ≤ L
dz 2
i i (0) = I
i i (L) = Ge vm (L) (8.1)

Here current I is injected into the front face and two impulse currents are injected
into the outer cylinder. If we are thinking of this as a model of an axon, we could
throw away the external sources and think of the current I injected into the front face
as the current that arises from membrane voltage changes that propagate forward
from the dendrite and soma system. Hence, the front face current I is a lumped sum
approximation of the entire dendrite and soma subsystem response. On the other
hand, if we are modeling a dendrite, we could think of the front face current I as
a lumped sum model of the synaptic voltages that have propagated forward up to
that point from the the rest of the dendrite system we are not modeling. The external
current sources are then currents induced by synaptic interactions or currents flowing
through pores in the membrane. Of course, voltage modulated gates would be handled
differently!
Since our differential equation system is linear, to solve a problem like (8.1),
we can simply add together the solutions to individual problems. This is called
8.4 Synaptic Currents 215

Fig. 8.7 Dendrite model with synaptic current injections

superposition of solutions and it is a very important tool in our work. Hence, to solve
(8.1) we solve

d 2 vm
λ2c − vm = 0, 0 ≤ z ≤ L
dz 2
i i (0) = I
i i (L) = Ge vm (L) (8.2)

and

d 2 vm
λ2c − vm = −ro λ2c I0 δ(z − z 0 ), 0 ≤ z ≤ L
dz 2
i i (0) = 0
i i (L) = Ge vm (L) (8.3)

and

d 2 vm
λ2c − vm = −ro λ2c I1 δ(z − z 1 ), 0 ≤ z ≤ L
dz 2
i i (0) = 0
i i (L) = Ge vm (L) (8.4)
216 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

and add the solutions together. Since we already know the solution to (8.2), it suffices
to solve (8.3).

8.4.1 A Single Impulse

Consider a family of problems of the form (8.5)

d 2 vm
λ2c − vm = −ro λ2c I0 keC (z − z 0 ), 0 ≤ z ≤ L
dz 2
i i (0) = 0
i i (L) = Ge vm (L) (8.5)

where the family {kec } of impulses are modeled similar to what we have done before:
each is zero off [z 0 − C, z 0 + C], symmetric around z 0 and the area under the curve
is 1 for all C. So the only difference here is that our pulse family always delivers
a constant 1 amp of current and we control the magnitude of the delivered current
by the multiplier I0 . This way we can do the argument just once and know that our
results hold for different magnitudes I1 and so on. We assume for now that the site of
current injection is z 0 which is in (0, L). The case of z 0 being 0 or L will then require
only a slight modification of our arguments which we will only sketch leaving the
details to the reader. As usual, each current pulse delivers I0 amps of current even
though the base of the pulse is growing smaller and smaller. Physically, we expect,
like in the infinite cable problem, that the voltage acts like a decaying exponential
on either side of z 0 . To see this is indeed the idealized solution we obtain when we
let C go to 0, we resort to the following model:
⎧ z−z 0

⎨ A1 e z−zλc ,
C
0 ≤ z ≤ z0 − C
z−z 0
vmC (z) = αC e λc + β C e− λc + φCp (z),
0
z0 − C ≤ z ≤ z0 + C

⎩ C − z−z 0
A 2 e λc , z0 + C ≤ z ≤ L

The parts of the model before z 0 − C and after z 0 + C are modeled with exponential
decay, while the part where the pulse is active is modeled with the full general
solution to the problem having the form φh (z)+φCp (z), where φCh is the homogeneous
solution to the problem and φCp is the particular solution obtained from the variations
of parameters technique for a pulse keC . Since the pulse keC is smooth, we expect the
voltage solution to be smooth also; hence our solution and its derivative must be
continuous at the points z 0 − C and z 0 + C. This will give us four equations in four
unknowns we can solve for the constants AC1 , AC2 , αC and β C . Recall the auxiliary
equation for this differential equation is

λ2c r 2 − 1 = 0
8.4 Synaptic Currents 217

with roots 1
λc
and − λ1c . The homogeneous solution is then

z−z 0 z−z 0
φh (z) = B1 e λc + B2 e− λc

Using the method of Variation of Parameters, we search for a particular solution of


the form
z−z 0 z−z 0
φnp (z) = U1 (z)e λc + U2 (z)e− λc

where the coefficient functions U1 and U2 satisfy


 z−z 0 z−z 0   dU   
e λc e− λc 1
0
dz
=
−ro I0 keC (z − z 0 )
z−z 0 z−z 0
− λ1c e−
1 dU2
λc
e λc λc
dz

This is easily solved using Cramer’s rule to give

dU1 r o λc I 0 C z−z 0
=− ke (z − z 0 )e− λc
dz 2
dU2 r o λc I 0 C z−z 0
= ke (z − z 0 )e λc
dz 2

We can integrate then to obtain


 z
r 0 λc I 0 s−z 0
U1 (z) = − keC (s − z 0 ) e− λc ds
2 z
 z0
r 0 λc I 0 s−z 0
U2 (z) = keC (s − z 0 ) e λc ds
2 z0

giving
z−z 0 z−z 0
φCp (z) = U1 (z) e λc + U2 (z) e− λc
  z 
r 0 λc I 0 s−z 0 z−z 0
+ − keC (s − z 0 ) e− λc ds e λc
2 z
  z0 
r 0 λc I 0 s−z 0 z−z 0
+ ke (s − z 0 ) e
C λ c ds e− λc
2 z0

Now we rewrite this a bit more compactly as follows:


 
r 0 λc I 0 z
r 0 λc I 0 z
keC (s − z 0 ) e− λc ds
s−z s−z
φCp (z) = − keC (s − z 0 ) e λc ds +
2 z0 2 z0
  
z
z−x
= −r0 λc I0 keC (s − z 0 ) sinh ds
z0 λc
218 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Hence, the particular solution for pulse keC is


  
z
z−s
φCp (z) = −r0 λc I0 ke (s − z 0 ) sinh dx
z0 λc

8.4.2 Forcing Continuity

When we modeled current injections before in Sect. 7.3, we forced continuity in the
solution and the derivative of the solution to find the unknown constants. To do this,
we need the derivative terms which are given below:
⎧ z − z0

⎪ C
⎪ A



1
e λc , 0 ≤ z ≤ z0 − C

⎪ λc

⎨ z − z0 z − z0
dvmC C
= α e λc − β e λc + dφ p ,
C C −
⎪ z0 − C ≤ z ≤ z0 + C
dz ⎪
⎪ λc λc dz

⎪ z − z0




C −
⎩ − A 2 e λc , z0 + C ≤ z ≤ L
λc

Then, continuity at z 0 − C and z 0 + C gives

AC1 e−C = αC e−C + β C eC + φCp (z 0 − C)


AC2 e−C = Cn eC + Dn e−C + φCp (z 0 + C)
AC1 −C αC −C β C C dφnp
e = e − e + (z 0 − C)
λc λc λc dz
AC αC C β C −C dφnp
− 2 e−C = e − e + (z 0 + C)
λc λc λc dz

which can be rewritten in the form

AC1 e−C − αC e−C − β C eC = φCp (z 0 − C) (8.6)


AC2 e−C −α e −β e
C C C −C
= φCp (z 0 + C) (8.7)
dφCp
AC1 e−C − αC e−C + β C eC = λc (z 0 − C) (8.8)
dz
dφCp
−AC2 e−C − αC eC + β C e−C = λc (z 0 + C) (8.9)
dz
8.4 Synaptic Currents 219

Computing (Eq. 8.7 + Eq. 8.8), (Eq. 8.7 − Eq. 8.8), (Eq. 8.9 and Eq. 8.9) and (Eq. 8.9
− Eq. 8.9), we find

dφCp
2 AC1 e−C − 2αC e−C = φCp (z 0 − C) + λc (z 0 − C)
dz
dφCp
−2β C eC = φCp (z 0 − C) − λc (z 0 − C)
dz
dφCp
−2αC eC = φCp (z 0 + C) + λc (z 0 + C)
dz
dφCp
2 AC2 e−C − 2β C e−C = φCp (z 0 + C) − λc (z 0 + C)
dz

Although very messy, this can be solved (not so easy!) to give

dφCp
2 AC1 e−C = 2αC e−C + φCp (z 0 − C) + λc (z 0 − C)
dz
 
dφCp
= − φCp (z 0 + C) + λc (z 0 + C) e−2C + φCp (z 0 − C)
dz
C
dφ p
+ λc (z 0 − C)
dz
dφCp
2 AC2 e−C = 2Dn e−C + φCp (z 0 + C) − λc (z 0 + C)
dz
 
dφCp
= − φ p (z 0 − C) − λc
n
(z 0 + C) e−2C + φCp (z 0 + C)
dz
dφCp
− λc (z 0 + C)
dz
or
 
1 C dφCp
AC1 = − φ (z 0 + C) + λc (z 0 + C) e−C
2 p dz
 
1 C dφCp
+ φ (z 0 − C) + λc (z 0 − C) eC
2 p dz
 
1 C dφCp
AC2 = − φ (z 0 − C) − λc (z 0 + C) e−C
2 p dz
 
1 C dφCp
+ φ (z 0 + C) − λc (z 0 + C) eC
2 p dz
220 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

8.4.3 The Limiting Solution

The above solutions work for all positive C. We note


 z0 + C  
z0 + C − s
φCp (z 0 + C) = −r0 λc I0 ken (s − z 0 ) sinh
z0 λc

and so, using arguments very similar to those presented in Lemma 7.4.1, we can
show
1
lim φCp (z 0 + C) = −r0 λc I0 sinh(0)
C→0 2
=0

In a similar fashion, we can show


1
lim φCp (z 0 − C) = r0 λc I0 sinh(0)
C→0 2
=0

Finally, since
  
dφCp z
z−s
(z) = −r0 λc I0 keC (z − z 0 ) sinh(0) − r0 I0 keC (s − z 0 )cosh ds
dz z0 λc

we see
 z0 + C 
dφCp z−s
(z 0 + C) = −r0 I0 keC (s − z 0 )cosh ds
dz z0 λc

which gives

dφCp 1 r 0 I 0 λc
lim (z 0 + C) = −r0 I0 λc cosh(0) = − .
C→0 dz 2 2

and similarly

dφCp I0 r 0 I 0 λc
lim (z 0 − C) = r0 I0 λc cosh(0) = .
C→0 dz 2 2

Thus in the limit, we obtain the limiting constants

r 0 λc I 0
A1 = lim AC1 =
C→0 2
r 0 λ c I0
A2 = lim AC2 =
C→0 2
8.4 Synaptic Currents 221

This gives the limiting solution


 z−z
r 0 λc I 0 λ c 0
e , 0 ≤ z ≤ z0
vm (z) = 2
z−z
r 0 λc I 0 − λ c 0
2
e , z0 ≤ z ≤ L

which is essentially our usual idealized impulse solution from the infinite cable
model
r0 λc I0 − |z−z0 |
vm (z) = e λc , 0 ≤ z ≤ L
2

Note the values of αC and β C are not important for the limiting solution.

8.4.4 Satisfying Boundary Conditions

Since
di i
= −gm vm
dz

we see that for z below z 0 − C, we have, for integration constant γ C ,


z−z 0
i i (z) = −gm λc AC1 e λc + γC
z−z 0
= −G∞ AC1 e λc + γC

and the boundary condition i i (0) = 0 then implies


z0
γ C = G∞ AC1 e− λc

and for the second boundary condition, i i (L) = Ge vm (L), we use the last part of the
definition of vm to give us, for a new integration constant ζ C ,
z−z 0
i i (z) = G∞ AC2 e− λc + ζC

and so
L−z 0 L−z 0
G∞ An2 e− λc + ζ C = Ge AC2 e− λc

or
L−z 0
ζ C = AC2 e− λc (Ge − G∞ )
222 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Hence, from the above, we see that the limiting inner current solutions satisfy

r 0 λc I 0 − z 0
γ = lim γ C = G∞ e λc
C→0 2
r0 λc I0 − L−z0
ζ = lim ζ C = (Ge − G∞ ) e λc
C→0 2

giving for z below z 0

r0 λc I0 z−z0 r 0 λc I 0 − z 0
i i (z) = −G∞ e λc + G∞ e λc
2 2
and for z above z 0 ,

r0 λc I0 − z−z0 r0 λc I0 − L−z0
i i (z) = G∞ e λc + (Ge − G∞ ) e λc
2 2

8.4.5 Some Results

We can now see the membrane voltage solution for the stated problem

d 2 vm
λ2c − vm = 0, 0 ≤ z ≤ L
dz 2
i i (0) = I
i i (L) = Ge vm (L)

in Fig. 8.8. Note here there are no impulses applied. If we add the two impulses at
z 0 and z 1 as described by the differential equations (8.3) and (8.1), the solution to
the full problem for somewhat weak impulses at two points on the cable can be seen
in Fig. 8.9. For another choice of impulse strengths, we see the summed solution
in Fig. 8.10. For ease of comparison, we can plot the solutions for no impulses,
two impulse of low strength and two impulses of higher strength simultaneously in
Fig. 8.11.

8.5 Implications

Even though we have still not looked into the case of time dependent solutions, we
can still say a lot about the nature of the solutions we see in the time independent
case.
8.5 Implications 223

Fig. 8.8 Finite cable initial endcap current

Fig. 8.9 Finite cable current initializations: strong impulses


224 8 Time Independent Solutions to Finite and Half-Infinite Space Cables

Fig. 8.10 Finite cable current initializations: strong impulses

Fig. 8.11 Three finite cable current initializations


8.5 Implications 225

Table 8.1 Typical cable constants


Species a Cm Gm ri λc τm
Squid (Loligo Peali) 250 1 1 0.015 6.5 1
Lobster (Homanus Vulgaris) 37.5 1 0.5 1.4 2.5 2
Crab (Carcinus Maenas) 15 1 0.14 13.0 2.3 7
Lobster (Homanus Americanus) 50 – 0.13 1.0 5.1 –
Earthworm (Lumbricus Terrestris) 52.5 0.3 0.083 2.3 4.0 3.6
Marine worm (Myxicula 280 0.75 0.012 0.023 5.4 0.9
Infundibulum)
Cat (Motoneuron) – 2 0.4 – – 5.0
Frog muscle fiber (Sartorius) 37.5 2.5–6.0 0.25 4.5 2.0 10.0–24.0

• The space constant λc tells us how far we must be from the site of input current to
see significant attenuation of the resulting potential. Thus, if λc >> 1, the cable’s
membrane potential is close to position independent.
• An electrode used to input current or measure voltage can be thought of as infini-
tesimal in tip size if the tip size is very small compared to λc .
• Our underlying cable equation is a linear PDE. Hence, the superposition principle
applies and we can use it to handle arbitrary arrangements of current sources.
• We already know that

 
a 1 √
λc ≈ ≈ a
2ρi G m 2ρi G m

implying λc decreases as the cable fiber inner radius decreases.


µF
Now let a be the cable radius in µm, Cm be membrane capacitance in cm 2 , G m be
mS
membrane conductance in cm2 , ri be internal resistance of the protoplasm per unit
length in M
cm
, λc be the cable space constant in mm and τm be the cable membrane
time constant in m sec. Then consider a table of these typical cable constants as
shown in Table 8.1 which can be found in many reference texts.
λc µm
From Table 8.1, we see that the earthworm gives 1000a µm is 4000
52.5
or 76.2. If we
assume this ratio holds, then for a cable with a equal to 0.5 µm, we see that the space
constant for this cable would be 76.2 × 0.5 µm or 38.1 µm which is 0.038 mm.
The earthworm cable fiber is unmylenated and so signals are not insulated from
transmission loss. This extrapolation shows that in this unmylenated case, we would
expect the fiber to transmit signal poorly as the fiber radius drops. Of course, many
species protect themselves against this transmission loss by shielding the fibers using
mylenin, but that is another story.
Part IV
Excitable Neuron Models
Chapter 9
A Primer on Series Solutions

We now discuss what we mean by a series of functions and what we mean by


convergence of this series. This is a complicated topic and so we’ll ease into it
slowly. We’ll start with a long motivating example. The cable equation can also be
solved for solutions that are functions of space and time. To do this we need to
introduce a new technique called the Separation of Variables Method. This will lead
to a type of solution which is written in infinite series form. Hence, new ideas and
new mathematics! We have discussed Separation of Variables earlier in Peterson
(2015).

9.1 The Separation of Variables Method

We have been discussing the equation whose solutions describe the voltage on a
dendritic cable. Recall the general model is

∂2 ∂
β2 −−α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
(x, 0) = f (x).

for positive constants α and β. The domain is the usual half infinite [0, L] × [0, ∞)
where the spatial part of the domain corresponds to the length of the dendritic cable.
The boundary conditions ux (0, t) = 0 and ux (L, t) = 0 are called Neumann Bound-
ary conditions. The conditions u(0, t) = 0 and u(L, t) = 0 are known as Dirichlet
Boundary conditions. The ballstick neuron model we solve in Chap. 11 uses a differ-
ent set of boundary conditions from these because the cable end cap membrane must

© Springer Science+Business Media Singapore 2016 229


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_9
230 9 A Primer on Series Solutions

interact with the cell body membrane. We discuss this solution later. The solution to
a model such as this is a function (x, t) which is sufficiently smooth to have partial
derivatives with respect to the needed variables continuous for all the orders required.
For these problems, the highest order we need is the second order partials. One way
to find the solution is to assume we can separate the variables so that we can write
(x, t) = u(x)w(t). If we make this separation assumption, we will find solutions
that must be written as what are called infinite series and to solve the boundary con-
ditions, we will have to be able to express boundary functions as series expansions.
Hence, we will have to introduce some new ideas in order to understand these things.
Let’s motivate what we need to do by applying the separation of variables technique
to the cable equation. This will shows the ideas we need to use in a specific example.
Then we will step back and go over the new mathematical ideas of series and then
return to the cable model and finish finding the solution. In Chap. 10 we apply the
method to other linear PDE models.
We assume a solution of the form (x, t) = u(x) w(t) and compute the needed
partials. This leads to a the new equation

d2u dw
β2 w(t) − u(x)w(t) − αu(x) = 0.
dx 2 dt
Rewriting, we find for all x and t, we must have
 2 
2d u dw
w(t) β 2
− u(x) = αu(x) .
dx dt

Rewriting, we have
2
β 2 ddxu2 − u(x) α dw
= dt , 0 ≤ x <≤ L, t > 0.
u(x) w(t)

The only way this can be true is if both the left and right hand side are equal to the
separation constant . This leads to the decoupled Eqs. 9.1 and 9.2.

dw
α =  w(t), t > 0, (9.1)
dt
d2u
β 2 2 = (1 + ) u(x), 0 ≤ x ≤ L, (9.2)
dx
We also have boundary conditions. Our assumption leads to the following boundary
conditions in x:

du
(0) w(t) = 0, t > 0,
dx
du
(L) w(t) = 0, t > 0.
dx
9.1 The Separation of Variables Method 231

Since these equations must hold for all t, this forces

du
(0) = 0, (9.3)
dx
du
(L) = 0. (9.4)
dx

Equations 9.1–9.4 give us the boundary value problem in u(x) we need to solve.
Then, we can find w.

9.1.1 Determining the Separation Constant

The model is then


1+
u − u=0
β2
du
(0) = 0,
dx
du
(L) = 0.
dx
We have already solved a system like this when we looked at the solution to the wave
equation; hence, the work we do here is quite familiar. We are looking for nonzero
solutions, so any choice of separation constant  that leads to a zero solution will
be rejected.

9.1.1.1 Case I: 1 +  = ω 2 , ω = 0

The model to solve is

ω2
u − u=0
β2
u (0) = 0,
u (L) = 0.

with characteristic equation r 2 − ωβ 2 = 0 with the real roots ± √ωD . The general
2

solution of this second order model is given by


   
ω ω
u(x) = A cosh x + B sinh x
β β
232 9 A Primer on Series Solutions

which tells us
   
ω ω ω ω
u (x) = A sinh x + B cosh x
β β β β

Next, apply the boundary conditions, u (0) = 0 and u (L) = 0. Hence,

u (0) = 0 = B
 
ω
u (L) = 0 = A sinh L
β
 
Hence, B = 0 and A sinh L ωβ = 0. Since sinh is never zero when ω is not zero, we
see A = 0 also. Hence, the only u solution is the trivial one and we can reject this
case.

9.1.1.2 Case II: 1 +  = 0

The model to solve is now

u = 0
u (0) = 0,
u (L) = 0.

with characteristic equation r 2 = 0 with the double root r = 0. Hence, the general
solution is now

u(x) = A + B x

Applying the boundary conditions, u(0) = 0 and u(L) = 0. Hence, since u (x) = B,
we have

u (0) = 0 = B
u (L) = 0 = BL

Hence, B = 0 but the value of A can’t be determined. Hence, any arbitrary constant
which is not zero is a valid non zero solution. Choosing A = 1, let u0 (x) = 1 be our
chosen nonzero solution for this case. We now need to solve for w in this case. Since
 = −1, the model to solve is

dw 1
= − w(t), 0 < t,
dt α
w(L) = 0.
9.1 The Separation of Variables Method 233

The general solution is w(t) = Ce− α t for any value of C. Choose C = 1 and we set
1

w0 (y) = e− α t .
1

Hence, the product φ0 (x, t) = u0 (x) w0 (t) solves the boundary conditions. That is

φ0 (x, t) = e− α t .
1

is a solution.

9.1.1.3 Case III: 1 +  = −ω 2 , ω = 0

ω2
u + u=0
β2
u (0) = 0,
u (L) = 0.

The general solution is given by


   
ω ω
u(x) = A cos x + B sin x
β β

and hence
   
 ω ω ω ω
u (x) = −A sin x + B cos x
β β β β

Next, apply the boundary conditions to find

u (0) = 0 = B
 
ω
u (L) = 0 = A sin L
β
 
Hence, B = 0 and A sin L ωβ = 0. Thus, we can determine a unique value of A
 
only if sin L ωβ = 0. If ω = nπβ
L
, we can solve for A and find A = 0, but otherwise,
A can’t be determined. So the only solutions are the trivial or zero solutions unless
ωL = nπβ. Letting ωn = nπβ L
, we find a non zero solution for each nonzero value of
A of the form
   
ωn nπ
un (x) = A cos x = A cos x .
β L
234 9 A Primer on Series Solutions

  A = 1. Then we have an infinite


For convenience, let’s choose all the constants
family of nonzero solutions un (x) = cos nπ
L
x and an infinite family of separation

constants n = −1 − ωn2 = −1 − n Lπ2 D . We can then solve the w equation. We must


2 2

solve

dw (1 + ωn2 )
=− w(t), t ≥ 0.
dt α
The general solution is

1+ωn2 1+n2 π 2 β 2
w(t) = Bn e− α t
= Bn e− αL 2
t

Choosing the constants Bn = 1, we obtain the wn functions

n2 π 2 β 2
wn (t) = e− αL 2
t

Hence, any product

φn (x, t) = un (x) wn (t)

will solve the model with the x boundary conditions and any finite sum of the form,
for arbitrary constants An


N 
N
N (x, t) = An φn (x, t) = An un (x) wn (t)
n=1 n=1


N  
nπ 1+n2 π 2 β 2
= An cos x e− αL2 t
n=1
L

Adding in the 1 +  = 0 case, we find the most general finite term solution has the
form


N 
N
N (x, t) = A0 φ0 (x, t) + An φn (x, t) = A0 u0 (x)w0 (t) + An un (x) wn (t)
n=1 n=1


N  
nπ 1+n2 π 2 β 2
= A0 e− α t + x e− αL2 t .
1
An cos
n=1
L

Now these finite term solutions do solve the boundary conditions ∂ ∂x


(0, t) = 0 and
∂
∂x
(L, t) = 0, but how do we solve the remaining condition (x, 0) = f (x)? To do
this, we note since we can assemble the finite term solutions for any value of N, no
matter how large, it is clear we should let N → ∞ and express the solution as
9.1 The Separation of Variables Method 235


 ∞

(x, t) = A0 φ0 (x, t) + An φn (x, t) = A0 u0 (x)w0 (t) + An un (x) wn (t)
n=1 n=1

  
nπ 1+n2 π 2 β 2
= A0 e− α t + x e− αL2 t .
1
An cos
n=1
L

This is the form that will let us solve the remaining boundary condition. These
solutions are written in what is called infinite series form we need to back up and
discuss carefully what we mean by letting N → ∞.

9.1.1.4 Homework

Exercise 9.1.1 Use separation of variables to find the general infinite series solution
to the cable equation with Dirichlet boundary data given below.

∂2 ∂
β2 −−α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
(0, t) = 0,
(L, t) = 0,
(x, 0) = f (x).

9.2 Infinite Series

To discuss infinite series, we need to understand limiting processes better. We can


then add on the new ideas we need.

9.2.1 Simple Limits from Calculus

In your earlier calculus courses, you learned about limits and convergence to a limit
in certain situations. For example, we know if a function f is continuous at the point
x0 in its domain, then we can say

lim f (x) = f (x0 )


x→x0

which is short hand for saying the limit of f (x) as x approaches x0 exists and that the
value of the limit is f (x0 ). More precisely, we can use a different language to express
this: the  − δ form. We would say the limit of f (x) as x approaches x0 exists if there
is a number A so that given any positive tolerance  there is a positive radius δ so that
236 9 A Primer on Series Solutions

|x − x0 | < δ =⇒ |f (x) − A| < .

This seems like a hard statement to understand, but it simply says in very precise
language that as x gets close to x0 , the corresponding function values f (x) get close to
A also. There are all kinds of ways to make this statement seem even more forbidding.
For example, saying it the way we did above, assumes the function f is defined on
all the x values within δ of x0 . So we could adjust our statement to say

|x − x0 | < δ and x is in the domain of f =⇒ |f (x) − A| < .

but usually, we know that this statement is dependent on x being in the domain of
f without saying and so we write the statement in the more relaxed form. Now, to
finish with the idea of continuity, we then have to assume the value of A is the same as
f (x0 ). If we restricted our attention to x values moving towards x0 only from the left,
we could call this the left hand limit as x goes to x0 and denote it by limx→x0− f (x).
Similarly, If we restricted our attention to x values moving towards x0 only from
the right, we could call this the right hand limit as x goes to x0 and denote it by
limx→x0+ f (x). If you think about it a bit, the limit only exists if and only if the two
one sided limits both exist and match the value A.
A couple of standard examples will help you understand this. Let the function f
be defined like this:
 2
t , 0 ≤ t < 2,
f (t) =
−t 2 , 2 ≤ t ≤ 4

Then, it is easy to see limx→2− f (x) = 4 and limx→2+ f (x) = −4 and since the right
and left hand limits don’t match, f is not continuous at t = 2. If you graph this
function, you can see what this means visually: the graph of f has a jump at the point
t = 2. We can redefine f so that the right and left hand limits match but f is still not
continuous at t = 2 as follows. Let f be defined as
⎧ 2
⎨ t , 0 ≤ t < 2,
f (t) = 10, t = 2,
⎩ 2
t , 2 < t ≤ 4

This function f has both the right and left hand limits equal to 4, so the limit of f
as t approaches 2 does exist. However, the limit value 4 does not match the function
value f (2) = 10 and so this function is not continuous at t = 2. Of course, this lack
of continuity is there simply because we defined the function badly at t = 2. Since
this lack of continuity can easily be removed by just redefining f as
⎧ 2
⎨ t , 0 ≤ t < 2,
f (t) = 4, t = 2,
⎩ 2
t , 2 < t ≤ 4
9.2 Infinite Series 237

i.e., f (t) = t 2 on [0, 4], we call this a removeable discontinuity. A more sophisticated
example is the function g(t) = sin(t) t
which is undefined at t = 0. It is well-known
that the limit as t → 0 of g(t) is 1. Hence, we can define g so that is it continuous
for all t as follows:
 sin(t)
, t = 0,
g(t) = t
1, t = 0.

In a similar way, if f has a derivative at x0 in its domain, it means that the limit of
the slopes of the lines through the pairs (x0 , f (x0 )) and (x, f (x)) exists and equals
some number B. More formally, we say f is differentiable at x0 if there is a number
B so that as x approaches x0 the slopes f (x)−f
x−x0
(x0 )
approach the value B. In our more
technical  − δ language, if a positive tolerance  is chosen, then there is a positive
δ so that

f (x)−f (x0 )
|x − x0 | < δ =⇒ x−x0
− B < .

The value B is usually denoted by the symbol f  (x0 ) and the right and left hand
limits are then denoted by (f  )+ (x0 ) and (f  )− (x0 ), respectively. It is possible for the
derivative f  to exist on an interval, but fail to be continuous at some point in the
interval. Consider this function f
⎧  

t 2 sin 1
, t = 0,
f (t) = t

1, t=0

The function limt→0 f (t) = 0 and so we have removed the discontinuity f would
normally have at t = 0 by defining it to have that value at 0. Then f is continuous at
0 and we have for t = 0 that
   
 1 1
f (t) = 2t sin − 2 cos .
t t

Then, we find
 
t 2 sin 1
t
−0

f (0) = lim
 t
t→0
1
= lim t sin
t→0 t
238 9 A Primer on Series Solutions

Now make a change of variable and let y = 1/t. Then the above limit changes to

sin(y)
f  (0) = lim
y→∞ y

which we clearly see is 0 as the numerator is bounded between −1 and 1 yet the
denominator grows without bound. Hence, f  (0) exists and equals 0. However, the
limit as t approaches 0 from either direction gives
   
1 1
lim 2t sin − 2 cos
t→0 t t
 
which does not exist as the second term −2 cos 1
t
oscillates between −2 and 2 in
any circle (−r, r) around 0 no matter how small r is chosen. Hence, the limit can not
exist. Hence, since the limit does not exist, the definition of continuity for f  fails.
We would need the limit to exist and for the value of the limit to match the value of
the function. So here, we have f  exists for all t but f  fails to be continuous at t = 0.
We see strange things can happen with functions!

9.2.2 Sequences

A sequence of real numbers is just a list such as this

{c1 , c2 , c3 , . . .}

The numbers in this list do not have to have any pattern at all such as the sequence
of sine values using radians for the argument:

{c1 = sin(1), c2 = sin(2), c3 = sin(3), . . . , cn = sin(n), . . .}

The sequence could be increasing such as

{c1 = 1, c2 = 2, c3 = 3, . . . , cn = n, . . .}

which simply increases without bound or it could be a sequence which alternates


between to fixed values such as

c1 = (−1)1 , c2 = (−1)2 , c3 = (−1)3 , . . . , cn = (−1)n , . . . .


9.2 Infinite Series 239

A more interesting simple example is the collection



1 1
c1 = 1, c2 = , c3 = , . . .
2 3

which can be written using the formula cn = n1 . As n grows without bound, i.e. as
n → ∞, we can see that cn → 0. Next, note the sequence

1 1
c1 = 2, c2 = 1 + , c3 = 1 + , . . .
2 3

can be written using the formula cn = 1 + n1 and clearly cn → 1 as n → ∞. We


need a more precise way of saying the values of a sequence approach a fixed number
as for larger indices n. So let’s state this idea more generally. If (cn ) is a sequence
of real numbers, we say the sequence (cn ) converges to the number A and write
limn→∞ cn = A. We can state this using the more formal language of tolerances
as follows. We say the sequence (cn ) converges to the number A if for any positive
tolerance  there is a positive integer N so that

n > N =⇒ |cn − A| < .

Less precisely, this means that the difference between the numbers cn and the limiting
value A is arbitrarily small once n is large enough. Now, for a simple sequence of real
numbers, there are special types of lack of convergence which we call divergence.
The sequence (cn ) might never stop growing, the example is cn = n which moves
to ∞ as n → ∞; the sequence (cn ) has limit −∞, the example is cn = −n; and the
sequence oscillates between a finite number of fixed choices. One example of this is
cn = (−1)n which flips between −1 and 1 and so thereis no  fixed number A it can
have as a limiting value. Another example is cn = sin nπ3
which moves between
   
the values {sin π3 , 0, sin 2π
3
} none of which can be the limiting value A.

9.2.3 Series of Positive Terms

If you add up positive numbers, it is common sense to realize the partial sums you
get never go down in value. Hence, if (an ) is some sequence of positive numbers,
then the partial sums sn = ni=1 ai are always going up in value. If we allow some of
the terms to be zero, then it is possible for these sums to plateau until a new positive
term is added in, so if we look at the partial sums of non negative terms, we would
say they are non decreasing to reflect the fact that the partial sums might plateau as
we said. The behavior of these partial sums is fairly easy to predict. The partial sums
240 9 A Primer on Series Solutions

either never stop growing or they grow towards some upper bound. Let’s look at the
growth towards an upper bound idea first. Take the open interval (0, 2). Notice that if
x is in (0, 2), x is always bounded above by 2. Further, it is easy to see that although
other numbers such as 3, 2.5, 2.1 and so forth are also upper bounds for this interval,
2 is the smallest or least such upper bound. We call such a least upper bound, the
supremum of this set. We can be more formal with these ideas but this is enough
for us here. For another example, consider the function tanh(x) which has the two
horizontal asymptotes −1 and 1. We know for any real number x, tanh(x) is always
above −1 and below 1. So the supremum of the set {tanh(x) : −∞ < x < ∞} is 1. A
little thought shows the number −1 is the greatest possible lower bound. We call such
a number the infimum of the set. Now, the big idea here is that a supremum is not the
same as a maximum. Look at the example of the interval (0, 2). The value 2 is not in
the interval, so we can’t say that there is a maximum value of x in this interval. We can
say that 2 is the supremum of the values of x from this interval though, even though
there is no maximum value. In the second example, 1 is the supremum of the set of
tanh(x) values but there is no value of x where tanh(x) = 1. Hence, the value of 1 can
not be achieved using any value of x. So again, it is true 1 is the supremum of the set
of possible values tanh(x) even though a maximum value is not achieved. Let’s look
at a third example using the function values −x 2 . The values {−x 2 : −∞ < x < ∞}
have a supremum value of 0 and this supremum value is achieved at the point 0;
hence, we know this set of values does have a maximum value.
Let’s be a bit more precise and prove a small result. Suppose (an ) is a sequence of
non negative terms and let (Sn ) be its corresponding sequence of partial sums. Since
the partial sums are always non decreasing in this case, we can see that the sequence
of partial sums either increases to ∞ or it has a finite supremum, S. If it increases
to ∞, we say the sequence of partial sums diverges to ∞. We can prove that if the
sequence of partial sums has a finite supremum S, the Sn → S is the formal way we
defined earlier.
To do that, pick a positive tolerance . Is it possible that every partial sum Sn lies
below or equals the supremum minus this tolerance, S − ? Suppose that was true.
Then, we would have the inequality Sn ≤ S −  for n. But that would say that the
value S −  was an upper bound also. However, when we defined the supremum of
a set of numbers, we noted that the supremum is the least such upper bound. So,
since S is the least upper bound value, we also have the inequality S ≤ S − ! But
this makes no sense as S can not be less than itself. So we must conclude that our
assumption is wrong. All the values Sn can’t be below or equal S − . There has to
be at least one value, Sn , so that we have the inequalities S −  < Sn ≤ S.
Now we can show the partial sums of a sequence of non negative terms must
converge to its supremum value as long as the supremum is finite. Pick any positive
tolerance . By the argument above, there is at least one SN satisfying S− < SN ≤ S.
However, the partial sums are always non decreasing, so we can say more. Since
SN ≤ Sn for all n > N, we have S −  < SN ≤ Sn ≤ S for all n > N. Now just
rearrange this a bit and we see

n > N =⇒ 0 ≤ S − Sn < .
9.2 Infinite Series 241

This is precisely how we defined the convergence of a sequence. We can say now
Sn = ni=1 an → S when the supremum S is finite. We use a special notation for this
limiting value S. We write S = ∞ i=n0 ai to denote the supremum or limiting value of
the sequence of partial sums when the underlying sequence is {an0 , an0 + 1, . . . , }.
This is called an infinite series of real numbers and this compact notation is very
useful. Another way of writing the convergence statement then is as
∞ n
n > N =⇒ 0 ≤ ai − ai < .
i=1 i=1

where for expositional convenience we let the starting value n0 = 1, although of


course, it could be 2 or 20 etc. The term ∞ i=1 ai −
n
i=1 ai occurs so frequently,

that it is often written as the symbol i=n+1 ai . This is often called the remainder of
the series from the index n + 1 on. Of course, this is just a symbol, like many of the
symbols we have in calculus, for a fairly complicated limit idea.
Hence, in this section, we have found that if ∞ i=1 ai < ∞, the sequence of partial
sums converges.

9.2.4 Series of Functions

Now let’s look


 atsequences of functions
  made up of building blocks of the form
un (x) = cos L or vn (x) = sin nπ

L
for various values of the integer n. The
number L is a fixed value here. We can combine these functions into finite sums: let
UN (x) and VN (x) be defined as follows:


N  

UN (x) = an sin x .
n=1
L

and


N  

VN (x) = b0 + bn cos x .
n=1
L

If we fixed the value of x to be say, x0 , the collection of numbers

{U1 (x0 ), U2 (x0 ), U3 (x0 ), . . . , Un (x0 ), . . . }

and

{V0 (x0 ), V1 (x0 ), V2 (x0 ), V3 (x0 ), . . . , Vn (x0 ), . . . }


242 9 A Primer on Series Solutions

are the partial sums formed from the sequences of cosine and sine numbers. However,
the underlying sequences can be negative, so these are not sequences of non negative
terms like we previously discussed. These sequences of partial sums may or may
not have a finite supremum value. Nevertheless,  we still
 represent the supremum

using the same notation: i.e. the supremum of Ui (x0 ) and the supremum of
 ∞   i=1  
Vi (x0 ) can be written as ∞ a
n=1 n sin nπ
L
x and b0 + ∞
b
n=1 n cos nπ
L
x .
i=0
Let’s consider the finite sequence

{U1 (x0 ), U2 (x0 ), U3 (x0 ), . . . , Un (x0 )}.

This sequence of real numbers converges to a possibly different number for each x0 ;
hence, let’s call this possible limit S(x0 ). Now the limit may not exist, of course. We
will write limn→ Un (x0 ) = S(x0 ) when the limit exists. If the limit does not exist for
some value of x0 , we will understand that the value S(x0 ) is not defined in some way.
Note, from our discussion above, this could mean the limiting value flips between
a finite set of possibilities, the limit approaches ∞ or the limit approaches −∞. In
any case, the value S(x0 ) is not defined as a finite value. We would say this precisely
as follows: given any positive tolerance , there is a positive integer N so that

n
 
n > N =⇒ ai sin iπ
L
− S(x0 ) < .
i=1

We use the notation of the previous section and write this as


n  

lim ai sin = S(x0 ).
n−>∞
i=1
L

with limiting value, S(x0 ) written as



 

S(x0 ) = ai sin ,
i=1
L

As before, this symbol is called an infinite series and we see we get a potentially
different series at each point x0 . The error term S(x0 ) − Un (x0 ) is then written as


n   ∞
  
iπ iπ
S(x0 ) − ai sin x0 = ai sin x0 ,
i=1
L i=n+1
L

which you must remember is just a short hand for this error. Now that we have an
infinite series notation defined, we note the term Un (x0 ), which is the sum of n terms,
9.2 Infinite Series 243
 
∞ iπ
is also called the nth partial sum of the series i=1 ai sin x
L 0
. Note we can define
the convergence at a point x0 for the partial sums of the cos functions in a similar
manner.

9.2.5 Fourier Series

A general trigonometric series S(x) has the following form

∞     
iπ iπ
S(x) = b0 + an sin x + bn cos x
i=1
L L

for any numbers an and bn . Of course, there is no guarantee that this series will
converge at any x! If we start with a function f which is continuous on the interval
[0, L], we can define the trigonometric series associated with f as follows

1
S(x) = < f,1 >
L
∞  
         
2 iπ iπ 2 iπ iπ
+ f (x), sin x sin x + f (x), cos x cos x .
L L L L L L
i=1

This series is called the Fourier Series for f and the coefficients in the Fourier series
for f are called the Fourier coefficients of f . Since these coefficients are based on
inner products with the normalized sin and cos functions, we could call these the
normalized Fourier coefficients. Let’s be clear about this and a bit more specific. The
nth Fourier sin coefficient, n ≥ 1, of f is as follows:
 L  
2 iπ
an (f ) = f (x) sin x dx
L 0 L

The nth Fourier cos coefficient, n ≥ 0, of f are defined similarly:



1 L
b0 (f ) = f (x) dx
L 0
 L  
2 iπ
bn (f ) = f (x) cos x dx, n ≥ 1.
L 0 L
244 9 A Primer on Series Solutions

9.3 The Cable Model Infinite Series Solution

We now know series of the form


N 

nπ 1+n2 π 2 β 2
− α1 t
A0 e + An cos x e− αL2 t .
n=1
L

are like Fourier series although in terms of two variables. We will show these series
converge pointwise for x in [0, L] and all t. We can show that we can take the partial
derivative of this series solutions term by term to obtain


N  
nπ nπ 1+n2 π 2 β 2
−An sin x e− αL2 t .
n=1
L L

This series evaluated at x = 0 and x = L gives 0 and hence the Neumann conditions
are satisfied. Hence, the solution (x, t) given by


N  
nπ 1+n2 π 2 β 2
(x, t) = A0 e − α1 t
+ An cos x e− αL2 t .
n=1
L

for the arbitrary sequence of constants (An ) is a well-behaved solution on our domain.
The remaining boundary condition is

(x, 0) = f (x), for 0 ≤ x ≤ L

and

  

(x, 0) = A0 + An cos x .
n=1
L

Rewriting in terms of the series solution, for 0 ≤ x ≤ L, we find



  

A0 + An cos x = f (x)
n=1
L

The Fourier series for f is given by



  

f (x) = B0 + Bn cos x
n=1
L
9.3 The Cable Model Infinite Series Solution 245

with

1 L
B0 = f (x),
L 0
  
2 L nπ
Bn = f (x) cos x dx.
L 0 L

Then, setting these series equal, we find that the solution is given by An = Bn for all
n ≥ 0.

9.3.1 Homework

Solve the following cable models using separation of variables. Recall from Sect. 7.5.1
that we can calculate the Fourier series coefficients for a delta function of the form
Hδ(x − x0 ) easily to obtain

1 L 1
B0 = Hδ(x − x0 ) dx =
L 0 L
    
2 L iπ 2 iπ
Bn = Hδ(x − x0 ) sin x dx = sin x0 , n ≥ 1.
L 0 L L L

You can use these results to work the exercises below.

Exercise 9.3.1

∂2 ∂
0.0009 −  − 0.006 = 0, for 0 ≤ x ≤ 10, t > 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(10, t) = 0,
∂x
(x, 0) = f (x).

where f (x) = 100δ(x − 3), the pulse of magnitude 100 applied instantaneously at
position x = 3.

Exercise 9.3.2

∂2 ∂
0.25 −  − 0.0008 = 0, for 0 ≤ x ≤ 100, t > 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
246 9 A Primer on Series Solutions

∂
(100, t) = 0,
∂x
(x, 0) = f (x).

where f (x) = 200δ(x − 4), the pulse of magnitude 100 applied instantaneously at
position x = 4.

Exercise 9.3.3

∂2 ∂
0.25 −  − 0.0008 = 0, for 0 ≤ x ≤ 100, t > 0,
∂x 2 ∂t
(0, t) = 0,
(10, t) = 0,
(x, 0) = f (x).

where f (x) = 300δ(x − 3), the pulse of magnitude 200 applied instantaneously at
position x = 3.5.

Exercise 9.3.4

∂2 ∂
0.125 −  − 0.004 = 0, for 0 ≤ x ≤ 15, t > 0,
∂x 2 ∂t
(0, t) = 0,
(15, t) = 0,
(x, 0) = f (x).

where f (x) = 500δ(x − 8), the pulse of magnitude 300 applied instantaneously at
position x = 9.5.

9.4 The Membrane Voltage Cable Equation

Now our interest is the cable equation which we have derived using ideas from
biology and physics. For the cable equation, we think of the dendritic cylinder as
having end caps made of the same membrane as its walls. For boundary conditions,
we will impose what are called zero-rate end cap potentials–this means that each end
cap is at equipotential: hence the rate of change of the potential vm with respect to the
space variable λ is zero at both ends. Thus, we look the solution to the homogeneous
full transient cable equation

∂ 2 vm (z, t) ∂vm
λ2C = vm (z, t) + τM , 0 ≤ z ≤ , t ≥ 0, (9.5)
∂z2 ∂t
∂vm (0, t)
= 0, (9.6)
∂z
9.4 The Membrane Voltage Cable Equation 247

∂vm (, t)
= 0, (9.7)
∂z
vm (z, 0) = f (z), 0 ≤ z ≤ . (9.8)

This is the general cable equation with β = λC and α = τ . For convenience, we can
replace Eqs. 9.5–9.8 with a normalized form using the transformations

t z 
τ = , λ= , L= ,
τM λC λC
v̂m = vm (λC λ, τM τ ).

This gives us the system

∂ 2 v̂m ∂ v̂m
= v̂m + , 0 ≤ λ ≤ L, τ ≥ 0 (9.9)
∂λ2 ∂τ
∂ v̂m (0, τ )
=0 (9.10)
∂λ
∂ v̂m (L, τ )
= 0, (9.11)
∂λ
v̂m (λ, 0) = fˆ (z), 0 ≤ λ ≤ L. (9.12)

where fˆ = f (λC λ). This is the general cable equation with β = 1 and α = 1. As
usual, we assume a solution of the form v̂m (λ, τ ) = u(λ) w(τ ). We have already
solved this in Sect. 7.2.1 so we can just state the results now. The solution is

  
nπ 1+n2 π 2
v̂m (λ, τ ) = A0 e −τ
+ An cos λ e− L2 τ .
n=1
L

for the arbitrary sequence of constants (An ). The constants An are then chosen to be
the Fourier coefficients of fˆ . The Fourier series for f is given by

  

f (x) = B0 + Bn cos x
n=1
L

with

1 L
B0 = f (x)dx,
L 0
  
2 L nπ
Bn = f (x) cos x dx.
L 0 L

The solution is given by choosing An = Bn for all n ≥ 0. We now need to look at the
convergence of Fourier series as our solutions require it to make sense!
248 9 A Primer on Series Solutions

9.5 Fourier Series Components

To prove that Fourier series converge pointwise for the kind of data functions f we
want to use, requires a lot more work. So let’s get started. Let’s go back and look at
the sin and cos functions we have been using. They have many special properties.

9.5.1 Orthogonal Functions

  [0,
We will now look at some common sequences of functions on the domain L] that
are very useful in solving models: the sequences of functions are sin iπL x for
  
integers i ≥ 1 and cos iπL x for integers i ≥ 0. The second sequence is often
   
written {1, cos πL x , cos 2π
L
x , . . .}. Here L is a positive number which often is
the length of a cable or spatial boundary.

9.5.1.1 The Sine Sequence

Let’s look carefully at the interval [0, L]. Using the definition of inner product on
C[0, L], by direct integration, we find for i = j
      L    
iπ jπ iπ jπ
sin x , sin x = sin x sin x dx
L L 0 L L
πx
Now use the substitution, y = L
to rewrite this as
     
iπ jπ L π
sin x , sin x = sin(iy) sin(jy)dy
L L π 0

Now the trigonometric substitutions

cos(u + v) = cos(u) cos(v) − sin(u) sin(v),


cos(u − v) = cos(u) cos(v) + sin(u) sin(v)

imply
 
1
sin(iy) sin(jy) = cos((i − j)y) − cos((i + j)y) .
2
9.5 Fourier Series Components 249

Using this identity in the integration, we see


 π    π   
L L
sin(iy) sin(jy)dy = cos (i − j)y − cos (i + j)y dy
π 0 0 π
   
 sin (i − j)y π sin (i + j)y π
L
= +
π i−j 0 i+j 0
= 0.
   
Hence, the functions sin L x and sin jπ

L
x are orthogonal on [0, L] if i = j. On
πx
the other hand, if i = j, we have, using the same substitution y = L
, that
      π  π 
iπ iπ L L 1 − cos(2iy)
sin x , sin x sin(iy) sin(iy)dy = dy
L L π 0 π 0 2

using the identify cos(2u) = 1 − 2 sin2 (u). It then follows that


 π   π
L L y sin(2y)
sin(iy) sin(iy)dy = −
0π π 2 4 0
L
= .
2
 
Hence, letting un (x) = sin nπ
L
x , we have shown that

L
, i=j
< ui , uj > = 2
0, i = j.

j
Now define the new functions ûn by L2 un . Then, < ûi , ûj >= δi and the sequence
of functions (ûn ) are all mutually orthogonal. Next, define the length of a function f
by the symbol ||f || where

 L
||f || = f 2 (t)dt.
0

Using this definition of length, it is clear ||uˆn || = 1 always. So the sequence of


functions (ûn ) are all mutually orthogonal and length one.
250 9 A Primer on Series Solutions

9.5.1.2 The Cosine Sequence

Let’s look carefully at on the interval [0, L]. Using the definition of inner product on
C[0, L], by direct integration, we find for i = j with both i and j at least 1, that
      L    
iπ jπ iπ jπ
cos x , cos x = cos x cos x dx
L L 0 L L
πx
Again use the substitution, y = L
to rewrite this as
     
iπ jπ L π
cos x , cos x = cos(iy) cos(jy)dy
L L π 0

Again, the trigonometric substitutions

cos(u + v) = cos(u) cos(v) − sin(u) sin(v),


cos(u − v) = cos(u) cos(v) + sin(u) sin(v)

imply
 
1
cos(iy) cos(jy) = cos((i + j)y) + cos((i − j)y) .
2

Using this identity in the integration, we see


 π     π 
L L
cos(iy) cos(jy)dy = cos (i + j)y + cos (i − j)y dy
π 0 0 π
   
 sin (i + j)y π sin (i − j)y π
L
= +
π i+j 0 i−j 0
= 0.
   
Hence, the functions cos L x and cos jπ

L
x are orthogonal on [0, L] if i = j,
i, j ≥ 1.Next, we consider the case of the inner product of the function 1 with a
cos jπ L
x for j ≥ 1. This gives

    L 

jπ jπ
1, cos x = cos x dx
L 0 L
 π
L
= cos(jy)dy
π 0
9.5 Fourier Series Components 251

π
L sin(jy)
=
π j 0
= 0.
 

Thus, the functions 1 and cos L
x for any j ≥ 1 are also orthogonal. On the other
hand, if i = j, we have for i ≥ 1,
      π
iπ iπ L
cos x , cos x = cos(iy) cos(iy)dy
L L π 0
 π 
L 1 + cos(2iy)
= dy
π 0 2

using the identify cos(2u) = 2 cos2 (u) − 1. It then follows that


 π   π
L L y sin(2y)
cos(iy) cos(iy)dy = +
π 0 π 2 4 0
L
= .
2
We also easily find that < 1, 1 >= L. Hence, on [0, L], letting

v0 (x) = 1
 

vn (x) = cos x , n ≥ 1,
L

we have shown that


⎧1
⎨ L , i = j = 1,

< vi , vj > = L2 , i = j, i ≥ 1


0, i = j.

Now define the new functions



1
v̂0 (x) =
L
  
2 nπ
v̂n (x) = cos x , n ≥ 1,
L L

j
v̂n by L2 vn . Then, < v̂i , v̂j >= δi and the sequence of functions (v̂n ) are all mutually
orthogonal with length ||vn || = 1.
252 9 A Primer on Series Solutions

9.5.1.3 Fourier Coefficients Revisited

Let f be any continuous function


 on the interval [0, L]. Then we know f is Riemann
L
integrable and so ||f || = f (t)2 dt is a finite number. From Sect. 9.5.1.1, recall the
0       
sequence of functions {sin πL x , sin 2π L
x , . . .} and {1, cos π
L
x , cos 2π
L
x , . . .}
are mutually orthogonal sequences on the interval [0, L]. Further, we know that we
can divide each of the functions by their length to create the orthogonal sequences
of length one we called (ûn ) for n ≥ 1 and (v̂n ) for n ≥ 0, respectively. Consider for
any n


n 
n
0≤<f − < f , ûi > ûi , f − < f , ûj > ûj >
i=1 j=1

n 
n 
n
= < f , f > −2 (< f , ûi >)2 + < f , ûi >< f , ûj > < ûi , ûj >
i=1 i=1 j=1

n 
n
= < f , f > −2 (< f , ûi >)2 + (< f , ûi >)2
i=1 i=1

n
= < f,f > − (< f , ûi >)2 ,
i=1

j
where we use the fact that the < ûi , ûj >= δi . Hence, we conclude that for
n
i=1 (< f , ûi >) ≤ ||f ||2 . A similar argument shows that for all n,
2
all n,
n
i=0 (< f , v̂i >) ≤ ||f || . The numbers < f , ûi > and < f , v̂i > are called
2 2

the ith Fourier sine and ith Fourier cosine coefficients of f , respectively. Note this
is similar to the Fourier coefficients defined earlier but we are writing them in terms
of the normalized sin and cos functions. In fact, in the context of the sums, they are
the same; i.e.
  
2 2 2
< f , ûi > ûi = f , ui ui = < f , ui > ui
L L L

is the same term in both summations. We can do a similar expansion for the cos
functions. So depending on where you read about these things, you could see them
defined either way. Thus, we can rewrite the finite sums here in terms of the original
sin and cos functions. We have


n n     
2 iπ iπ
< f , ûi > ûi = f (x), sin x sin x
i=1 i=1
L L L
9.5 Fourier Series Components 253

and


n n     
1 2 iπ iπ
< f , v̂i > v̂i = < f (x), 1 > 1 f (x), cos x cos x .
i=0
L i=1
L L L

We often write sums like


 thisin terms of the original sine and cosine functions: the
coefficients 2
L
f (x), sin iπ
L
x are thus also called the ith Fourier sine coefficients
    
of f and the coefficients 1
L
f (x), 1) and L2 f (x), cos iπL x , the ith Fourier cosine
coefficients of f . You can think of these as the un normalized Fourier coefficients
for f , if you want as they are based on the un normalized sin and cos functions. This
ambiguity in the definition is easy to remember and it comes about because it is
easy to write these sorts of finite expansions of f in terms of its Fourier coefficients
in terms of the original sine and cosine functions. We are now ready to discuss the
convergence of what are called Fourier series. We start with the sin and cos sequences
discussed above. We can say more about them.

9.5.1.4 Fourier Coefficients Go to Zero

We will now show the nth Fourier sine and cosine coefficients must go to zero. From
the previous section, we know that ni=1 | < f , ûi > |2 ≤ ||f ||2 and ni=0 | <
f , v̂i > |2 ≤ ||f ||2 which tells us that the series ∞i=1 | < f , ûi > | ≤ ||f || and
2 2

i=0 | < f , v̂i > | ≤ ||f || . Hence, since these series of non negative terms are
2 2

bounded above, they must converge. Pick any positive tolerance . Let’s focus on the
sin series first.
Since this series converges to say SS, there is a positive integer N so that n >
N =⇒ |Sn − SS| < 2 , where Sn is the usual partial sum. Thus, we can say for any
n > N + 1, we have

|Sn − Sn−1 | = |Sn − SS + SS − Sn−1 |


≤ |Sn − SS| + |SS − Sn−1 |
 
< +
2 2
= .

From the definition of partial sums, we know Sn − Sn−1 = (< f , ûn >)2 . Hence, we
know n > N =⇒ (< f , ûn >)2 < . But this implies limn→∞ < f , ûn >= 0 which
is the result we wanted to show. It is clear this is the same as
  
2 L nπ
lim f (x) sin x = 0.
n→∞ L 0 L
254 9 A Primer on Series Solutions

Now, a similar argument will show that limn→∞ < f , v̂n >= 0 or equivalently
 L  
2 nπ
lim f (x) cos x = 0.
n→∞ L 0 L

9.6 The Convergence of Fourier Series

The Fourier series associated to the continuous function f on [0, L] is the series

1
S(x) = < f,1 >
L
∞           
2 iπ iπ 2 iπ iπ
+ f (x), sin x sin x + f (x), cos x cos x .
i=1
L L L L L L

We will sneak up on the analysis of this series by looking instead at the Fourier
series of f on the interval [0, 2L]. The sin and cos functions we have discussed
 were labeled un and vn respectively.
in Sects. 9.5.1.1 and 9.5.1.2  On the interval
[0, L], their lengths were L2 for each un and vn for n ≥ 1 and L1 for v0 . We used
these lengths to define the normalized functions ûn and v̂n which formed mutually
orthogonal sequences. On the interval [0, 2L] the situation is virtually the same. The
only difference is that on [0, 2L], we still have
 

un (x) = sin x ,n ≥ 1
L
v0 (x) = 1
 

vn (x) = cos x ,n ≥ 1
L

but now, although we still have orthogonality, the lengths change. We find

L, i = j
< ui , uj > =
0, i = j.
⎧ 1
⎨ 2L , i = j = 1,
< vi , vj > = L, i = j, i ≥ 1

0, i = j.

The normalized functions are now


  
1 nπ
ûn (x) = sin x
L L
9.6 The Convergence of Fourier Series 255

1
v̂0 (x) =
2L
  
1 nπ
v̂n (x) = cos x , n ≥ 1.
L L

The argument given in Sect. 9.5.1.4 still holds with just obvious changes. So these
Fourier coefficients go to zero as n → ∞ also. This series on [0, 2L] does not
necessarily converge to the value f (x) at each point in [0, 2L]; in fact, it is known
that there are continuous functions whose Fourier series does not converge at all. Still,
the functions of greatest interest to us are typically functions that have continuous
derivatives except at a finite number of points and for those sorts of functions, S(x)
and f (x) usually match. We are going to prove this in the work below. Consider the
difference between a typical partial sum SN (x) and our possible target f (x).

1
|SN (x) − f (x)| = < f,1 >
2L
N      
1 iπ iπ
+ f (x), sin x sin x
i=1
L L L
    
1 iπ iπ
+ f (x), cos x cos x − f (x)
L L L
 L
1
= f (t) dt
2L 0
N      
1 2L iπ iπ
+ f (t) sin t sin x
i=1
L 0 L L
   
iπ iπ
+ cos t cos x dt − f (x)
L L

Now, sin(u) sin(v) + cos(u) cos(v) = cos(u − v) and hence we can rewrite the above
as follows:
 2L  N    
1 1 2L iπ
|SN (x) − f (x)| = f (t) dt + f (t) cos (t − x) dt − f (x)
2L 0 i=1
L 0 L
   
1 
N
1 2L iπ
= f (t) + cos (t − x) dt − f (x)
L 0 2 i=1
L
256 9 A Primer on Series Solutions

9.6.1 Rewriting SN (x)

Next, we use another identity. We know from trigonometry that


       
y 1 1
cos(iy) sin = sin i + y − sin i − y
2 2 2

and so
 
N    
1 iπ π
+ cos (t − x) sin (t − x)
2 L 2L
i=1
   N       
1 π 1 π 1 π
= sin (t − x) + sin i + (t − x) − sin i − (t − x)
2 2L 2 L 2 L
i=1
     
1 π 1 3π 1 π
= sin (t − x) + sin (t − x) − sin (t − x)
2 2L 2 2L 2 2L
   
1 5π 1 3π
+ sin (t − x) − sin (t − x)
2 2L 2 2L
   
1 7π 1 5π
+ sin (t − x) − sin (t − x)
2 2L 2 2L
...    
1 (2N + 1)π 1 (2N − 1)π
+ sin (t − x) − sin (t − x)
2 2L 2 2L
  
1 1 π
= sin N + (t − x)
2 2 L

We have found
  
π
   1
sin N+ 1
(t
− x)
1 
N 2 2 L

+ cos (t − x) =   (9.13)
2 L π
i=1 sin 2L (t − x)

Note the argument t − x is immaterial and for any y, the identity can also be written
as
  
1 π
   1
sin N + 2 L y
1 
N 2

+ cos y =   (9.14)
2 L π
i=1 sin 2L y
9.6 The Convergence of Fourier Series 257

Now, we use this to rewrite SN (x). We can then use this identity to find
    
1 2L 1
sin N + 21 πL (t − x)
SN (x) = f (t) 2
π  dt
L 0 sin 2L (t − x)

Making the change of variable y = t − x, we have


         
1 2L 1
sin N + 21 πL (t − x) 1 2L−x 1
sin N + 21 πL y
f (t) 2 π  dt = f (y + x) 2 π  dy.
L 0 sin 2L (t − x) L −x sin 2L y

Now, switch the integration variable y back to t to obtain the form we want:
 1   
1 2L−x sin N + 21 πL t
SN (x) = f (t + x) 2
π  dt.
L −x sin 2L t

We can rewrite this even more. All of the individual sin terms are periodic over the
interval [0, 2L]. We extend the function f to be periodic also by defining

fˆ (x + 2nL) = f (x), 0 < x < 2L.

and defining what happens at the endpoints 0, ±2L, ±4L and so on using one sided
limits. Since the original f is continuous on [0, 2L], we know f (0+ ) and f (2L − ) both
exists and match f (0) and f (2L), respectively. Because these two values need not
be the same, the periodic extension will always have a potential discontinuity at the
point 2nL for all integers n. We will define the periodic extension at these points as

fˆ (2nL − ) = f (2L − ), and fˆ (2nL + ) = f (0+ )


1
fˆ (2nL) = (f (0+ ) + f (2L − )).
2
For example, if f is the square wave

H, 0 ≤ x ≤ L,
f (x) =
0, L < 2L

which has a discontinuity at L, then the periodic extension will have discontinuities
at each multiple 2nL as fˆ (2L − ) = 0, f (0+ ) = H and f (2nL) is the average value.
 2L−x  2L
However, the value of the integral −x and 0 are still the same. Hence, SN (x)
can be written as
 1   
1 2L ˆ sin N + 21 πL t
SN (x) = f (t + x) 2
π  dt.
L 0 sin 2L t
258 9 A Primer on Series Solutions

9.6.2 Rewriting SN − F

It would be nice if we could pull the f (x) at the end of this expression into the integral
sign. This is how we can do that. Consider

1
 2L  1 
N 

 
1 1 
N
L


 2L
+ cos (t) dt = t+ sin (t)
L 0 2 L L 2 iπ L 0
i=1 i=1
 
N      
1 L iπ iπ
= L+ sin (2L) − sin (0) .
L iπ L L
i=1
= 1.

Hence, we can say

f (x) = f (x) × 1
   
1 2L 1 
N

= + cos (t) f (x) dt
L 0 2 i=1
L

However, using Eq. 9.14, we can rewrite again as

f (x) = f (x) × 1
    
1 2L 21 sin N + 21 πL t
= π  f (x) dt
L 0 sin 2L t

Using the periodic extension fˆ , the equation above is still valid. Hence, SN (x)−f (x) =
SN (x) − fˆ (x) and we find

|SN (x) − f (x)|


 1    
1 2L ˆ sin((N + 21 ) πL t) 1 2L 21 sin((N + 21 ) πL t) ˆ
= f (t + x) 2 π dt − π f (x) dt
L 0 sin( 2L t) L 0 sin( 2L t)
 2L   
1 sin((N + 21 ) πL t)
= ˆ ˆ
f (t + x) − f (x) π
2L 0 sin( 2L t)
 2L ˆ   
1 (f (t + x) − fˆ (x)) 1 π
=   sin N + t
2L 0 π 2 L
sin 2L t

 form by defining the function h on [0, 2L] by


We can package this in aconvenient
h(t) = fˆ (t + x) − fˆ (x) / sin π
2L
t Hence, the convergence of the Fourier series
associated with f on [0, 2L] is shown by establishing that
9.6 The Convergence of Fourier Series 259
   
1 2L
1 π
lim |SN (x) − f (x)| = lim h(t) sin N+ t =0
N→∞ N→∞ 2L 0 2 L
 
π
We can simplify our arguments a bit more by noticing the function t/ sin 2L
t has
a removeable discontinuity at t = 0. This follows from a simple L’Hopital’s rule
argument. Hence,  function is continuous on[0, 2L]
 this  and so there is a constant C
π π
so that |t/ sin 2L t | ≤ C. This implies |1/ sin 2L t | ≤ C 1/t on the interval and
so we can establish the convergence we want by showing
 
 fˆ (t + x) − fˆ (x)   
1 2L
1 π
lim sin N + t = 0.
N→∞ 2L 0 t 2 L
 
Hence, we need to look at the function H(t) = fˆ (t+x)− fˆ (x) /t in our convergence
discussions.

9.6.3 Convergence

It is straightforward to shown that the sequence of functions wN (x) = sin N +
 
1 π
2 L
t are mutually orthogonal with length L. Hence, the functions ŵN (x) =

1
w (x) have length one and are orthogonal. Hence, we already know that if H is
L N
continuous on [0, 2L], then the Fourier coefficients < H, ŵN >→ 0 using arguments
just like we did in Sect. 9.5.1.4. For our purposes, we will only look at two kinds of
functions f : the first is differentiable at x and the second has f has right and left sided
derivatives at x.

9.6.3.1 f Is Differentiable

On the interval [0, 2L], we can see that H(t) is continuous at every point except
possible t = 0. At t = 0, continuity of H comes down to whether or not H has a
removeable discontinuity at 0. First, note

fˆ (t + x) − fˆ (x)
lim H(t) = lim = f  (x)
t→0 t→ t
260 9 A Primer on Series Solutions

since we assume f is differentiable on [0, 2L]. So H has a removeable discontinuity


at 0 as long as we define H(0) = f  (x). Hence at each point where f has a derivative,
we have shown that SN (x) → f (x); i.e. the Fourier series of f on the interval [0, 2L]
converges to f (x).

9.6.3.2 f Has One Sided Derivatives

Now we assume f is differentiable to the left of x and to the right of f . This would
include the case where f has a jump discontinuity at x as well as the case where
f has a corner there. Hence (f  (x))+ and (f  (x))− exist and are finite numbers. We
can handle this case by going back to our estimates and replacing f (x) by the new
function 21 (f (x + ) + f (x − )) where f (x + ) is the right hand value and f (x − ) is the left
hand value of the jump, respectively. Then, note

 L     
1  
N N L
1 iπ 1 1 L iπ
+ cos (t) dt = t+ sin (t)
L 0 2 L L 2 iπ L 0
i=1 i=1
      
1 L  L
N
iπ iπ
= + sin (L) − sin (0) .
L 2 iπ L L
i=1
1
= .
2

and

1
 2L  1 
N 

 
1 1 
N
L


 2L
+ cos (t) dt = t+ sin (t)
L L 2 L L 2 iπ L L
i=1 i=1
 
N      
1 L L iπ iπ
= + sin (2L) − sin (L) .
L 2 iπ L L
i=1
1
= .
2

Hence, we can say


 L  
1 
N
1 2 iπ
f (x + ) = 2f (x + ) × = + cos (t) f (x + ) dt
2 L 0 2 i=1
L
 L 1 
2 sin((N + 21 ) πL t)
= 2
π f (x + )dt
L 0 sin( 2L t)
9.6 The Convergence of Fourier Series 261

and
1
f (x − ) = 2f (x − ) ×
2
 2L   
1 
N
2 iπ
= + cos (t) f (x + ) dt
LL 2 i=1
L
 2L  1   
2 sin N + 21 πL t
= 2
 π
 f (x − )dt
L L sin 2L t

Thus, 21 (f (x + ) + f (x − )) can be rewritten as



 L 1  
1 1 sin N + 21 πL t
(f (x + ) + f (x − )) = 2
π  f (x + )dt
2 L 0 sin 2L t
    
1 2L 21 sin N + 21 πL t
+ π  f (x − )dt
L L sin 2L t
L  2L
We can also rewrite the SN (x) terms as two integrals, 0 and L giving
 1     1   
1 L sin N + 21 πL t 1 2L ˆ sin N + 21 πL t
SN (x) = fˆ (t + x) 2 π  dt + f (t + x) 2 π  dt.
L 0 sin 2L t L L sin 2L t

Combining, we obtain
 L  1   
1 π
1 1 ˆf (t + x) − fˆ (x + ) 2 sin N + 2 L t
|SN (x) − (f (x + ) + f (x − ))| ≤ π dt
2 L 0 sin 2L t
   1  
1 π

1 2L ˆ 2 sin N + 2 L t
+ f (t + x) − fˆ (x − ) π dt .
L L sin 2L t

Using the triangle inequality and using the same overestimates as before, we find the
series will converge as long as
 L ˆ    
1 f (t + x) − fˆ (x + ) 1 π
lim sin N+ t dt = 0,
t→0+ 2L 0 t 2 L

and
 L ˆ    
1 f (t + x) − fˆ (x + ) 1 π
lim sin N + t dt = 0,
t→(2L)− 2L 0 t 2 L

The integrand in the first estimate is continuous on [0, L] if the integrand has a
removeable discontinuity at t = 0. This is true as when t → 0+ , the limiting value is
(f (x))+ . Hence, using the arguments of Sect. 9.5.1.4, these terms go to 0 in the limit
262 9 A Primer on Series Solutions

as N → ∞. To understand the second limit, remember fˆ is the periodic extension of


f on [0, 2L]. Hence, the limit as t → 2L of the integrand is the same as the limit as
t → 0− of the integrand. By assumption, this limit is (f  (x))− and thus, the second
integrand has a removeable discontinuity as well. We conclude that at any point where
f has a jump discontinuity with f differentiable from the right and the left at this point,
the series converges to the average of the jump values: SN (x) → 21 (f (x + ) + f (x − )).

9.7 Fourier Sine Series

Let f be defined only on the interval [0, L]. Extend f to be an odd function fo on
[0, 2L] as follows:

f (x), 0 ≤ x ≤ L,
fo (x) =
−f (2L − x), L < x ≤ 2L.

Then extend fo periodically as usual to fˆo . The Fourier coefficient for the sin terms
are then
 2L        
1 iπ 1 L iπ 1 2L iπ
fo (t) sin t dt = f (t) sin t dt + (−f (2L − t)) sin t dt.
L 0 L L 0 L L L L

Consider the second integration. Making the change of variable y = 2L − t, we find


 2L     
1 iπ 1 0 iπ
(−f (2L − t)) sin t dt = (−f (y)) sin (2L − y) (−dy).
L L L L L L

But iπ
L
(2L − y) = 2iπ − iπ
L
y and since sin term 2π periodic, we have
 L     
1 iπ 1 0 iπ
(−f (y)) sin (2L − y) dy = (−f (y)) sin (−y) (−dy)
L 0 L L L L
  
1 L iπ
= f (y) sin (y) dy.
L 0 L

This is the same as the first integral. Hence, we have shown


 2L     
1 iπ 2 L iπ
fo (t) sin t dt = f (t) sin t dt.
L 0 L L 0 L

The terms corresponding to the cos parts will all then be zero. The argument is
straightforward.
 2L        
1 iπ 1 L iπ 1 2L iπ
fo (t) cos t dt = f (t) cos t dt + (−f (2L − t)) cos t dt.
L 0 L L 0 L L L L
9.7 Fourier Sine Series 263

Consider the second integration. Making the change of variable y = 2L − t, we find


 2L     
1 iπ 1 0 iπ
(−f (2L − t)) cos t dt = (−f (y)) cos (2L − y) (−dy).
L L L L L L

Again, iπL (2L − y) = 2iπ − iπ


L
y and since cos term 2π periodic and cos is an even
function, we have
 2L     
1 iπ 1 0 iπ
(−f (2L − t)) cos t dt = f (y) cos y dy
L L L L L L
 L  
1 iπ
−f (y) cos y dy
L 0 L

which is the negative of the first integral. So all of these coefficients are zero. The
 2L
last one is 0 fo (t)dt = 0 because f0 is odd on this interval. Thus, all the cos based
terms in the Fourier series vanish. The Fourier series on the interval [0, 2L] of the
odd extension fo becomes the standard Fourier sine series on the interval [0, L] of
the function f .

 ∞     
2 iπ iπ
< f , ûi > ûi = f (x), sin x sin x .
i=1 i=1
L L L

We know now from Sect. 9.6.3 this converges to f (x) at each point x where f is
differentiable and converges to the average 21 (f (x + ) + f (x − )) at each point x where
f has one sided finite derivatives. Note because the sin functions are always 0 at the
endpoints 0 and L, this series must converge to 0 at those points.

9.8 Fourier Cosine Series

Let f be defined only on the interval [0, L]. Extend f to be an even function fe on
[0, 2L] as follows:

f (x), 0 ≤ x ≤ L,
fe (x) =
f (2L − x), L < x ≤ 2L.

Then extend fe periodically as usual to fˆe . The Fourier coefficient for the sin terms
are now
 2L        
1 iπ 1 L iπ 1 2L iπ
fe (t) sin t dt = f (t) sin t dt + f (2L − t) sin t dt.
L 0 L L 0 L L L L
264 9 A Primer on Series Solutions

Consider the second integration. Making the change of variable y = 2L − t, we find


 2L    
1 iπ 1 0 iπ
f (2L − t)) sin t dt = f (y) sin (2L − y) (−dy)
L L L L L L
  
1 L iπ
= f (y) sin (−y) dy.
L 0 L

However, sin is an odd function and thus the second integral is the negative of the
first and these coefficients vanish. Next, consider the first Fourier cos coefficient.
This is
 2L  L 
1 1 1 2L
fe (t)dt = f (t)dt + f (2L − t)dt
2L 0 2L 0 L L
 L  0 
1 1 1 L
= f (t)dt + f (y)(−dy) = f (t)dt.
2L 0 L L L 0

Now let’s look at the other cos based coefficients. We have


 2L        
1 iπ 1 L iπ 1 2L iπ
fe (t) cos t dt = f (t) cos t dt + f (2L − t) cos t dt.
L 0 L L 0 L L L L

Consider the second integration. Making the change of variable y = 2L − t, we find


 2L    
1 iπ 1 0 iπ
f (2L − t) cos t dt = f (y) cos (2L − y) (−dy)
L L L L L L
 L  
1 iπ
= f (y) cos (2L − y) dy
L 0 L

Again, iπL (2L − y) = 2iπ − iπ


L
y and since cos term 2π periodic and cos is an even
function, we have
 2L     
1 iπ 1 L iπ
(−f (2L − t)) cos t dt = f (y) cos y dy
L L L L 0 L

This is the same as the first integral. Thus, the Fourier series on the interval [0, 2L]
of the even extension fe becomes the standard Fourier cosine series on the interval
[0, L] of the function f

 ∞     
1 2 iπ iπ
< f , v̂i > v̂i = < f (x), 1 > + f (x), cos x cos x .
i=0
L i=1
L L L

We know from Sect. 9.6.3 this series converges to f (x) at each point x where f is
differentiable and converges to the average 21 (f (x + ) + f (x − )) at each point x where
f has one sided finite derivatives.
9.9 MatLab Implementation 265

9.9 MatLab Implementation

We will need to approximate Fourier series expansions for arbitrary functions f when
we solve the cable equation. All of these approximations require that we find inner
products of the form < f , un > for some function un which is a sin or cos term.
In Chap. 2, we discussed Newton–Cotes methods for integration and in Sect. 2.5,
we went over the Graham-Schmidt Orthogonalization method that takes linearly
independent vectors/functions {f1 , . . . , fN } and outputs orthogonal linearly indepen-
dent vectors of length one, {g1 , . . . , gN }. A standard test to see if our numerical
inner product calculations are sufficiently accurate is to compute the N × N matrix
d = (< gi , gj >) which should be the essentially the N × N identify matrix as the
off diagonal entries should all be zero. However, if the inner product computations
are inaccurate, off diagonal values need not be zero and the GSO method will fail.
So we begin with a search for a better inner product.

9.9.1 Inner Products Revisited

The errors we get when we use the Newton-Cotes formulae can be unacceptable.
Hence, we will handle our inner product calculations using a Riemann sum approx-
imation to the needed integral. This is not very sophisticated, but it works well and
is easy to program. The function innerproduct to do this is shown below. This
b
code approximates a f (t)g(t)dt using a Riemann sum with N terms formed from a
uniform partition based on the subinterval length b−a
N
. This performs well in practice
for us.

Listing 9.1: Riemann sum innerproduct


f u n c t i o n c = i n n e r p r o d u c t ( f , g , a , b ,N)
%
%
h = @( t ) f ( t ) ∗ g ( t ) ;

d e l x = ( b−a ) /N;
x = l i n s p a c e ( a , b ,N+1) ;
c = 0;
f o r i =1:N
c = c+ h ( x ( i ) ) ∗ d e l x ;
end

end

We can check how accurate we are with these inner product calculation by using
them to do a Graham-Schmidt orthogonalization on the functions 1, t, t 2 , . . . , t N on
the interval [a, b]. The code to do this is in the function GrahamSchmidtTwo.
This function returns the new orthogonal of length one functions gi and also prints
out the matrix with terms < gi , gj > which should be an identity. The input NIP is
266 9 A Primer on Series Solutions

the number of terms to use in the Riemann sum approximations to the inner product
and N is size of the number of functions we perform GSO on.

Listing 9.2: Using Riemann sums for GSOs: Graham–SchmidtTwo


f u n c t i o n g = GrahamSchmidtTwo ( a , b , N, NIP )
%
% Perform Graham − S c h m i d t O r t h o g o n a l i z a t i o n
% on a s e t o f f u n c t i o n s t ˆ 0 , . . . , t ˆN
5 %
%S e t u p f u n c t i o n h a n d l e s
f = S e t U p F u n c t i o n s (N) ;
g = c e l l (N+1 ,1) ;

10 n f = s q r t ( i n n e r p r o d u c t ( f { 1 } , f { 1 } , a , b , NIP ) ) ;
g {1} = @( x ) f {1}( x ) / n f ;
d = z e r o s (N+1 ,N+1) ;
f o r k =2:N+1
%compute n e x t o r t h o g o n a l p i e c e
15 p h i = @( x ) 0 ;
f o r j = 1 : k−1
c = i n n e r p r o d u c t ( f {k } , g{ j } , a , b , NIP ) ;
p h i = @( x ) ( p h i ( x )+c ∗g{ j } ( x ) ) ;
end
20 p s i = @( x ) ( f {k } ( x ) − p h i ( x ) ) ;
n f = s q r t ( i n n e r p r o d u c t ( p s i , p s i , a , b , NIP ) ) ;
g{k} = @( x ) ( p s i ( x ) / n f ) ;
end

25 f o r i =1:N+1
f o r j =1:N+1
d ( i , j ) = i n n e r p r o d u c t ( g{ i } , g{ j } , a , b , NIP ) ;
end
end
30 d
end

Here is a typical run.

Listing 9.3: Sample GrahamSchmidtTwo run


g = GrahamSchmidtTwo ( 0 , 2 , 2 , 5 0 0 0 ) ;

This computes the GSO of the functions 1, t, t 2 on the interval [0, 2] using Riemann
sum approximations with 5000 points. The matrix < gi , gj > which is calculated is

Listing 9.4: GSO Orthogonality results: first 3 powers of t


d =

1 . 0 0 0 0 e+00 −1.3459 e −13 1 . 7 6 5 6 e −13


4 −1.3459 e −13 1 . 0 0 0 0 e+00 6 . 1 1 7 1 e −13
1 . 7 6 5 6 e −13 6 . 1 1 7 1 e −13 1 . 0 0 0 0 e+00

This is the 3×3 identify that we expect. Next, we do GSO on the functions 1, t, . . . , t 6 .
9.9 MatLab Implementation 267

Listing 9.5: Running GSO on the first 5 powers of t


g = GrahamSchmidtTwo ( 0 , 2 , 6 , 5 0 0 0 ) ;

This also generates the identity matrix we expect for < gi , gj >.

Listing 9.6: GSO Orthogonality results: first 5 powers of t


d =

1 . 0 0 0 0 e+00 −1.3459 e −13 1 . 7 6 5 6 e −13 −2.0684 e −13 1.8885 e


−13
4 −1.3459 e −13 1 . 0 0 0 0 e+00 6 . 1 1 7 1 e −13 −1.8011 e −12 3.6344 e
−12
1 . 7 6 5 6 e −13 6 . 1 1 7 1 e −13 1 . 0 0 0 0 e+00 −1.0743 e −11 4.8201 e
−11
−2.0684 e −13 −1.8011 e −12 −1.0743 e −11 1 . 0 0 0 0 e+00 3.8416 e
−10
1 . 8 8 8 5 e −13 3 . 6 3 4 4 e −12 4 . 8 2 0 1 e −11 3 . 8 4 1 6 e −10 1.0000 e
+00

To compute the first N terms of the Fourier Cosine series of afunction  f on the
interval [0, L], we first need a way to encode all the functions cos L x . We do this

in the function SetUpCosines.

Listing 9.7: SetUpCosines


f u n c t i o n f = S e t U p C o s i n e s ( L ,N)
%
% Setup f u n c t i o n handles
%
5 f = c e l l (N+1 ,1) ;
f o r i =1:N+1
f { i } = @( x ) c o s ( ( i −1)∗ p i ∗x /L ) ;
end

   
π
This generates handles to the functions 1, cos L x , cos 2π
L
x and so forth ending
 
with cos Nπ
L
x . A similar function encodes the corresponding sin functions we need
for the first N terms of a Fourier Sine series. The function is called SetUpSines
with code

Listing 9.8: SetUpSines


f u n c t i o n f = S e t U p S i n e s ( L ,N)
%
% Setup f u n c t i o n handles
%
5 f = c e l l (N, 1 ) ;
f o r i =1:N
f { i } = @( x ) s i n ( i ∗ p i ∗x /L ) ;
end
268 9 A Primer on Series Solutions
   
This generates handles to the functions sin πL x , sin 2π
L
x and so forth ending with
 
sin NπL
x . Let’s check how accurate our innerproduct calculations are on the sin
and cos terms. First, we modify the functions which set up the sin and cos functions
to return functions of length one on the interval [0, L]. This is done in the functions
SetUpOrthogCos and SetUpOrthogSin.

Listing 9.9: SetUpOrthogCos


f u n c t i o n f = SetUpOrthogCos ( L ,N)
%
% Setup f u n c t i o n handles
%
5 f = c e l l (N+1 ,1) ;
f {1} = @( x ) s q r t ( 1 / L ) ;
f o r i =2:N+1
f { i } = @( x ) s q r t ( 2 / L ) ∗ c o s ( ( i −1)∗ p i ∗x /L ) ;
end

and

Listing 9.10: SetUpOrthogSin


1 f u n c t i o n f = SetUpOrthogSin ( L ,N)
%
% Setup f u n c t i o n handles
%
f = c e l l (N, 1 ) ;
6 f o r i =1:N
f { i } = @( x ) s q r t ( 2 / L ) ∗ s i n ( ( i −1)∗ p i ∗x /L ) ;
end

Then, we can check the accuracy of the inner product calculations by computing the
matrix d = (< fi , fj >). We do this with the new function CheckOrtho. We input
the function f and interval [a, b] endpoints a and b and the number of terms to use
in the Riemann sum approximation of the inner product, NIP.

Listing 9.11: Checking orthogonality of the GSO: CheckOrtho


f u n c t i o n CheckOrtho ( f , a , b , NIP )
%
% Perform Graham − S c h m i d t O r t h o g o n a l i z a t i o n
% on a s e t o f f u n c t i o n s f
5 %
%S e t u p f u n c t i o n h a n d l e s
N = length ( f ) ;

f o r i =1:N
10 f o r j =1:N
d ( i , j ) = i n n e r p r o d u c t ( f { i } , f { j } , a , b , NIP ) ;
end
end
d
15 end
9.9 MatLab Implementation 269

Let’s try it with the cos functions. We use a small number of terms for the Riemann
sums, NIP = 50 and compute < gi , gj > for the first 7 functions.

Listing 9.12: The code to check cos orthogonality


f = SetUpOrthogCos ( 5 , 7 ) ;
g = CheckOrtho ( f , 0 , 5 , 5 0 ) ;

We do not get the identity matrix as we expect some of the off diagonal values are
too large.

Listing 9.13: Checking Orthogonality for cosine functions: NIP = 50


d =

3 1 . 0 e+00 2 . 8 e −02 −5.5 e −17 2 . 8 e −02 −1.2 e −16 2 . 8 e −02 −4.5 e −17
2 . 8 e −02
2 . 8 e −02 1 . 0 e+00 4 . 0 e −02 −1.2 e −16 4 . 0 e −02 4 . 8 e −17 4 . 0 e −02
1 . 1 e −16
−5.5 e −17 4 . 0 e −02 1 . 0 e+00 4 . 0 e −02 −6.2 e −17 4 . 0 e −02 −2.0 e −16
4 . 0 e −02
2 . 8 e −02 −1.2 e −16 4 . 0 e −02 1 . 0 e+00 4 . 0 e −02 −5.5 e −17 4 . 0 e −02
−6.9 e −18
−1.1 e −16 4 . 0 e −02 −6.2 e −17 4 . 0 e −02 1 . 0 e+00 4 . 0 e −02 −9.7 e −17
4 . 0 e −02
8 2 . 8 e −02 4 . 8 e −17 4 . 0 e −02 −5.5 e −17 4 . 0 e −02 1 . 0 e+00 4 . 0 e −02
2 . 8 e −17
−4.5 e −17 4 . 0 e −02 −2.0 e −16 4 . 0 e −02 −9.7 e −17 4 . 0 e −02 1 . 0 e+00
4 . 0 e −02
2 . 8 e −02 1 . 1 e −16 4 . 0 e −02 −6.9 e −18 4 . 0 e −02 2 . 8 e −17 4 . 0 e −02
1 . 0 e+00

Resetting NIP = 200, we find a better result.

Listing 9.14: Checking Orthogonality for cosine functions: NIP = 200


d =

1 . 0 e+00 7 . 1 e −03 −6.1 e −17 7 . 1 e −03 −7.1 e −17 7 . 1 e −03 −3.9 e −17
7 . 1 e −03
7 . 1 e −03 1 . 0 e+00 1 . 0 e −02 −5.5 e −17 1 . 0 e −02 −1.1 e −16 1 . 0 e −02
−3.8 e −17
5 6 . 1 e −17 1 . 0 e −02 1 . 0 e+00 1 . 0 e −02 −7.8 e −17 1 . 0 e −02 −1.6 e −16
1 . 0 e −02
7 . 1 e −03 −5.5 e −17 1 . 0 e −02 1 . 0 e+00 1 . 0 e −02 −2.7 e −16 1 . 0 e −02
−3.3 e −17
7 . 1 e −17 1 . 0 e −02 −7.8 e −17 1 . 0 e −02 1 . 0 e+00 1 . 0 e −02 −1.0 e −16
1 . 0 e −02
7 . 1 e −03 −1.2 e −16 1 . 0 e −02 −2.6 e −16 1 . 0 e −02 1 . 0 e+00 1 . 0 e −02
2 . 1 e −17
3 . 9 e −17 1 . 0 e −02 −1.6 e −16 1 . 0 e −02 −1.0 e −16 1 . 0 e −02 1 . 0 e+00
1 . 0 e −02
10 7 . 1 e −03 −3.8 e −17 1 . 0 e −02 −3.3 e −17 1 . 0 e −02 2 . 1 e −17 1 . 0 e −02
1 . 0 e+00
270 9 A Primer on Series Solutions

We can do even better by increasing NIP, of course. We encourage you to do these


experiments yourself. We did not show the results for the sin terms, but they will be
similar.

9.9.1.1 Homework

Exercise 9.9.1 Find the GSO of the functions f1 (t) = t 2 , f2 (t) = cos(2t) and f3 (t) =
4t 3 on the interval [−1, 2] using the implementations given in this section for various
values of NIP. Check to see the matrix d is the diagonal.

Exercise 9.9.2 Find the GSO of the functions f1 (t) = 1, f2 (t) = t and f3 (t) = t 2
on the interval [−1, 1] using the implementations given in this section for various
values of NIP. Check to see the matrix d is the diagonal.

Exercise 9.9.3 Find the GSO of the functions f1 (t) = 1, f2 (t) = t and f3 (t) = t 2
on the interval [−1, 4] using the implementations given in this section for various
values of NIP. Check to see the matrix d is the diagonal.

9.9.2 Fourier Cosine and Sine Approximation

We can then calculate the first N + 1 terms of a Fourier series or the first N
terms of a Fourier Sine series using the functions FourierCosineApprox and
FourierSineApprox, respectively. Let’s look at the Fourier Cosine approxima-
tion first. This function returns a handle to the function p which is the approximation


N
p(x) = < f , gi > gi (x)
n=0

 
where gi (x) = cos iπ
L
x . It also returns the Fourier cosine coefficients A1 = 1
L
<
f , g0 > through AN+1 = L2 < f , gN >. We must choose how many points to use in
our Riemann sum inner product estimates – this is the input variable N. The other
inputs are the function handle f and the length L. We also plot our approximation
and the original function together so we can see how we did.
9.9 MatLab Implementation 271

Listing 9.15: FourierCosineApprox


f u n c t i o n [ A, p ] = F o u r i e r C o s i n e A p p r o x ( f , L ,M,N)
%
% p i s t h e Nth F o u r i e r A p p r o x i m a t i o n
% f is the or igi nal function
5 % M i s t h e number o f Riemann sum t e r m s i n t h e i n n e r product
% N i s t h e number o f t e r m s i n t h e a p p r o x i m a t i o n
% L is the i n t e r v a l length

% g e t t h e f i r s t N+1 F o u r i e r c o s a p p r o x i m a t i o n s
10 g = S e t U p C o s i n e s ( L ,N) ;

% g e t Fourier Cosine C o e f f i c i e n t s
A = z e r o s (N+1 ,1) ;
A( 1 ) = i n n e r p r o d u c t ( f , g { 1 } , 0 , L ,M) /L ;
15 f o r i =2:N+1
A( i ) = 2∗ i n n e r p r o d u c t ( f , g{ i } , 0 , L ,M) /L ;
end

% g e t Nth F o u r i e r C o s i n e A p p r o x i m a t i o n
20 p = @( x ) 0 ;
f o r i =1:N+1
p = @( x ) ( p ( x ) + A( i ) ∗g{ i } ( x ) ) ;
end

25 x = linspace (0 ,L,101) ;
f o r i =1:101
y( i ) = f (x( i ) ) ;
end
yp = p ( x ) ;
30
figure
s = [ ’ Fourier Cosine A p p r o x i m a t i o n with ’ , i n t 2 s t r (N+1) , ’ term ( s ) ’ ] ;
p l o t ( x , y , x , yp ) ;
x l a b e l ( ’x axis ’ ) ;
35 y l a b e l ( ’y axis ’ ) ;
title (s) ;

end

We will test our approximations on two standard functions: the sawtooth curve
and the square wave. To define these functions, we will use an auxiliary function
splitfunc which defines a new function z on the interval [0, L] as follows

f (x) 0 ≤ x < L2 ,
z(x) =
g(x) L2 ≤ x ≤ L

The arguments to splitfunc are the functions f and g, the value of x for we wish
to find the output z and the value of L.

Listing 9.16: Splitfunc


function z = s p l i t f u n c (x , f , g , L)
%
i f x < L/2
z = f (x) ;
5 else
z = g(x) ;
end
272 9 A Primer on Series Solutions

It is easy then to define a sawtooth and a square wave with the following code. The
square wave, Sq has value H on [0, L2 ) and value 0 on [ L2 , L]. In general, the sawtooth
curve, Saw, is the straight line connecting the point (0, 0) to ( L2 , H) on the interval
[0, L2 ] and the line connecting ( L2 , H) to (L, 0) on the interval ( L2 , L). Thus,

H 0 ≤ x < L2 ,
Sq(x) =
0 L2 ≤ x ≤ L

and
2
Hx 0 ≤ x < L2 ,
Saw(x) = L
2H − L Hx L2 ≤ x ≤ L
2

We implement the sawtooth in the function sawtooth.

Listing 9.17: Sawtooth


f u n c t i o n f = s a w t o o t h ( L ,H)
%
%
% f l e f t = H/ ( L / 2 ) x
5 % = 2Hx/L
% check f l e f t (0) = 0
% f l e f t ( L / 2 ) = 2HL/ ( 2 L ) = H
%
% f r i g h t = H + (H − 0 ) / ( L/2 − L ) ( x − L / 2 )
10 % = H − ( 2H/L ) ∗ x + ( 2H/L ) ∗ ( L / 2 )
% = H − 2H/L ∗ x + H
% = 2H − 2Hx/L
% c h e c k f r i g h t ( L / 2 ) = 2H − 2HL/ ( 2L ) = 2H −H = H
% f r i g h t (L) = 2H − 2HL/L = 0
15 %
fleft = @( x ) 2∗ x∗H/L ;
f r i g h t = @( x ) 2∗H − 2∗H∗x/L ;
f = @( x ) s p l i t f u n c ( x , f l e f t , f r i g h t , L ) ;

20 end

As an example, we build a square wave and sawtooth of height 10 on the inter-


val [0, 10]. It is easy to plot these functions as well, although we won’t show the
plots yet. We will wait until we can compare the functions to their Fourier series
approximations. However, the plotting code is listed below for your convenience.
Note the plot must be set up in a for loop as the inequality checks in the function
splitfunc do not handle a vector argument such as the x from a linspace
command correctly.
9.9 MatLab Implementation 273

Listing 9.18: Build a sawtooth and square wave


f = @( x ) 1 0 ;
g = @( x ) 0 ;
Saw = s a w t o o t h ( 1 0 , 1 0 ) ;
Sq = @( x ) s p l i t f u n c ( x , f , g , 1 0 ) ;
5 x = linspace (0 ,10 ,101) ;
f o r i =1:101
> ySq ( i ) = Sq ( x ( i ) ) ;
> ySaw ( i ) = Saw ( x ( i ) ) ;
> end

9.9.2.1 Homework

Exercise 9.9.4 Write the functions needed to generate a periodic square wave on
the intervals [0, L] ∪ [L, 2L] ∪ [2L, 3L] ∪ . . . ∪ [N − 1)L, NL] of height H. Generate
the need graphs also.

Exercise 9.9.5 Write the functions needed to generate a periodic square wave on
the intervals [0, L] ∪ [L, 2L] ∪ [2L, 3L] ∪ . . . ∪ [N − 1)L, NL] with the high and low
value reversed; i.e., the square wave is 0 on the front part and H on the back part of
each chunk of length L. Generate the need graphs also.

Exercise 9.9.6 Write the functions needed to generate a periodic sawtooth wave on
the intervals [0, L] ∪ [L, 2L] ∪ [2L, 3L] ∪ . . . ∪ [N − 1)L, NL]. Generate the need
graphs also.

Exercise 9.9.7 Write the functions needed to generate a periodic sawtooth - square
wave on multiple intervals of length [0, 2L] where the first [0, L] is the sawtooth and
the second [L, 2L] is the square. Generate the need graphs also.

9.9.3 Testing the Approximations

We can then test the Fourier Cosine Approximation code. This code generates the
plot you see in Fig. 9.1.

Listing 9.19: The Fourier cosine approximation to a sawtooth


1 f = @( x ) 1 0 ;
g = @( x ) 0 ;
Saw = s a w t o o t h ( 1 0 , 1 0 ) ;
Sq = @( x ) s p l i t f u n c ( x , f , g , 1 0 ) ;
[ Acos , p c o s ] = F o u r i e r C o s i n e A p p r o x ( Saw , 1 0 , 1 0 0 , 5 ) ;

We can then do the same thing and approximate the square wave with the command
274 9 A Primer on Series Solutions

Fig. 9.1 Six term Fourier cosine series approximation to a sawtooth: NIP = 100

Listing 9.20: The Fourier cosine approximation to a square wave with 6 terms
[ Acos , p c o s ] = F o u r i e r C o s i n e A p p r o x ( Sq , 1 0 , 1 0 0 , 5 ) ;

Note these approximations are done using only 100 terms in the Riemann sum approx-
imations to the inner product. This generates the relatively poor approximation shown
in Fig. 9.2.
We do better if we increase the number of terms to 11.

Fig. 9.2 Six term Fourier cosine series approximation to a square wave: NIP = 100
9.9 MatLab Implementation 275

Fig. 9.3 Eleven term Fourier cosine series approximation to a square wave: NIP = 100

Listing 9.21: Fourier cosine approximation to the square wave with 11 terms
[ Acos , p c o s ] = F o u r i e r C o s i n e A p p r o x ( Sq , 1 0 , 1 0 0 , 1 0 ) ;

This generates the improvement we see in Fig. 9.3. The code for FourierSine-
Approx is next. It is quite similar to the cosine approximation code and so we will
say little about it. It returns the Fourier sine coefficients as A with A1 = L2 < f , g1 >
 
through AN = L < f , gN > where gi (x) = sin iπL x . It also returns the handle to
2

the Fourier sine approximation


N
p(x) = < f , gi ) > gi (x).
n=1

Listing 9.22: FourierSineApprox


f u n c t i o n [ A, p ] = F o u r i e r S i n e A p p r o x ( f , L ,M,N)
%
% p i s t h e Nth F o u r i e r A p p r o x i m a t i o n
% f is the or igi nal function
5 % M i s t h e number o f Riemann sum t e r m s i n t h e i n n e r p r o d u c t
% N i s t h e number o f t e r m s i n t h e a p p r o x i m a t i o n
% L is the i n t e r v a l length
276 9 A Primer on Series Solutions

% get the f i r s t N Fourier sine approximations


10 g = S e t U p S i n e s ( L ,N) ;

% g e t Fourier Sine C o e f f i c i e n t s
A = z e r o s (N, 1 ) ;
f o r i =1:N
15 A( i ) = 2∗ i n n e r p r o d u c t ( f , g{ i } , 0 , L ,M) /L ;
end

% g e t Nth F o u r i e r S i n e A p p r o x i m a t i o n
p = @( x ) 0 ;
20 f o r i =1:N
p = @( x ) ( p ( x ) + A( i ) ∗g{ i } ( x ) ) ;
end

x = linspace (0 ,L,101) ;
25 f o r i =1:101
y( i ) = f (x( i ) ) ;
end
yp = p ( x ) ;

30 figure
s = [ ’ Fourier Sine A p p r o x i m a t i o n with ’ , i n t 2 s t r (N) , ’ term ( s ) ’ ] ;
p l o t ( x , y , x , yp ) ;
x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’y axis ’ ) ;
35 title (s) ;
p r i n t −dpng ’ F o u r i e r S i n e A p p r o x . png ’ ;
end

Let’s test the approximation code on the square wave. using 22 terms. The sin approx-
imations are not going to like the starting value at 10 as you can see in Fig. 9.4. The
approximation is generated with the command

Listing 9.23: Fourier sine approximation to a square wave with 22 terms


[ Asin , p s i n ] = F o u r i e r S i n A p p r o x ( Sq , 1 0 , 1 0 0 , 2 2 ) ;

We could do similar experiments with the sawtooth function. Note, we are not using
many terms in the inner product calculations. If we boost the number of terms, NIP,
to 500, we would obtain potentially better approximations. We will leave that up to
you.

9.9.3.1 Homework

Exercise 9.9.8 Generate the Fourier Cosine Approximation with varying number
of terms and different values of NIP for the periodic square wave. Draw figures as
needed.
Exercise 9.9.9 Generate the Fourier Sine Approximation with varying number of
terms and different values of NIP for the periodic square wave. Draw figures as
needed.
Exercise 9.9.10 Generate the Fourier Cosine Approximation with varying number
of terms and different values of NIP for the periodic sawtooth wave. Draw figures
as needed.
9.9 MatLab Implementation 277

Fig. 9.4 Twenty two term Fourier sine series approximation to a square wave: NIP = 100

Exercise 9.9.11 Generate the Fourier Sine Approximation with varying number of
terms and different values of NIP for the periodic sawtooth wave. Draw figures as
needed.
Exercise 9.9.12 Generate the Fourier Cosine Approximation with varying number
of terms and different values of NIP for the periodic sawtooth-square wave. Draw
figures as needed.
Exercise 9.9.13 Generate the Fourier Sine Approximation with varying number of
terms and different values of NIP for the periodic sawtooth-square wave. Draw
figures as needed.
Exercise 9.9.14 Generate the Fourier Sine Approximation with varying number of
terms and different values of NIP for pulses applied at various locations. Draw
figures as needed.
Exercise 9.9.15 Generate the Fourier Cosine Approximation with varying number
of terms and different values of NIP for pulses applied at various locations. Draw
figures as needed.

9.9.4 Cable Membrane Approximations

We can use our code to approximate Fourier cosine and sine series to approximate
the separation of variables solution to the cable equation with Neumann conditions.
Recall the cable model is
278 9 A Primer on Series Solutions

∂2 ∂
β2 −−α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
(x, 0) = f (x).

with solution

 ∞

(x, t) = A0 φ0 (x, t) + An φn (x, t) = A0 u0 (x)w0 (t) + An un (x) wn (t)
n=1 n=1


N  
nπ 1+n2 π 2 β 2
= A0 e − α1 t
+ An cos x e− αL2 t .
n=1
L

where the coefficients An satisfy



1 L
A0 = f (x),
L 0
 L  
2 nπ
An = f (x) cos x dx.
L 0 L

We can now write code to find an approximation to this infinite series solution. The
function will be called CableNeumannApprox as we have Neumann boundary
conditions here. We can’t solve the problem over infinite time, so we will develop
the approximation for a fixed time interval [0, T ] for some positive T . We need to
input the values of α and β, the data function f, the number of terms to use in our
Riemann sum approximations to inner products, M, and finally, the number of terms
of the infinite series to use, N. The full definition of the function is then

Listing 9.24: CableNeumannApprox arguments


f u n c t i o n p = CableNeumannApprox ( a l p h a , beta , f ,M, N, L , T)

We then get the Fourier Cosine approximations we need and setup the inline functions
as usual which store the various cos functions we need in a cell data structure.

Listing 9.25: Get Fourier cosine approximation to f


% Get F o u r i e r C os ine Ap p r oxi ma ti on t o f f o r N ter m s
[ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L ,M,N) ;

4 % Get C os i ne F u n c t i o n s
u = S e t U p C o s i n e s ( L ,N) ;
9.9 MatLab Implementation 279

Next, we define the exponential functions we need and store in a cell.

Listing 9.26: Define the needed exponential functions


% Get t h e e x p o n e n t i a l f u n c t i o n s
v = c e l l (N+1 ,1) ;
v {1} = @( t ) exp (− t / a l p h a ) ;
f o r i = 2 :N+1
5 c = ( 1 + i ˆ2∗ p i ˆ2∗ b e t a ˆ 2 ) / ( a l p h a ∗L ˆ 2 ) ;
v{ i } = @( t ) exp (− c ∗ t ) ;
end

We define an inline function to store our approximation to the series solution as


follows:

Listing 9.27: Generate the approximation to the series solution


% Construct the approximate s o l u t i o n
% g e t Nth F o u r i e r S i n e A pproximation
3 p = @( x , y ) 0 ;
f o r i =1:N
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

We want to visualize this solution so we set up a meshgrid for our discretization


of the space and time domain [0, L] × [0, T ].

Listing 9.28: Setup the time and space domain


%
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 ,T ]
% s e t up x and y s t u f f
x = linspace (0 ,L,101) ;
5 t i m e = l i n s p a c e ( 0 , T, 1 0 1 ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
[ X, Time ] = m e s h g r i d ( x , t i m e ) ;
% s e t up s u r f a c e
Z = p (X, Time ) ;

Then, we generate the plot and end the function.

Listing 9.29: Generate the plot and end


1 %p l o t s u r f a c e
figure
mesh (X, Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’t axis ’ ) ;
6 z l a b e l ( ’ Cable Solution ’ ) ;
t i t l e ( ’ Cable Dirichlet Solution on Rectangle ’ ) ;
p r i n t −dpng ’ CableDirichlet . png ’ ;

end

For convenience, we show the full function below.


280 9 A Primer on Series Solutions

Listing 9.30: Cable Neumann Data Fourier Series Approximation


f u n c t i o n p = CableNeumannApprox ( a l p h a , be t a , f ,M, N, L , T)
%
% S o l v e b e t a ˆ2 u x x − u − a l p h a u t = 0 on [ 0 , L ] x [ 0 , T ]
%
5 % ( 0 , T)−−−−−−−−−−−−−−−−−−−−(L , T)
% | |
% | |
% u x ( 0 , t ) =0 | | u x (L , t ) = 0
% | |
10 % | |
% ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L , 0 )
% u(x ,0) = f (x)
%
% Separation of v a r i a b l e s gi ves s o l u t i o n i s
15 % u(x , t ) =
% A 0 e x p ( −(1/ a l p h a ) t )
% + sum {n=1}ˆ{ i n f i n i t y } A n c o s ( n p i x /L ) e x p (−(1+n ˆ2 p i ˆ2 b e t a ˆ 2 ) / (
alpha Lˆ2) t )
%
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Cosine
20 % c o e f f i c i e n t s o f f on [ 0 , L ]
%
% A n = 2∗< f ( y ) , c o s ( n p i x /L )>
%
% Get F o u r i e r C o s i n e A p p r o x i m a t i o n t o f f o r N t e r m s
25 [ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L ,M,N) ;

% Get C o s i n e F u n c t i o n s
u = S e t U p C o s i n e s ( L ,N) ;

30 % Get t h e e x p o n e n t i a l f u n c t i o n s
v = c e l l (N+1 ,1) ;
v{1} = @( t ) exp (− t / a l p h a ) ;
f o r i = 2 :N+1
c = ( 1 + i ˆ2∗ p i ˆ2∗ b e t a ˆ 2 ) / ( a l p h a ∗L ˆ 2 ) ;
35 v{ i } = @( t ) exp (− c ∗ t ) ;
end

% Construct the approximate s o l u t i o n


% g e t Nth F o u r i e r S i n e A p p r o x i m a t i o n
40 p = @( x , y ) 0 ;
f o r i =1:N
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

45 %
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 , T ]
% s e t up x and y s t u f f
x = linspace (0 ,L,101) ;
t i m e = l i n s p a c e ( 0 , T, 1 0 1 ) ;
50 % s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
[ X, Time ] = m e s h g r i d ( x , t i m e ) ;
% s e t up s u r f a c e
Z = p (X, Time ) ;

55 %p l o t s u r f a c e
figure
mesh (X, Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’t axis ’ ) ;
60 z l a b e l ( ’ Cable Solution ’ ) ;
t i t l e ( ’ Cable Dirichlet Solution on Rectangle ’ ) ;
p r i n t −dpng ’ C a b l e D i r i c h l e t . png ’ ;

end
9.9 MatLab Implementation 281

It is interesting to look at solutions to various pulses that are applied on the cable.
A rectangular pulse centered at x0 of width r and height H on the interval [0, L] has
the form

⎨ 0, 0 ≤ x ≤ x0 − r,
J(x) = H, x0 − r < x < x0 + r,

0, x0 + r ≤ x ≤ L

We code this in the function pulsefunc shown here.

Listing 9.31: pulsefunc


f u n c t i o n z = p u l s e f u n c ( x , x0 , r ,H)
%
i f x > x0−r && x < x0+r
z = H;
5 else
z = 0;
end

It is easy to approximate the solution to the cable equation with a data pulse of height
100 at location 1 of width 0.2. We’ll use 200 terms in our Riemann sum inner product
approximations, α = 0.5 and β = 0.025. Hence, we are using 20 terms here.

Listing 9.32: A cable solution for a pulse


L = 5;
T = 30;
3 p u l s e = @( x ) p u l s e f u n c ( x , 2 , . 2 , 1 0 0 ) ;
p = CableNeumannApprox ( 0 . 5 , . 0 2 5 , p u l s e , 2 0 0 , 2 0 , 5 , 3 0 ) ;

The returned function p(x, t) is shown in Fig. 9.5.

9.9.4.1 Homework

Exercise 9.9.16 Approximate the solution to the cable equation with Neumann data
on [0, 6] × [0, T ] for an appropriate value of T for α = 0.3 and β = 0.8 for a variety
of pulses applied to the cable at time 0.

Exercise 9.9.17 Approximate the solution to the cable equation with Neumann data
on [0, 4] × [0, T ] for an appropriate value of T for α = 1.3 and β = 0.08 for a
variety of pulses applied to the cable at time 0.

Exercise 9.9.18 Approximate the solution to the cable equation with Neumann data
on [0, 10] × [0, T ] for an appropriate value of T for α = 0.03 and β = 0.04 for a
variety of pulses applied to the cable at time 0.
282 9 A Primer on Series Solutions

Fig. 9.5 Twenty term Fourier series approximation to the cable equation with pulse data and
Neumann boundary conditions

Now it is straightforward to write a similar function for the approximation of the


cable equation solution with Dirichlet boundary conditions. We leave that to you.
Now redo the problems above with Dirichlet data.
Exercise 9.9.19 Approximate the solution to the cable equation with Dirichlet data
on [0, 6] × [0, T ] for an appropriate value of T for α = 0.3 and β = 0.8 for a variety
of pulses applied to the cable at time 0.
Exercise 9.9.20 Approximate the solution to the cable equation with Dirichlet data
on [0, 4] × [0, T ] for an appropriate value of T for α = 1.3 and β = 0.08 for a
variety of pulses applied to the cable at time 0.
Exercise 9.9.21 Approximate the solution to the cable equation with Dirichlet data
on [0, 10] × [0, T ] for an appropriate value of T for α = 0.03 and β = 0.04 for a
variety of pulses applied to the cable at time 0.

9.10 Convergence Analysis for the Cable Equation

Our general cable model is

∂2 ∂
β2 −−α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
9.10 Convergence Analysis for the Cable Equation 283

(x, 0) = f (x)

and using separation of variables, we found a series solution of the form



  
nπ L 2 +n2 π 2 β 2
(x, t) = B0 e− α t + x e− αL2 t .
1
Bn cos
n=1
L

where since the Fourier series for the boundary data function f is given by

  

f (x) = B0 + Bn cos x
n=1
L

we have

1 L
B0 = f (x),
L 0
 L  
2 nπ
Bn = f (x) cos x dx.
L 0 L

We have found this series solution by essentially assuming all of our series manip-
ulations are justified. We also assume the data function f does have a Fourier series
expansion. However, we haven’t shown the series solution actually satisfies the cable
equation and we haven’t been clear about the properties the data function f should
have to make this work. So in this chapter, we are going to work our way through
the material we need to answer these questions carefully. Now be warned, there is a
lot of reasoning in here. Many of you might prefer to just do the manipulations and
call it a day, but we assure you that your understanding of what you are doing and
your ability to create and solve models will be enhanced by this next journey. So roll
up your sleeves and let’s get started!

9.10.1 Uniform Convergence Ideas

So far we have talked about series of functions that converge pointwise to another
function. A stronger type of convergence is called uniform convergence and a
weaker one is called least squares or L 2 convergence. Let’s state the definition
of pointwise convergence more precisely.

Definition 9.10.1 (Pointwise Convergence of a Sequence and a Series of Functions)


Let {un } be a sequence of functions defined on the interval [a, b]. Let {Sn } be the
usual sequence of partial sums that this sequence determines.
We say un converges pointwise at a point t in [a, b] if limn→∞ un (t) exists. At
each point t where this limit exists, we define the limit function U to have the value
284 9 A Primer on Series Solutions

U(t) = limn→∞ un (t). In more precise terms, given a positive , there is a positive
integer N (depending on t and ) so that

n > N =⇒ |un (t) − U(t)| < .

We say Sn converges pointwise at a point t in [a, b] if limn→∞ Sn (t) exists. At each


point t where this limit exists, we define the limit function S to have the value
S(t) = limn→∞ Sn (t). In more precise terms, given a positive , there is a positive
integer N (depending on t and ) so that

n > N =⇒ |Sn (t) − S(t)| < .

Example 9.10.1 The sequence un (t) = t n on the interval [0, 1], converges pointwise
to

0 0≤t<1
U(t) =
1 t = 1.

Example 9.10.2 The series built from the sequence un (t) = t n on the interval
(−1, 1), has the partial sums Sn (t) = 1 + t + t 2 + . . . + t n . A well know identity
n+1
tells us that Sn (t) = 1−t
1−t
. Hence, it is easy to show that Sn converges pointwise to
S(t) = 1−t on (−1, 1).
1

In contrast to the idea of pointwise convergence, there is the notion of uniform


convergence. Here, the N we use in the definition of pointwise convergence, depends
only on the value of .

Definition 9.10.2 (Uniform Convergence of a Sequence and a Series of Functions)


Let {un } be a sequence of functions defined on the interval [a, b] and assume un
converges pointwise to U on [a, b]. We say un converges uniformly to the function
U on [a, b] if given a positive , there is a positive integer N (depending on  only)
so that

n > N =⇒ |un (t) − U(t)| < , for all t ∈ [a, b].

Let {un } be a sequence of functions defined on the interval [a, b] and let {Sn } be the
usual sequence of partial sums that this sequence determines. We say Sn converges
uniformly to the function S on [a, b] if given a positive , there is a positive integer
N (depending on  only) so that

n > N =⇒ |Sn (t) − S(t)| < , for all t ∈ [a, b].

Example 9.10.3 The sequence un (t) = sin(t)


n
converges uniformly to the function
U(t) = 0 for all t.
9.10 Convergence Analysis for the Cable Equation 285

Definition 9.10.3 (Least Squares Convergence of a Series of Functions)


Let {un } be a sequence of integrable functions defined on the interval [a, b] and let
{Sn } be the usual sequence of partial sums that this sequence determines. We say Sn
converges in least squares to the function S on [a, b] if given a positive , there is a
positive integer N (depending on  only) so that
 b
n > N =⇒ |Sn (t) − S(t)|2 < .
a

ptws
Comment 9.10.1 We often denote these convergences as Sn −→S (pointwise),
unif L 2
Sn −→S (uniform) and Sn −→S (Least Squares),

A final result we will need is that if a sequence of continuous functions converges


uniformly on an interval, then the limit function must also be continuous.

Theorem 9.10.1 (Uniform Convergence of Continuous Functions Implies a Con-


tinuous Limit)
Let {un } be a sequence of continuous functions defined on the interval [a, b] and
assume un converges uniformly to U on [a, b]. Then U is continuous on [a, b].
Let {un } be a sequence of continuous functions defined on the interval [a, b] and
let {Sn } be the usual sequence of partial sums that this sequence determines. Assume
Sn converges uniformly to the function S on [a, b]. Then S is also continuous.

Proof Let  > 0 be given. Then since un converges uniformly to U on [a, b], there
is a positive integer N so that

n > N =⇒ |un (t) − U(t)| < , for all t ∈ [a, b].
3
Pick any two points t and consider for another s the difference U(t) − U(s). We see

|U(t) − U(s)| = |U(t) − un (t) + un (t) − un (s) + un (s) − U(s)|


≤ |U(t) − un (t)| + |un (s) − un (s)| + |un (s) − U(s)|.

The first and third terms are less than 3
when n > N. So we have

2
|U(t) − U(s)| < + |un (s) − un (s)|.
3
To finish the argument, note we can fix n to be any integer larger than N and this
inequality holds. For this n, since un is continuous, there is a δ > 0 so that |un (s) −
un (t)| < 3 when |t − s| < δ. Using this we have
286 9 A Primer on Series Solutions

|t − s| < δ =⇒ |U(t) − U(s)| < 

This says U is continuous at t and since t was arbitrarily chosen, we have U is


continuous on [a, b]. A similar argument works for the sequence Sn and shows S is
continuous. 

Note that uniform and least squares convergence gives us a way to decide how
many terms we want to use so that we are close to the limit function S in some way
on the entire interval [a, b] but pointwise convergence does not let us get that sort of
information. Hence, it would be nice if we could understand when our Fourier series
do more than converge pointwise.

9.10.2 A Fourier Series Example

Let’s do an example. Assume we have a function f extended periodically on the


interval [0, 2L] to fˆ as usual with Fourier series

1
S(x) = < f,1 >
L
∞           
2 iπ iπ 2 iπ iπ
+ f (x), sin x sin x + f (x), cos x cos x .
i=1
L L L L L L
     
and using b0 = 1
L
< f , 1 >, bn = 2
L
f (x), cos iπ
L
x and an = 2
L
f (x), sin iπ
L
x
as usual, we can write

∞     
iπ iπ
S(x) = b0 + ai sin x + bi cos x .
i=1
L L

Now if we assume f  exists in [0, 2L], we know the Fourier series of f converges to
f pointwise at each point and we have

∞     
iπ iπ
f (x) = b0 + ai sin x + bi cos x .
i=1
L L

9.10.2.1 Bounded Coefficients


 2L
let Sn be the nth partial sum of the series above. Then assuming 0 (f  )2 (x)dx is
finite, we have
9.10 Convergence Analysis for the Cable Equation 287

n     
iπ iπ
0 ≤ < f − b0 − ai sin x + bi cos x ,
i=1
L L
n     
iπ jπ
f − b0 − aj sin x + bj cos x >
j=1
L L

   
As usual, we let ui (x) = sin iπ
L
x and vi (x) = cos iπ
L
x with v0 (x) = 1. Then, we
can rewrite this as


n 
n
0 ≤ < f − b0 v0 (x) − (ai ui (x) + bi vi ), f − b0 v0 (x) − (aj uj (x) + bj vj (x)) >
i=1 j=1

Thus, we find, after a lot of manipulation


n
0 ≤ ||f − b0 v0 (x) − (ai ui (x) + bi vi (x))||2 =< f  , f  > −2b0 < f , v0 > +b02 < v0 , v0 >
i=1

n 
n 
n 
n
−2 ai < f , ui > −2 bi < f , vi > + ai2 < ui , ui > + bi2 < vi , vi >
i=1 i=0 i=1 i=1

j j
because all the cross terms such as < v0 , ui >= 0, < v0 , vi >= δ0 < ui , uj >= δi
j
and < vi , vj >= δi . Hence, since < f , vi >= bi and < f , ui >= ai we have


n 
n 
n
0 ≤ ||f − b0 v0 (x) − (ai ui (x) + bi vi )||2 = < f , f > −b02 − ai2 − bi2
i=1 i=1 i=1

We conclude that


n
b02 + (ai2 + bi2 ) ≤ ||f ||2
i=1


This tells us that the series of positive terms, b02 + i=1 (ai
2
+ bi2 ) converges.

9.10.2.2 The Derivative Series

Let’s assume f is differentiable on [0, 2L] and we extend f  periodically as well. We


can calculate the Fourier series of f  like usual. Now if we wanted to ensure this
series converged to f  , we could assume f  exists on [0, 2L] except at a finite number
of points where the right and left hand derivatives are both finite. Then we know
the Fourier series of f  exists also and converges pointwise to f  (x) at each point
288 9 A Primer on Series Solutions

x where f  (x) is continuous. However, we can calculate the Fourier series without
those assumptions. Let the Fourier series of f  be T (x). Then

1
T (x) = < f , 1 >
2L
∞  
         
1  iπ iπ 1  iπ iπ
+ f (x), sin x sin x + f (x), cos x cos x .
L L L L L L
i=1

The first coefficient is


1 1
< f , 1 > = (f (2L) − f (0))
2L 2L
Now let’s consider the other Fourier coefficients carefully. We can rewrite each
coefficient using integration by parts to find,
     
1  iπ 1 2L  iπ
f (x), cos x = f (x), cos x dx
L L L 0 L
  2L   
1 iπ 1 iπ 2L iπ
= (f (x) cos x + f (x) sin x dx
L L 0 L L 0 L
    2L  
1  iπ 1 iπ
f (x), sin x = f  (x), sin x dx
L L L 0 L
  2L   
1 iπ 1 iπ 2L iπ
= (f (x) sin x − f (x) cos x dx
L L 0 L L 0 L

A little thought shows we can rewrite this as


       
1  iπ 1 2Liπ 0iπ iπ
f (x), cos x = f (2L) cos − f (0) cos + ai
L L L L L L
 
1 iπ
= f (2L) − f (0) + ai
L L
       
1  iπ 1 2Liπ 0π iπ
f (x), sin x = f (2L) sin − f (0) sin − bi
L L L L L L

Now if we assume f (2L) = f (0), these reduce to

1 1
< f , 1 > = (f (2L) − f (0)) = 0
 2L   2L 
1  iπ 1 iπ iπ
f (x), cos x = f (2L) − f (0) + ai = ai
L L L L L
  
1  iπ iπ
f (x), sin x = − bi
L L L
9.10 Convergence Analysis for the Cable Equation 289

Hence, if f is periodic, we find

∞     
πi iπ πi iπ
T (x) = − bi sin x + ai cos x .
i=1
L L L L

This is the same result we would have found if we differentiated the Fourier series
for f term by term. So we conclude that the Fourier series of f  can be found be
differentiating the Fourier series for f term by term.

9.10.2.3 The Derivative Coefficient Bounds

We can apply the derivation we did above for f to the series expansion for f  we have
just found. We find


n
b̂02 + (âi2 + b̂i2 ) ≤ ||f  ||2
i=1

where here b̂0 = 0, âi = − πi


L i
b and b̂i = πi
L i
a. Hence, we have

π2  2 2
n
i (ai + bi2 ) ≤ ||f  ||2
L 2 i=1

9.10.3 Uniform Convergence for f

We are almost at the point where we can see circumstances where the Fourier series
expansion of f converges uniformly to f on the interval [0, 2L]. We need a few more
technical tools. From earlier calculus courses, we know what the Cauchy–Schwartz
inequality is for vectors in 2 . If the vectors X and Y had components [a1 , a2 ] and
[b1 , b2 ] , respectively, we have
 
 2  2

2  
|ai ||bi | ≤  2
ai bi2
i=1 i=1 i=1

where we have written the dot product and the vector lengths in summation notation.
We suspect we can prove this result for vectors in n and also for Riemann integrable
functions. Here is the result for sequences.
Theorem 9.10.2 (Cauchy–Schwartz Inequalites)
If X and Y in n have components [a1 , . . . , an ] and [b1 , . . . , bn ] , respectively, we
have
290 9 A Primer on Series Solutions
 
 N  N

N  
|ai ||bi | ≤  2
ai bi2
i=1 i=1 i=1

∞ ∞
Further, if the series i=1 ai2 and i=1 bi2 both converge, we can say
 
∞ ∞ ∞
  
|ai ||bi | ≤  ai2  bi2
i=1 i=1 i=1

Proof These statements are fairly easy to prove. We know that for any two numbers
α and β that (|α| − |β|)2 ≥ 0. Hence, we can say

1 2 1 2
|α||β| ≤ α + β .
2 2
N
Now let’sconsider two vectors
 X and Y in with components labeled as usual.
N N
Let u = i=1 ai and v =
2
i=1 bi . Now if α = u and β = v , we see for any
2 ai bi

index i, we have

ai bi 1 1
| || | ≤ 2 ai2 + 2 bi2 .
u v 2u 2v
Now sum this inequality over all the components to get

1  1  2 1  2
N N N
|ai ||bi | ≤ 2 ai + 2 b .
uv i=1 2u i=1 2v i=1 i
 
N N
But since u = i=1 ai2 and v = i=1 bi2 , this becomes

1 
N
1 1
|ai ||bi | ≤ 2 u2 + 2 v 2 = 1
uv i=1 2u 2v

Hence, multiplying both sides by uv, we have the inequality we want


 
 N  N

N  
|ai ||bi | ≤ uv =  2
ai bi2 .
i=1 i=1 i=1

Now if the series ∞ 2


i=1 ai and
∞ 2
i=1 bi converge, using the same argument on the
first N terms of the series, we have
9.10 Convergence Analysis for the Cable Equation 291
 
 N  N

N  
|ai ||bi | ≤ uv =  2
ai bi2 .
i=1 i=1 i=1

 
∞ ∞
where now we let u = a
i=1 i
2
and v = i=1 bi2 . The partial sums are less the
the sum of the series in each case, so we have
 
∞ ∞

N
 
|ai ||bi | ≤ uv =  ai2  bi2 .
i=1 i=1 i=1


 of nonnegative terms i=1 |ai ||bi | are
But this says the partial sumsof the series
∞ 2 ∞ 2
bounded above by the bound i=1 ai i=1 bi . Hence the supremum on these
partial sums which is the sum of this series also satisfies this bound. We conclude
 
∞ ∞ ∞
  
|ai ||bi | ≤ uv =  2
ai bi2 .
i=1 i=1 i=1 

Now let’s look at the result for Riemann integrable functions.

Theorem 9.10.3 (Cauchy–Schwartz Integration Inequalites)


If f and g are two Riemann integrable functions on the interval [a, b], it follows that
 
 b  b  b
|f (x)g(x)| dx ≤ f 2 (x) dx g 2 (x) dx
a a a

Proof Again, this statements is fairly easy to prove. We know that for any two
numbers α and β that

1 2 1 2
|α||β| ≤ α + β .
2 2

b
Now if f and g are continuous on the interval [a, b], we let u = f 2 (x)dx and
 a
b 2 |f (x)| |g(x)|
v= a g (x)dx. Then, letting α = u and β = v , we have

|f (x)| |g(x)| 1 1
≤ 2 f 2 (x) 2 g 2 (x).
u v 2u 2v
or
uv 2 uv
|f (x)| |g(x)| ≤ f (x) 2 g 2 (x).
2u2 2v
292 9 A Primer on Series Solutions

Now integrate both sides from a to b to obtain


 
b
v b
u 2 u2 v uv 2
| f (x)| |g(x)| ≤ f 2 (x) dx g (x) dx = + = uv.
a 2u a 2v 2u 2v

which gives the desired inequality:


 
 b  b  b
|f (x)g(x)| dx ≤ f 2 (x) dx g 2 (x) dx
a a a


We also need some tests to determine if our Fourier series converge uniformly.
Theorem 9.10.4 (Tests for Uniform Convergence)
Assume we have a sequence of functions (fi ) on the interval [a, b].
1. If there is a sequence of constants (Ki ) so that ∞ i=1 Ki converges and |fi (x)| ≤ Ki
on [a, b] for each index i, then ∞ i=1 f i (x) converges uniformly to a limit function
S(x) on [a, b].
2. Assume the series ∞ i=1 fi (x) converges pointwise to S(x) on [a, b]. Further,
assume there is a sequence of constants (Ki ) so that ∞ 2
i=1 Ki converges. Then if

 m
 2
m > n =⇒ |Sm (x) − Sn (x)| ≤  Ki
i=n+1


then i=1 fi (x) converges uniformly to a limit function S(x) on [a, b].
Proof There are two separate arguments here.
1. Since we always know

 ∞

fi (x) ≤ Ki ,
i=1 i=1

we know the series converges pointwise at each x in [a, b]. Let the sum of this
series be the function S(x). Consider the difference of two partial sums, Sn (x) and
Sm (x) where m > n. Then, we have


m
|Sm (x) − Sn (x)| = fi (x)
i=n+1
m
≤ |fi (x)|
i=n+1
m
≤ Ki ,
i=n+1
9.10 Convergence Analysis for the Cable Equation 293

Since we know the series ∞ i=1 Ki converges to some value K, given a positive
tolerance  we know there is a positive integer N so that


n
1
n > N =⇒ K − Ki < .
i=1
4

Hence, for m > n > N, we have


m 
m 
n
Ki = Ki − Ki
i=n+1 i=1 i=1
 
n   
m 
= K− Ki − K − Ki
i=1 i=1
1 1 1
<  +  = .
4 4 2
Thus, going back to our original inequality for |Sm (x) − Sn (x), we see there is a
positive integer N so that if m and n exceed N, we have for all x in [a, b], that


m
|Sm (x) − Sn (x)| = fi (x)
i=n+1
m
≤ |fi (x)|
i=n+1
m
≤ Ki
i=n+1
1
< 
2
Since this is true for all m > N, take the limit on m on both sides. Since all the terms
here are continuous, we can say limm |Sm (x) − Sn (x)| = | limm Sm (x) − Sn (x)|.
But we know limm Sm (x) = S(x) and so we can say for all x that

lim |Sm (x) − Sn (x)| = S(x) − Sn (x)


m→∞

1
≤ <
2
But this says Sn converges uniformly to S on [a, b].
294 9 A Primer on Series Solutions

2. In the second case, we assume the series converges pointwise to S. We know that

 m
 2
m > n =⇒ |Sm (x) − Sn (x)| ≤  Ki .
i=n+1

Since we also assume that the series ∞ 2


i=1 Ki converges, by the same sort of
argument we used in the first part, we know that for any  > 0, there is a positive
integer N so that


n
2
m > n =⇒ Ki2 <
i=n+1
4

Combining, we see

 n
 2 
m > n =⇒ |Sm (x) − Sn (x)| ≤  Ki <
i=n+1
2

Now, let m → ∞ to see that for all x in [a, b], that



|S(x) − Sn (x)| ≤ <
2
This tells us the convergence is uniform. 

9.10.3.1 Uniform Convergence of Fourier Series

Now let’s get back to the question of the uniform convergence of the Fourier series
for f . We assume f is continuous and periodic on [0, 2L] and that f  exists at all but
finitely many points. Hence, we know the Fourier series of f exists and converges to
f (x). From our earlier arguments, if f has Fourier series

∞     
iπ iπ
f (x) = b0 + ai sin x + bi cos x .
i=1
L L

then we know for all n

π2  2 2
n
i (ai + bi2 ) ≤ ||f  ||2 .
L 2 i=1

Let’s look at the partial sums of absolute values.


9.10 Convergence Analysis for the Cable Equation 295


n    n    n    n  
iπ iπ iπ iπ
b0 1 + (ai sin x + (bi cos x = (ai sin x + (bi cos x
L L L L
i=1 i=1 i=1 i=0
n   n  
1 iπ 1 iπ
= (i ai sin x + (i bi cos x .
i L i L
i=1 i=0

Let Tn denote the nth partial sum here. Then, the difference of the nth and mth partial
sum for m > n gives


m   m  
1 iπ 1 iπ
Tm (x) − Tn (x) = (i ai sin x + (i bi cos x .
i=n1
i L i=n+1
i L

Now apply our analogue of the Cauchy–Schwartz inequality for series.


m   m  
1 iπ 1 iπ
Tm (x) − Tn (x) ≤ (i |ai | sin x + (i bi cos x
i=n+1
i L i=n+1
i L
 
 m  m  2
  1 iπ
≤ i2 |ai |2  sin x
i=n+1 i=n+1
i2 L
 
 m  m  2
  1 iπ
+ i2 |bi |2  cos x
i=n+1 i=n+1
i2 L
   
 m  m  m  m
  1   1
≤ i2 |ai |2  +  i 2 |b |2 
i
i=n+1 i=n+1
i2 i=n+1 i=n+1
i2

Now each of the front pieces satisfy



 L2  2
i2 ai2 ≤ ||f ||
i=1
π2

 L2  2
i2 bi2 ≤ ||f ||
i=1
π2

Hence,

     m

m
iπ m
iπ 2L||f  ||   1
Tm (x) − Tn (x) ≤ (ai sin x + (bi cos x ≤  .
i=n+1
L i=n+1
L π i=n+1
i2

We can then apply Theorem 9.10.4 to conclude the Fourier series of f converges
uniformly to f under these circumstances! Let’s summarize this result.
296 9 A Primer on Series Solutions

Theorem 9.10.5 (Uniform Convergence of Fourier Series)


Given f on [0, 2L], assume f is continuous with f (0) = f (2L) and f  exists at all but
a finite number of points on [0, 2L] with finite right and left hand derivatives at these
points. Then the Fourier series of f converges uniformly to f on [0, 2L].

9.10.4 Extending to Fourier Sin and Fourier Cosine Series

The arguments above also apply to the Fourier sin and Fourier cosine series we have
discussed. In those cases, we have a function f defined only on [0, L]. If we extend
f as an odd function periodically to [0, 2L], the Fourier series for this extension is
given by

  

Ai sin x
i=1
L

where
 L  
2 iπ
Ai = f (x) sin x dx.
L 0 L

If we extend f periodically as an even function, then the extension satisfies f (0) =


f (2L) and its Fourier series is

  

Bi cos x
i=1
L

where

1 L
B0 = f (x)dx
L 0
  
2 L iπ
Bi = f (x) cos x dx.
L 0 L

9.10.4.1 The Fourier Sine Series

From our previous discussions about uniform convergence, we know that is f (0) −
f (2L) and f  exists on [0, 2L] with at most a finite number of points where f  does
not exist but the right and left hand derivatives do, then the Fourier series for f on
[0, 2L] converges uniformly to f . For the odd extension to f to [0, 2L], if we require
f be continuous on [0, L], then since at x = 0 and x = L, the Fourier sine series
gives
9.10 Convergence Analysis for the Cable Equation 297


  

Ai sin 0 =0
i=1
L
∞  

Ai sin L =0
i=1
L

we see f (0) = f (L) = 0. Hence, f satisfies the periodic requirement that f (0) = f (L).
Hence, we suspect that the derived series

  
iπ iπ
Ai cos x
i=1
L L

is actually the same as f  . Let’s check this out by direct calculation. We have (remem-
ber the inner products here are on the interval [0, L] now)
 
n   n  
 iπ iπ  jπ jπ
f − Ai cos x ,< f − Aj cos x
i=1
L L j=1
L L
 n   
  iπ  iπ
= < f , f > −2 Ai f , cos x
i=1
L L
n  n     
iπ jπ iπ jπ
+ Ai Aj cos x , cos x
i=1 j=1
L L L L
 n   
iπ iπ
= −2 Ai f  , cos x
i=1
L L
 i2 π 2
n     
iπ iπ
+ A2
cos x , cos x .
i=1
L2 i L L

Integrating by parts, we find


      L  
iπ iπ iπ L iπ
f  , cos x = f (x) cos x +
f (x) sin x dx
L L0 L 0 L
 L  
iπ iπ
= f (x) sin x dx
L 0 L
iπ L iπ
= Ai = Ai .
L 2 2
since f (0) = f (L). Further, we know
     L  
iπ iπ 2 iπ L
l < cos x , cos x = cos x dx = .
L L 0 L 2
298 9 A Primer on Series Solutions

Thus,
 
n 
 n   n
 iπ iπ  jπ jπ i2 π 2 2
f − Ai cos x ,< f − Aj cos x = −2 A
i=1
L L j=1
L L i=1
2L i

n
i2 π 2 L
+ A2i
i=1
L2 2
n 2 2
i π 2
=− A .
i=1
2L i

We conclude that for all n,


n
i2 π 2
A2i ≤ ||f  ||2 .
i=1
2L

This implies that the series ∞ i π 2 2


2
i=1 2L Ai converges. The same argument we used
before then tells us that the original Fourier sine series for f converges uniformly to
f (x) on [0, L].

9.10.4.2 The Fourier Cosine Series

For the even extension to f to [0, 2L], we will require that f (x) be continuous at
x = 0 and x = L. Hence, we must have the Fourier cosine series gives

 
 ∞

B0 + Bi cos 0 = B0 + Bi = f (0)
i=1
L i=1
∞   ∞

B0 + Bi cos L = B0 + Bi (−1)n = f (L).
i=1
L i=1

We still suspect that the derived series



  
iπ iπ
− Bi sin x
i=1
L L

is actually the same as f  . Let’s calculate this directly. We have


 
n   n  
iπ iπ jπ jπ
f + Bi sin x ,< f + Bj sin x
i=1
L L j=1
L L
9.10 Convergence Analysis for the Cable Equation 299


n   
  iπ  iπ
=< f , f > +2 Bi f , sin x
i=1
L L
 n  n     
iπ jπ iπ jπ
+ Ai Aj sin x , sin x
i=1 j=1
L L L L
n   
iπ iπ
=2 Ai f  , sin x
i=1
L L
 i2 π 2
n     
iπ iπ
+ 2
A sin x , sin x .
i=1
L2 i L L

Integrating by parts, we find


    L   
 iπ iπ iπ L iπ
f , sin x = f (x) sin x − f (x) cos x dx
L L 0 L 0 L
  
iπ L iπ
=− f (x) cos x dx
L 0 L
iπ L iπ
=− Bi = − Bi .
L 2 2
Note, we no longer need to know that f (0) = f (L). Further, we know
   
iπ iπ L
l < sin x , sin x = .
L L 2

Thus,
 
n   n   n
 iπ iπ  jπ jπ i2 π 2 2
f + Bi cos x ,< f + Bj cos x = −2 B
i=1
L L j=1
L L i=1
2L i

n
i2 π 2 L
+ Bi2
i=1
L2 2
n 2 2
i π 2
=− B .
i=1
2L i

We conclude that for all n,


n
i2 π 2
Bi2 ≤ ||f  ||2 .
i=1
2L
300 9 A Primer on Series Solutions

This implies that the series ∞ i π


2 2
2
i=1 2L Bi converges. The same argument we used
before then tells us that the original Fourier cosine series for f converges uniformly
to f (x) on [0, L].

9.10.5 Back to Convergence of the Cable Solution

Again, recall our general cable model is

∂2 ∂
β2 −−α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
(x, 0) = f (x).

has a series solution of the form



  
nπ L 2 +n2 π 2 β 2
(x, t) = B0 e− α t + x e− αL2 t .
1
Bn cos
n=1
L

where since the Fourier series for the boundary data function f is given by

  

f (x) = B0 + Bn cos x
n=1
L

we have

1 L
B0 = f (x),
L 0
 L  
2 nπ
Bn = f (x) cos x dx.
L 0 L

First, let’s look at some common series we will see.

Theorem 9.10.6 (Common Convergent Series)


• For any integer n0 , The series ∞ 1
n=n0 n2 converges.

• For any integer n0 and positive constant c, the series n=n0 e−cn converges.

• For any integer n0 and positive constant c, the series n=n0 ne−cn converges.

• For any integer n0 and positive constant c, the series n=n0 n2 e−cn converges.
9.10 Convergence Analysis for the Cable Equation 301

Proof The arguments to show these results are valid are straightforward.
• For convenience, let’s assume n0 = 1 and c = 1. Our arguments will not change
much if these constants are different from those values. Pick a positive integer
N. Let PN be the partition of the interval [1, N] into pieces of length 1. Then the
Riemann sum for evaluation points which are chosen to be the right hand endpoints
of each of the subintervals created by the partition underestimates the area under
the curve y = t12 on the interval [1, N]. We have

N  N
1 1 1
2
× 1 < 2
dt = 1 − ≤ 1.
i=2
i 1 t N

Hence, this series is always bounded by 1 and so it must converge.


• For convenience, again assume n0 = 1 and c = 1. Choose PN as before. Then the
Riemann sum for right hand endpoints underestimates the area under the curve
y = e−t on the interval [1, N]. We have


N  N
−i
e ×1< e−t dt = 1 − e−N ≤ 1.
i=2 0

Hence, this series is always bounded by 1 and so it must converge.


• We assume the usual partition PN . The function ne−n has a maximum at n = 1 and
after that it decays to 0. So from n = 1 on, it is a decreasing function. Then the
Riemann sum for evaluation points which are chosen to be the right hand endpoints
of each of the subintervals created by the partition underestimates the area under
the curve y = te−t on the interval [1, N]. We have


N  N
ie−i × 1 < te−t dt.
i=2 0

N
The integral 0 te−t dt can be integrated by parts to show its value is always
bounded by a constant C. Hence, this series is always bounded by C and so it
must converge.
• We assume the usual partition PN . The function n2 e−n has a maximum at n = 2
and after that it decays to 0. So from n = 2 on, it is a decreasing function. Then the
Riemann sum for evaluation points which are chosen to be the right hand endpoints
of each of the subintervals created by the partition underestimates the area under
the curve y = te−t on the interval [1, N]. We have


N  N
i2 e−i × 1 < t 2 e−t dt.
i=2 0
302 9 A Primer on Series Solutions
N
The integral 0 t 2 e−t dt can also be integrated by parts to show its value is always
bounded by a constant D. Hence, this series is always bounded by D and so it must
converge. 

Comment 9.10.2 We can also show that series of the form n e−n , n ne−n , and
2 2

2 −n2
nn e etc. converge although it is easier to use a test we have not discussed
called the Ratio Test to do this.

We now need some additional tests.

Theorem 9.10.7 (Tests for Derivative Uniform Convergence)


Assume we have a sequence of continuously differentiable functions (fi ) on the inter-
val [a, b]. If the series ∞ i=1 fi (x) converges pointwise to S(x) on [a, b] and and the
series ∞ i=1 if 
(x) converges uniformly to v(x) on [a, b], S  (x) = v(x) on [a, b].
x
Proof We know fi (x) = fi (a) + a fi (t)dt. Thus,


n 
n  x 
n 
fi (x) = fi (a) + fi (t) dt
i=1 i=1 a i=1

Let’s look at the term involving the derivatives. Consider


 x  x 
n   x 
n 
v(t)dt − fi (t) dt ≤ v(t)dt − fi (t) dt
a a i=1 a i=1
 b 
n 
≤ v(t) − fi (t) dt.
a i=1

Since we assume ni=1 fi (t) converges uniformly to v(t) on [a, b], for a given  > 0,
there is a positive integer N so that

n 

n > N =⇒ v(t) − fi (t) < .
i=1
2(b − a)

Using this, we see


 x  x 
n   b 
n 
v(t)dt − fi (t) dt ≤ v(t) − fi (t) dt < .
a a i=1 a i=1

 
x n 
x
So we can conclude that a i=1 fi (t) dt converges to a v(t)dt for all x. Letting
n go to infinity, we therefore have
9.10 Convergence Analysis for the Cable Equation 303

    
n n x n
x
fi (x) = fi (a) + fi (t) dt =⇒ S(x) = S(a) + a v(t)dt
i=1 i=1 a i=1

Applying the Fundamental Theorem of Calculus, we see S  (x) = v(x) for all x. 

9.10.5.1 Convergence of the Cable Solution: Simplified Analysis

The formal series solution is



  
nπ L 2 +n2 π 2 β 2
(x, t) = B0 e − α1 t
+ Bn cos x e− αL2 t .
n=1
L

Before we get our hands dirty with the ugly details, let’s set all the parameters here
to the value of 1 to make life easier. Hence, we have L = 1, α = 1 and π β = 1. The
solution is then


(x, t) = B0 e−t + Bn cos(nπx) e−(1+n )t .
2

n=1

Now, we can estimate the Bn coefficients as


 
1 L 1 L
|B0 | ≤ |f (x)|dx ≤ |f (x)|dx,
L 0 L 0
   
2 L nπ 2 L
|Bn | ≤ |f (x)| cos x dx ≤ |f (x)|dx.
L 0 L L 0
L
Letting C = L2 0 |f (x)|dx, we see Hence, |Bn | ≤ C for all n ≥ 0. Note, we can get
a nice constant C no matter what value L has in our solution! Further, we have

e−(1+n )t
≤ e−n t .
2 2

Thus, for any fixed t > 0, we have the estimate



 ∞

|Bn || cos(nπx)| e−(1+n )t
C e−n t .
2 2

n=1 n=1

Using Theorem 9.10.6, we note the series on the right hand side converges. We can
then apply Theorem 9.10.4 to see the series on the left hand side converges uniformly
to (x, t) on the interval [0, 1] as long as t > 0. Since each of the individual functions
in the series on the left hand side is continuous and convergence is uniform, we can
use Theorem 9.10.1 to see the limit function for the left hand side series is continuous
304 9 A Primer on Series Solutions

on [0, 1] for each t > 0. Hence, the function (x, t) is continuous on the domain
[0, 1] × [t, ∞) for any positive t. At t = 0, the series for (x, t) becomes


B0 + Bn cos(nπx).
n=1

which is the Fourier cosine series for f on [0, 1]. Now from our previous work with
the Fourier cosine series, we know this series converges uniformly to f (x) as long
as f is continuous on [0, 1] with a derivative that exists for all but a finite number of
points. Hence, we see
 ∞ 
lim |(x, t) = lim B0 e−t + Bn cos(nπx) e−(1+n )t
2

t→0 t→0
n=1
= f (x) = (x, 0).

So we know (x, t) is continuous on [0, L] × [0, ∞). Now let’s look at the partial
derivatives. If we take the partial derivative with respect to t of the series for (x, t)
term by term, we find the function Dt (x, t) given by


Dt (x, t) = −B0 e−t − Bn (1 + n2 ) cos(nπx) e−(1+n )t
2

n=1

The series portion for Dt (x, t) satisfies the estimate



 ∞

−(1+n2 )t
C(1 + n2 ) e−n t .
2
|Bn |(1 + n )| cos(nπx)| e
2

n=1 n=1

Applying Theorem 9.10.6, we see the series on the right hand side converges for any
t > 0. Then, using Theorem 9.10.4, we see the series for Dt (x, t) converges uniformly.
Since it is built from continuous functions, we know limit function is continuous for
t > 0 because the convergence is uniform. Finally, applying Theorem 9.10.7, we see
the series for ∂
∂t
is the same as the series Dt (x, t) we found by differentiating term
by term. The formal partial derivatives of the cable series solution with respect to x
are then


Bn nπ sin(nπx) e−(1+n )t
2
Dx (x, t) = −
n=1


Bn n2 π 2 cos(nπx) e−(1+n )t
2
Dxx (x, t) = −
n=1

Now we can estimate the Bn coefficients as usual with the constant C as before.
Hence, |Bn | ≤ C for all n ≥ 0. Also, again, we have
9.10 Convergence Analysis for the Cable Equation 305

e−(1+n )t
≤ e−n t .
2 2

The series for the two partial derivatives with respect to x satisfies

 ∞

|Bn |nπ| sin(nπx)| e−(1+n )t
Cnπ e−n
2 2
≤ t

n=1 n=1

and

 ∞

|Bn |n2 π 2 | sin(nπx)| e−(1+n )t
Cn2 π 2 e−n
2 2
≤ t

n=1 n=1

Applying Theorem 9.10.6, we see both of the series on the right hand side converge
for any t > 0. Then, using Theorem 9.10.4, we see the series for Dx (x, t) and Dxx (x, t)
converge uniformly. Since these series are built from continuous functions, we then
know the limit function is continuous for t > 0 since the convergence is uniform.
Finally, applying Theorem 9.10.7, we see the series for ∂ ∂x
is the same as the series
Dx (x, t) we find by differentiating term by term. Further, the series for ∂∂x2 is the
2

same as the series Dxx (x, t) we also find by differentiating term by term. Hence, on
[0, 1] × (0, ∞) we can compute

 ∞  ∞
∂2 ∂
Bn n2 π 2 cos(nπx) e−(1+n )t − B0 e−t − Bn cos(nπx) e−(1+n )t
2 2
−− =−
∂x 2 ∂t
n=1 n=1


+ B0 e−t + Bn (1 + n2 π 2 ) cos(nπx) e−(1+n
2 )t

n=1
= 0.

So that we see our series solution satisfies the partial differential equation. To check
the boundary conditions, because of continuity, we can see
  ∞ 
∂ −(1+n2 )t
(0, t) = − Bn nπ sin(nπx) e =0
∂x n=1 x=0
  ∞ 
∂
Bn nπ sin(nπx) e−(1+n )t
2
(1, t) = − = 0.
∂x n=1 x=1

and finally, the data boundary condition gives

(x, 0) = f (x).

Note, we can show that higher order partial derivatives of  are also continuous even
though we have only limited smoothness in the data function f . Hence, the solutions
of the cable equation smooth irregularities in the data.
306 9 A Primer on Series Solutions

9.10.5.2 Convergence of the General Cable Solution: Detailed Analysis

The formal series solution in the most general case is then



  
nπ L 2 +n2 π 2 β 2
(x, t) = B0 e− α t + x e− αL2 t .
1
Bn cos
n=1
L

Now we can estimate the Bn coefficients as before by the same constant C. Hence,
|Bn | ≤ C for all n ≥ 0. Further, we now have

L 2 +n2 π 2 β 2 n2 π 2 β 2
e− αL 2
t
≤ e− αL 2
t
.

Thus, for any fixed t > 0, we have the estimate



   ∞

nπ L 2 +n2 π 2 β 2 n2 π 2 β 2
|Bn | cos x e− αL 2
t
≤ C e− αL 2
t
.
n=1
L n=1

Using Theorem 9.10.6, we note the series on the right hand side converges. We can
then apply Theorem 9.10.4 to see the series on the left hand side converges uniformly
to (x, t) on the interval [0, L] as long as t > 0. Since each of the individual functions
in the series on the left hand side is continuous and convergence is uniform, we can
use Theorem 9.10.1 to see the limit function for the left hand side series is continuous
on [0, L] for each t > 0. Hence, the function (x, t) is continuous on the domain
[0, L] × [t, ∞) for any positive t. At t = 0, the series for (x, t) becomes

  

B0 + Bn cos x .
n=1
L

which is the Fourier cosine series for f on [0, L]. Now from our previous work with
the Fourier cosine series, we know this series converges uniformly to f (x) as long
as f is continuous on [0, L] with a derivative that exists for all but a finite number of
points. Hence, we see
 ∞   
− α1 t nπ 2 2 2 2
− L +nαL2π β t
lim |(x, t) = lim B0 e + Bn cos x e
t→0 t→0
n=1
L
= f (x) = (x, 0).

So we know (x, t) is continuous on [0, L] × [0, ∞). Now let’s look at the partial
derivatives. If we take the partial derivative with respect to x of the series for (x, t)
term by term, we find the function Dt (x, t) given by
9.10 Convergence Analysis for the Cable Equation 307

∞  
1 − 1 t  L 2 + n2 π 2 β 2 nπ L 2 +n2 π 2 β 2
Dt (x, t) = −B0 e α − Bn cos x e− αL2 t
α n=1
αL 2 L

The series portion for Dt (x, t) then satisfies the estimate



   ∞
L 2 + n2 π 2 β 2 nπ 2 2 2 2
− L +nαL2π β t L 2 + n2 π 2 β 2 − n2 π22β2 t
|Bn | cos x e ≤ C e αL .
n=1
αL 2 L n=1
αL 2

Applying Theorem 9.10.6, we again see the series on the right hand side converges
for any t > 0. Then, using Theorem 9.10.4, we see the series for D1 (x, t) con-
verges uniformly. Since it is built from continuous functions, we know limit func-
tion is continuous for t > 0 because the convergence is uniform. Finally, applying
Theorem 9.10.7, we see the series for ∂∂t
is the same as the series Dt (x, t) we found
by differentiating term by term.
The formal partial derivatives of the cable series solution with respect to x are
analyzed in a similar manner. We have

  
nπ nπ L 2 +n2 π 2 β 2
Dx (x, t) = − sin
Bn x e− αL2 t
n=1
L L
∞  
n2 π 2 nπ L 2 +n2 π 2 β 2
Dxx (x, t) = − Bn 2 cos x e− αL2 t
n=1
L L

Now we can estimate the Bn coefficients by C and the exponential term again as

L 2 +n2 π 2 β 2 n2 π 2 β 2
e− αL 2
t
≤ e− αL 2
t
.

Then series terms for the two partial derivatives with respect to x satisfy

   ∞
nπ nπ L 2 +n2 π 2 β 2 nπ − n2 π22β2 t
|Bn | sin x e− αL2 t ≤ C e αL
n=1
L L n=1
L

and

   ∞
n2 π 2 nπ 2 2 2 2
− L +nαL2π β t nπ − n2 π22β2 t
|Bn | 2 cos x e ≤ C e αL .
n=1
L L n=1
L

Applying Theorems 9.10.4 and 9.10.6, we see the series for Dx (x, t) and Dxx (x, t)
converge uniformly for t > 0. Since these series are built from continuous functions,
we then know the limit function is continuous for t > 0 Since the convergence is
uniform, these limit functions are also continuous. Finally, applying Theorem 9.10.7,
we see the series for ∂ and the series for ∂∂x2 are the same as the series Dx (x, t) and
2

∂x
308 9 A Primer on Series Solutions

Dxx (x, t) that we find by differentiating term by term. It is then an easy calculation
to see that the series solution satisfies the cable equation with the given boundary
conditions.

Comment 9.10.3 The arguments we presented in this chapter are quite similar to
the ones we would use to analyze the smoothness qualities of the solutions to other
linear partial differential equations with boundary conditions. We didn’t want to go
through all of them in this text as we don’t think there is a lot of value in repeating
these arguments over and over. Just remember that to get solutions with this kind of
smoothness requires that the series we formally compute converge uniformly. If we
did not have that information, our series solutions would not have this amount of
smoothness. But that is another story!

Reference

J. Peterson, in Calculus for Cognitive Scientists: Higher Order Models and Their Analysis. Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015 in press)
Chapter 10
Linear Partial Differential Equations

The cable equation is an example of a linear partial differential equation and we


have already seen how to solve it using separation of variables. There are several
other models and we will illustrate how these models look on simple domains for
convenience.

The Wave Equation: We seek functions (x, t) so that

∂2 ∂2
− c2 2 =0
∂t 2 ∂x
(x, 0) = f (x), for 0 ≤ x ≤ L
∂
(x, 0) = g(x), for 0 ≤ x ≤ L
∂t
(0, t) = 0, for 0 ≤ t
(L, t) = 0, for 0 ≤ t

for some positive constant c. The solution of this equation approximates the motion
of a nice string with no external forces applied. The domain here is the infinite
rectangle [0, L] × [0, ∞).
Laplace’s Equation: The solution (x, y) of this equation is a time independent
solution to a problem such as the distribution of heat on a membrane stretch over
the domain given that various heat sources are applied to the boundary. Here, the
domain is the finite square [0, L]×[0, L]. In the problem below, three of the edges
of the square are clamped to 0 and the remaining one must follow the heat profile
given by the function f (x).

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ L
∂x

© Springer Science+Business Media Singapore 2016 309


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_10
310 10 Linear Partial Differential Equations

∂
(L, y) = 0, for 0 ≤ y ≤ L
∂x
(x, L) = 0, for 0 ≤ x ≤ L
(x, 0) = f (x), for 0 ≤ x ≤ L

The Heat/Diffusion Equation: The solution of this equation, (x, t), is the time
dependent value of heat or temperature of a one dimensional bar which is having
a heat source applied to it initially. It can also model a substance moving through
a domain using diffusion with diffusion constant D as discussed in Chap. 5. The
domain is again half infinite: [0, L] × [0, ∞).

∂ ∂2
−D =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(L, t) = 0, for 0 < t
(x, 0) = f (x), for 0 < x < L

This equation is very relevant to our needs. Indeed, in Peterson (2015), we derive
this equation using a random walk model and learn how to interpret the diffusion
constant D in terms of the space constant λC and the time constant τM . However,
we will not discuss that here.

10.1 The Separation of Variables Method Revisited

As we know from Chap. 9, one way to find the solution to these models is to assume
we can separate the variables and write (x, t) = u(x)w(t) or (x, y) = u(x)w(y). If
we make this separation assumption, we find solutions that must be written as infinite
series and to solve the boundary conditions, we must express boundary functions as
series expansions.

10.1.1 The Wave Equation

We will solve this wave equation model.

∂2 ∂2
− c2 2 = 0
∂t 2 ∂x
(x, 0) = f (x), for 0 ≤ x ≤ L
∂
(x, 0) = g(x), for 0 ≤ x ≤ L
∂t
10.1 The Separation of Variables Method Revisited 311

(0, t) = 0, for 0 ≤ t
(L, t) = 0, for 0 ≤ t

for some positive constant c. We assume a solution of the form (x, t) = u(x) w(t)
and compute the needed partials for Wave Equation. This leads to a the new equation

d2w 2
2 d u
u(x) − c w(t) = 0.
dt 2 dx 2
Rewriting, we find for all x and t, we must have

d2w 2
2 d u
u(x) = c w(t).
dt 2 dx 2
Now put all the u quantities on the left hand side and all the w ones on the right hand
side. This gives

d2 w 2

dt 2
c2 ddxu2
= , 0 ≤ x ≤ L, t ≥ 0.
w(t) u(x)

The only way this can be true is if both the left and right hand side are always
a constant. This common constant value we will denote by  and it is called the
separation of variables constant for this model. This leads to the decoupled equa-
tions 10.1 and 10.2.

d2w
=  w(t), t ≥ 0, (10.1)
dt 2
c2 d 2 u
=  u(x), 0 ≤ x ≤ L. (10.2)
dx 2
We also have boundary conditions. Our assumption leads to the following boundary
conditions in x:

u(0) w(t) = 0, t ≥ 0,
u(L) w(t) = 0, t ≥ 0.

Since these equations must hold for all t, this forces

u(0) = 0, (10.3)
u(L) = 0. (10.4)

Equations 10.1–10.4 give us the boundary value problem in u(x) we need to solve.
We also have to solve a system for the variable w(t).
312 10 Linear Partial Differential Equations

10.1.1.1 Determining the Separation Constant

Let’s look at the model in x and for convenience, let u denote the second derivative
with respect to x. The model is then

c2 u − u = 0
u(0) = 0,
u(L) = 0.

We are looking for nonzero solutions, so any choice of separation constant  that
leads to a zero solution will be rejected. Hence, our job is to find the values of  that
give rise to nonzero solutions.
Case I:  = ω 2 , ω = 0: The model to solve is

ω2
u − u=0
c2
u(0) = 0,
u(L) = 0.

with characteristic equation r 2 − ωc2 = 0 with the real roots ± ωc . The general solution
2

of this second order model is given by


   
ω ω
u(x) = A cosh x + B sinh x
c c

Next, apply the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
 
ω
u(L) = 0 = B sinh L
c
 
Hence, A = 0 and B sinh L ωc = 0. Since sinh is never zero when ω is not zero,
we see B = 0 also. Hence, the only u solution is the trivial one and we can reject
this case. There is no need to look at the corresponding w solutions as we construct
the solution to the wave equation from the products u(x)w(t). Hence, if u(x) = 0
always, the product is also zero.
Case II:  = 0: The model to solve is now

u = 0
u(0) = 0,
u(L) = 0.
10.1 The Separation of Variables Method Revisited 313

with characteristic equation r 2 = 0 with the double root r = 0. Hence, the general
solution is now

u(x) = A + B x

Applying the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
u(L) = 0 = BL

Hence, A = 0 and B = 0 and the u solutions are trivial. We reject this case as well.
Case III:  = −ω 2 , ω = 0:

ω2
c2 u + u=0
c2
u(0) = 0,
u(L) = 0.

The general solution is given by


   
ω ω
u(x) = A cos x + B sin x
c c

Next, apply the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
 
ω
u(L) = 0 = B sin L
c
 
Hence, A = 0 and B sin L ωc = 0. We now see an interesting result. We can
 
determine a unique value of B only if sin L ωc = 0. Since ω = 0 by assumption, if
ω
c
L = nπ for any integer n = 0, we find the value of B can not be determined as we
have the equation 0 = B × 0. If ω = nπcL
, we can solve for B and find B = 0. So the
only solutions are the trivial or zero solutions unless ωL = nπc. Letting ωn = nπc L
,
we find a a non zero solution for each nonzero value of B of the form
   
ωn nπ
un (x) = B sin x = B sin x .
c L

It is only necessary to use all integers n ≥ 1 as sin is an odd function and so


the solutions for negative integers are just the negative of the solutions for positive
integers. For convenience, let’s choose all the constants B = 1. Then we have an
314 10 Linear Partial Differential Equations
 
infinite family of nonzero solutions un (x) = sin nπ
L
x and an infinite family of

separation constants n = −ωn2 = − n Lπ2 c .


2 2 2

We can then solve the w equation. We must solve

d2w
+ ωn2 w(t) = 0, t ≥ 0.
dt 2
The general solution is

wn (t) = C cos(ωn t) + D sin(ωn t)


   
nπc nπc
= C cos t + D sin t
L L

as we will get a different time solution for each choice of ωn . Hence, any product

φn (x, t) = un (x) wn (t)

will solve the model with the x boundary conditions. In fact, any finite sum of the
form, for arbitrary constants Cn and Dn


N 
N
N (x, t) = φn (x, t) = un (x) wn (t)
n=1 n=1


N      
nπ nπc nπc
= sin x Cn cos t + Dn sin t
n=1
L L L

will solve the model with x boundary conditions as well.

10.1.1.2 The Infinite Series Solution

Using what we know about Fourier series and series in general from Chap. 9, we can
show the series of the form

      
nπ nπc nπc
sin x An cos t + Bn sin t
n=1
L L L

converge pointwise for x in [0, L] and all t. We haven’t gone through all the details
of this argument yet but we will. Hence, we will form the solution (x, t) given by

 ∞

(x, t) = φn (x, t) = un (x) wn (t)
n=1 n=1
10.1 The Separation of Variables Method Revisited 315


      
nπ nπc nπc
= sin x Cn cos t + Dn sin t
n=1
L L L

for the arbitrary sequences of constants (Cn ) and (Dn ). We can show we can find the
partial derivatives of this series pointwise by differentiating term by term. Hence,

∞
∂ ∂w
(x, t) = un (x)
∂t n=1
∂t
∞      
nπ nπc nπc nπc nπc
= sin x −Cn sin t + Dn cos t .
n=1
L L L L L

which we can then use to solve the boundary conditions with data functions.

10.1.1.3 Handling the Other Boundary Conditions

We can easily find that



  

(x, 0) = sin x Cn ,
n=1
L

and

∞  
∂ nπ nπc
(x, 0) = sin x Dn .
∂t n=1
L L

The remaining boundary conditions are

(x, 0) = f (x), for 0 ≤ x ≤ L


∂
(x, 0) = g(x), for 0 ≤ x ≤ L
∂t
These are rewritten in terms of the series solution, for 0 ≤ x ≤ L, as

  

Cn sin x = f (x),
n=1
L
∞  
nπc nπ
Dn sin x = g(x).
n=1
L L

The theory of Fourier series tells us that any piecewise differentiable function h can
be written as the series
316 10 Linear Partial Differential Equations


  

h(x) = An sin x
n=1
L

where the coefficients are given by the integral


 L  
2 nπ
An = h(x) sin x dx.
L 0 L

Since this is a Fourier series, the series converges pointwise. For now, apply these
ideas to the functions f and g to write

  

f (x) = An sin x
n=1
L
∞  

g(x) = Bn sin x
n=1
L

with
  
2 L nπ
An = f (x) sin x dx
L 0 L
  
2 L nπ
Bn = g(x) sin x dx
L 0 L

Then, setting these series equal, we find



   ∞
  
nπ nπ
Cn sin x = x ,
An sin
n=1
L n=1
L
∞   ∞  
nπc nπ nπ
Dn sin x = Bn sin x .
n=1
L L n=1
L

Writing these series on the left hand side only we find after some term by term
manipulations

∞    

Cn − An sin x =0
n=1
L
∞    
nπc nπ
Dn − Bn sin x =0
n=1
L L

Since these series converge pointwise, the only way they can equal 0 for all x is if
the individual terms equal zero. Hence, for each n, we must have
10.1 The Separation of Variables Method Revisited 317
   

Cn − An sin x =0
L
   

Dn nπc − Bn sin x = 0.
L

Since this is true for all x, the coefficients must equal zero and so we find that the
solution is given by Cn = An and Dn = Bnπc nL
for all n ≥ 1. The ideas here are really
quite general so we can apply them quite easily to the other models. The technique
we use above is called coefficient matching.

10.1.1.4 Summary

Let’s summarize the approach.

• Assume the solution is in separated form, (x, t) = u(x)w(t).


• Convert the model into two ordinary differential equation (ODE) models. The two
models are connected by a separation constant .
• The u(x) ODE problem is a boundary value problem (BVP) with parameter . We
must find nontrivial, i.e. non zero, solutions to it. We find there are infinitely many
such solutions for a sequence of  values. This requires we study this model for
the cases  = ω 2 ,  = 0 and  = −ω 2 for any ω = 0. This requires knowledge
of how to solve such ODE models.
• Once the BVP is solved, it tells us the sequence of separation constants we can
use to solve the other ODE model. This gives us one nontrivial solution family for
each of these separation constant values, φn (x, t) = un (x)wn (t).
• We form the family of series solutions ∞ n=1 φn (x, t) and express the boundary
function data given by f and g as Fourier series.
• Then equate the series solution at the boundaries which have function data to the
series for the boundary data and match coefficients to find the correct solution to
the model.

10.1.1.5 Homework

Solve the following problems using separation of variables.

Exercise 10.1.1

∂2 ∂2
− 25 =0
∂t 2 ∂x 2
(x, 0) = 0.1x 2 , for 0 ≤ x ≤ 10
∂
(x, 0) = 0, for 0 ≤ x ≤ 10
∂t
318 10 Linear Partial Differential Equations

(0, t) = 0, for 0 ≤ t
(10, t) = 0, for 0 ≤ t

Exercise 10.1.2

∂2 ∂2
− 4 =0
∂t 2 ∂x 2
(x, 0) = 0, for 0 ≤ x ≤ 5
∂
(x, 0) = 0.05x 2 , for 0 ≤ x ≤ 5
∂t
(0, t) = 0, for 0 ≤ t
(5, t) = 0, for 0 ≤ t

10.1.2 Laplace’s Equation

Next, let’s focus on solving Laplace’s equation.

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ L
∂x
∂
(L, y) = 0, for 0 ≤ y ≤ L
∂x
(x, L) = 0, for 0 ≤ x ≤ L
(x, 0) = f (x), for 0 ≤ x ≤ L

We assume a solution of the form (x, y) = u(x) w(y) and compute the needed
partials for Laplace’s Equation. This leads to a the new equation

d2w d2u
u(x) + 2 w(y) = 0.
dy2 dx

Rewriting, we find for all x and y, we must have

d2w d2u
u(x) 2
= − 2 w(y).
dy dx

Now put all the u quantities on the left hand side and all the w ones on the right hand
side. This gives

d2 w d2 u
dy2 dx 2
− = , 0 ≤ x, y ≤ L.
w(y) u(x)
10.1 The Separation of Variables Method Revisited 319

The only way this can be true is if both the left and right hand side are always
a constant. This common constant value  is called the separation of variables
constant for this model. This leads to the decoupled equations 10.5 and 10.6.

d2w
= − w(y), 0 ≤ y ≤ L, (10.5)
dy2
d2u
=  u(x), 0 ≤ x ≤ L. (10.6)
dx 2
We also have boundary conditions. Our assumption leads to the following boundary
conditions in x:

du
(0) w(y) = 0, for 0 ≤ y ≤ L,
dx
du
(L) w(y) = 0, for 0 ≤ y ≤ L,
dx
u(x) w(L) = 0, for 0 ≤ x ≤ L.

Since these equations must hold for all y for the first two and all x for the last, this
forces
du
(0) = 0, (10.7)
dx
du
(L) = 0, (10.8)
dx
w(L) = 0. (10.9)

Equations 10.5–10.8 give us the boundary value problem in u(x) we need to solve.
We also have to solve a system for the variable w(y) with condition 10.9.

10.1.2.1 Determining the Separation Constant

Let’s look at the model in x:

u − u = 0
u (0) = 0,
u (L) = 0.

We are looking for nonzero solutions, so any choice of separation constant  that
leads to a zero solution will be rejected. Hence, our job is to find the values of  that
give rise to nonzero solutions.
320 10 Linear Partial Differential Equations

Case I:  = ω 2 , ω = 0: The model to solve is

u − ω 2 u = 0
u (0) = 0,
u (L) = 0.

with characteristic equation r 2 − ω 2 = 0 with the real roots ±ω. The general solution
of this second order model is given by

u(x) = A cosh(ωx) + B sinh(ωx)

with

u (x) = A ω sinh(ωx) + B ω cosh(ωx)

Next, apply the boundary conditions, u (0) = 0 and u (L) = 0. Hence,

u (0) = 0 = B
u (L) = 0 = Aω sinh(Lω)

Hence, B = 0 and A sinh(Lω) = 0. Since sinh is never zero when ω is not zero, we
see A = 0 also. Hence, the only u solution is the trivial one and we can reject this
case. Again, there is no need to look at the corresponding w solutions as we construct
the solution to Laplace’s equation from the products u(x)w(y). Hence, if u(x) = 0
always, the product is also zero.
Case II:  = 0: The model to solve is now

u = 0

u (0) = 0,
u (L) = 0.

with characteristic equation r 2 = 0 with the double root r = 0. Hence, the general
solution is now

u(x) = A + B x

with u (x) = B. Applying the boundary conditions, u (0) = 0 and u (L) = 0. Hence,

u (0) = 0 = B
u (L) = 0 = B

Hence, B = 0 and there is no constraint on A. Hence, any arbitrary constant which


is not zero is a valid non zero solution. Choosing A = 1, let u0 (x) = 1 be our chosen
10.1 The Separation of Variables Method Revisited 321

nonzero solution for this case. We now need to solve for w in this case. The model
to solve is

d2w
= 0, 0 ≤ y ≤ L,
dy2
w(L) = 0.

The general solution is w(y) = A + By and applying the boundary condition, we find
w(L) = A + BL = 0. Hence, solving for B, we find B = − AL . The corresponding
family of solutions for w in this case is
 
A y
w(y) = A − y = A 1 −
L L
L−y
=A
L

Since A is arbitrary, we can choose the arbitrary constant A


L
= 1 and set

L−y
w0 (y) = .
L
Hence, the product 0 (x, y) = u0 (x) w0 (y) solves the boundary conditions. That is

L−y
0 (x, y) =
L
is a solution.
Case III:  = −ω 2 , ω = 0:

u + ω 2 u = 0
u (0) = 0,
u (L) = 0.

The general solution is given by

u(x) = A cos(ωx) + B sin(ωx)

with

u (x) = −A ω sin(ωx) + B ω cos(ωx)


322 10 Linear Partial Differential Equations

Next, apply the boundary conditions, u (0) = 0 and u (L) = 0. Hence,

u (0) = 0 = B
u (L) = 0 = A sin(Lω)

Hence, B = 0 and A sin(Lω) = 0. We can determine a unique value of A only if


sin(Lω) = 0. Since ω = 0 by assumption, if ωL = nπ for any integer n = 0, we find
the value of A can not be determined. Of course, if ω = nπcL
, we can solve for A and
find A = 0. So the only solutions are the trivial or zero solutions unless ωL = nπ.
Letting ωn = nπ L
, we find a a non zero solution for each nonzero value of A of the
form
 

un (x) = A cos(ωn x) = A cos x .
L

It is only necessary to use all integers n ≥ 1 as cos is an even function and so the
solutions for negative integers are the same of the solutions for positive integers. For
convenience, let’s choose all the constants A = 1. Then we have an infinite family
of nonzero solutions un (x) = cos( nπL
x) and an infinite family of separation constants
n = −ωn2 = − nLπ2 . We can then solve the w equation. We must solve
2 2

d2w
− ωn2 w(y) = 0, 0 ≥ y ≥ L,
dy2
wn (L) = 0.

The general solution is

wn (y) = C cosh(ωn y) + D sinh(ωn y)


   
nπ nπ
= C cosh y + D sinh y
L L

Applying the boundary condition, we have

wn (L) = C cosh(ωn L) + D sinh(ωn L) = 0.

Neither cosh or sinh are zero here, so we can solve for D in terms of C to find

cosh(ωn L)
D = −C .
sinh(ωn L)

Hence, we find a family of nontrivial solutions of the form

cosh(ωn L)
wn (y) = C cosh(ωn y) − C sinh(ωn y)
sinh(ωn L)
10.1 The Separation of Variables Method Revisited 323
 
cosh(ωn y) sinh(ωn L) − cosh(ωn L) sinh(ωn y)
=C
sinh(ωn L)

Using the hyperbolic function identity sinh(u − v) = sin(u) cosh(v) − sinh(u)


cosh(v), we can rewrite this as
 
C
wn (y) = sinh ωn (L − y) .
sinh(ωn L)

C
Finally, the term sinh(ωn L)
is arbitrary as C is arbitrary. Choosing the arbitrary constant
to be 1 always, we obtain a family of solutions of the form
 
wn (y) = sinh ωn (L − y)

for all integers n ≥ 1. Hence, any product

φn (x, t) = un (x) wn (y)

will solve the model with the x boundary conditions. In fact, any finite sum of the
form, for arbitrary constants An


N 
N
N (x, y) = An φn (x, y) = An un (x) wn (y)
n=1 n=1


N    
nπ nπ
= An cos x sinh (L − y)
n=1
L L

will solve the model with our boundary conditions as well.

10.1.2.2 The Infinite Series Solution

Again, we can show series of the form



    
nπ nπ
cos x sinh (L − y)
n=0
L L

converge pointwise for x, y in [0, L]. Hence, we will form the solution (x, y)
given by

 ∞

(x, y) = An φn (x, y) = An un (x) wn (y)
n=0 n=0
324 10 Linear Partial Differential Equations

∞    
L−y  nπ nπ
= A0 + An cos x sinh (L − y)
L n=1
L L

for the arbitrary sequence of constants (An ).

10.1.2.3 Handling the Other Boundary Conditions

We can easily find that



  

(x, 0) = A0 + An cos x sinh(nπ),
n=1
L

The remaining boundary condition is

(x, 0) = f (x), for 0 ≤ x ≤ L

We know we can write



  

f (x) = B0 + Bn cos x
n=1
L

with

1 L
B0 = f (x)dx
L 0
  
2 L nπ
Bn = f (x) cos x dx, n ≥ 1
L 0 L

Then, setting the series equal, we find



   ∞
  
nπ nπ
A0 + An cos x sinh(nπ) = B0 + Bn cos x ,
n=1
L n=1
L

Equating coefficients, we have A0 = B0 and An = Bn


sinh(nπ)
.

10.1.2.4 Summary

Let’s summarize this approach again.

• Assume the solution is in separated form (x, y) = u(x)w(y).


10.1 The Separation of Variables Method Revisited 325

• Convert the model into two ordinary differential equation (ODE) models. These
two models are connected by a separation constant .
• The u(x) problems is a boundary value problem (BVP) with parameter . We
must find nontrivial, i.e. non zero, solutions to it. We find there are infinitely many
such solutions for a sequence of  values. This requires we study this model for
the cases  = ω 2 ,  = 0 and  = −ω 2 for any ω = 0. This requires knowledge
of how to solve such ODE models.
• Once the BVP is solved, it tells us the sequence of separation constants we can
use to solve the other ODE model. This gives us one nontrivial solution family for
each of these separation constant values, φn .
• We form the family of series solutions ∞ n=1 φn and express the boundary function
data given by f as a Fourier series.
• Then equate the series solution at the boundary which has function data to the
series for the boundary data and match coefficients to find the correct solution to
the model.

10.1.2.5 Homework

Exercise 10.1.3

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ 10
∂x
∂
(7, y) = 0, for 0 ≤ y ≤ 10
∂x
(x, 10) = 0, for 0 ≤ x ≤ 7
(x, 0) = 1.2x 4 , for 0 ≤ x ≤ 7.

Exercise 10.1.4

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ 2
∂x
∂
(5, y) = 0, for 0 ≤ y ≤ 2
∂x
(x, 2) = 0, for 0 ≤ x ≤ 5
(x, 0) = 1.2x 2 , for 0 ≤ x ≤ 5.
326 10 Linear Partial Differential Equations

10.1.3 The Heat/Diffusion Equation

We will solve this heat equation model.

∂ ∂2
−D =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(L, t) = 0, for 0 < t
(x, 0) = f (x), for 0 < x < L

for some positive constant D which in the case of diffusion is called the diffusion
constant. We again assume a solution of the form (x, t) = u(x) w(t) and compute
the needed partials. This leads to a the new equation

dw d2u
u(x) − D 2 w(t) = 0.
dt dx
Rewriting, we find for all x and t, we must have

dw d2u
u(x) = D 2 w(t).
dt dx
Rewriting, we have
2
dw
D ddxu2
dt
= , 0 ≤ x <≤ L, t > 0.
w(t) u(x)

As usual, the only way this is true is if both the left and right hand side equal the
separation constant  for this model. This leads to the decoupled equations 10.10
and 10.11.
dw
=  w(t), t > 0, (10.10)
dt
d2u
D 2 =  u(x), 0 ≤ x ≤ L, (10.11)
dx
We also have boundary conditions. Our assumption leads to the following boundary
conditions in x:

u(0) w(t) = 0, t > 0,


u(L) w(t) = 0, t > 0.
10.1 The Separation of Variables Method Revisited 327

Since these equations must hold for all t, this forces

u(0) = 0, (10.12)
u(L) = 0. (10.13)

Equations 10.10–10.13 give us the boundary value problem in u(x) we need to solve.
Once we have the u solution, we can solve the system for the variable w(t).

10.1.3.1 Determining the Separation Constant

The model is then

D u − u = 0
u(0) = 0,
u(L) = 0.

We are looking for nonzero solutions, so any choice of separation constant  that
leads to a zero solution will be rejected. Hence, our job is to find the values of  that
give rise to nonzero solutions.
Case I:  = ω 2 , ω = 0: The model to solve is

ω2
u − u=0
D
u(0) = 0,
u(L) = 0.

with characteristic equation r 2 − ωD = 0 with the real roots ± √ωD . The general
2

solution of this second order model is given by


   
ω ω
u(x) = A cosh √ x + B sinh √ x
D D

Next, apply the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
 
ω
u(L) = 0 = B sinh L √
D
 
Hence, A = 0 and B sinh L √ωD = 0. Since sinh is never zero when ω is not zero,
we see B = 0 also. Hence, the only u solution is the trivial one and we can reject this
case.
328 10 Linear Partial Differential Equations

Case II:  = 0: The model to solve is now

u = 0
u(0) = 0,
u(L) = 0.

with characteristic equation r 2 = 0 with the double root r = 0. Hence, the general
solution is now

u(x) = A + B x

Applying the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
u(L) = 0 = BL

Hence, A = 0 and B = 0 and the u solutions are trivial. We reject this case as well.
Case III:  = −ω 2 , ω = 0:

ω2
u + u=0
D
u(0) = 0,
u(L) = 0.

The general solution is given by


   
ω ω
u(x) = A cos √ x + B sin √ x
D D

Next, apply the boundary conditions, u(0) = 0 and u(L) = 0. Hence,

u(0) = 0 = A
 
ω
u(L) = 0 = B sin L √
D
 
Hence, A = 0 and B sin L √ωD = 0. Thus, we can determine a unique value of B
 
ω
only if sin L D = 0. If ω = nπc

L
, we can solve for B and find B = 0, but otherwise,
B can’t be determined. So the only solutions are the trivial or zero solutions unless
√ √
ωL = nπ D. Letting ωn = nπL D , we find a a non zero solution for each nonzero
value of B of the form
10.1 The Separation of Variables Method Revisited 329
   
ωn nπ
un (x) = B sin √ x = B sin x .
D L

  B = 1. Then we have an infinite


For convenience, let’s choose all the constants
family of nonzero solutions un (x) = sin nπ
L
x and an infinite family of separation

constants n = −ωn2 = − n Lπ2 D . We can then solve the w equation. We must solve
2 2

dw
= −ωn2 w(t), t ≥ 0.
dt
The general solution is

n2 π 2 D
w(t) = Bn e−ωn t = Bn e−
2 t
L2

as we will get a different time solution for each choice of ωn . Choosing the constants
Bn = 1, we obtain the wn functions
n2 π 2 D
wn (t) = e− L2
t

Hence, any product

φn (x, t) = un (x) wn (t)

will solve the model with the x boundary conditions and any finite sum of the form,
for arbitrary constants An


N 
N
N (x, t) = φn (x, t) = un (x) wn (t)
n=1 n=1


N  
nπ n2 π 2 D
= sin x e− L2 t
n=1
L

will solve the model with x boundary conditions as well.

10.1.3.2 The Infinite Series Solution

We know series of the form



  
nπ n2 π 2 D
sin x e− L2 t
n=1
L
330 10 Linear Partial Differential Equations

converge pointwise for x in [0, L] and all t. Hence, form the solution (x, t) as

 ∞

(x, t) = φn (x, t) = un (x) wn (t)
n=1 n=1
∞  
nπ n2 π 2 D
= sin x e− L2 t
n=1
L

for the arbitrary sequence of constants (An ).

10.1.3.3 Handling the Other Boundary Condition

We can easily find that



  

(x, 0) = An sin x
n=1
L

The remaining boundary condition is

(x, 0) = f (x), for 0 ≤ x ≤ L

Rewriting in terms of the series solution, for 0 ≤ x ≤ L, we find



  

An sin x = f (x)
n=1
L

The Fourier series for f is given by



  

f (x) = An sin x
n=1
L

with
 L  
2 nπ
Bn = f (x) sin x dx
L 0 L

Then, setting these series equal, we find that the solution is given by An = Bn for all
n ≥ 1.
10.1 The Separation of Variables Method Revisited 331

10.1.3.4 Homework

Exercise 10.1.5

∂ ∂2
− 10 =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(8, t) = 0, for 0 < t
(x, 0) = 10e−0.002t , for 0 < x < 8.

Exercise 10.1.6

∂ ∂2
−4 =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(12, t) = 0, for 0 < t
(x, 0) = 0.05 cos(t 2 ), for 0 < x < 12.

10.2 Fourier Series Approximate Methods

Using the Fourier approximation tools we built in Chap. 9, we can now write appli-
cation code that will approximate the separation of variables solutions to linear PDE.
We will show code for one particular set of boundary conditions for each problem.
We will write functions to solve models with Dirichlet boundary conditions (i.e. the
solution is set to 0 on two boundaries) and those with Dirichlet boundary conditions
(a partial of the solution is set to 0 on two boundaries).

10.2.1 The Wave Equation

In order to write the approximation code for the wave equation solutions, we first
must solve the model using separation of variables.

10.2.1.1 Dirichlet Boundary Conditions

A typical Wave equation with Dirichlet boundary conditions is given below.

∂2 2∂ 
2
− c =0
∂t 2 ∂x 2
(x, 0) = f (x), for 0 ≤ x ≤ L
332 10 Linear Partial Differential Equations

∂
(x, 0) = 0, for 0 ≤ x ≤ L
∂t
(0, t) = 0, for 0 ≤ t
(L, t) = 0, for 0 ≤ t

Applying separation of variables, we let (x, t) = u(x)w(t) and find

c2 u − n u = 0, for 0 ≤ x ≤ L
u(0) = 0,
u(L) = 0.

w − n w = 0, for t ≥ 0,
w  (0) = 0.
 2
where the separation constants are n = − nπc L
for n = 1, 2, . . .. The boundary
   
conditions on x lead to the solutions un (x) = sin nπ
L
x and w n (t) = cos nπc
L
t .
The infinite series solution is then

    
nπ nπc
(x, t) = An sin x cos t .
n=1
L L

Hence, to satisfy the last boundary condition, we must have



  

(x, 0) = An sin x
n=1
L

  

= f (x) = Bn sin x ,
n=1
L
 
L
where Bn = 2
L 0 f (s) sin nπ
L
s ds. This tells us we choose the constants (An )
so that An = Bn . The code to compute the approximation for N terms is given in
WaveDirichletApprox. The code approximates the solution to the Dirichlet
wave model on the rectangle [0, L1] × [0, L2]. The parameter M is the number
of terms we want touse in the Riemann sum approximations to our needed inner
L
products 0 f (s) sin nπ
L
s ds. Finally, we draw the surface which corresponds to the
approximate solution N (x, t) using nx points for the x interval and nt points for
the t interval. If we use reasonable small values of nx and nt, we will get a surface we
can rotate easily with our mouse to see in different perspectives. However, if these
values are large, the Octave to gnuplot interface is flawed and the resulting surface
10.2 Fourier Series Approximate Methods 333

will still rotate, but with a significant time delay. In this function, we approximate
the series as follows: First, we get the first N Fourier sine series coefficients.
Listing 10.1: Get Fourier sine coefficients
% Get F o u r i e r S i n e Approximation t o f f o r N term s
[ A, fN ] = F o u r i e r S i n e A p p r o x ( f , L1 ,M,N) ;

Then, we set up function handles for all of the needed sin functions.
Listing 10.2: Setup sine functions
% Get S i n e F u n c t i o n s
u = S e t U p S i n e s ( L1 ,N) ;

We then construct the cos function handles we will use in the approximation.
Listing 10.3: Setup cosine functions
% Get t h e c o s f u n c t i o n s
v = c e l l (N, 1 ) ;
3 f o r i = 1 :N
v{ i } = @( t ) c o s ( i ∗ p i ∗ c ∗ t /L1 ) ;
end

Finally, we define the surface function p(x, t) as the partial sum of the first N terms.
Listing 10.4: Construct the approximate solution
% Construct the approximate s o l u t i o n
% g e t Nth F o u r i e r S i n e Appro ximati on
p = @( x , t ) 0 ;
f o r i =1:N
5 p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

Once p(x, t) is defined, we can plot the approximate surface. We set up a mesh of
(x, t) points and calculate all the needed surface values for all the mesh points using
the code below.
Listing 10.5: Setup plot domain
%
% draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
4 x = l i n s p a c e ( 0 , L1 , nx ) ;
t = l i n s p a c e ( 0 , L2 , nt ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
[ X, T ] = m e s h g r i d ( x , t ) ;
% s e t up s u r f a c e
9 Z = p (X, T) ;
334 10 Linear Partial Differential Equations

We then plot the surface using the mesh command setting labels and so forth as
usual.

Listing 10.6: Plot approximate solution surface


%p l o t s u r f a c e
figure
mesh (X, T , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
5 y l a b e l ( ’t axis ’ ) ;
z l a b e l ( ’ Wave Solution ’ ) ;
t i t l e ( ’ Wave Dirichlet Solution on Rectangle ’ ) ;
p r i n t −dpng ’ WaveDirichlet . png ’ ;

The full code then looks like this:

Listing 10.7: WaveDirichletApprox


f u n c t i o n p = W a v e D i r i c h l e t A p p r o x ( f , c ,M, N, nx , nt , L1 , L2 )
2 % f i s t h e boundary data
% M i s t h e number o f t e r m s i n t h e Riemann sum a p p r o x i m a t i o n s
% to the inner products
% N i s t h e number o f t e r m s i n t h e s e r i e s a p p r o x i m a t i o n t o t h e
% solution
7 % nx i s t h e number o f p o i n t s t o u s e i n t h e s u r f a c e p l o t f o r x
% n t i s t h e number o f p o i n t s t o u s e i n t h e s u r f a c e p l o t f o r t
% L1 i s t h e l e n g t h o f t h e x i n t e r v a l
% L2 i s t h e l e n g t h o f t h e t i n t e r v a l
%
12 % S o l v e u t t − c ˆ2 U xx u = 0 on [ 0 , L ] x [ 0 , L ]
%
% ( 0 , L2 )−−−−−−−−−−−−−−−−−−−−(L1 , L2 )
% | |
% | |
17 % u ( 0 , t ) =0 | | u ( L1 , t ) = 0
% | |
% | |
% ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
22 % u t (x ,0) = 0
%
% Separation of v a r i a b l e s giv es s o l u t i o n i s
% u(x , t ) =
% sum {n=1}ˆ{ i n f i n i t y } A n s i n ( n p i x / L1 ) c o s ( n p i c t / L1 )
27 %
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Sine
% c o e f f i c i e n t s o f f on [ 0 , L ]
%
% A n = ( 2 / L1 ) <f , s i n ( n p i x /L1>
32 %
% Get F o u r i e r S i n e A p p r o x i m a t i o n t o f f o r N t e r m s
[ A, fN ] = F o u r i e r S i n e A p p r o x ( f , L1 ,M,N) ;

% Get S i n e F u n c t i o n s
37 u = S e t U p S i n e s ( L1 ,N) ;

% Get t h e c o s f u n c t i o n s
v = c e l l (N, 1 ) ;
f o r i = 1 :N
42 v{ i } = @( t ) c o s ( i ∗ p i ∗ c ∗ t /L1 ) ;
end

% Construct the approximate s o l u t i o n


% g e t Nth F o u r i e r S i n e A p p r o x i m a t i o n
47 p = @( x , t ) 0 ;
f o r i =1:N
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end
%
10.2 Fourier Series Approximate Methods 335

52 % draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
x = l i n s p a c e ( 0 , L1 , nx ) ;
t = l i n s p a c e ( 0 , L2 , n t ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
57 [ X, T ] = m e s h g r i d ( x , t ) ;
% s e t up s u r f a c e
Z = p (X, T) ;

%p l o t s u r f a c e
62 figure
mesh (X, T , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’y axis ’ ) ;
z l a b e l ( ’ Wave Solution ’ ) ;
67 t i t l e ( ’ Wave Dirichlet Solution on Rectangle ’ ) ;
p r i n t −dpng ’ W a v e D i r i c h l e t . png ’ ;

end

Here is a typical session with a sawtooth curve as the data f .

Listing 10.8: Sample Wave Equation Approximate solution


L = 5;
H = 10;
saw = s a w t o o t h ( L ,H) ;
c = 1;
5 p = WaveDirichletApprox ( saw , c , 5 0 0 , 5 , 2 1 , 4 1 , 5 , 2 0 ) ;

The surface approximation can be seen in Fig. 10.1. Note even though the number
of points in our mesh is low, the surface plot is reasonably good.
We can check to see if the boundary conditions are satisfied by adding a few
lines of code. To the function WaveDirichletApprox, we can calculate the

Fig. 10.1 5 term Fourier series approximation to the wave equation with sawtooth wave data and
Dirichlet boundary conditions
336 10 Linear Partial Differential Equations

approximations to ∂ ∂x
and ∂
∂t
and return them as the functions pd1 and pd2. The
first line of the function becomes

Listing 10.9: Altering WaveDirichletApprox to return partials


function [ p , pd1 , pd2 ] = WaveDirichletApprox ( f , c ,M, N, nx , nt , L1 , L2 )

and we add lines to handle the partial derivative approximations.

Listing 10.10: Setting up partial derivative approximations


% Get S i n e F u n c t i o n s
% r e t u r n s s i n ( i ∗ p i ∗ x /L )
u = S e t U p S i n e s ( L1 ,N) ;
4
% Get t h e s i n d e r i v a t i v e f u n c t i o n s
up = c e l l (N, 1 ) ;
f o r i = 1 :N
up{ i } = @( x ) ( ( i ∗ p i ∗ c ) /L1 ) ∗ c o s ( i ∗ p i ∗ c ∗x/L1 ) ;
9 end

% Get t h e c o s f u n c t i o n s
v = c e l l (N, 1 ) ;
f o r i = 1 :N
14 v{ i } = @( t ) c o s ( i ∗ p i ∗ c ∗ t /L1 ) ;
end

% Get t h e c o s d e r i v a t i v e f u n c t i o n s
vp = c e l l (N, 1 ) ;
19 f o r i = 1 :N
vp { i } = @( t ) −(( i ∗ p i ∗ c ) /L1 ) ∗ s i n ( i ∗ p i ∗ c ∗ t /L1 ) ;
end

% Construct the approximate s o l u t i o n


24 p = @( x , t ) 0 ;
f o r i =1:N
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

29 % C o n s t r u c t t h e a p p r o x i m a t e s o l u t i o n f o r pd1 :
% p a r t i a l o f p w r t argument 1
pd1 = @( x , t ) 0 ;
f o r i =1:N
pd1 = @( x , t ) ( pd1 ( x , t ) + A( i ) ∗up{ i } ( x ) . ∗ v{ i } ( t ) ) ;
34 end

% C o n s t r u c t t h e a p p r o x i m a t e s o l u t i o n f o r pd2 :
% p a r t i a l o f p w r t argument 2
pd2 = @( x , t ) 0 ;
39 f o r i =1:N
pd2 = @( x , t ) ( pd2 ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ vp { i } ( t ) ) ;
end

The rest of the code is the same and so we do not show it. You can alter the code
to add these checks easily if you want. When we run the code using the sawtooth
function like before, we use
10.2 Fourier Series Approximate Methods 337

Listing 10.11: The wave solution with dirichlet BC using saw data
[ p , pd1 , pd2 ] = WaveDirichletApprox ( saw , c , 5 0 0 , 5 , 2 1 , 4 1 , 5 , 2 0 ) ;

and we test the boundary conditions by constructing functions which we can plot
to see if we obtain the requested boundary behavior. We define functions bottom,
bottomprime, right and left for these checks. We will leave it to you to verify
that we are indeed satisfying the boundary conditions. Note since the approximations
are built from functions that satisfy the x boundary conditions, the left and right
functions are guaranteed to work.

Listing 10.12: Testing the boundary conditions


bottom = @( x ) p ( x , 0 ) ;
bottomprime = @( x ) pd2 ( x , 0 ) ;
l e f t = @( t ) p ( 0 , t ) ;
r i g h t = @( t ) p ( 5 , t ) ;
5 x = linspace (0 ,5 ,21) ;
time = l i n s p a c e ( 0 , 1 0 , 4 1 ) ;
f o r i =1:21
> ysaw ( i ) = saw ( x ( i ) ) ;
> end
10 p l o t ( x , ysaw , x , bottom ( x ) ) ;
p l o t ( x , bottomprime ( x ) ) ;
p l o t ( time , r i g h t ( t i m e ) ) ;
p l o t ( time , l e f t ( t i m e ) ) ;

10.2.1.2 Neumann Boundary Conditions

A Wave equation with Neumann boundary conditions has the following form:

∂2 ∂2
− c2 2 =0
∂t 2 ∂x
(x, 0) = f (x), for 0 ≤ x ≤ L
∂
(x, 0) = 0, for 0 ≤ x ≤ L
∂t
∂
(0, t) = 0, for 0 ≤ t
∂x
∂
(L, t) = 0, for 0 ≤ t
∂x
Applying separation of variables, we let (x, t) = u(x)w(t) and find

c2 u − n u = 0, for 0 ≤ x ≤ L
338 10 Linear Partial Differential Equations

u (0) = 0,
u (L) = 0.
w  − n w = 0, for t ≥ 0,
w  (0) = 0.
 2
where the separation constants are again n = − nπc L
for n = 0, 1, . . .. The
 
boundary conditions on x lead to the solutions un (x) = cos nπL
x and wn (t) =
 
cos nπc
L
t . The infinite series solution is then


    
nπ nπc
(x, t) = A0 + An cos x cos t .
n=1
L L

Hence, to satisfy the last boundary condition, we must have



  

(x, 0) = A0 + An cos x
n=1
L

  

= f (x) = B0 + Bn cos x ,
n=1
L
 
L L
where B0 = 1
L 0 f (s) dsn and for n > 1, Bn = 2
L 0 f (s) cos nπ
L
s ds. This tells
us we choose the constants (An ) so that An = Bn . The code to compute this approxi-
mation is quite similar to what we did in the code for WaveDirichletApprox.
This code is named WaveNeumannApprox. Since we are using Neumann bound-
ary conditions, the series expansions are in terms of cos functions this time. There
are a few changes in the calculations. We return N + 1 coefficients when we call
FourierCosineApprox.

Listing 10.13: Get fourier cosine approximations


% Get F o u r i e r C osine Approximation t o f f o r N terms
% r e t u r n s A( 1 ) = ( 1 /L ) < f ( x ) , 1>
% A( 2 ) = ( 2 /L ) < f ( x ) , c o s ( p i x /L>
[ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L1 ,M,N) ;

The call to SetUpCosines also returns N + 1 cos functions rather than N handles.
We also set up N + 1 cos functions of time as well.
10.2 Fourier Series Approximate Methods 339

Listing 10.14: Setup cosine functions


% Get Cosine F u n c t i o n s
% r e t u r n s u {1} = 1 , u {2} = c o s ( p i x /L ) e t c
u = S e t U p C o s i n e s ( L1 ,N) ;

5 % Get t h e c o s f u n c t i o n s
v = c e l l (N+1 ,1) ;
v {1} = @( t ) 1 ;
f o r i = 2 :N+1
v{ i } = @( t ) c o s ( ( i −1) ∗ p i ∗ c ∗ t /L1 ) ;
10 end

Finally, we set up the approximation as we did before.

Listing 10.15: Setup approximation solution


% Construct the approximate s o l u t i o n
p = @( x , t ) 0 ;
f o r i =1:N+1
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
5 end

The full listing is given below.

Listing 10.16: WaveNeumannApprox


f u n c t i o n p = WaveNeumannApprox ( f , c ,M, N, nx , nt , L1 , L2 )
% f i s t h e boundary data
% M i s t h e number o f t e r m s i n t h e Riemann sum a p p r o x i m a t i o n s
% to the inner products
5 % N i s t h e number o f t e r m s i n t h e s e r i e s a p p r o x i m a t i o n t o t h e
% solution
% nx i s t h e number o f p o i n t s t o u s e i n t h e s u r f a c e p l o t f o r x
% n t i s t h e number o f p o i n t s t o u s e i n t h e s u r f a c e p l o t f o r t
% L1 i s t h e l e n g t h o f t h e x i n t e r v a l
10 % L2 i s t h e l e n g t h o f t h e t i n t e r v a l
%
% S o l v e u t t − c ˆ2 U xx u = 0 on [ 0 , L ] x [ 0 , L ]
%
% ( 0 , L2 )−−−−−−−−−−−−−−−−−−−−(L1 , L2 )
15 % | |
% | |
% u x ( 0 , t ) =0 | | u x ( L1 , t ) = 0
% | |
% | |
20 % ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
% u t (x ,0) = 0
%
% Separation of v a r i a b l e s giv es s o l u t i o n i s
25 % u(x , t ) = A 0 +
% sum {n=1}ˆ{ i n f i n i t y } A n c o s ( n p i x / L1 ) c o s ( n p i c t / L1 )
%
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Sine
% c o e f f i c i e n t s o f f on [ 0 , L ]
30 %
% A 0 = ( 1 / L1 ) <f , 1>
% A n = ( 2 / L1 ) <f , s i n ( n p i x /L1>
%
% Get F o u r i e r C o s i n e A p p r o x i m a t i o n t o f f o r N t e r m s
35 % r e t u r n s A( 1 ) = ( 1 / L ) < f ( x ) , 1>
% A( 2 ) = ( 2 / L ) < f ( x ) , c o s ( p i x /L>
[ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L1 ,M,N) ;

% Get C o s i n e F u n c t i o n s
340 10 Linear Partial Differential Equations

40 % r e t u r n s u {1} = 1 , u {2} = c o s ( p i x /L ) e t c
u = S e t U p C o s i n e s ( L1 ,N) ;

% Get t h e c o s f u n c t i o n s
v = c e l l (N+1 ,1) ;
45 v{1} = @( t ) 1 ;
f o r i = 2 :N+1
v{ i } = @( t ) c o s ( ( i −1)∗ p i ∗ c ∗ t /L1 ) ;
end

50 % Construct the approximate s o l u t i o n


p = @( x , t ) 0 ;
f o r i =1:N+1
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end
55
%
% draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
x = l i n s p a c e ( 0 , L1 , nx ) ;
60 t = l i n s p a c e ( 0 , L2 , n t ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
[ X, T ] = m e s h g r i d ( x , t ) ;
% s e t up s u r f a c e
Z = p (X, T) ;
65
%p l o t s u r f a c e
figure
mesh (X, T , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
70 y l a b e l ( ’t axis ’ ) ;
z l a b e l ( ’ Wave Solution ’ ) ;
t i t l e ( ’ Wave Neumann S olution on Rectangle ’ ) ;
p r i n t −dpng ’ W a v e N e u m a n n . png ’ ;

75 end

Using a sawtooth curve as the data f , we generate the approximation solution with a
few lines of code.

Listing 10.17: Testing on saw data


L = 5;
H = 10;
saw = s a w t o o t h ( L ,H) ;
c = 1;
5 p = WaveNeumannApprox ( saw , c , 5 0 0 , 5 , 2 1 , 4 1 , 5 , 2 0 ) ;

The surface approximation can be seen in Fig. 10.2.


We can again check to see if the boundary conditions are satisfied by adding a
few lines of code. To the function WaveNeumannApprox, we can calculate the
approximations to ∂∂x
and ∂
∂t
as before and return them as the functions pd1 and
pd2. The first line of the function becomes

Listing 10.18: Altering WaveNeumannApprox to return partial information


function [ p , pd1 , pd2 ] = WaveNeumannApprox ( f , c ,M, N, nx , nt , L1 , L2 )

and we add lines similar to what we did before to handle the partial derivative
approximations.
10.2 Fourier Series Approximate Methods 341

Fig. 10.2 5 term Fourier series approximation to the wave equation with sawtooth wave data and
Neumann boundary conditions

Listing 10.19: Setting up the partial derivative approximations


% Get Cosine F u n c t i o n s
% r e t u r n s u {1} = 1 , u {2} = c o s ( p i x /L ) e t c
u = S e t U p C o s i n e s ( L1 ,N) ;
4
% Get t h e c o s d e r i v a t i v e f u n c t i o n s
up = c e l l (N+1 ,1) ;
up {1} = @( x ) 0 ;
f o r i = 2 :N+1
9 up{ i } = @( x ) − ( ( ( i −1) ∗ p i ∗ c ) /L1 ) ∗ s i n ( ( i −1) ∗ p i ∗ c ∗x/L1 ) ;
end

% Get t h e c o s f u n c t i o n s
v = c e l l (N+1 ,1) ;
14 v {1} = @( t ) 1 ;
f o r i = 2 :N+1
v{ i } = @( t ) c o s ( ( i −1) ∗ p i ∗ c ∗ t /L1 ) ;
end

19 % Get t h e c o s d e r i v a t i v e f u n c t i o n s
vp = c e l l (N+1 ,1) ;
vp {1} = @( t ) 0 ;
f o r i = 2 :N+1
vp { i } = @( t ) −(( i ∗ p i ∗ c ) /L1 ) ∗ s i n ( i ∗ p i ∗ c ∗ t /L1 ) ;
24 end

% Construct the approximate s o l u t i o n


p = @( x , t ) 0 ;
f o r i =1:N+1
29 p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

% Construct the approximate s o l u t i o n f o r pd1 :


% p a r t i a l o f p w r t argument 1
342 10 Linear Partial Differential Equations

34 pd1 = @( x , t ) 0 ;
f o r i =1:N+1
pd1 = @( x , t ) ( pd1 ( x , t ) + A( i ) ∗up{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

39 % C o n s t r u c t t h e a p p r o x i m a t e s o l u t i o n f o r pd2 :
% p a r t i a l o f p w r t argument 2
pd2 = @( x , t ) 0 ;
f o r i =1:N+1
pd2 = @( x , t ) ( pd2 ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ vp { i } ( t ) ) ;
44 end

You can alter the code to add these checks easily if you want. When we run the code
using the sawtooth function like before, we use

Listing 10.20: Solving and returning the partial information


1 p , pd1 , pd2 ] = WaveNeumannApprox ( saw , c , 5 0 0 , 5 , 2 1 , 4 1 , 5 , 2 0 ) ;

and we test the boundary conditions by constructing functions which we can plot to
see if we obtain the requested boundary behavior. We define the functions bottom,
bottomprime, right and left for these checks as we did for the Dirichlet data
and perform the check as usual.

10.2.2 Laplace’s Equation

Now let’s look at approximations to Laplace’s equation on the rectangle [0, L1] ×
[0, L2].

10.2.2.1 Dirichlet Boundary Conditions

We solve a problem of this form

∂2 ∂2
+ =0
∂x 2 ∂y2
(0, y) = 0, for 0 ≤ y ≤ L1
(L1, y) = 0, for 0 ≤ y ≤ L2
(x, L2) = 0, for 0 ≤ x ≤ L1
(x, 0) = f (x), for 0 ≤ x ≤ L1
10.2 Fourier Series Approximate Methods 343

We assume a solution of the form (x, y) = u(x) w(y). This leads to

u − n u = 0, for 0 ≤ x ≤ L1,


u(0) = 0,
u(L1) = 0,
w  + n w = 0, for 0 ≤ y ≤ L2,
w(L2) = 0.
 2
where the separation constants are n = − nπ L1
for n = 1, 2, . . .. The boundary
  
conditions on x lead to the solutions un (x) = sin nπ
L1
x and w n (y) = sinh nπ
L1
(L2 −

y) . The infinite series solution is then


    
nπ nπ
(x, y) = An sin x sinh (L2 − y) .
n=1
L1 L1

Hence, to satisfy the last boundary condition, we must have



  

(x, 0) = An sin x sinh(nπ)
n=1
L1

  

= f (x) = Bn sin x ,
n=1
L1
 
 L1
where Bn = 2
L1 0 f (s) sin nπ
L1
s ds. This tells us we choose the constants (An )
so that An = Bn  . The function we will use to approximate this solution is
nπL2
sinh L1

LaplaceDirichletApprox whose calling signature is similar to the ones we


used in the approximations to the Wave equation.

Listing 10.21: LaplaceDirichletApprox arguments


f u n c t i o n p = L a p l a c e D i r i c h l e t A p p r o x ( f ,M, N, nx , ny , L1 , L2 )
344 10 Linear Partial Differential Equations

We have added the arguments nx and ny that are the number of x and y points to use
in the surface plot of the approximate solution. The code to build the approximation
is similar. First, we get the Fourier sine coefficients of the boundary data function
f and then we create the handles to the component sin and sinh functions. Finally,
when we construct the function p which
 is the approximate solution, we scale the

nπL2
individual terms by the needed sinh L1
terms.

Listing 10.22: Build approximation solution


% Get F o u r i e r S i n e Approximation t o f f o r N terms
% r e t u r n s ( 2 / L1 ) <f , u n>
[ A, fN ] = F o u r i e r S i n e A p p r o x ( f , L1 ,M,N) ;

5 % Get S i n e F u n c t i o n s
u = S e t U p S i n e s ( L1 ,N) ;

% Get t h e s i n h f u n c t i o n s
v = c e l l (N, 1 ) ;
10 f o r i = 1 :N
v{ i } = @( y ) s i n h ( i ∗ p i ∗ ( L2−y ) /L1 ) ;
end

% Construct the approximate s o l u t i o n


15 % g e t Nth F o u r i e r S i n e Approximati on
p = @( x , y ) 0 ;
f o r i =1:N
p = @( x , y ) ( p ( x , y ) + (A( i ) / s i n h ( i ∗ p i ∗L2/L1 ) ) ∗u{ i } ( x ) . ∗ v{ i } ( y ) )
;
end

The full code is listed below.

Listing 10.23: LaplaceDirichletApprox


1 f u n c t i o n p = L a p l a c e D i r i c h l e t A p p r o x ( f ,M, N, nx , ny , L1 , L2 )
%
% S o l v e g r a d ˆ2 u = 0 on [ 0 , L1 ] x [ 0 , L2 ]
% u ( x , L2 ) = 0
% ( 0 , L2 )−−−−−−−−−−−−−−−−−−−−(L1 , L2
6 % | |
% | |
% u ( 0 , y ) =0 | | u ( L1 , y ) = 0
% | |
% | |
11 % ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
%
% Separation of v a r i a b l e s gives s o l u t i o n i s
% u(x , y) =
16 % sum {n=1}ˆ{ i n f i n i t y } A n s i n ( n p i x / L1 ) s i n h ( n p i ( L2−y ) / L1 )
%
10.2 Fourier Series Approximate Methods 345

% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Sine


% c o e f f i c i e n t s o f f on [ 0 , L1 ] d i v i d e d b y s i n h ( n p i )
%
21 % A n = 2∗< f ( y ) , s i n ( n p i y / L1 )> / ( L1 s i n h ( n p i L2 / L1 ) )
%
% Get F o u r i e r S i n e A p p r o x i m a t i o n t o f f o r N t e r m s
% r e t u r n s ( 2 / L1 ) <f , u n>
[ A, fN ] = F o u r i e r S i n e A p p r o x ( f , L1 ,M,N) ;
26
% Get S i n e F u n c t i o n s
u = S e t U p S i n e s ( L1 ,N) ;

% Get t h e s i n h f u n c t i o n s
31 v = c e l l (N, 1 ) ;
f o r i = 1 :N
v{ i } = @( y ) s i n h ( i ∗ p i ∗ ( L2−y ) /L1 ) ;
end

36 % Construct the approximate s o l u t i o n


% g e t Nth F o u r i e r S i n e A p p r o x i m a t i o n
p = @( x , y ) 0 ;
f o r i =1:N
p = @( x , y ) ( p ( x , y ) + (A( i ) / s i n h ( i ∗ p i ∗L2/L1 ) ) ∗u{ i } ( x ) . ∗ v{ i } ( y ) ) ;
41 end

%
% draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
46 x = l i n s p a c e ( 0 , L1 , nx ) ;
y = l i n s p a c e ( 0 , L2 , ny ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , y ( j ) )
[ X,Y] = m e s h g r i d ( x , y ) ;
% s e t up s u r f a c e
51 Z = p (X,Y) ;

%p l o t s u r f a c e
figure
mesh (X, Y, Z , ’ EdgeColor ’ , ’ black ’ ) ;
56 x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’y axis ’ ) ;
z l a b e l ( ’ Laplace Solution ’ ) ;
t i t l e ( ’ Laplace Dirichlet Solution on Rectangle ’ ) ;
p r i n t −dpng ’ L a p l a c e D i r i c h l e t . png ’ ;
61
end

Let’s look at how we use this function. We construct a square wave data function and
then solve Laplace’s equation on the rectangle.

Listing 10.24: A sample solution with 10 terms


L1 = 5 ;
L2 = 1 0 ;
3 f = @( x ) 1 0 ;
g = @( x ) 0 ;
Sq = @( x ) s p l i t f u n c ( x , f , g , L1 ) ;
p = L a p l a c e D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 1 0 , 4 1 , 5 1 , L1 , L2 ) ;
346 10 Linear Partial Differential Equations

Fig. 10.3 10 term Fourier series approximation to Laplace’s equation with square wave data and
Dirichlet boundary conditions

The returned function p(x, y) is the approximation to our model with the generated
surface shown in Fig. 10.3.
We can do a better job by using more terms as is shown next. This time we use 20
terms. The resulting surface plot is better as is seen in Fig. 10.4.

Fig. 10.4 20 term Fourier series approximation to Laplace’s equation with square wave data and
Dirichlet boundary conditions
10.2 Fourier Series Approximate Methods 347

Listing 10.25: A sample solution with 20 terms


p = L a p l a c e D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 4 1 , 5 1 , 2 0 , L1 , L2 ) ;

10.2.2.2 Neumann Boundary Conditions

We next solve a Laplace model with Neumann conditions.

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ L
∂x
∂
(L, y) = 0, for 0 ≤ y ≤ L
∂x
(x, L) = 0, for 0 ≤ x ≤ L
(x, 0) = f (x), for 0 ≤ x ≤ L

We assume a solution of the form (x, y) = u(x) w(y). This leads to

u − n u = 0, for 0 ≤ x ≤ L1,


u (0) = 0,

u (L1) = 0,

w + n w = 0, for 0 ≤ y ≤ L2,
w(L2) = 0.
 2
where the separation constants are n = − nπ L1
for n = 0, 1, 2, . . .. The boundary
  
conditions on x lead to the solutions un (x) = cos L1 x and wn (y) = sinh nπ

L1
(L2 −

y) . The infinite series solution is then

  ∞
    
L2 − y nπ nπ
(x, y) = A0 + An cos x sinh (L2 − y) .
L2 n=1
L1 L1

Hence, to satisfy the last boundary condition, we must have



    
nπ nπL2
(x, 0) = A0 + An sin x sinh
n=1
L1 L1
348 10 Linear Partial Differential Equations


  

= f (x) = B0 + Bn cos x ,
n=1
L1
 
 L1
where B0 = 1
L1
and for n ≥ 1, Bn = 2
L1 0 f (s) cos nπ
L1
s ds. This tells us we
choose the constants A0 = B0 and for n ≥ 1, (An ) so that An = Bn  . The
nπL2
sinh L1

function we will use to approximate this solution is LaplaceNeumannApprox.

Listing 10.26: LaplaceNeumannApprox arguments


f u n c t i o n p = LaplaceNeumannApprox ( f ,M, N, nx , ny , L1 , L2 )

The full source code is shown below.

Listing 10.27: LaplaceNeumannApprox


f u n c t i o n p = LaplaceNeumannApprox ( f ,M, N, nx , ny , L1 , L2 )
%
% S o l v e g r a d ˆ2 u = 0 on [ 0 , L1 ] x [ 0 , L2 ]
4 % u ( x , L2 ) = 0
% ( 0 , L2 )−−−−−−−−−−−−−−−−−−−−(L1 , L2 )
% | |
% | |
% u x ( 0 , y ) =0 | | u x ( L1 , y ) = 0
9 % | |
% | |
% ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
%
14 % Separation of v a r i a b l e s giv es s o l u t i o n i s
% u ( x , y ) = A 0 (1 − y / L2 )+
% sum {n=1}ˆ{ i n f i n i t y } A n c o s ( n p i x / L1 ) s i n h ( ( n p i / L1 ) ( L2− y ) )
%
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Sine
19 % c o e f f i c i e n t s o f f on [ 0 , L1 ] d i v i d e d b y s i n h ( n p i L2 / L1 )
%
% A 0 = <f ,1>/L1
% A n = 2∗<f , c o s ( n p i x / L1 )> / ( L1 s i n h ( n p i L2 / L1 )
%
24 % Get F o u r i e r C o s i n e A p p r o x i m a t i o n t o f f o r N+1 t e r m s
[ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L1 ,M,N) ;

% Get C o s i n e F u n c t i o n s
u = S e t U p C o s i n e s ( L1 ,N) ;
29
% Get t h e y f u n c t i o n s
v = c e l l (N+1 ,1) ;
v{1} = @( y ) 1 − y / L2 ;
f o r i = 2 :N+1
34 v{ i } = @( y ) s i n h ( ( i −1)∗ p i ∗ ( L2−y ) /L1 ) ;
end

% Construct the approximate s o l u t i o n


% g e t (N+1) t h A p p r o x i m a t i o n t o PDE s o l u t i o n
10.2 Fourier Series Approximate Methods 349

39 c = A( 1 ) ;
p = @( x , y ) c ;
for i =2:N+1
d = s i n h ( ( i −1)∗ p i ∗L2/L1 ) ;
p = @( x , y ) ( p ( x , y ) + (A( i ) / d ) ∗u{ i } ( x ) . ∗ v{ i } ( y ) ) ;
44 end

%
% draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
49 x = l i n s p a c e ( 0 , L1 , nx ) ;
y = l i n s p a c e ( 0 , L2 , ny ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , y ( j ) )
[ X,Y] = m e s h g r i d ( x , y ) ;
% s e t up s u r f a c e
54 Z = p (X,Y) ;

%p l o t s u r f a c e
figure
mesh (X, Y, Z , ’ EdgeColor ’ , ’ black ’ ) ;
59 x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’y axis ’ ) ;
z l a b e l ( ’ Laplace Solution ’ ) ;
t i t l e ( ’ Laplace Neumann Solution on Square ’ ) ;
p r i n t −dpng ’ L a p l a c e N e u m a n n . png ’ ;
64
end

Next, we approximate the solution to the Laplace Neumann model for square wave
boundary data using 5 terms.

Listing 10.28: Sample solution with 5 terms


p = LaplaceNeumannApprox ( Saw , 5 0 0 , 5 , 3 1 , 4 1 , 5 , 1 0 ) ;

In this approximation, we generate the surface shown in Fig. 10.5.

Fig. 10.5 5 term Fourier series approximation to Laplace’s equation with square wave data and
Neumann boundary conditions
350 10 Linear Partial Differential Equations

10.2.3 The Heat Equation

Next, we consider heat equations on a rectangle.

10.2.3.1 Dirichlet Boundary Conditions

The problem we want to solve is

∂ ∂2
−D =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(L, t) = 0, for 0 < t
(x, 0) = f (x), for 0 < x < L1

We assume a solution of the form (x, y) = u(x) w(t). This leads to

D u − n u = 0, for 0 ≤ x ≤ L1,


u(0) = 0,
u(L1) = 0,

w − n w = 0, for 0 ≥ t,

 2
where the separation constants are n = −D for n = 1, 2, . . .. The boundary

L1
 
conditions on x lead to the solutions un (x) = sin nπ
L1
x and wn (t) = e−n t . The
infinite series solution is then
 2

  
−D nπ
t
nπ L1
(x, t) = An sin x e .
n=1
L1

Hence, to satisfy the last boundary condition, we must have



  

(x, 0) = An sin x
n=1
L1

  

= f (x) = Bn sin x ,
n=1
L1
10.2 Fourier Series Approximate Methods 351
 
 L1
where Bn = 2
L1 0 f (s) sin nπ
L1
s ds. This tells us we choose the constants
(An ) so that An = Bn . The function we will use to approximate this solution is
HeatDirichletApprox whose calling signature is similar to the ones we have
used before in the earlier models. The full code is listed below.

Listing 10.29: HeatDirichletApprox


f u n c t i o n p = H e a t D i r i c h l e t A p p r o x ( f ,M, N, nx , nt , D, L1 , L2 )
%
% S o l v e u t −D u { x x } = 0 on [ 0 , L1 ] x [ 0 , L2 ]
%
5 % ( 0 , t )−−−−−−−−−−−−−−−−−−−−(L1 , t )
% | |
% | |
% u ( 0 , t ) =0 | | u (L , t ) = 0
% | |
10 % | |
% ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
%
% Separation of v a r i a b l e s gives s o l u t i o n i s
15 % u(x , y) =
% sum {n=1}ˆ{ i n f i n i t y } A n s i n ( n p i x / L1 ) e x p ( −D n ˆ2 p i ˆ2 t /L ˆ 2 )
%
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Sine
% c o e f f i c i e n t s o f f on [ 0 , L1 ]
20 %
% A n = 2∗< f ( y ) , s i n ( n p i y / L1 )>
%
% Get F o u r i e r S i n e A p p r o x i m a t i o n t o f f o r N t e r m s
[ A, fN ] = F o u r i e r S i n e A p p r o x ( f , L1 ,M,N) ;
25
% Get S i n e F u n c t i o n s
u = S e t U p S i n e s ( L1 ,N) ;

% Get t h e e x p f u n c t i o n s
30 v = c e l l (N, 1 ) ;
f o r i = 1 :N
v{ i } = @( t ) exp ( −D∗ i ˆ2∗ p i ˆ2∗ t /L1 ˆ 2 ) ;
end

35 % Construct the approximate s o l u t i o n


% g e t Nth F o u r i e r S i n e A p p r o x i m a t i o n
p = @( x , t ) 0 ;
f o r i =1:N
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
40 end

%
% draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
45 x = l i n s p a c e ( 0 , L1 , nx ) ;
t = l i n s p a c e ( 0 , L2 , n t ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
[ X, T ] = m e s h g r i d ( x , t ) ;
% s e t up s u r f a c e
50 Z = p (X, T) ;

%p l o t s u r f a c e
figure
mesh (X, T , Z , ’ EdgeColor ’ , ’ black ’ ) ;
352 10 Linear Partial Differential Equations

55 x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’t axis ’ ) ;
z l a b e l ( ’ Heat Solution ’ ) ;
t i t l e ( ’ Heat Dirichlet Solution on Square ’ ) ;
p r i n t −dpng ’ H e a t D i r i c h l e t . png ’ ;
60
end

Let’s look a quick test of this function to solve the Heat equation using square wave
data. We set the diffusion constant to D = 0.02 and solve the model over 80 time
units. Note we use a relatively coarse gridding strategy for the plot; nx = 41 and
nt = 121. The decay of the solution is quite slow and unless we plot it over a long
time interval, we don’t see much change.

Listing 10.30: Sample solution with 10 terms


L1 = 5 ;
f = @( x ) 1 0 ;
g = @( x ) 0 ;
4 Sq = @( x ) s p l i t f u n c ( x , f , g , L1 ) ;
p = H e a t D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 1 0 , 4 1 , 1 2 1 , . 0 2 , L1 , 8 0 ) ;

The returned function p(x, t) is the approximation to our model with the generated
surface shown in Fig. 10.6.
We can also solve the heat equation using pulse data. Recall, a rectangular pulse
centered at x0 of width r and height H on the interval [0, L] has the form

Fig. 10.6 10 term Fourier series approximation to the heat equation with square wave data and
Dirichlet boundary conditions
10.2 Fourier Series Approximate Methods 353

⎨ 0, 0 ≤ x ≤ x0 − r,
J(x) = H, x0 − r < x < x0 + r,

0, x0 + r ≤ x ≤ L

which we coded in the function pulsefunc.

Listing 10.31: pulsefunc


f u n c t i o n z = p u l s e f u n c ( x , x0 , r ,H)
%
i f x > x0−r && x < x0+r
z = H;
5 else
z = 0;
end

It is then easy to approximate the solution to the heat equation with a data pulse of
height 100 at location 1 of width 0.2. As you would expect, we need more terms in
the Fourier series to approximate this pulse reasonably well. Hence, we are using 40
terms here.

Listing 10.32: Sample solution with 40 terms


p u l s e = @( x ) p u l s e f u n c ( x , 2 , . 2 , 1 0 0 ) ;
p = H e a t D i r i c h l e t A p p r o x ( p u l s e , 5 0 0 , 4 0 , 3 1 , 2 2 1 , . 0 0 0 2 , L1 , 8 0 0 ) ;

The returned function p(x, t) is shown in Fig. 10.7.

Fig. 10.7 40 term Fourier series approximation to the heat equation with pulse data and Dirichlet
boundary conditions
354 10 Linear Partial Differential Equations

10.2.3.2 Neumann Boundary Conditions

The problem we want to solve is

∂ ∂2
−D = 0
∂t ∂x 2
∂
(0, t) = 0, for 0 < t
∂x
∂
(L, t) = 0, for 0 < t
∂x
(x, 0) = f (x), for 0 < x < L1

We assume a solution of the form (x, y) = u(x) w(t). This leads to

D u − n u = 0, for 0 ≤ x ≤ L1,


u (0) = 0,
u (L1) = 0,
w  − n w = 0, for 0 ≥ t,

 2
where the separation constants are n = −D for n = 0, 1, 2, . . .. The bound-

L1
 
ary conditions on x lead to the solutions u0 (x) = 1 and un (x) = cos nπL1
x for n ≥ 1.
The solutions for t are then w0 (t) = 1 and wn (t) = e−n t for n ≥ 1. The infinite
series solution is then
 2
∞   −D nπ t
nπ L1
(x, t) = A0 + An cos x e .
n=1
L1

Hence, to satisfy the last boundary condition, we must have



  

(x, 0) = A0 + An cos x
n=1
L1

  

= f (x) = B0 + Bn cos x ,
n=1
L1
 
 L1
where B0 = 1
L
and Bn = 2
L1 0 f (s) cos nπ
L1
s ds for n ≥ 1; hence, (An )
so that An = Bn . The function we will use to approximate this solution is
10.2 Fourier Series Approximate Methods 355

HeatNeumannApprox whose calling signature is similar to the ones we have


used before in the earlier models. The full code is listed below.

Listing 10.33: HeatNeumannApprox


f u n c t i o n p = HeatNeumannApprox ( f ,M, N, nx , nt , D, L1 , L2 )
%
% S o l v e u t −D u { xx } = 0 on [ 0 , L1 ] x [ 0 , L2 ]
%
5 % ( 0 , t )−−−−−−−−−−−−−−−−−−−−(L1 , t )
% | |
% | |
% u x ( 0 , t ) =0 | | u x (L , t ) = 0
% | |
10 % | |
% ( 0 , 0 )−−−−−−−−−−−−−−−−−−−−(L1 , 0 )
% u(x ,0) = f (x)
%
% Separation of v a r i a b l e s giv es s o l u t i o n i s
15 % u(x , y) = A 0 +
% sum {n=1}ˆ{ i n f i n i t y } A n c o s ( n p i x /L ) e x p ( −D n ˆ2 p i ˆ2 t /L ˆ 2 )
%
% where t h e c o e f f i c i e n t s A n are t h e F o u r i e r Cosine
% c o e f f i c i e n t s o f f on [ 0 , L ]
20 %
% A 0 = <f ,1>/L
% A n = 2∗<f , c o s ( n p i x /L )>
%
% Get F o u r i e r C o s i n e A p p r o x i m a t i o n t o f f o r N+1 t e r m s
25 [ A, fN ] = F o u r i e r C o s i n e A p p r o x ( f , L1 ,M,N) ;

% Get C o s i n e F u n c t i o n s
u = S e t U p C o s i n e s ( L1 ,N) ;

30 % Get t h e e x p f u n c t i o n s
v = c e l l (N+1 ,1) ;
v{1} = @( t ) 1 ;
f o r i = 2 :N+1
v{ i } = @( t ) exp ( −D∗ i ˆ2∗ p i ˆ2∗ t /L1 ˆ 2 ) ;
35 end

% Construct the approximate s o l u t i o n


% g e t (N+1) t h A p p r o x i m a t i o n t o PDE s o l u t i o n
p = @( x , t ) 0 ;
40 f o r i =1:N+1
p = @( x , t ) ( p ( x , t ) + A( i ) ∗u{ i } ( x ) . ∗ v{ i } ( t ) ) ;
end

%
45 % draw s u r f a c e f o r g r i d [ 0 , L1 ] x [ 0 , L2 ]
% s e t up x and y s t u f f
x = l i n s p a c e ( 0 , L1 , nx ) ;
t = l i n s p a c e ( 0 , L2 , n t ) ;
% s e t up g r i d o f x and y p a i r s ( x ( i ) , t ( j ) )
50 [ X, T ] = m e s h g r i d ( x , t ) ;
% s e t up s u r f a c e
Z = p (X, T) ;

%p l o t s u r f a c e
55 figure
mesh (X, T , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’x axis ’ ) ;
y l a b e l ( ’t axis ’ ) ;
z l a b e l ( ’ Laplace Solution ’ ) ;
60 t i t l e ( ’ Laplace Neumann Solution on Square ’ ) ;
p r i n t −dpng ’ H e a t N e u m a n n . png ’ ;

end
356 10 Linear Partial Differential Equations

As an example, let’s solve the heat equation using multiple pulse data. The function
pulsefunc(x,x0,r,H) gives us a rectangular pulse centered at x0 of width r
and height H on any interval. For convenience, denote such a pulse of height 1 by the
function P(x0 , r). Then a pulse of height H is simply HP(x0 , r). We now apply two
pulses, 100P(2, 0.3) and 200P(4, 0.1) as boundary data. Since this boundary data is
more complicated, let’s look at it Fourier cosine approximations first. We generate
this pulse with the code

Listing 10.34: Two pulses


p1 = @( x ) p u l s e f u n c ( x , 2 , . 3 , 1 0 0 ) ;
p2 = @( x ) p u l s e f u n c ( x , 4 , . 1 , 2 0 0 ) ;
p u l s e = @( x ) p1 ( x ) + p2 ( x ) ;

and we compute the Fourier cosine approximations as usual with these lines. Recall
the line FourierCosineApprox(pulse,5,100,5); is setting the number
of terms in the Riemann sum approximations to the inner product calculations to
100, the interval to [0, 5] and the number of Fourier terms to 6. Hence, we gener-
ate approximations all the way to 1400 Riemann sum terms and 61 Fourier cosine
coefficients.

Listing 10.35: Fourier cosine approximation to the double pulse


[ A, p ] = FourierCosineApprox ( pulse ,5 ,100 ,5) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,100 ,10) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,100 ,20) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,100 ,40) ;
5 [ A, p ] = FourierCosineApprox ( pulse ,5 ,100 ,60) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,400 ,60) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,800 ,60) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,1200 ,60) ;
[ A, p ] = FourierCosineApprox ( pulse ,5 ,1400 ,60) ;

We show the approximation we will use in our approximation of the heat model in
Fig. 10.8 which uses 41 Fourier coefficients and 500 terms in the Riemann sum.
Then, we can approximate the solution to the heat model for a diffusion coefficient
D = 0.0002 over 300 time units.
Linear Partial Differential Equations!the Heat equation with Neumann BC: a
sample solution with 40 terms for two pulses

Listing 10.36: Sample solution with 40 terms


1 p u l s e = @( x ) p u l s e f u n c ( x , 2 , . 2 , 1 0 0 ) ;
L1 = 5 ;
p = HeatNeumannApprox ( p u l s e , 5 0 0 , 4 0 , 3 1 , 1 2 1 , . 0 0 0 2 , L1 , 3 0 0 ) ;

The returned function p(x, t) is shown in Fig. 10.9.


10.2 Fourier Series Approximate Methods 357

Fig. 10.8 41 term Fourier series approximation for dual pulse data

Fig. 10.9 41 term Fourier series approximation to the heat equation with dual pulse data and
Neumann boundary conditions

10.2.3.3 Homework

Exercise 10.2.1 Solve the Heat equation using square wave data (L1 = 4) with the
diffusion constant to D = 0.0004. Solve the model over an appropriate length of
358 10 Linear Partial Differential Equations

time using a the gridding strategy you think is good. Use the split function as coded
below.
Listing 10.37: Sample session
L1 = 4 ;
2 f = @( x ) 2 0 ;
g = @( x ) 0 ;
Sq = @( x ) s p l i t f u n c ( x , f , g , L1 ) ;
% Here we u s e N = 5 0 0 , nx = 10 and n t = 41 b u t e x p e r i m e n t w i t h
% different choices
7 p = H e a t D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 1 0 , 4 1 , 1 2 1 , . 0 2 , L1 , 8 0 ) ;

Experiment with a variety of gridding strategies and the length of time until you get
a good plot of the decay of the solution.
Exercise 10.2.2 Solve the Heat equation using square wave data (L1 = 14) with
the diffusion constant to D = 0.4. Solve the model over an appropriate length of
time using a the gridding strategy you think is good. Use the split function as coded
below.

Listing 10.38: Sample session


L1 = 4 ;
f = @( x ) 8 0 ;
3 g = @( x ) 0 ;
Sq = @( x ) s p l i t f u n c ( x , f , g , L1 ) ;
% Here we u s e N = 5 0 0 , nx = 10 and n t = 41 b u t e x p e r i m e n t w i t h
% different choices
p = H e a t D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 1 0 , 4 1 , 1 2 1 , . 0 2 , L1 , 8 0 ) ;

Experiment with a variety of gridding strategies and the length of time until you get
a good plot of the decay of the solution.

Exercise 10.2.3 Solve the Heat equation using square wave data (L1 = 4) with the
diffusion constant to D = 0.0004. Solve the model over an appropriate length of
time using a the gridding strategy you think is good. Use the split function as coded
below.

Listing 10.39: Sample session


L1 = 9 ;
f = @( x ) 0 ;
3 g = @( x ) 3 0 ;
Sq = @( x ) s p l i t f u n c ( x , f , g , L1 ) ;
% Here we u s e N = 5 0 0 , nx = 10 and n t = 41 b u t e x p e r i m e n t w i t h
% different choices
p = H e a t D i r i c h l e t A p p r o x ( Sq , 5 0 0 , 1 0 , 4 1 , 1 2 1 , . 0 2 , L1 , 8 0 ) ;

Experiment with a variety of gridding strategies and the length of time until you get
a good plot of the decay of the solution.
Reference 359

Reference

J. Peterson, BioInformation Processing: A Primer on Computational Cognitive Science. Springer


Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015 in press)
Chapter 11
Simplified Dendrite—Soma—Axon
Information Processing

Let’s review the basics of information processing in a typical neuron. There are
many first sources for this material; some of them are Introduction to Neurobiology
(Hall 1992), Ionic Channels of Excitable Membranes (Hille 1992), Foundations of
Cellular Neurophysiology (Johnston and Wu 1995)], Rall’s review of cable theory in
the 1977 Handbook of Physiology (Rall 1977) and Cellular Biophysics: Transport
and Electrical Properties (Weiss 1996a, b).
Our basic model consists of the following structural elements: A neuron which
consists of a dendritic tree (which collects sensory stimuli and sums this information
in a temporally and spatially dependent way), a cell body (called the soma) and an
output fiber (called the axon). Individual dendrites of the dendritic tree and the axon
are all modeled as cylinders of some radius a whose length  is very long compared
to this radius and whose walls are made of a bilipid membrane. The inside of each
cylinder consists of an intracellular fluid and we think of the cylinder as lying in a
bath of extracellular fluid. So for many practical reasons, we can model a dendritic
or axonal fiber as two concentric cylinders; an inner one of radius a (this is the actual
dendrite or axon) and an outer one with the extracellular fluid contained in the space
between the inner and outer membranes.
The potential difference across the inner membrane is essentially due to a balance
between the electromotive force generated by charge imbalance, the driving force
generated by charge concentration differences in various ions and osmotic pressures
that arise from concentration differences in water molecules on either side of the
membrane. Roughly speaking, the ions of importance in our simplified model are
the potassium K + , sodium Na+ and chloride Cl− ions. The equilibrium potential
across the inner membrane is about −70 millivolts and when the membrane potential
is driven above this rest value, we say the membrane is depolarized and when it is
driven below the rest potential, we say the membrane is hyperpolarized. The axon of
one neuron interacts with the dendrite of another neuron via a site called a synapse.
The synapse is physically separated into two parts: the presynaptic side (the side the
axon is on) and the postsynaptic side (the side the dendrite is on). There is an actual
physical gap, the synaptic cleft, between the two parts of the synapse. This cleft is
filled with extracellular fluid.
© Springer Science+Business Media Singapore 2016 361
J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_11
362 11 Simplified Dendrite—Soma—Axon Information Processing

If there is a rapid depolarization of the presynaptic site, a chain of events is initial-


ized which culminates in the release of specialized molecules called neurotransmit-
ters into the synaptic cleft. There are pores embedded in the postsynaptic membrane
whose opening and closing are dependent on the potential across the membrane that
are called voltage-dependent gates. In addition, the gates generally allow the passage
of a specific ion; so for example, there are sodium, potassium and chloride gates.
The released neurotransmitters bind with the sites specific for the Na+ ion. Such
sites are called receptors. Once bound, Na+ ions begin to flow across the membrane
into the fiber at a greater rate than before. This influx of positive ions begins to drive
the membrane potential above the rest value; that is, the membrane begins to depo-
larize. The flow of ions across the membrane is measured in gross terms by what
are called conductances. Conductance has the units of reciprocal ohms; hence, high
conductance implies high current flow per unit voltage. Thus the conductance of a
gate is a good way to measure its flow. We can say that as the membrane begins to
depolarize, the sodium conductance, gNa , begins to increase. This further depolarizes
the membrane. However, the depolarization is self-limited as the depolarization of
the membrane also triggers the activation of voltage-dependent gates for the potas-
sium ion, K + , which allow potassium ions to flow through the membrane out of the
cell. So the increase in the sodium conductance, gNa triggers a delayed increase in
potassium conductance, gK (there are also conductance effects due to chloride ions
which we will not mention here). The net effect of these opposite driving forces is
the generation of a potential pulse that is fairly localized in both time and space. It
is generated at the site of the synaptic contact and then begins to propagate down
the dendritic fiber toward the soma. As it propagates, it attenuates in both time and
space. We call these voltage pulses Post Synaptic Pulses or PSPs.
We model the soma itself as a small isopotential sphere, small in surface area
compared to the surface area of the dendritic system. The possibly attenuated values
of the PSPs generated in the dendritic system at various times and places are assumed
to propagate without change from any point on the soma body to the initial segment
of the axon which is called the axon hillock. This is a specialized piece of membrane
which generates a large output voltage pulse in the axon by a coordinated rapid
increase in gNa and gK once the axon hillock membrane depolarizes above a critical
trigger value. The axon itself is constructed in such a way that this output pulse,
called the action potential, travels without change throughout the entire axonal fiber.
Hence, the initial depolarizing voltage impulse that arrives at a given presynaptic site
is due to the action potential generated in the presynaptic neuron by its own dendritic
system.
The salient features of the ball stick model are thus:

• Axonal and dendritic fibers are modeled as two concentric membrane cylinders.
• The axon carries action potentials which propagate without change along the fiber
once they are generated. Thus if an axon makes 100 synaptic contacts, we assume
that the depolarizations of each presynaptic membrane are the same.
• Each synaptic contact on the dendritic tree generates a time and space localized
depolarization of the postsynaptic membrane which is attenuated in space as the
11 Simplified Dendrite—Soma—Axon Information Processing 363

pulse travels along the fiber from the injection site and which decrease in magnitude
the longer the time is since the pulse was generated.
• The effect of a synaptic contact is very dependent on the position along the dendritic
fiber that the contact is made—in particular, how far was the contact from the axon
hillock (i.e., in our model, how far from the soma)? Contacts made in essentially the
same space locality have a high probability of reinforcing each other and thereby
possibly generating a depolarization high enough to trigger an action potential.
• The effect of a synaptic contact is very dependent on the time at which the contact
is made. Contacts made in essentially the same time frame have a high probability
of reinforcing each other and thereby possibly generating a depolarization high
enough to trigger an action potential.

11.1 A Simple Model of a Dendrite: The Core Conductor


Model

We can model the above dendrite fiber reasonably accurately by using what is called
the core conductor model (see Fig. 11.1). We have gone over this before, but let’s
repeat it here so we can easily refer to it for this discussion. We assume the following:

Fig. 11.1 The dendrite fiber model


364 11 Simplified Dendrite—Soma—Axon Information Processing

• The dendrite is made up of two concentric cylinders. Both cylinders are bilayer
lipid membranes with the same electrical characteristics. There is conducting fluid
between both the inner and outer cylinder (extracellular solution) and inside the
inner cylinder (intracellular solution). These solutions are assumed homogeneous
and isotropic; in addition, Ohm’s law is valid within them.
• All electrical variables are assumed to have cylindrical symmetry; hence, all vari-
ables are independent of the traditional polar angle θ. In particular, currents in
the inner and outer fluids are longitudinal only (that is, up and down the dendritic
fiber). Finally, current through the membrane is always normal to the membrane
(that is the membrane current is only radial).
• A circuit theory description of currents and voltages is adequate for our model. At
a given position along the cylinder, the inner and outer conductors are at the same
potential (if you slice the cylinder at some point along its length perpendicular to
its length, all voltage measurements in the inner and outer solutions will have the
same voltage). The only radial voltage variation occurs in the membrane itself.

There are many variables associated with this model; although the model is very
simplified from the actual biological complexity, it is still formidably detailed. These
variables are described below:
z: the position of along the cable measured from some reference zero (m),
t: the current time (sec),
Io (z, t): the total longitudinal current flowing in the +z direction in the outer
conductor (amps),
Ii (z, t): the total longitudinal current flowing in the +z direction in the inner
conductor (amps),
Jm (z, t): the membrane current density in the inner conductor to the outer conduc-
tor (amp/m2 ),
Km (z, t): the membrane current per unit length from the inner conductor to the
outer conductor (amp/m),
Ke (z, t): the current per unit length due to external sources applied in a cylindri-
cally symmetric manner. So it we think of a presynaptic neuron’s axon
generating a postsynaptic pulse in a given postsynaptic neuron, we can
envision this synaptic contact occurring at some point z along the cable
and the resulting postsynaptic pulse as a Dirac delta function impulse
applied to the cable as a high current Ke which lasts for a very short time
(amp/m),
Vm (z, t): the membrane potential which is consider + when the inner membrane
is positive with respect to the outer one (volts),
Vi (z, t): the potential in the inner conductor (volts),
Vo (z, t): the potential in the outer conductor (volts),
ro : the resistance per unit length in the outer conductor (ohms/m),
ri : the resistance per unit length in the inner conductor (ohms/m),
a: the radius of the inner cylinder (m).
11.1 A Simple Model of a Dendrite: The Core Conductor Model 365

Careful reasoning using Ohm’s law and Kirchhoff’s laws for current and voltage
balance lead to the well-known steady state equations:

∂Ii ∂Io
= −Km (z, t), = Km (z, t) − Ke (z, t) (11.1)
∂z ∂z
∂Vi ∂Vo
= −ri Ii (z, t), = −ro Io (z, t), Vm = Vi − Vo (11.2)
∂z ∂z

These equations look at what is happening in the concentric cylinder model at equi-
librium; hence, the change in the potential across the inner membrane is due entirely
to the longitudinal variable z. From Eq. 11.2, we see

∂Vm ∂Vi ∂Vo


= − = ro Io (z, t) − ri Ii (z, t)
∂z ∂z ∂z

implying

∂ 2 Vm ∂Io ∂Ii
= ro − ri = (ri + ro )Km (z, t) − ro Ke (z, t).
∂z2 ∂z ∂z

Using Eq. 11.2, we then obtain the core conductor equation

∂ 2 Vm
= (ri + ro )Km (z, t) − ro Ke (z, t). (11.3)
∂z2

It is much more useful to look at this model in terms of transient variables which are
perturbations from rest values. We define

Vm (z, t) = Vm0 + vm (z, t), Km (z, t) = Km0 + km (z, t), Ke (z, t) = Ke0 + ke (z,
(11.4)
t)

where the rest values are respectively Vm0 (membrane rest voltage), Km0 (membrane
current per length base value) and Ke0 (injected current per length base value). With
the introduction of these transient variables, we are able to model the flow of current
across the inner membrane more precisely. We introduce the conductance per length
gm (Siemens/cm or 1/(ohms cm) and capacitance per length cm (fahrads/cm) of the
membrane and note that we can think of a patch of membrane as as simple RC circuit.
This leads to the transient cable equation

∂ 2 vm ∂vm
= (ri + ro )gm vm (z, t) + (ri + ro )cm − ro ke (z, t). (11.5)
∂z 2 ∂t

If we write the transient cable equation into an appropriate scaled form, we gain great
insight into how membrane voltages propagate in time and space relative to what
may be called fundamental scales. Define
366 11 Simplified Dendrite—Soma—Axon Information Processing

cm
τM = (11.6)
gm
1
λc = √ (11.7)
(ri + ro ) gm

Note that τM is independent of the geometry of the cable and depends only on
dendritic fiber characteristics. We will call τM the fundamental time constant (that is,
this constant determines how quickly a membrane potential decays to one half on its
initial value) of the solution for reasons we will see shortly. On the other hand, the
constant λc is dependent on the geometry of the cable fiber and we will find it is the
fundamental space constant of the system (that is, the membrane potential decays to
one half of its value within this distance along the cable fiber).
If we let CM and G M denote the capacitance and conductance per square cm of
the membrane, the circumference of the cable is 2πa and hence the capacitance and
conductance per length are given by

cm = 2πaCM (11.8)
gm = 2πaG M (11.9)

and we see clearly that the ratio τM is simply GCMM . This clearly has no dependence on
the cable radius showing yet again that this constant is geometry independent. We
note that the units of τM are in seconds. The space constant can be shown to have
units of cm and defining ρi to be the resistivity (ohm-cm) of the inner conductor, we
can show that
ρi
ri = . (11.10)
π a2
From this it follows that
1 1
λC = √ a2 . (11.11)
2ρi G M

Clearly, the space constant is proportional to the square root of the fiber radius and
the proportionality constant is geometry independent. Another important constant is
the Thévenin equivalent conductance, G ∞ , which is defined to be

gm
G ∞ = λC gm = . (11.12)
ri + ro

For most biologically plausible situations, the outer conductor resistance per unit
length is very small in comparison to the inner conductor’s resistance per unit length.
Hence, ri  ro and Eq. 11.12 can be rewritten using Eqs. 11.9 and 11.10 to have
the form
11.1 A Simple Model of a Dendrite: The Core Conductor Model 367

 
gm 2G M 3
G∞ = =π a2 . (11.13)
ri ρi

which shows that G ∞ is proportional to the three halves power of the fiber radius
a with a proportionality constant which is geometry independent. With all this said,
we note that ri + ro = λ21g and hence, we can rewrite the transient cable equation
C m
as

∂ 2 vm ∂vm
λ2C = vm + τM − ro λ2C ke . (11.14)
∂z 2 ∂t

11.2 Time Independent Solutions to the Cable Model

There are three important classes of solution to the properly scaled cable equation:
for the cases of an infinite, semi-infinite and finite length cable respectively; further,
we are interested in both time independent and dependent solutions, which we will
discuss in the next section. The three types of solution here are for the infinite, semi-
infinite and finite cable models. We model the applied current as a current impulse
of the form ke Ie δ(z − 0), where Ie is the magnitude of the impulse which is applied
at position z = 0 using the Dirac delta function δ(z − 0). The resulting steady state
equation is given by

d 2 vm
λ2C = vm − ro λ2C Ie δ(z − 0).
dz2

which has solution


λC ro Ie −|z|
vm (z) = e λC (11.15)
2
The noticeable characteristics of this solution are that its spatial decay is completely
determined by the space constant λC and the decay is symmetric across the injection
site at z = 0. Within one space constant, the potential drops by 1e .
In the semi-infinite cable case, we assume the cable begins at z = 0 and extends
out to infinity to the right. We assume a current Ie is applied at z = 0 and we can
show the appropriate differential equation to solve is

d 2 vm
λ2C = vm , ii (0) = Ie
dz2

where ii denotes the transient inner conductor current. This system has solution
368 11 Simplified Dendrite—Soma—Axon Information Processing

Ie − z
vm (z) = e λC
gm λC

ri + ro − z
= Ie e λC
gm

which we note is defined only for z ≥ 0. Note that the ratio vimi (0) (0)
reduces to the
Thévenin constant G ∞ . This ratio is current to voltage, so it has units of conductance.
Therefore, it is very useful to think of this ratio as telling us what resistance we see
looking into the mouth of the semi-infinite cable. While heuristic in nature, this will
give us a powerful way to judge the capabilities of dendritic fibers for information
transmission.
Finally, in the finite cable version, we consider a finite length, 0 ≤ z ≤ , of
cable with current Ie pumped in at z = and a conductance load of G e applied at the
far end z = . The cable can be thought of as a length of fiber whose two ends are
capped with membrane that is identical to the membrane that makes up the cable.
The load conductance G e represents the conductance of the membrane capping the
cable or the conductance of another cell body attached at that point. The system to
solve is now

d 2 vm
λ2C = vm , ii (0) = Ie , ii () = G e vm ().
dz2

This has solution


   
−z −z
Ie cosh λC
+ Ge
G∞
sinh λC
vm (z) =     , 0 ≤ z ≤ . (11.16)
G ∞ sinh  + Ge
cosh 
λC G i nfty λC

ii (0)
with Thévenin equivalent conductance vm (0)
given by
   
 
sinh λC
+ Ge
G∞
cosh λC
G T () = G ∞     , 0 ≤ z ≤ . (11.17)
 
cosh λC
+ Ge
G∞
sinh λC

Now if the end caps of the cable are patches of membrane whose specific conductance
is the same as the rest of the fiber, the surface area of the cap is πa2 which is much
smaller than the surface of the cylindrical fiber, 2πa. Hence, the conductance of the
cylinder without caps is 2πaG M which is very large compared to the conductance
of a cap, πa2 G M . So little current will flow through the caps and we can approximate
this situation by thinking of the cap as an open circuit (thereby setting G e = 0). We
can think of this as the open-circuit case. Using Eqs. 11.16 and 11.17, we find
11.2 Time Independent Solutions to the Cable Model 369
 
−z
Ie cosh λC
vm (z) =   , 0 ≤ z ≤ . (11.18)
G ∞ sinh 
λC
 

G T () = G ∞ tanh , 0 ≤ z ≤ . (11.19)
λC

11.3 The Dendritic Voltage Model

The cable equation for the normalized membrane voltage is a nice model of the
voltage on the excitable nerve cell dendrite which results from a voltage source
being applied to the dendritic cable. For zero-rate end cap conditions, the model,
as discussed and solved in Sect. 9.4, is stated below: which we have derived using
ideas from biology and physics.

∂ 2 vm (z, t) ∂vm
λ2C = vm (z, t) + τM , 0 ≤ z ≤ , t ≥ 0,
∂z2 ∂t
∂vm (0, t)
= 0,
∂z
∂vm (, t)
= 0,
∂z
vm (z, 0) = f (z), 0 ≤ z ≤ .

This is the general cable equation with β = λC and α = τ . We then normalized the
variables using the transformations

t z 
τ = , λ= , L= ,
τM λC λC
v̂m = vm (λC λ, τM τ ).

This gave the system

∂ 2 v̂m ∂ v̂m
= v̂m + , 0 ≤ λ ≤ L, τ ≥ 0
∂λ2 ∂τ
∂ v̂m (0, τ )
=0
∂λ
∂ v̂m (L, τ )
= 0,
∂λ
v̂m (λ, 0) = fˆ (z), 0 ≤ λ ≤ L.

where fˆ = f (λC λ). Now denote the applied voltage at time zero by V (λ). Since, this
is the general cable equation with β = 1 and α = 1, the solution is
370 11 Simplified Dendrite—Soma—Axon Information Processing


  
nπ 1+n2 π 2
−τ
v̂m (λ, τ ) = A0 e + An cos λ e− L2 τ .
n=1
L

with A − n = Bn with
L
1
B0 = f (x)dx,
L 0
L  
2 nπ
Bn = f (x) cos x dx.
L 0 L

The functions un (λ) = cos(ωn λ) and the scalars ωn are known as the eigenvalues and
eigenfunctions of the differential equation operator—a fancy name for the model –
u with zero rate endcap boundary conditions. We haven’t called them this before
in our previous chapters on the separation of variables technique, but in a sense the
work we do here is very analogous to the usual eigenvalue/eigenvector analysis we
do for matrices. We can say a lot more about this in more advanced courses; in
particular we discuss this carefully in Peterson (2015a). However, that is beyond our
scope here. We wanted to mention this type of phrasing because we will need to
mention it in a bit when we actually try to solve the Ball Stick model. Anyway, for
this problem, the spatial eigenvalues are then β0 = 0 with eigenfunction u0 (λ) = 1
and βn = −ωn2 = − nLπ2 for any nonzero integer n with associated eigenfunctions
2 2

un (λ) = cos(ωn λ). It is also easy to redo our original analysis to shown that we can
use un (λ) = cos(ωn (L − λ)) as the eigenfunctions. Still in either case, there are an
infinite number of eigenvalues satisfying |βn | → ∞. Further, these eigenfunctions
are mutually orthogonal. The normalized eigenfunctions are then
1
û0 (λ) = √ ,
L

2
ûn (λ) = cos(ωn λ), n ≥ 1
L
or
1
û0 (λ) = √ ,
L

2
ûn (λ) = cos(ωn (L − λ)), n ≥ 1
L

It is easy to see that with our usual inner product, < ûn , ûn >= 1 for all integers
n ≥ 0. It is possible to show—again, the details are in other texts such as Peterson
(2015a)—that any continuous function f has the representation


f (λ) = < f , ûn (λ) > ûn (λ
n=0
11.3 The Dendritic Voltage Model 371

which converges in the least squares sense. Recall we talked about these ideas in
Chap. 9 so you can go back there and review if you need to. When this is true, we
say these functions form a complete orthonormal sequence.

11.4 The Ball and Stick Model

We can now extend our simple dendritic cable model to what is called the ball and
stick neuron model. This consists of an isopotential sphere to model the cell body or
soma coupled to a single dendritic fiber input line. We will model the soma as a simple
parallel resistance/ capacitance network and the dendrite as a finite length cable as
previously discussed (see Fig. 11.2). In Fig. 11.2, you see the terms I0 , the input
current at the soma/dendrite junction starting at τ = 0; ID , the portion of the input
current that enters the dendrite (effectively determined by the input conductance to the
finite cable, G D ); IS , the portion of the input current that enters the soma (effectively
determined by the soma conductance G S ); and CS , the soma membrane capacitance.
We assume that the electrical properties of the soma and dendrite membrane are the
same; this implies that the fundamental time and space constants of the soma and
dendrite are given by the same constant (we will use our standard notation τM and
λC as usual). It takes a bit of work, but it is possible to show that with a reasonable
zero-rate left end cap condition the appropriate boundary condition at λ = 0 is given
by

∂ v̂m ∂ v̂m
ρ (0, τ ) = tanh(L) v̂m (0, τ ) + (0, τ ) , (11.20)
∂λ ∂τ

Fig. 11.2 The ball and stick model


372 11 Simplified Dendrite—Soma—Axon Information Processing

where we introduce the fundamental ratio ρ = GGDS , the ratio of the dendritic conduc-
tance to soma conductance. For more discussion of the ball and stick model boundary
conditions we use here, you can look at the treatment in Rall (1977, Chap. 7, Sect. 2).
The full system to solve is therefore:

∂ 2 v̂m ∂ v̂m
= v̂m + , 0 ≤ λ ≤ L, τ ≥ 0. (11.21)
∂λ 2 ∂τ
∂ v̂m
(L, τ ) = 0, (11.22)
∂λ
∂ v̂m ∂ v̂m
ρ (0, τ ) = tanh(L) v̂m (0, τ ) + (0, τ ) . (11.23)
∂λ ∂τ

Applying the technique of separation of variables, v̂m (λ, τ ) = u(λ)w(τ ), leads to


the system:

u (λ)w(τ ) = u(λ)w(τ ) + u(λ)w (τ )


ρu (0)w(τ ) = tanh(L) u(0)w(τ ) + u(0)w  (τ )
u (L)w(τ ) = 0

This leads again to the ratio equation

u (λ) − u(λ) w  (τ )


= .
u(λ) w(τ )

Since these ratios hold for all τ and λ, they must equal a common constant . Thus,
we have
d2u
= (1 + )u, 0 ≤ λ ≤ L, (11.24)
dλ2
dw
= w, τ ≥ 0. (11.25)

The boundary conditions then become

u (L) = 0
ρu (0) = (1 + ) tanh(L)u(0).

The only case where we can have non trivial solutions to Eq. 11.24 occur when
1+ = −α2 for some constant α. There are several cases to consider, but the details
are quite similar to those of the zero rate endcap case and so are not included. The
general solution to Eq. 11.24 is then of the form A cos(α(L − λ)) + B sin(α(L − λ)).
Since

u (λ) = α A sin(α(L − λ)) − α B cos(α(L − λ))


11.4 The Ball and Stick Model 373

we see

u (L) = −α B = 0,

and so B = 0. Then,

u(0) = A cos(αL)
u (0) = αA sin(αL)

to satisfy the last boundary conditions, we find, since 1 +  = −α2 ,


 
α A ρ sin(αL) + α tanh(L) cos(αL) = 0

A non trivial solution for A then requires α must satisfy the transcendental equation

tanh(L)
tan(αL) = −α = −κ(αL), (11.26)
ρ

where κ = tanh(L)
ρL
. The values of α that satisfy Eq. 11.26 give us the eigenvalue of our
original problem,  = −1−α2 . The eigenvalues of our system can be determined by
the solution of the transcendental Eq. 11.26. This is easy to do graphically as you can
see in Fig. 11.3). It can be shown that the eigenvalues form a monotonically increasing
sequence starting with α0 = 0 and with the values αn approaching asymptotically
the values 2n−1
2
π. Hence, there are a countable number of eigenvalues of the form
n = −1 − αn2 leading to a general solution of the form

v̂mn (λ, τ ) = An cos(αn λ) e−(1+αn )τ .


2
(11.27)

Hence, this system uses the pairs αn (the solution to the transcendental Eq. 11.26)
and cos[αn (L − λ)]. In fact, we can show by direct integration that for n = m,

L sin((αn + αm )L) sin((αn − αm )L)


cos(αn (L − λ)) cos(αm (L − λ)) dλ = + = 0.
0 2(αn + αm ) 2(αn − αm )
 
(2n−1)π
Since lim αn − 2
= 0, we see there is an integer Q so that

L
cos(αn (L − λ)) cos(αm (L − λ)) ≈ 0
0

if n and m exceed Q. We could say these functions are approximately orthogonal.


The separation of variables technique gives rise to general solutions of the form
374 11 Simplified Dendrite—Soma—Axon Information Processing

Fig. 11.3 The ball and stick eigenvalue problem



v̂m (λ, τ ) = A0 e−τ + An cos(αn (L − λ))e−(1+αn )τ .
2

n=1

When τ = 0, this means we want to know if the series




v̂m (λ, 0) = A0 + An cos(αn (L − λ))
n=1

converges for the appropriate numbers An . To solve this model, for an applied con-
tinuous voltage pulse V to the cable we will want to expand V in terms of the
eigenfunctions and equate coefficients. That is, we would write


V (λ) = V0 + Vn cos(αn (L − λ))
n=1

and match coefficients from the expansion of v̂m (λ, 0) given above. However, to do
that we need to know if any V can be written like this and to know that the expansion
of v̂m at τ = 0 is valid. Remember, that a family of functions is complete if we can
do this. Now our family of functions here is not orthogonal so we certainly can’t get
11.4 The Ball and Stick Model 375

a complete orthonormal sequence. However, as discussed very carefully in Peterson


(2015a), it is possible to show that expansions like this are indeed permissible using
this family of functions. Also, note for τ > 0, the series expansions are eventually
so strongly damped by the decay exponentials, that convergence is guaranteed so it
is only a potential problem at 0. Further, note since the numbers αn are not integers
this is not a Fourier series expansion as we have discussed previously and so none of
that analysis applies. Hence, suffice it to say, there is a need to dig into this question
carefully even though doing so in this book is not appropriate. We will not present
these details here, therefore, and ask you go to a source like Peterson (2015a) for the
details. We conclude this discussion by noting these expansions are permitted.
Thus, as usual, we expect the most general solution is given by


Q
−τ
An cos(αn (L − λ))e−(1+αn )τ
2
v̂m (λ, τ ) = A0 e + (11.28)
n=1


An cos(αn (L − λ))e−(1+αn )τ
2
+ (11.29)
n=Q+1

Since the spatial functions are approximately orthogonal, the computation of the
coefficients An for n > Q can be handled with a straightforward inner product
calculation. The calculation of the first Q coefficients must be handled as a linear
algebra problem.

11.5 Ball-Stick MatLab Solutions

There are several ways to solve the ball-stick cable equation with a time dependency.
One way to find a solution is to transform the cable equation into what is called
a diffusion equation. We then use the properties of the solution to the diffusion
equation and some variable transformations to obtain the cable solution. This is done
in Peterson (2015c). We will use the Separation of Variables technique as discussed
above here.
Let’s assume we are applying a spatially varying voltage V (λ) at τ = 0 to our
model. This means our full problem is

∂ 2 v̂m ∂ v̂m
= v̂m + , 0 ≤ λ ≤ L, t ≥ 0.
∂λ2 ∂τ
v̂m (λ, 0) = V (λ), τ ≥ 0
∂ v̂m
(L, τ ) = 0,
∂λ
∂ v̂m ∂ v̂m
ρ (0, τ ) = tanh(L) v̂m (0, τ ) + (0, τ ) .
∂λ ∂τ
376 11 Simplified Dendrite—Soma—Axon Information Processing

We have solved this problem and found



  
nπ 1+n2 π 2
v̂m (λ, τ ) = A0 e−τ + An cos λ e− L2 τ .
n=1
L

We know we can approximate the solution v̂m as


Q
v̂m (λ, τ ) = A0 e−τ + An cos(αn (L − λ))e−(1+αn )τ
2

n=1

for any choice of integer Q we wish. At τ = 0, to satisfy the desired applied voltage
condition, we must have


Q
v̂m (λ, 0) = A0 + An cos(αn (L − λ)).
n=1

We can approximately solve this problem then by finding constants A0 to AQ so that


Q
V (λ) = A0 + An cos(αn (L − λ)).
n=1

11.5.1 Approximating the Solution

For convenience, let φi (λ) denote the function cos(αn (L − λ)), where φ0 (λ) = 1
always. Then, note for each integer i, 0 ≤ i ≤ Q, we have
L L
2 2
V (s) φi (s) ds = A0 φ0 (s) φi (s) ds
L 0 L 0

Q
2 L
+An φn (s) φi (s) ds
n=1
L 0

To make this easier to write out, we again use “inner product” < f , g > defined by
L
2
< f,g > = f (s)g(s) ds.
L 0

Using this new notation, we see we are trying to find constants A0 to AQ so that
11.5 Ball-Stick MatLab Solutions 377
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
< φ0 , φ0 > < φ1 , φ0 > · · · < φQ , φ0 > A0 < V, φ0 >
⎢ < φ0 , φ 1 > < φ 1 , φ 1 > · · · < φQ , φ1 > ⎥ ⎢ A1 ⎥ ⎢ < V, φ1 > ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ .. .. .. .. ⎥ ⎢ .. ⎥ ⎢ .. ⎥
⎢ . . . . ⎥ ⎢ . ⎥ ⎢ . ⎥
⎢ ⎥ ⎢ ⎥=⎢ ⎥
⎢ < φ0 , φi > < φ 1 , φi > · · · < φQ , φi > ⎥ ⎢ Ai ⎥ ⎢ < V, φi > ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ .. .. .. .. ⎥ ⎢ . ⎥ ⎢ .. ⎥
⎣ . . . . ⎦ ⎣ .. ⎦ ⎣ . ⎦
< φ0 , φQ > < φ 1 , φQ > · · · < φQ , φQ > AQ < V, φQ >

For convenience, call this coefficient matrix M and define the vectors B and D by
⎡ ⎤ ⎡ ⎤
A0 < V, φ0 >
⎢ A1 ⎥ ⎢ < V, φ1 > ⎥
⎢ ⎥ ⎢ ⎥
⎢ .. ⎥ ⎢ .. ⎥
⎢ . ⎥ ⎢ . ⎥
B=⎢ ⎢ Ai ⎥
⎥, D = ⎢
⎢ < V, φi > ⎥

⎢ ⎥ ⎢ ⎥
⎢ . ⎥ ⎢ .. ⎥
⎣ .. ⎦ ⎣ . ⎦
AQ < V, φQ >

Then we find the desired constants A0 to AQ by solving

M B = D.

If M is invertible, this is an easy calculation. We can simplify this a bit further. We


know
1. The case n = m with n and m not equal to 1: Here, we have

L sin((αn + αm )L) sin((αn − αm )L)


cos(αn (L − λ)) cos(αm (L − λ)) dλ = +
0 2(αn + αm ) 2(αn − αm )

However, we also know

sin(αn L) = −κ (αn L) cos(αn L)

Standard trigonometric formulae tell us

sin(αn L + αm L) = sin(αn L) cos(αm L) + sin(αm L) cos(αn L)


sin(αn L − αm L) = sin(αn L) cos(αm L) − sin(αm L) cos(αn L)

So, the pieces of the “inner products” become


sin((αn + αm )L) sin(αn L) cos(αm L) + sin(αm L) cos(αn L)
=
2(αn + αm ) 2(αn + αm )
378 11 Simplified Dendrite—Soma—Axon Information Processing

−κ αn L cos(αm L) cos(αn L) − κ αm L cos(αm L) cos(αn L)


=
2(αn + αm )
L
= −κ cos(αm L) cos(αn L)
2

and
sin((αn − αm )L) sin(αn L) cos(αm L)+ sin(αm L) cos(αn L)
=
2(αn − αm ) 2(αn + αm )
−κ (αn L) cos(αm L) cos(αn L) + κ (αm L) cos(αm L) cos(αn L)
=
2(αn + αm )
L
= −κ cos(αm L) cos(αn L).
2

and hence,
L
2
cos(αn (L − λ)) cos(αm (L − λ)) dλ = −2κ cos(αm L) cos(αn L).
L 0

2. If n = 0 with m > 0: Since n = 0, the “inner product” integration is a bit


simpler. We have

2 L
sin((αm )L)
cos(αm (L − λ)) dλ = 2
L 0 αm L

However, of course, we also know

sin(αm L) = −κ (αm L) cos(αm L)

So, the “inner product” becomes

sin(αm L)
2 = −2κ cos(αm L)
αm L

Hence, we conclude
L
2
cos(αm (L − λ)) = −2κ cos(αm L).
L 0

3. n = m, n > 0: Here, a direct integration gives

2 L
2 L
1 + cos(αn (L − λ))
cos2 (αn (L − λ)) dλ = dλ
L 0 L 0 2
1
= 1+ sin(αn L).
2αn L
11.5 Ball-Stick MatLab Solutions 379

4. n = m = 0: Finally, we have
L
2
dλ = 2.
L 0

Plugging this into our “inner products”, we see we need to solve


⎡ 1 1 1 ⎤ ⎡ ⎤ ⎡ ⎤
− 2κ 2 cos(β1 ) ··· 2 cos(βQ ) A0 < V, φ0 >
⎢ 1 cos(β1 ) 1 γ
− 4κ · · · cos(β1 ) cos(βQ ) ⎥ ⎢ A1 ⎥ ⎢ < V, φ1 > ⎥
⎢2 1 ⎥ ⎢ ⎥ ⎢ ⎥
⎢ . .. .. .. ⎥ ⎢ .. ⎥ ⎢ .. ⎥
⎢ .. ⎥ ⎢ . ⎥ ⎢ ⎥
⎢ . . . ⎥ ⎢ ⎥=− 1 ⎢ . ⎥
⎢ 1 ⎥ ⎢ Ai ⎥ ⎢ < V, φi > ⎥
⎢ 2 cos(βi ) cos(β1 ) cos(βi ) · · · cos(βi ) cos(βQ ) ⎥ ⎢ ⎥ 4κ ⎢ ⎥
⎢ ⎥ ⎢ . ⎥ ⎢ .. ⎥
⎢ .. .. .. .. ⎥ ⎣ .. ⎦ ⎣ ⎦
⎣ . . . . ⎦ .
1 cos(β ) cos(β ) cos(β )
Q 1 Q ··· 1
− 4κ γQ AQ < V, φQ >
2

where we use βi to denote αi L and the γi to replace the term 1 + 2α1i L sin(2αi L). For
example, if L = 5, ρ = 10 and Q = 5, we find with an easy MatLab calculation that
M is

Listing 11.1: M Matrix


−25.0023 −0.4991 0.4962 −0.4917 0.4855 −0.4778
−0.4991 −12.2521 −0.9906 0.9815 −0.9691 0.9538
3 0.4962 −0.9906 −12.2549 −0.9760 0.9637 −0.9485
−0.4917 0.9815 −0.9760 −12.2594 −0.9548 0.9397
0.4855 −0.9691 0.9637 −0.9548 −12.2655 −0.9279
−0.4778 0.9538 −0.9485 0.9397 −0.9279 −12.2728

which has a non zero determinant so that we can solve the required system.

11.5.2 Applied Voltage Pulses

If we specialize to an applied voltage pulse V (λ) = V ∗ δ(λ − λ0 ), note this is


interpreted as a sequence of pulses keC satisfying for all positive C

λ0 +C
keC (s) ds = V ∗ .
λ0 −C

Hence, for all C, we have

2 λ0 +C C
< keC , φ0 > = k (s) ds
L λ0 −C e
2
= V∗
L
380 11 Simplified Dendrite—Soma—Axon Information Processing

Thus, we use

2V ∗
< V ∗ δ(λ − λ0 ), φ0 > = .
L
Following previous discussions, we then find for any i larger than 0, that

2V ∗
< V ∗ δ(λ − λ0 ), φi > = cos(αi (L − λ0 )).
L
Therefore, for an impulse voltage applied to the cable at position λ0 of size V ∗ , we
find the constants we need by solving M B = D for
⎡ ⎤
1
⎢ cos(α1 (L − λ0 )) ⎥
⎢ ⎥
⎢ .. ⎥
V∗ ⎢⎢ . ⎥
⎥.
D=− ⎢ ⎥
2kL ⎢ cos(αi (L − λ 0 )) ⎥
⎢ .. ⎥
⎣ . ⎦
cos(αQ (L − λ0 ))

If we had two impulses applied, one at λ0 of size V0∗ and one at λ1 of size V1∗ , we can
find the desired solution by summing the solution to each of the respective parts. In
this case, we would find a vector solution B0 and B1 following the procedure above.
The solution at λ = 0, the axon hillock, would then be


Q
v̂m (0, τ ) = (B00 + B10 ) e−τ + (B0n + B1n ) cos(αn L) e−(1+αn )τ
2

n=1

11.6 Ball and Stick Numerical Solutions

To see how to handle the Ball and Stick model numerically with MatLab, we will
write scripts that do several things. We will try to explain, as best we can, the general
principles of our numerical modeling using home grown code rather than built in
MatLab functions. We need
1. A way to find Q eigenvalues numerically.
2. A routine to construct the matrix M we need for our approximations.
3. A way to solve the resulting matrix system for the coefficients we will use to build
our approximate voltage model.
To solve for the eigenvalues numerically, we will use root finding techniques. to solve
for the roots of
11.6 Ball and Stick Numerical Solutions 381

tanh(L)
tan(αL) + (αL) = 0.
ρL

for various choices of L and ρ. We know the roots we seek are always in the intervals
[ π2 , π], [ 3π
2
, 2π] and so on, so it is easy for us to find useful lower and upper bounds for
the root finding method. Since tan is undefined at the odd multiples of π2 , numerically,
it is much easier to solve instead
tanh(L)
sin(αL) + (αL) cos(αL) = 0.
ρL

To do this, we write the function f2 as

Listing 11.2: Ball and Stick Eigenvalues


f u n c t i o n y = f 2 ( x , L , rho )
%
% L = l e n g t h of the dendrite cable in s p a t i a l l e n g t h s
% r h o = r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
5 %
%
kappa = tanh ( L ) / ( rho ∗L ) ;
u = x∗L ;
y = s i n ( u ) + kappa ∗u∗ c o s ( u ) ;

11.6.1 Root Finding and Simple Optimization

The original finite difference Newton Method was for functions of one argument
and was discussed in Sect. 11.6.1. Hence, we will have to modify the MatLab code
for our purposes now. Our function f2(x,L,rho) depends on three parameters,
so we modify our feval statements to reflect this. The new code is pretty much
the same with each feval statement changed to add ,L,rho to the argument
list.

Listing 11.3: Modified Finite Difference Newton Method


function [ x , f x , n E v a l s , aF , bF ] = . . .
GlobalNewtonFDTwo ( fName , L , rho , a , b , t o l x , t o l f , nEvalsMax )
%
% fName a s t r i n g t h a t i s t h e name o f t h e f u n c t i o n f ( x )
5 % a,b we l o o k f o r t h e r o o t i n t h e i n t e r v a l [ a , b ]
% tolx t o l e r a n c e on t h e s i z e o f t h e i n t e r v a l
% tolf tolerance of f ( current approximation to root )
% nEvalsMax Maximum Number o f d e r i v a t i v e E v a l u a t i o n s
%
10 % x Approximate z e r o o f f
% fx The v a l u e o f f a t t h e a p p r o x i m a t e z e r o
% nEvals The Number o f D e r i v a t i v e E v a l u a t i o n s Needed
% aF , bF the f i n a l i n t e r v a l the approximate root l i e s in ,
% [ aF , bF ]
382 11 Simplified Dendrite—Soma—Axon Information Processing

15 %
% Termination I n t e r v a l [ a , b ] has s i z e < t o l x
% | f ( approximate root ) | < t o l f
% Have e x c e e d e d nEvalsMax d e r i v a t i v e Evaluations
%
20 f a = f e v a l ( fName , a , L , rho ) ;
f b = f e v a l ( fName , b , L , rho ) ;
x = a;
f x = f e v a l ( fName , x , L , rho ) ;
d e l t a = s q r t ( eps ) ∗ abs ( x ) ;
25 f p v a l = f e v a l ( fName , x+d e l t a , L , rho ) ;
fpx = ( f p v a l −f x ) / d e l t a ;

nEvals = 1 ;
k = 1;
30 disp ( ’ ’)
d i s p ( ’ Step | k | a(k) | x(k) | b(
k) ’ )
d i s p ( s p r i n t f ( ’ Start | %6 d | %12.7 f | %12.7 f | %12.7 f ’ , k , a , x , b
));
while ( a b s ( a−b )>t o l x ) && ( a b s ( f x )> t o l f ) && ( n E v a l s<nEvalsMax ) | | (
n E v a l s ==1)
%[ a , b ] b r a c k e t s a r o o t and x=a o r x=b
35 c h e c k = S t e p I s I n ( x , f x , fpx , a , b ) ;
i f check
%Take Newton S t e p
x = x − fx / fpx ;
else
40 %Take a B i s e c t i o n S t e p :
x = ( a+b ) / 2 ;
end
f x = f e v a l ( fName , x , L , rho ) ;
f p v a l = f e v a l ( fName , x+d e l t a , L , rho ) ;
45 fpx = ( f p v a l −f x ) / d e l t a ;
n E v a l s = n E v a l s +1;
i f f a ∗ f x <=0
%t h e r e i s a r o o t i n [ a , x ] . Use r i g h t e n d p o i n t .
b = x;
50 fb = fx ;
else
%t h e r e i s a r o o t i n [ x , b ] . Bring in l e f t endpoint .
a = x;
fa = fx ;
55 end
k = k +1;
i f ( check )
d i s p ( s p r i n t f ( ’ Newton | %6 d | %12.7 f | %12.7 f | %12.7 f ’ , k , a
, x , b) ) ;
else
60 d i s p ( s p r i n t f ( ’ Bisection | %6 d | %12.7 f | %12.7 f | %12.7 f ’ , k , a
, x , b) ) ;
end
end
aF = a ;
bF = b ;

We can then write the script FindRoots.

Listing 11.4: Finding Ball and Stick Eigenvalues


f u n c t i o n z = F i n dR o o t s (Q, L , rho , l b t o l , u b t o l )
%
% Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
5 % rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% l b t o l = a s m a l l t o l e r a n c e t o add t o t h e l o w e r b o u n d s we u s e
% u p t o l = a s m a l l t o l e r a n c e t o add t o t h e u p p e r b o u n d s we u s e
%
z = z e r o s (Q, 1 ) ;
10 LB = z e r o s (Q, 1 ) ;
UB = z e r o s (Q, 1 ) ;
11.6 Ball and Stick Numerical Solutions 383

kappa = tanh ( L ) / ( rho ∗L ) ;


f o r n=1:Q
LB( n ) = ( ( 2 ∗ n −1) / ( 2 ∗ L ) ) ∗ p i ∗ l b t o l ;
15 UB( n ) = n∗ p i /L∗ u b t o l ;
[ z ( n ) , f x , n E v a l s , aF , bF ] = GlobalNewtonFDTwo ( ’ f2 ’ , L , rho , LB( n ) ,MB( n
) ,10ˆ −6 ,10ˆ −8 ,500) ;
w = z ∗L ;
l b = L∗LB ;
d i s p ( s p r i n t f ( ’n = %3 d EV = %12.7 f LB = %12.7 f Error = %12.7 f
’ , n , w( n ) , l b ( n ) ,w( n )− l b ( n ) ) ) ;
20 d i s p ( s p r i n t f ( ’n %3 d function value = %12.7 f original function
value = %12.7 f ’ , n , s i n (w( n ) ) + kappa ∗w( n ) ∗ c o s (w( n ) ) , t a n (w( n ) )
+ kappa ∗w( n ) ) ) ;

end

11.6.1.1 Sample Runs

Let’s try running this for the first two eigenvalues. Here is the sesssion:

Listing 11.5: Finding Two Eigenvalues


FindRoots ( 2 , 5 , 1 0 , 1 . 0 , 1 . 0 ) ;

3 Step | k | a(k) | x(k) | b(k


)
Start | 1 | 0.3141593 | 0.3141593 |
0.6283185
Bisection | 2 | 0.4712389 | 0.4712389 |
0.6283185
Bisection | 3 | 0.5497787 | 0.5497787 |
0.6283185
Newton | 4 | 0.5497787 | 0.6186800 |
0.6186800
8 Newton | 5 | 0.6160148 | 0.6160148 |
0.6186800
Newton | 6 | 0.6160148 | 0.6160149 |
0.6160149
n = 1 EV = 3 . 0 8 0 0 7 4 5 LB = 1.5707963 Error =
1.5092782
n 1 function value = −0.0000000
o r i g i n a l function value = 0.0000000
13
Step | k | a(k) | x(k) | b(k
)
Start | 1 | 0.9424778 | 0.9424778 |
1.2566371
Bisection | 2 | 1.0995574 | 1.0995574 |
1.2566371
Bisection | 3 | 1.1780972 | 1.1780972 |
1.2566371
18 Newton | 4 | 1.1780972 | 1.2335644 |
1.2335644
Newton | 5 | 1.2321204 | 1.2321204 |
1.2335644
n = 2 EV = 6 . 1 6 0 6 0 2 2 LB = 4.7123890 Error =
1.4482132
n 2 function value = −0.0000000
o r i g i n a l function value = − 0.0000000
384 11 Simplified Dendrite—Soma—Axon Information Processing

Now we will run this for 20 eigenvalues for L = 5 and ρ = 10 but we have com-
mented out the intermediate prints in GlobalNewtonFDTwo to save space! We
keep printing out the actual f 2 values just to make sure our numerical routines are
working like we want.

Listing 11.6: 20 Eigenvalues


FindRoots ( 2 0 , 5 ,10 ,1.0 ,1.0) ;
n = 1 EV = 3 . 0 8 0 0 7 4 5 LB = 1.5707963 Error =
1.5092782
n 1 function value = − 0.0000000
original function value = 0.0000000
5 n = 2 EV = 6 . 1 6 0 6 0 2 2 LB = 4.7123890 Error =
1.4482132
n 2 function value = − 0.0000000
original function value = −0.0000000
n = 3 EV = 9 . 2 4 2 0 1 6 8 LB = 7.8539816 Error =
1.3880352
n 3 function value = − 0.0000000
10 original function value = 0.0000000
n = 4 EV = 1 2 . 3 2 4 7 1 5 2 LB = 10.9955743 Error =
1.3291410
n 4 function value = 0.0000000
original function value = 0.0000000
...
15 n = 20 EV = 61.9402349 LB = 61.2610567 Error =
0.6791782
n 20 f u n c t i o n value = 0.0000000
original function value = 0.0000000

11.6.2 The Ball and Stick Matrix Construction

To construct the matrix M, we need, we will use the following function.

Listing 11.7: Finding the Ball and Stick coefficient Matrix


f u n c t i o n M = FindM (Q, L , rho , z )
%
3 % Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
% rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% M = matrix o f c o e f f i c i e n t s f o r our approximate v o l t a g e
% model
8 % In MatLab t h e r o o t n u m b e r i n g i s o f f b y 1 ; s o
% t h e r o o t s we f i n d s t a r t a t 1 and end a t Q .
% So M i s Q+1 b y Q+1.
kappa = tanh ( L ) / ( rho ∗L ) ;
w = z e r o s (1+Q, 1 ) ;
13 M = z e r o s (1+Q,1+Q) ;
w( 1 ) = 0 ;
% set f i r s t diagonal position
M( 1 , 1 ) = −1/(2∗ kappa ) ;
f o r n=1:Q
18 w( n+1) = z ( n ) ∗L ;
end
11.6 Ball and Stick Numerical Solutions 385

% s e t f i r s t column
f o r n = 2 :Q+1
M( 1 , n ) = 0 . 5 ∗ c o s (w( n ) ) ;
23 end
% s e t f i r s t row
f o r n = 2 :Q+1
M( n , 1 ) = 0 . 5 ∗ c o s (w( n ) ) ;
end
28 % s e t main b l o c k
f o r m=2:Q+1
f o r n = 2 :Q+1
i f m ˜= n
M(m, n ) = c o s (w(m) ) ∗ c o s (w( n ) ) ;
33 end
i f m == n
M(m,m) = −1/(4∗ kappa ) ∗ ( 1 + s i n ( 2 ∗w(m) ) / ( 2 ∗w(m) ) ) ;
end
end
38 end

This is pretty easy to use. For example, for Q = 6, we have

Listing 11.8: Q = 6
Q = 6;
2 L = 5;
rho = 1 0 ;
z = FindRoots (Q, L , rho , 1 . 0 , 1 . 0 ) ;
n = 1 EV = 3 . 0 8 0 0 7 4 5 LB = 1.5707963 Error =
1.5092782
n 1 function value = − 0.0000000
7 o r i g i n a l function value = 0.0000000
n = 2 EV = 6 . 1 6 0 6 0 2 2 LB = 4.7123890 Error =
1.4482132
n 2 function value = − 0.0000000
o r i g i n a l function value = −0.0000000
n = 3 EV = 9 . 2 4 2 0 1 6 8 LB = 7.8539816 Error =
1.3880352
12 n 3 function value = − 0.0000000
o r i g i n a l function value = 0.0000000
n = 4 EV = 1 2 . 3 2 4 7 1 5 2 LB = 10.9955743 Error =
1.3291410
n 4 function value = 0.0000000
o r i g i n a l function value = 0.0000000
17 n = 5 EV = 1 5 . 4 0 9 0 4 3 6 LB = 14.1371669 Error =
1.2718767
n 5 function value = − 0.0000000
o r i g i n a l function value = 0.0000000
n = 6 EV = 1 8 . 4 9 5 2 8 8 4 LB = 17.2787596 Error =
1.2165288
n 6 function value = 0.0000000
22 o r i g i n a l function value = 0.0000000
M = FindM (Q, L , rho , z ) ;

The resulting M matrix is


386 11 Simplified Dendrite—Soma—Axon Information Processing

Listing 11.9: M Matrix


M=
2
−25.0023 −0.4991 0.4962 −0.4917 0.4855 −0.4778
0.4690
−0.4991 −12.2521 −0.9906 0.9815 −0.9691 0.9538
−0.9361
0.4962 −0.9906 −12.2549 −0.9760 0.9637 −0.9485
0.9309
−0.4917 0.9815 −0.9760 −12.2594 −0.9548 0.9397
−0.9223
7 0.4855 −0.9691 0.9637 −0.9548 −12.2655 −0.9279
0.9106
−0.4778 0.9538 −0.9485 0.9397 −0.9279 −12.2728
−0.8963
0.4690 −0.9361 0.9309 −0.9223 0.9106 −0.8963
−12.2812

Since we know that eventually, the roots or eigenvalues will become close to an odd
multiple of π2 , we see that the axon voltage which is v̂m (λ, 0) is


Q ∞

v̂m (λ, 0) = A0 + An cos(αn (L − λ)) + An cos(αn (L − λ))
n=1 n=Q+1

where Q + 1 is the value where the cos(αn L) = 0 within our tolerance choice. At
the Axon Hillock, λ = 0, we have


Q ∞

v̂m (0, 0) = A0 + An cos(αn L) + An cos(αn L)
n=1 n=Q+1

However, the terms past Q + 1 are zero and so our approximate solution at the axon
hillock at time 0 is just


Q
v̂m (0, 0) = A0 + An cos(αn L).
n=1

However, as time increases, the voltage wave initiated by impulse travels towards
the axon hillock. It dampens or attenuates as it goes. The magnitude of the depo-
larization or hyperpolarization seen at the axon hillock depends on the time we
wish to look at. Recall, the solution to our impulse at the axon hillock, λ = 0, is
given by
11.6 Ball and Stick Numerical Solutions 387


Q
v̂m (0, τ ) = A0 e−τ + An cos(αn L) e−(1+αn )τ
2
(11.30)
n=1


An cos(αn L) e−(1+αn )τ .
2
+ (11.31)
n=Q+1

The strong damping given by e−(1+αn )τ for n > Q tells us these last terms are very
2

negligible. So a good approximation to the transient membrane voltage at the axon


hillock as a function of time is


Q
v̂m (0, τ ) = A0 e−τ + An cos(αn L) e−(1+αn )τ .
2
(11.32)
n=1

The membrane voltage at the axon hillock is then the sum of the equilibrium voltage
VR (typically −70 mV) and v̂m (0, τ ). An interesting question is how do we estimate
Q? We did it with a short MatLab script.

Listing 11.10: Finding Q


1 f u n c t i o n N = F i n d R o o t S i z e ( EndValue , L , rho , l b t o l , u b t o l )
%
% EndValue = how f a r we want t o s e a r c h t o f i n d
% w h e r e a p p r o x i m a t i o n can s t o p
% Q = t h e number o f e i g e n v a l u e s we want t o f i n d
6 % L = the l e n g t h of the dendrite in space constants
% rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% lbtol = a s m a l l t o l e r a n c e t o add t o t h e l o w e r b o u n d s we u s e
% uptol = a s m a l l t o l e r a n c e t o add t o t h e u p p e r b o u n d s we u s e
%
11 % set Q
Q = EndValue ;
z = z e r o s (Q, 1 ) ;
LB = z e r o s (Q, 1 ) ;
UB = z e r o s (Q, 1 ) ;
16 kappa = tanh ( L ) / ( rho ∗L ) ;
N = Q;
f o r n=1:Q
LB( n ) = ( ( 2 ∗ n −1) / ( 2 ∗ L ) ) ∗ p i ∗ l b t o l ;
UB( n ) = n∗ p i /L∗ u b t o l ;
21 [ z ( n ) , f x , n E v a l s , aF , bF ] = GlobalNewtonFDTwo ( ’ f2 ’ , L , rho , LB( n ) ,UB( n
) ,10ˆ −6 ,10ˆ −8 ,500) ;
w = z ∗L ;
t e s t v a l u e = a b s ( c o s (w( n ) ) ) ;
i f ( a b s ( t e s t v a l u e ) < 10ˆ −3)
d i s p ( s p r i n t f ( ’n = %3 d root = %12.7 f testvalue = %12.7 f ’ , n , w( n
) , testvalue ) ) ;
26 N = n;
break ;
end
end
d i s p ( s p r i n t f ( ’n = %3 d root = %12.7 f testvalue = %12.7 f ’ , n , w( n ) ,
testvalue ) ) ;

We can find Q for given values of L and ρ as follows:


388 11 Simplified Dendrite—Soma—Axon Information Processing

Listing 11.11: Finding the Minimal Q For a Resonable Orthogonality


L = 5;
rho = 10;
N = F i n d R o o t S i z e ( 2 0 0 0 0 , L , rho , 1 . 0 , 1 . 0 ) ;
n = 15918 root = 50006.3020635 t e s t v a l u e = 0.0010000

Of course, we can’t really use this information! If you try to solve our approximation
problem using Q = 15918, you will probably do as we did and cause your laptop to
die in horrible ways. The resulting matrix M we need is 15918 × 15918 in size and
most of us don’t have enough memory for that! There are ways around this, but for
our purposes, we don’t really need to use a large value of Q.

11.6.3 Solving for Impulse Voltage Sources

First, we need to set up the data vector. We do this with the script

Listing 11.12: Finding the Ball and Stick Data Vector


f u n c t i o n D = FindData (Q, L , rho , z , Vmax , lambda0 )
%
% Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
5 % rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% z = eigenvalue vector
% D = data vector
% Vmax = s i z e of v o l t a g e impulse
% lambda0 =
10 % M = matrix o f c o e f f i c i e n t s f o r our approximate v o l t a g e
% model
%
kappa = tanh ( L ) / ( rho ∗L ) ;
w = z e r o s (1+Q, 1 ) ;
15 D = z e r o s (1+Q, 1 ) ;
m u l t i p l i e r = −Vmax/ ( 2 ∗ kappa ∗L ) ;
%
w( 1 ) = 0 ;
f o r n=1:Q
20 w( n+1) = z ( n ) ;
end
D( 1 ) = m u l t i p l i e r ;
f o r n = 2 :Q+1
D( n ) = m u l t i p l i e r ∗ c o s (w( n ) ∗ ( L − lambda0 ) ) ;
25 end

Next, we can use the linear system solvers we have discussed in Peterson (2015b).
To solve our system MB = D, we then use the LU decomposition and the lower and
upper triangular solvers as follows:
1. We find the LU decomposition of M.
2. Then, we compute apply Gaussian elimination to transform the system into lower
triangular form.
3. Finally, we use our upper triangular solver tool to find the solution.
11.6 Ball and Stick Numerical Solutions 389

A typical MatLab session would have this form for our previous L = 5, Q = 6
(remember, this gives us 7 values as the value 0 is also used in our solution), ρ − 10
for a pulse of size 200 administered at location λ = 2.5.

Listing 11.13: Finding the Approximate Solution


[ L , U, p i v ] = GePiv (M) ;
y = L T r i S o l ( L ,D( p i v ) ) ;
B = U T r i S o l (U, y ) ;

where B is the vector of coefficients we need to form the solution


Q
V (λ, τ ) = B0 e−τ + Bn cos(αn (L − λ)) e−(1+αn )τ .
2

n=1

The axon hillock voltage is then V (0, τ ). We compute the voltage with the script

Listing 11.14: Finding the Axon Hillock Voltage


f u n c t i o n [ V,AH] = F i n d V o l t a g e (Q, L , rho , z ,M,D)
2 %
% Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
% rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% z = eigenvalue vector
7 % D = data vector
% M = matrix o f c o e f f i c i e n t s f o r our approximate v o l t a g e
% model
%
% s e t t i m e s c a l e f o r d e n d r i t e model
12 TD = 5 . 0 ;
%
[ Lower , Upper , p i v ] = GePiv (M) ;
y = L T r i S o l ( Lower ,D( p i v ) ) ;
B = U T r i S o l ( Upper , y ) ;
17 E r r o r = Lower∗Upper∗B − D( p i v ) ;
D i f f = M∗B−D;
e = norm ( E r r o r ) ;
e2 = norm ( D i f f ) ;
d i s p ( s p r i n t f ( ’ norm of LU residual = %12.7 f norm of MB - D = %12.7 f ’ , e ,
e2 ) ) ;
22 % s e t s p a t i a l and t i m e b o u n d s
% d i v i d e L i n t o 300 p a r t s
lambda = l i n s p a c e ( 0 , L , 3 0 1 ) ;
%d i v i d e t i m e i n t o 100 p a r t s
tau = l i n s p a c e ( 0 ,TD, 1 0 1 ) ;
27 V = zeros (301 ,101) ;
% f i n d v o l t a g e a t s p a c e p o i n t l a m b d a ( s ) and t i m e p o i n t t a u ( t )
for s = 1:301
for t = 1:101
V( s , t ) = B( 1 ) ∗ exp (− t a u ( t ) ) ;
32 f o r n=1:Q
V( s , t ) = V( s , t ) + B( n+1)∗ c o s ( z ( n ) ∗ ( L − lambda ( s ) ) ) . . .
∗ exp (−(1+ z ( n ) ˆ 2 ) ∗ t a u ( t ) ) ;
end
end
37 end
AH = V ( 1 , : ) ;
390 11 Simplified Dendrite—Soma—Axon Information Processing

We can compute a representative axon hillock voltage as follows:

Listing 11.15: Axon Hillock Voltage Computation


Q = 40;
2 L = 5;
rho = 1 0 ;
z = FindRoots (Q, L , rho , 1 . 0 , 1 . 0 ) ;
M = FindM (Q, L , rho , z ) ;
Vmax = 1 0 0 ;
7 location = 2.0;
D = FindData (Q, L , rho , z , Vmax , l o c a t i o n ) ;
[ V,AH] = F i n d V o l t a g e (Q, L , rho , z ,M,D) ;
t = linspace (0 ,5 ,101) ;
x = linspace (0 ,5 ,301) ;
12 p l o t ( t ,AH) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Transient Axon Hillock Response to Pulse 100 at 2.0 ’ ) ;

Fig. 11.4 Initial axon hillock voltage for pulse of size 100 at location 2.0. This uses the t = 0
values which possess least square solution artifacts

This generates the plot of Fig. 11.4. We are plotting the transient axon hillock voltage
versus time. Note we are using the computed axon hillock voltage over the entire time
interval [0, 5]. The least squares solution used at t = 0 is not very representative of
the true voltage. A better approximation is obtained by starting the plot one time value
up from zero: here, the index 1 in the t vector corresponds to 5/100 milliseconds.
This small amount of time allows some attenuation from the damped exponentials of
time to remove the least squares artifacts. We show this in Fig. 11.5. We can also plot
voltage versus distance. V evaluated at time 0 tells us how we have approximated
our impulse at location 2.0 of magnitude 100 as a function of distance along the
11.6 Ball and Stick Numerical Solutions 391

Fig. 11.5 Initial axon


hillock voltage for pulse of
size 100 at location 2.0. This
starts at t = 0.05 to lessen
the least square solution
artifacts

Fig. 11.6 Model


approximation to an impulse
of size 100 at location 2.0:
This starts with the voltage at
t = 0 so there are least
squares solution artifacts

dendritic cable. Of course, if we use the voltage values starting at t = 0, we will


see least squares artifacts. We show this in Fig. 11.6 where we obtain a typical least
squares approximation to the pulse. If we only count voltage values past the first time
tick in our time vector (i.e. t ≥ 0.05), we get a better measure of the axon hillock
voltage. We show this in Fig. 11.7.
392 11 Simplified Dendrite—Soma—Axon Information Processing

Fig. 11.7 Model


approximation to an impulse
of size 100 at location 2.0.
This starts at t = 0.05 to
lessen the least squares
solution artifacts

Listing 11.16: Plot Of Model Approximation To Pulse


p l o t ( x ,V ( : , 2 ) ) ;
x l a b e l ( ’ Cable distance ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Model Approximation to Pulse 100 at 2.0 at initial time ’ )
;

We can combine these MatLab scripts into one function: GetAxonHillock2


which is shown below.

Listing 11.17: GetAxonHillock2


f u n c t i o n [ tau , lambda , V,AH, I n p u t ] = G e t A x o n H i l l o c k 2 (Q, L , TD, rho , Vmax ,
location )
% Inputs :
% Q t h e number o f e i g e n v a l u e s we want t o f i n d
% L the l e n g t h of the dendrite in space constants
5 % rho t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% TD l e n g t h of time i n t e r v a l
% Vmax s i z e of v o l t a g e impulse
% location l o c a t i o n of pulse
%
10 % Outputs
% tau d e n d r i t i c time in u n i t s of time c o n s t a n t s
% lambda d e n d r i t i c p o s i t i o n in units of space constants
% V the solution at (z , t )
% AH the s o l u t i o n at (1 , t )
15 % Input t h e s o l u t i o n a s ( z , 0 ) t o s e e i f match t o
% input voltage is reasonable
%
% V a r i a b l e s used in t h e code
% z eigenvalue vector
20 % D data vector
% M matrix o f c o e f f i c i e n t s f o r our approximate v o l t a g e
% model
11.6 Ball and Stick Numerical Solutions 393

%
25 % get eigenvalue vector z
z = F i n d R o o t s (Q, L , rho , 1 . 0 , 1 . 0 ) ;
% get c o e f f i c i e n t matrix M
M = FindM (Q, L , rho , z ) ;
% compute d a t a v e c t o r f o r i m p u l s e
30 D = FindData (Q, L , rho , z , Vmax , l o c a t i o n ) ;
% S o l v e MB = D s y s t e m
[ Lower , Upper , p i v ] = GePiv (M) ;
y = L T r i S o l ( Lower ,D( p i v ) ) ;
B = U T r i S o l ( Upper , y ) ;
35 % check errors
E r r o r = Lower∗Upper∗B − D( p i v ) ;
D i f f = M∗B−D;
e = norm ( E r r o r ) ;
e2 = norm ( D i f f ) ;
40 d i s p ( s p r i n t f ( ’ norm of LU residual = %12.7 f norm of MB - D = %12.7 f ’ , e ,
e2 ) ) ;
% s e t d e n d r i t i c s p a t i a l and t i m e b o u n d s
% d i v i d e d e n d r i t i c t i m e i n t o 100 p a r t s
tau = l i n s p a c e ( 0 ,TD, 1 0 1 ) ;
% d i v i d e d e n d r i t i c s p a c e L i n t o 300 p a r t s
45 lambda = l i n s p a c e ( 0 , L , 3 0 1 ) ;
%
V = zeros (301 ,101) ;
A = z e r o s (Q, 1 ) ;
f o r n = 1 :Q
50 A( n ) = B( n+1) ;
end
% f i n d v o l t a g e a t s p a c e p o i n t l a m b d a ( s ) and t i m e p o i n t t a u ( t )
for s = 1:301
for t = 1:101
55 w = z ∗ ( L−lambda ( s ) ) ;
u = −(1+ z . ∗ z ) ∗ t a u ( t ) ;
V( s , t ) = B( 1 ) ∗ exp (− t a u ( t ) )+ d o t (A, c o s (w) . ∗ exp ( u ) ) ;
end
end
60 % axon h i l l o c k i s a t l a m b d a = 1
AH = V ( 1 , : ) ;
% p u l s e i s modeled a t i n i t i a l time by
Input = V( : , 1 ) ;

Now, let’s see what happens if we increase Q.

Listing 11.18: Increasing Q


1 [ tau , lambda , V40 , AH40 , I n p u t 4 0 ] = G e t A x o n H i l l o c k 2 ( 4 0 , L , 1 0 , rho , Vmax
, location ) ;
norm o f LU r e s i d u a l = 0 . 0 0 0 0 0 0 0 norm o f MB−D = 0.0000000
[ tau , lambda , V80 , AH80 , I n p u t 8 0 ] = G e t A x o n H i l l o c k 2 ( 8 0 , L , 1 0 , rho , Vmax
, location ) ;
norm o f LU r e s i d u a l = 0 . 0 0 0 0 0 0 0 norm o f MB−D = 0.0000000
[ tau , lambda , V120 , AH120 , I n p u t 1 2 0 ] = G e t A x o n H i l l o c k 2 ( 1 2 0 , L , 1 0 , rho ,
Vmax , l o c a t i o n ) ;
6 norm o f LU r e s i d u a l = 0 . 0 0 0 0 0 0 0 norm o f MB−D = 0.0000000
p l o t ( t , AH40 , ’-’ , t , AH80 , ’ --’ , t , AH120 , ’ -. ’ ) ;
l e g e n d ( ’Q = 40 ’ , ’Q = 80 ’ , ’Q = 120 ’ ) ;

The new plot in Fig. 11.8 shows that the how the axon hillock voltage approximation
is altered by the use of more terms in the expansion. In this plot, we plot the voltages
starting at t = 0 so that all exhibit the least squares solution artifacts. We could
394 11 Simplified Dendrite—Soma—Axon Information Processing

Fig. 11.8 Axon hillock


response to an impulse of
size 100 at location 2.0;
Q = 40, 80 and 120: time
starts at 0

Fig. 11.9 Axon hillock


response to an impulse of
size 100 at location 2.0; Q =
40, 80 and 120: t starts at
0.05

eliminate them by starting the plots after one time tick as we do in Fig. 11.9. Higher
Q values are, of course, better although they cost more to compute.

Listing 11.19: Simple Plot


p l o t ( t ( 2 : 1 0 1 ) ,AH40 ( 2 : 1 0 1 ) , ’-’ , t ( 2 : 1 0 1 ) ,AH80 ( 2 : 1 0 1 ) , ’ --’ , t ( 2 : 1 0 1 )
, AH120 ( 2 : 1 0 1 ) , ’ -. ’ ) ;

We can also look at how the approximation to the pulse changes with Q in
Fig. 11.10 starting at t = 0 and after one time tick in Fig. 11.11.
11.6 Ball and Stick Numerical Solutions 395

Fig. 11.10 Model


approximation to an impulse
of size 100 at location 2.0; Q
= 40, 80 and 120 starting at
time zero

Fig. 11.11 Model


approximation to an impulse
of size 100 at location 2.0; Q
= 40, 80 and 120 starting at
time 0.05

Now let’s look at what happens with several pulses. We have a pulse of 100 at 2.0,
one of 300 at 4.5. The code is as follows:

Listing 11.20: Two Pulses

Q = 40;
L = 5;
rho = 1 0 ;
4 TD = 5 . 0 ;
Vmax1 = 1 0 0 ;
location1 = 2.0;
[ tau , lambda , V1 , AH1, I n p u t 1 ] = G e t A x o n H i l l o c k 2 (Q, L , TD, rho , Vmax1 ,
location1 ) ;
396 11 Simplified Dendrite—Soma—Axon Information Processing

Fig. 11.12 Transient axon


hillock voltage for pulse of
size 300 at location 4.5

Vmax2 = 3 5 0 ;
9 location2 = 4.5;
[ tau , lambda , V2 , AH2, I n p u t 2 ] = G e t A x o n H i l l o c k 2 (Q, L , TD, rho , Vmax2 ,
location2 ) ;

The axon hillock voltage for the second pulse starting with time at one time tick is
seen in Fig. 11.12. We also show the pulse itself in Fig. 11.13.

Listing 11.21: Axon Hillock Responses


p l o t ( t a u ( 2 : 1 0 1 ) ,AH2( 2 : 1 0 1 ) ) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Transient Axon Hillock Voltage Response to Pulse 300 at
4.5 ’ ) ;
5 p l o t ( lambda , V2 ( : , 2 ) ) ;
x l a b e l ( ’ Dendritic Distance ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Model Approximation to Pulse 300 at 4.5 ’ ) ;

Finally, we add the responses together in Fig. 11.14 and the inputs in Fig. 11.15.

Listing 11.22: Adding Responses


p l o t ( t a u ( 2 : 1 0 1 ) ,AH1( 2 : 1 0 1 ) , ’-’ , t a u ( 2 : 1 0 1 ) ,AH2( 2 : 1 0 1 ) , ’ --’ , t a u
( 2 : 1 0 1 ) ,AH1( 2 : 1 0 1 )+AH2( 2 : 1 0 1 ) , ’ -. ’ ) ;
2 l e g e n d ( ’AH Pulse 1 ’ , ’AH Pulse 2 ’ , ’ Summed Pulse ’ ) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Summed Transient Axon Hillock Response : Pulse 100 at 2.0 ,
300 at 4.5 ’ ) ;
p l o t ( lambda , V1 ( : , 2 ) , ’-’ , lambda , V2 ( : , 2 ) , ’ --’ , lambda , V1 ( : , 2 )+V2
( : , 2 ) , ’ -. ’ ) ;
7 l e g e n d ( ’ Pulse 1 at 2.0 ’ , ’ Pulse 2 at 4.5 ’ , ’ Summed Pulse ’ , ’
location ’ , ’ best ’ ) ;
11.7 Ball Stick Project 397

Fig. 11.13 Model


approximation to an impulse
of size 300 at location 4.5

Fig. 11.14 Axon hillock


voltage for pulse of size 300
at location 4.5 and Size 100
at location 2.0

11.7 Ball Stick Project

Let’s compute the axon—hillock voltage given above for a number of possible
choices. It is clear that the solution v̂m we obtain depends on
1. The length of the cable L.
2. The ratio of the dendritic to soma conductance, ρ.
3. The space constant λc as it depends on the cable radius a.
4. The truncation constant Q; we clearly make error by using only a finite number
of terms.
5. The values of α1 to αQ . These have to be determined numerically as the solution
of a transcendental equation as discussed in the text.
398 11 Simplified Dendrite—Soma—Axon Information Processing

Fig. 11.15 Model


approximation for pulse of
size 300 at location 4.5 and
size 100 at location 2.0

With this said, let’s calculate the axon—hillock voltage for various given applied
voltages to the cable.

Exercise 11.7.1 Compute this voltage for sums of impulses voltages applied at inte-
ger spatial constant distances: λ = 0 to λ = L:


L
V (λ) = Vi∗ δ(λ − i).
i=0

Use the following voltage profiles and use a variety of values of Q to do the approx-
imations. Do these for the choices ρ ∈ {0.1, 1.0, 10.0}.

1. L = 1: Here V0∗ is applied at location 0.25 and V1∗ is applied at location 0.75.
(a) Use V0∗ = 10 and V1∗ = 0.
(b) Use V0∗ = 0 and V1∗ = 10.
(c) Use V0∗ = 100 and V1∗ = 0.
(d) Use V0∗ = 0 and V1∗ = 100.
2. L = 5: Here V0∗ is applied at location 0.25 and V5∗ is applied at location 4.75.
The others are applied at integer locations.
(a) Use V0∗ = 10, V1∗ = 0, V2∗ = 0, V3∗ = 0, V4∗ = 0 and V5∗ = 10
(b) Use V0∗ = 0, V1∗ = 0, V2∗ = 10, V3∗ = 0, V4∗ = 0 and V5∗ = 0
(c) Use V0∗ = 100, V1∗ = 0, V2∗ = 0, V3∗ = 0, V4∗ = 0 and V5∗ = 100
(d) Use V0∗ = 0, V1∗ = 0, V2∗ = 100, V3∗ = 0, V4∗ = 0 and V5∗ = 0
3. L = 10: Since the cable is so long, we will assume all Vi∗ are 0 except the ones
listed. Here V0∗ is applied at location 0.25 and V10

is applied at location 9.75.
The others are applied at integer locations.
11.7 Ball Stick Project 399

(a) Use V0∗ ∗


= 10 and V10 = 10
(b) Use V5∗ = 10
(c) Use V0∗ = 100 and V10∗
= 100
(d) Use V5∗ = 100

• Use your judgment to provide reasonable plots of the information you have gath-
ered above.
• Can you draw any conclusions about how to choose Q, L and ρ for our modeling
efforts?

References

Z. Hall, An Introduction to Molecular Neurobiology (Sinauer Associates Inc., Sunderland, 1992)


B. Hille, Ionic Channels of Excitable Membranes (Sinauer Associates Inc., Sunderland, 1992)
D. Johnston, S. Miao-Sin Wu, Foundations of Cellular Neurophysiology (MIT Press, Cambridge,
1995)
J. Peterson, Boundary Value Problems and Fourier Series (Lulu Press, Raleigh, 2015a). Unpublished
notes available from author
J. Peterson Calculus for Cognitive Scientists: Higher Order Models and Their Analysis (Springer
Series on Cognitive Science and Technology, Singapore, 2015b in press)
J. Peterson, BioInformation Processing: A Primer On Computational Cognitive Science (Springer
Series on Cognitive Science and Technology, Singapore, 2015c in press)
W. Rall. Core Conductor Theory and Cable Properties of Neurons, chapter 3, pages 39–67.
Unknown, 1977
T. Weiss, Cellular Biophysics, vol. 1, Transport (MIT Press, Cambridge, 1996a)
T. Weiss, Cellular Biophysics, vol. 2, Electrical properties (MIT Press, Cambridge, 1996b)
Chapter 12
The Basic Hodgkin–Huxley Model

We now discuss the Hodgkin–Huxley model for the generation of the action potential
of an excitable nerve cell. We use the standard Ball and Stick model of Chap. 11.
As previously mentioned, there are many variables are needed to describe what is
happening inside and outside the cellular membrane, and to some extent, inside the
membrane for a standard cable model. There are many of them, so it doesn’t hurt
to keep repeating them! Standard references for this material are Johnston and Wu
(1995) and Weiss (1996a, b). These variables, their meanings and their units are given
in Table 12.1.
The salient variables needed to describe what is happening inside and outside the
cellular membrane and to some extent, inside the membrane are then
• Vm0 is the rest value of the membrane potential.
• Km0 is the rest value of the membrane current per length density.
• Ke0 is the rest value of the externally applied current per length density.
• Ii0 is the rest value of the inner current.
• Io0 is the rest value of the outer current.
• Vi0 is the rest value of the inner voltage.
• Vo0 is the rest value of the outer voltage.
• ri is the resistance of the inner fluid of the cable.
• ro is the resistance of the outer fluid surrounding the cable.
• gm is the membrane conductance per unit length.
• cm is the membrane capacitance per unit length.
The membrane voltage can be shown to satisfy the partial differential equation 12.1
which dimensional analysis shows has units of volts/(cm2 ).

∂ 2 Vm
= (ri + ro )Km − ro Ke (12.1)
∂z2

© Springer Science+Business Media Singapore 2016 401


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_12
402 12 The Basic Hodgkin–Huxley Model

Table 12.1 Hodgkin–Huxley Variable Meaning Units


variable units
Vm Membrane potential mV
Km Membrane current per nA/cm
length
Ke Externally applied current nA/cm
Ii Inner current nA
Io Outer current nA
Ie External current nA
Im Membrane current nA
Vi Inner voltage mV
Vo Outer voltage mV
ri Resistance inner fluid per µohms/cm
length
ro Resistance outer fluid per µohms/cm
length
gm Membrane conductance µSiemens/cm
per length
cm Membrane capacitance per nano
length Fahrads/cm
GM Membrane conductance µSiemens/cm
CM Membrane capacitance nano
Fahrads/cm

In the standard core conductor model, the membrane is not modeled at all, but we
now need to be more careful. A realistic description of how the membrane activity
contributes to the membrane voltage must use models of ion flow which are controlled
by gates in the membrane. A simple model of this sort is based on work that Hodgkin
and Huxley (1952), Hodgkin (1952, 1954) performed in the 1950s. We start by
expanding the membrane model to handle potassium, sodium and an all purpose
current, called leakage current, using a modification of our original simple electrical
circuit model of the membrane. We will think of a gate in the membrane as having
an intrinsic resistance and the cell membrane itself as having an intrinsic capacitance
as shown in Fig. 12.1. This is a picture of an idealized cell with a small portion
of the membrane blown up into an idealized circuit: we see a small piece of the
lipid membrane with an inserted gate. Thus, we expand the single branch of our
old circuit model to multiple branches—one for each ion flow we wish to model.
The ionic current consists of the portions due to potassium, KK , sodium, KNa and
leakage KL . The leakage current is due to all other sources of ion flow across the
membrane which are not being explicitly modeled. This would include ion pumps;
gates for other ions such as Calcium, Chlorine; neurotransmitter activated gates and
so forth. We will assume that the leakage current is chosen so that there is no excitable
neural activity at equilibrium. We are thus led to the model shown in Fig. 12.2. We
will replace our empty membrane box by a parallel circuit model. Now this box is
12 The Basic Hodgkin–Huxley Model 403

Fig. 12.1 The membrane and gate circuit model

Fig. 12.2 The equivalent Ii (z, t) Ii (z + Δz, t)


electrical network model Vi (z, t) Vi (z + Δz, t)
ri Δz Ω ri Δz Ω ri Δz Ω
a b

Km (z, t) Δz Km (z + Δz, t) Δz

Vm (z, t) Membrane Membrane Vm (z + Δz, t)

ro Δz Ω ro Δz Ω ro Δz Ω
d c
Vo (z, t) Vo (z + Δz, t)
Io (z, t) Io (z + Δz, t)

Ke (z, t) Δz Ke (z + Δz, t) Δz

really a chunk of membrane that is z wide. In the first cable model, we assume our
membrane has a constant resistance and capacitance. We know that conductance is
reciprocal resistance, so our model will consist to a two branch circuit: one branch
is contains a capacitor and the other, the conductance element. We will let cm denote
the membrane capacitance density per unit length (measured in fahrad
cm
). Hence, in our
membrane box which is z wide, we see the value of capacitance should be cm z.
Similarly, we let gm be the conductance per unit length (measured in ohm−cm
1
) for the
membrane. The amount of conductance for the box element is thus gm z. In Fig. 12.3,
we illustrate our new membrane model. Since this is a resistance-capacitance parallel
circuit, it is traditional to call this an RC membrane model.
In Fig. 12.3, the current going into the element is Km (z, t)z and we draw the
rest voltage for the membrane as a battery of value Vm0 . We know that the membrane
current, Km , satisfies Eq. 12.2:

∂Vm
Km (z, t) = gm Vm (z, t) + cm (12.2)
∂t
404 12 The Basic Hodgkin–Huxley Model

Fig. 12.3 The RC membrane model

In terms of membrane current densities, all of the above details come from modeling
the simple equation

Km = Kc + Kion

where Km is the membrane current density, Kc is the current through the capacitative
side of the circuit and Kion is the current that flows through the side of the circuit that
is modeled by the conductance term, gm . We see that in this model

∂Vm
Kc = cm , Kion = gm Vm
∂t
However, we can come up with a more realistic model of how the membrane activity
contributes to the membrane voltage by adding models of ion flow controlled by
gates in the membrane. We have not done this before. In this chapter, and subsequent
ones, we will study intensely increasingly more sophisticated versions that model the
membrane gates as well as diffusion processes inside the cell that contribute to ion
flow across the membrane. Our models will initially be based on work that Hodgkin
and Huxley performed in the 1950s.
12.1 Adding Ion Membrane Currents 405

12.1 Adding Ion Membrane Currents

The standard Hodgkin–Huxley of an excitatory neuron consists of the equation for


the total membrane current, KM , obtained from Ohm’s law

∂Vm
Km = cm + KK + KNa + KL , (12.3)
∂t
where we have expanded the Kion term to include the contributions from the sodium
and potassium currents and the leakage current. The new equation for the membrane
voltage is thus

∂ 2 Vm
= (ri + ro )Km − ro Ke
∂z2
∂Vm
= (ri + ro ) cm + (ri + ro ) KK + (ri + ro ) KNa + (ri + ro ) KL − ro Ke
∂t
which can be simplified to what is seen in Eq. 12.5:

1 ∂ 2 Vm ro
= Km − Ke (12.4)
ri + ro ∂z2 ri + ro
∂Vm ro
= cm + KK + KNa + KL − Ke (12.5)
∂t ri + ro

12.2 The Hodgkin–Huxley Gates

In Fig. 12.4, we show an idealized cell with a small portion of the membrane blown up
into an idealized circuit. We see a small piece of the lipid membrane with an inserted
gate. We think of the gate as having some intrinsic resistance and capacitance. Now for
our simple Hodgkin–Huxley model here, we want to model a sodium and potassium
gate as well as the cell capacitance. So we will have a resistance for both the sodium
and potassium. In addition, we know that other ions move across the membrane due
to pumps, other gates and so forth. We will temporarily model this additional ion
current as a leakage current with its own resistance. We also know that each ion has
its own equilibrium potential which is determined by applying the Nernst equation.
The driving electromotive force or driving emf is the difference between the ion
equilibrium potential and the voltage across the membrane itself. Hence, if Ec is the
equilibrium potential due to ion c and Vm is the membrane potential, the driving
force is Vc − Vm . In Fig. 12.4, we see an electric schematic that summarizes what
we have just said. We model the membrane as a parallel circuit with a branch for
the sodium and potassium ion, a branch for the leakage current and a branch for
the membrane capacitance. From circuit theory, we know that the charge q across
a capacitor is q = C E, where C is the capacitance and E is the voltage across the
406 12 The Basic Hodgkin–Huxley Model

Fig. 12.4 The simple Hodgkin–Huxley membrane circuit model

capacitor. Hence, if the capacitance C is a constant, we see that the current through
the capacitor is given by the time rate of change of the charge

dq dE
=C
dt dt

If the voltage E was also space dependent, then we would write E(z, t) to indicate its
dependence on both a space variable z and the time t. Then the capacitative current
would be
dq ∂E
=C
dt ∂t
From Ohm’s law, we know that voltage is current times resistance; hence for each
ion c, we can say

Vc = Ic Rc

where we label the voltage, current and resistance due to this ion with the subscript
c. This implies

1
Ic = Vc = G c Vc
Rc

where G c is the reciprocal resistance or conductance of ion c. Hence, we can model


all of our ionic currents using a conductance equation of the form above. Of course,
the potassium and sodium conductances are nonlinear functions of the membrane
12.2 The Hodgkin–Huxley Gates 407

voltage V and time t. This reflects the fact that the amount of current that flows
through the membrane for these ions is dependent on the voltage differential across
the membrane which in turn is also time dependent. The general functional form for
an ion c is thus

Ic = G c (V, t)(V (t) − Ec (t))

where as we mentioned previously, the driving force, V − Ec , is the difference


between the voltage across the membrane and the equilibrium value for the ion
in question, Ec . Note, the ion battery voltage Ec itself might also change in time
(for example, extracellular potassium concentration changes over time). Hence, the
driving force is time dependent. The conductance is modeled as the product of a
activation, m, and an inactivation, h, term that are essentially sigmoid nonlinearities.
The activation and inactivation are functions of V and t also. The conductance is
assumed to have the form

G c (V, t) = G 0 mp (V, t) hq (V, t)

where appropriate powers of p and q are found to match known data for a given ion
conductance. We model the leakage current, IL , as

IL = gL (V (t) − EL )

where the leakage battery voltage, EL , and the conductance gL are constants that are
data driven. Hence, in terms of current densities, letting gK , gNa and gL respectively
denote the ion conductances per length, our full model would be

KK = gK (V − EK )
KNA = gNa (V − ENa )
KL = gL (V − EL )

We know the membrane voltage satisfies:

1 ∂ 2 Vm ∂Vm ro
= cm + KK + KNa + KL − Ke
ri + ro ∂z 2 ∂t ri + ro

We can rewrite this as

1 ∂ 2 Vm ∂Vm
= cm + gK (Vm − EK ) + gNa (Vm − ENa )
ri + ro ∂z 2 ∂t
ro
+ gL (Vm − EL ) − Ke
ri + ro
408 12 The Basic Hodgkin–Huxley Model

12.2.1 Activation and Inactivation Variables

We assume that the voltage dependence of our activation and inactivation has been
fitted from data. Hodgkin and Huxley modeled the time dependence of these variables
using first order kinetics. They assumed a typical variable of this type, say , satisfies
for each value of voltage, V :

d(V )
= α (V ) (1 − (V )) − β (V ) (V )
dt
(0) = 0 (V )

For convenience of exposition, we usually drop the functional dependence of  on


V and just write:
d
= α (1 − ) − β 
dt
(0) = 0

Rewriting, we see
1 d α
= −
α + β dt α + β
(0) = 0

We let
1
τ =
α + β
α
∞ =
α + β

allowing us to rewrite our rate equation as

d
τ = ∞ − 
dt
(0) = 0

12.3 The Voltage Clamped Protocol

Under certain experimental conditions, we can force the membrane voltage to be


independent of the spacial variable z. In this case, we find

∂ 2 Vm
=0
∂z2
12.3 The Voltage Clamped Protocol 409

which allows us to rewrite Eq. 12.6 as follows


dVm ro
cm + KK + KNa + KL − Ke = 0 (12.6)
dt ri + ro

The replacement of the partial derivatives with a normal derivative reflects the fact
that in the voltage clamped protocol, the membrane voltage depends only on the one
variable, time t. Since, cm is capacitance per unit length, the above equation can also
be interpreted in terms of capacitance, Cm , and currents, IK , INa , IL and an external
type current Ie . This leads to Eq. 12.7
dVm ro
Cm + IK + INa + IL − Ie = 0 (12.7)
dt ri + ro

Finally, if we label as external current, Ie , the term


ro
IE = Ie ,
ri + ro

the equation we need to solve under the voltage clamped protocol becomes Eq. 12.8.

dVm 1
= (−IK − INa − IL + IE ) (12.8)
dt CM

12.4 The Hodgkin–Huxley Sodium and Potassium Model

Hodgkin and Huxley modeled the sodium and potassium gates as

gNa (V ) = gNa
Max
MNA 3 (V ) HNA (V )
gK (V ) = gKMax MK 4 (V )

where the two activation variables, MNA and MK , and the one inactivation variable,
HNA , all satisfy the first order  kinetics as we have discussed. Hence, we know

τMNA MNA (t) = (MNA )∞ − MNA

τHNA HNA (t) = (HNA )∞ − HNA
τMK MK (t) = (MK )∞ − MK

with
1
τMNA =
αMNA + βMNA
αMNA
(MNA )∞ =
αMNA + βMNA
410 12 The Basic Hodgkin–Huxley Model

1
τHNA =
αHNA + βHNA
αHNA
(HNA )∞ =
αHNA + βHNA
1
τMK =
αMK + βMK
αMK
(MK )∞ =
αMK + βMK

Further, the coefficient functions, α and β for each variable required data fits as
functions of voltage. These were determined to be

V + 35.0
αMNA = −0.10
e−0.1 (V +35.0) − 1.0
−(V +60.0)
βMNA = 4.0 e 18.0

αHNA = 0.07 e−0.05 (V +60.0)


1.0
βHNA = (12.9)
(1.0 + e−0.1 (V +30.0) )
0.01 ∗ (V + 50.0)
αMK = − −0.1(V +50.0)
(e − 1.0)
−0.0125 (V +60.0)
βMK = 0.125 e

Of course these data fits were obtained at a certain temperature and assumed values
for all the other constants needed. These other parameters are given in the units below

voltage mV milli volts 10−3 Volts


current na nano amps 10−9 Amps
time ms milli seconds 10−3 Seconds
concentration mM milli moles 10−3 Moles
conductance µS micro Siemens 10−6 ohms−1
capacitance nF nano Fahrads 10−9 Fahrads

The Hodgkin–Huxley gates model of the membrane dynamics here thus consists of
the following differential equations:

dMNA
τMNA = (MNA )∞ − MNA
dt
dHNA
τHNA = (HNA )∞ − HNA
dt
12.4 The Hodgkin–Huxley Sodium and Potassium Model 411

dMK
τMK = (MK )∞ − MK
dt
dV IM − IK − INa − IL
=
dt CM

with initial conditions

MNA (0) = (MNA )∞ (V0 , 0)


HNA (0) = (HNA )∞ (V0 , 0)
MK (0) = (MK )∞ (V0 , 0)
V (0) = V0

We note that at equilibrium there is no current across the membrane. Hence, the
sodium and potassium currents are zero and the activation and inactivation variables
should achieve their steady state values which would be m∞ , h∞ and n∞ computed
at the equilibrium membrane potential which is here denoted by V0 .

12.4.1 Encoding the Dynamics

Now these dynamics are more difficult to solve than you might think. The sequence
of steps is this:
• Given the time t and voltage V compute

V + 35.0
αMNA = −0.10
e−0.1 (V +35.0) − 1.0
−(V +60.0)
βMNA = 4.0 e 18.0
αHNA = 0.07 e−0.05 (V +60.0)
1.0
βHNA =
(1.0 + e−0.1 (V +30.0) )
0.01 ∗ (V + 50.0)
αMK = − −0.1(V +50.0)
(e − 1.0)
−0.0125 (V +60.0)
βMK = 0.125 e

• Then compute the τ and steady state activation and inactivation variables

1
τMNA =
αMNA + βMNA
αMNA
(MNA )∞ =
αMNA + βMNA
412 12 The Basic Hodgkin–Huxley Model

1
τHNA =
αHNA + βHNA
αHNA
(HNA )∞ =
αHNA + βHNA
1
τMK =
αMK + βMK
αMK
(MK )∞ =
αMK + βMK

• Then compute the sodium and potassium potentials. In this model this is easy as
each is set only once since the internal and external ion concentrations always stay
the same and so Nernst’s equation only has to used one time. Here we use the
concentrations

[NA]o = 491.0
[NA]i = 50.0
[K]o = 20.11
[K]i = 400.0

These computations are also dependent on the temperature.


• Next compute the conductances since we now know (MNA (V ), HNA (V ) and
MK (V )).

gNa (V ) = gNa
Max
MNA 3 (V ) HNA (V )
gK (V ) = gKMax MK 4 (V )

Now here we will need the maximum sodium and potassium conductances gNa Max

and gKMax to finish the computation. These values must be provided as data and in
this model are not time dependent. Here we use

gNa
Max
= 120.0
gK = 36.0
Max

• Then compute the ionic currents:

INa = gNA (V )(V (t) − ENA )


IK = gK (V )(V (t) − EK )
IL = gL (V )(V (t) − EL )
12.4 The Hodgkin–Huxley Sodium and Potassium Model 413

where we use suitable values for the leakage conductance and battery voltage
such as

gL = 0.0287
EL = −50.0

We generally obtain these values with the rest.m computation which we will
discuss later.
• Finally compute the total current

IT = INA + IK + IL

• We can now compute the dynamics of our system at time t and voltage V : we let
IE denote the external current to our system which we must supply.

dV IE − IT
=
dt CM
dMNA (MNA )∞ − MNA
=
dt τMNA
dHNA (HNA )∞ − HNA
=
dt τHNA
dMK (MK )∞ − MK
=
dt τMK

where we use CM = 1.0.


The basic Hodgkin–Huxley model thus needs four independent variables which
we place in a four dimensional vector y which components assigned as follows:
⎡ ⎤
y[0] =V
⎢ y[1] = MNA ⎥
y=⎢
⎣ y[2]

= HNA ⎦
y[3] = MK

We encode the dynamics calculated above into a four dimensional vector f whose
components are interpreted as follows:
⎡ IE −IT ⎤
f [0] = CM
⎢ (MNA )∞ −MNA ⎥
⎢ f [1] = ⎥
⎢ τMNA ⎥
f =⎢ (HNA )∞ −HNA ⎥
⎢ f [2] = ⎥
⎣ τHNA ⎦
(MK )∞ −MK
f [3] = τMK
414 12 The Basic Hodgkin–Huxley Model

which in terms of our vector y becomes


⎡ IE −IT ⎤
f [0] = CM
⎢ (MNA )∞ −y[1] ⎥
⎢ f [1] = ⎥
⎢ τMNA ⎥
⎢ (HNA )∞ −y[2] ⎥
⎢ f [2] = ⎥
⎣ τHNA ⎦
(MK )∞ −y[3]
f [3] = τMK

So to summarize, at each time t and V , we need to calculate the four dimensional


dynamics vector f for use in our choice of ODE solver.

12.5 Computing the Solution Numerically

As an example of what we might do to solve this kind of a problem, we note that this
system can now be written in vector form as

dy
= f (t, y)
dt
y(0) = y0

where we have found that




V
⎢ MNA ⎥
y=⎢ ⎥
⎣ HNA ⎦ ,
MK

⎡ IM −IT ⎤
CM
⎢ (MNA )∞ −MNA ⎥
⎢ ⎥
⎢ τMNA ⎥
f = ⎢ (HNA )∞ −HNA ⎥
⎢ ⎥
⎣ τHNA ⎦
(MK )∞ −MK
τMK

with initial data


⎡ ⎤
V0
⎢ (MNA )∞ ⎥
y0 = ⎢ ⎥
⎣ (HNA )∞ ⎦
(MK )∞
12.5 Computing the Solution Numerically 415

The hardest part is to encode all of this in the vector form. The dynamic component
f [0] is actually a complicated function of (MNA ), (HNA ) and (MK ) as determined by
the encoding sequence we have previously discussed. Hence, the calculation of the
dynamics vector f is not as simple as defining each component of f as a functional
expression. Now recall that the Runge–Kutta order 4 requires multiple vector function
f evaluations per time step so that there is no way around the fact that solving this
system numerically is expensive!

12.6 The Simple MatLab Implementation

This MatLab is more complicated and it is worth your while to have review the
MatLab implementations we have discussed earlier. Simple code to manage our
solution of the Hodgkin–Huxley equations is given below. We simply integrate
the equations using a fixed time step repeatedly with a Runge–Kutta method of
order 4. This is not terribly accurate but it illustrates the results nicely nevertheless.
The MatLab code is organized as follows:
1. SolveSimpleHHOrig.m manages the action potential simulation. It calls
HHFixedRK.m to manage the solution of the model using the Runge–Kutta
approximation. We can do better than this in several ways. Right now, our dynam-
ics function does not have the form f (p, t, y) where p is a parameter vector which
allows us to pass in many convenient values each time the dynamics function
is called. We will fix that later. Also, we still use a fixed step size Runge–Kutta
method. We will use RKF5 code later so that we can use an adjustable step size
approach.
2. The code in HHFixedRK.m calls the implementation of Runge–Kutta order
2–4 in HHRKstep.m. RK code which does not have an adjustable step size
algorithm can handle sudden discontinuities in current inputs because there is
no error checking around the time point where the current suddenly jumps. In
our later RKF5 code, we will have to use modified current pulses which ramp
up quickly to their maximum value and then go down to their initial state in a
continuous way so that the errors can be calculated correctly. However, that is a
story for later.
3. The Runge–Kutta code must evaluate the dynamics function simpleHH.m many
times.
4. We also need to initialize the simulation to set the leakage currents to be 0; this
is done with the code in rest.m.
5. We also need to calculate Nernst voltages using the function IonBattery
Voltages which uses the function Nernst.
So here are the code snippets we need.
416 12 The Basic Hodgkin–Huxley Model

12.6.1 Managing the Simulation: SolveSimpleHH.m

The code to manage the solution of the ODE is given below:

Listing 12.1: Managing The MatLab Hodgkin–Huxley Simulation One


function [ t v a l s , g NA , g K , V, m NA, h NA , n K ] = . . .
SolveSimpleHHOrig ( fname , iename , t i n i t , t f i n a l , y0 , h , k , g NAmax ,
g Kmax )

%
5 % We u s e a s i m p l e Runge−K u t t a scheme
% u s i n g t h e Matlab f u n c t i o n below :
%
% f i n d number o f i n t e r a t i o n s t o do
n = c e i l ( ( t f i n a l − t i n i t ) /h ) +1;
10 %
m NA = z e r o s ( 1 , n ) ;
h NA = z e r o s ( 1 , n ) ;
n K = zeros (1 ,n) ;
g Na = z e r o s ( 1 , n ) ;
15 g K = zeros (1 ,n) ;
V = zeros (1 ,n) ;

[ t v a l s , y v a l s ] = HHFixedRK ( fname , iename , t i n i t , y0 , h , k , n ) ;

20 %
% store values in physical variables
%
V = yvals (1 ,1: n) ;
m NA = yvals (2 ,1: n) ;
25 h NA = yvals (3 ,1: n) ;
n K = yvals (4 ,1: n) ;

%
% Compute g Na and G K
30 %
for i = 1:n
u = m NA( i ) ∗m NA( i ) ∗m NA( i ) ∗h NA ( i ) ;
g NA ( i ) = g NAmax∗u ;
end
35
for i = 1:n
u = n K ( i ) ∗n K ( i ) ∗n K ( i ) ∗n K ( i ) ;
g K ( i ) = g Kmax ∗ u ;
end
40
end

12.6.2 Gate Code

In all of our calculations, we will need the equilibrium Nernst voltages for various
ions. We find these with a call to the function IonBatteryVoltages.
12.6 The Simple MatLab Implementation 417

Listing 12.2: Calculating Ion Voltages: IonBatteryVoltages.m


f u n c t i o n [ EK,ENA, T ] = I o n B a t t e r y V o l t a g e s ( KIn , KOut , NaIn , NaOut , TF)
%
% KIn i s t h e i n s i d e p o t a s s i u m c o n c e n t r a t i o n
% KOut i s t h e o u t s i d e p o t a s s i u m c o n c e n t r a t i o n
5 % NaIN i s t h e i n n e r sodium c o n c e n t r a t i o n
% NaOut i s t h e o u t e r sodium c o n c e n t r a t i o n
% TF i s t h e t e m p e r a t u r e i n F a h r e n h e i t
%
% ================================================
10 % Constants for Equilibrium Voltage C a l c u l a t i o n s
% ===============================================
%

% Rydberg ’ s C o n s t a n t
15 R = 8.31;
% K e l v i n Temperature ; c o n v e r t f a h r e n h e i t t o C e l s i u s
% d e f a u l t i s 9.3 Celsius
T = ( 5 / 9 ) ∗ (TF−32) ;
% Faraday ’ s c o n s t a n t
20 F = 9 . 6 4 9 e +4;
%
% Compute N e r n s t v o l t a g e s o f E K and E Na
% v o l t a g e = N e r n s t ( v a l e n c e , Temperature , InConc , OutConc )
%
25 % Sodium
% NA O = 4 9 1 . 0 ;
% NA I = 5 0 . 0 ;
ENA = N e r n s t ( 1 , T , NaIn , NaOut ) ;
% Potassium
30 % K O = 20.11;
% K I = 400.0;
EK = N e r n s t ( 1 , T , KIn , KOut ) ;

Now, the typical dynamics for the Hodgkin–Huxley model has the following form
in MatLab. It has input arguments of time, t, the current vector of y values and the
name of the function which calculates an external current, IE. We encode all of
the sodium and potassium gate model parameters directly into the function. This
makes the function one we have to edit every time we change any aspect of the
Hodgkin–Huxley gate models.

Listing 12.3: simpleHH Arguments


f u n c t i o n f = simpleHH ( t , y , IE )
% S t a n d a r d Hodgkin − Huxley Model
% units
% voltage mV
5 % current na
% time ms
% c o n c e n t r a t i o n mM
% conductance micro Siemens
% capacitance nF
10 %
% t = time
% y = dynamic v a r i a b l e s
% y input
% y (1) = V
418 12 The Basic Hodgkin–Huxley Model

15 % y ( 2 ) = m NA
% y ( 3 ) = h NA
% y (4) = m K
aa
% IE = e x t e r n a l i n p u t
20 %

The dynamics vector here is four dimensional, so we set its size next.

Listing 12.4: Set dimension of dynamics


f u n c t i o n f = simpleHH ( t , y , IE )
% set s i z e of f
%
f = zeros (1 ,4) ;
5 % ===============================================
% f vector assignments
% ===============================================
% f ( 1 ) = V dynamics
% f ( 2 ) = m NA dynamics
10 % f ( 3 ) = h NA dynamics
% f ( 4 ) = m K dynamics
%

We compute the Nernst battery voltages and set the maximum sodium and potassium
ion conductances.

Listing 12.5: Get Ion battery voltages


% ================================================
% Constants for Equilibrium Voltage C a l c u l a t i o n s
3 % ===============================================
[ E K , E NA ] = I o n B a t t e r y V o l t a g e s ( 4 0 0 . 0 , 2 0 . 1 1 , 5 0 . 0 , 4 9 1 . 0 , 6 9 ) ;

% max c o n d u c t a n c e f o r NA
g NA bar = 1 2 0 . 0 ;
8
% max c o n d u c t a n c e f o r K
g K bar = 3 6 . 0 ;

Then, we find the sodium current.

Listing 12.6: Calculate sodium current


% ================================================
% F a s t Sodium C u r r e n t
% ===============================================
% a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
5 %
% alpha mNA , beta mNA
%
sum = y ( 1 ) + 3 5 . 0 ;
i f sum > 0
12.6 The Simple MatLab Implementation 419

10 alpha mNA = −0.10∗sum / ( exp (−sum / 1 0 . 0 ) − 1 . 0 ) ;


else
alpha mNA = −0.10∗ exp ( sum/ 1 0 . 0 ) ∗sum / ( 1 . 0 − exp ( sum/
10.0) ) ;
end
%
15 sum = y ( 1 ) + 6 0 . 0 ;
i f sum > 0
beta mNA = 4 . 0 ∗ exp ( −sum / 1 8 . 0 ) ;
else
beta mNA = 4 . 0 ∗ exp ( −sum / 1 8 . 0 ) ;
20 end
%
m N A i n f i n i t y = alpha mNA / ( alpha mNA+beta mNA ) ;
t m NA = 1 . 0 / ( alpha mNA+beta mNA ) ;
%
25 f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
%
% a c t i v a t i o n , i n a c t i v a t i o n p a r a m e t e r f o r I NA
%
% alpha hNA , beta mNA
30 %
sum = ( y ( 1 ) + 6 0 . 0 ) / 2 0 . 0 ;
i f sum < 0
alpha hNA = 0 . 0 7 ∗ exp ( −sum ) ;
else
35 alpha hNA = 0 . 0 7 ∗ exp ( −sum ) ;
end
%
sum = y ( 1 ) + 3 0 . 0 ;
i f sum>0
40 beta hNA = 1 . 0 / ( 1 . 0 + exp (−sum / 1 0 . 0 ) ) ;
else
beta hNA = exp ( sum / 1 0 . 0 ) / ( exp ( sum / 1 0 . 0 ) + 1 . 0 ) ;
end
%
45 h N A i n f i n i t y = alpha hNA / ( alpha hNA+beta hNA ) ;
t h NA = 1 . 0 / ( alpha hNA+beta hNA ) ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
%
% I NA c u r r e n t
50 %
I NA = g NA bar ∗ ( y ( 1 )−E NA) ∗y ( 2 ) ∗y ( 2 ) ∗y ( 2 ) ∗y ( 3 ) ;

Next, we calculate the potassium current.

Listing 12.7: Calculate Potassium current


% ================================================
% Potassium Cu rr ent
% ===============================================
4 %
% a c t i v a t i o n / i n a c t i v a t i o n parameters for K
%
% alpha mK
%
9 sum = y ( 1 ) + 5 0 . 0 ;
i f sum > 0
alpha mK = −0.01∗sum / ( exp (−sum / 1 0 . 0 ) − 1 . 0 ) ;
else
alpha mK = −0.01∗ exp ( sum / 1 0 . 0 ) ∗sum / ( 1 . 0 − exp ( sum / 1 0 . 0 ) )
;
420 12 The Basic Hodgkin–Huxley Model

14 end
sum = ( y ( 1 ) + 6 0 . 0 ) ∗ 0 . 0 1 2 5 ;
i f sum > 0
beta mK = 0 . 1 2 5 ∗ exp ( −sum ) ;
else
19 beta mK = 0 . 1 2 5 ∗ exp ( −sum ) ;
end
t m K = 1 . 0 / ( alpha mK+beta mK ) ;
m K infinity = alpha mK / ( alpha mK+beta mK ) ;
f (4) = ( m K i n f i n i t y − y ( 4 ) ) /t m K ;
24 %
% I K current
%
I K = g K b a r ∗ ( y ( 1 )−E K ) ∗y ( 4 ) ∗y ( 4 ) ∗y ( 4 ) ∗y ( 4 ) ;

Finally, we set the leakage current.

Listing 12.8: Set leakage current


% ================================================
% L e a k a g e C u r r e n t : run r e s t .m t o f i n d a p p r o p r i a t e
3 g L value
% ===============================================
g leak = .0287;
E leak = −50.0;

8 %
% I L current
%
I l e a k = g l e a k ∗ ( y ( 1 )− E l e a k ) ;

We then set the cell capacitance, find the external input at this time and find the f(1)
term which gives the full cell dynamics.

Listing 12.9: Set cell capacitance and cable dynamics


%
% C e l l Capacitance
%
C M = 1.0;
5 s = f e v a l ( IE , t ) ;
% s = 0;
f ( 1 ) = ( s − I NA − I K − I l e a k ) /C M ;

Let’s change this, and at the same time make the code simpler and cleaner, by
introducing a more abstract model of the ion gates. The function used in the gate
models are all special cases of the of the general mapping F(Vm , p, q) with p ∈ 4
and q ∈ 2 defined by

p0 (Vm + q0 ) + p1
F(Vm , p, q) = .
ep2 (Vm +q1 ) + p3

For ease of exposition, here we will denote MNa by m, HNa by h and MK by n as,
historically, m, h and n have been used for these Hodgkin–Huxley models. The α
12.6 The Simple MatLab Implementation 421

and β pairs are thus described using the generic F mapping by

αm = F(Vm , pαm = {−0.10, 0.0, −0.1, −1.0},


qmα = {35.0, 35.0}),
βm = F(Vm , pβm = {0.0, 4.0, 0.0556, 0.0},
qmβ = {60.0, 60.0}),
αh = F(Vm , pαh = {0.0, 0.07, 0.05, 0.0},
qhα = {60.0, 60.0}),
β
βh = F(Vm , ph = {0.0, 1.0, −0.1, 1.0},
β
qh = {30.0, 30.0}),
αn = F(Vm , pαn = {−0.01, 0.0, −0.1, −1.0},
qnα = {50.0, 50.0}),
βn = F(Vm , pβn = {0.0, 0.125, 0.0125, 0.0},
qnβ = {60.0, 60.0}).

The p and q parameters control the shape of the action potential in a complex way.
We will think of alterations in the (p, q) pair associated with a given α and/or β as
a way of modeling how passage of ions through the gate are altered by the addition
of various ligands. These effects may or may not be immediate. For example, the
alterations to the p and q parameters may be due to the docking of ligands which
are manufactured through calls to the genome in the cell’s nucleus. In that case,
there may be a long delay between the initiation of a second messenger signal to
the genome and the migration of the ligands to the outside of the cell membrane.
In addition, proteins can be made which bind to the inside of a gate and thereby
alter the ion flow. We understand that this type of modeling is not attempting to
explain the details of such interactions. Instead, we are exploring an approach for
rapid identification and differentiation of the signals due to various toxins. For now,
we assume our standard Hodgkin–Huxley model uses gNa Max
= 120, gKMax = 36.0 and
the classical α, β functions are labeled as the nominal values. Hence, all we need to
do is code the information below in a vector 0 given by
⎡ ⎤
G 0Na = 120.0
⎢ 0 ⎥
⎢ G K = 36.0 ⎥
⎢ α 0 ⎥
⎢ (pm ) {−0.10, 0.0, −0.1, −1.0} (pβm )0 {0.0, 4.0, 0.0556, 0.0} ⎥
⎢ ⎥
⎢ α 0 β ⎥
⎢ (ph ) {0.0, 0.07, 0.05, 0.0} (ph )0 {0.0, 1.0, −0.1, 1.0} ⎥
0 = ⎢
⎢ (pα )0

⎢ n {−0.01, 0.0, −0.1, −1.0} (pβn )0 {0.0, 0.125, 0.0125, 0.0} ⎥

⎢ α 0 ⎥
⎢ (qm ) {35.0, 35.0} (qmβ )0 {60.0, 60.0} ⎥
⎢ ⎥
⎢ α 0 β ⎥
⎣ (qh ) {60.0, 60.0} (qh )0 {30.0, 30.0} ⎦
(qnα )0 {50.0, 50.0} (qnβ )0 {60.0, 60.0}

First, we write MatLab code to implement the function F.


422 12 The Basic Hodgkin–Huxley Model

Listing 12.10: Gate Dynamics Function


f u n c t i o n F = HHGates (V, p , q )
%
3 % V = incoming v o l t a g e
% p = p a r a m e t e r s f o r g a t e m odel
% q = p a r a m e t e r s f o r g a t e m odel
% gate value
%
8 Numerator = p ( 1 ) ∗ (V + q ( 1 ) ) + p ( 2 ) ;
Denominator = exp ( p ( 3 ) ∗ (V + q ( 2 ) ) ) + p ( 4 ) ;
F = Numerator / Denominator ;

We can then implement the classical Hodgkin–Huxley model dynamics as follows:

Listing 12.11: Classical HH Gate Model


f u n c t i o n a l p h a = GatesNAK ( gatesname ,V)
%
% g a t e s n a m e = name o f g a t e f u n c t i o n
% V = voltage
5 % alpha = ( a l p h a , b e t a ) p a i r s i n HH mode l
% a s many p a i r s a s t h e r e a r e i o n s
% i n t h e model
% T h i s i s s i m p l e Sodium , P o t a s s i u m model s o
% a l p h a , b e t a f o r mNA = a l p h a ( 1 ) , a l p h a ( 2 )
10 % a l p h a , b e t a f o r hNA = a l p h a ( 3 ) , a l p h a ( 4 )
% a l p h a , b e t a f o r mK = a l p h a ( 5 ) , a l p h a ( 6 )
%
% we n e e d p , q p a r a m e t e r v e c t o r s f o r e a c h o f t h e
% s i x alpha , beta p a i r s . T h e s e v a l u e s come from
15 % the l i t e r a t u r e
%
p = zeros (6 ,4) ;
q = zeros (6 ,2) ;
p = [ −0.1 ,0.0 , −0.1 , −1.0;...
20 0.0 ,4.0 ,0.0556 ,0.0;...
0.0 ,0.07 ,0.05 ,0.0;...
0.0 ,1.0 , −0.1 ,1.0;...
−0.01 ,0.0 , −0.1 , −1.0;...
0.0 ,0.125 ,0.0125 ,0.0];
25 %
q = [35.0 ,35.0;...
60.0 ,60.0;...
60.0 ,60.0;...
30.0 ,30.0;...
30 50.0 ,50.0;...
60.0 ,60.0];
%
a l p h a ( 1 ) = f e v a l ( gatesname , V, p ( 1 , : ) , q ( 1 , : ) ) ;
a l p h a ( 2 ) = f e v a l ( gatesname , V, p ( 2 , : ) , q ( 2 , : ) ) ;
35 a l p h a ( 3 ) = f e v a l ( gatesname , V, p ( 3 , : ) , q ( 3 , : ) ) ;
a l p h a ( 4 ) = f e v a l ( gatesname , V, p ( 4 , : ) , q ( 4 , : ) ) ;
a l p h a ( 5 ) = f e v a l ( gatesname , V, p ( 5 , : ) , q ( 5 , : ) ) ;
a l p h a ( 6 ) = f e v a l ( gatesname , V, p ( 6 , : ) , q ( 6 , : ) ) ;
end

This returns the three (α, β) pairs associated with the classical HH model as a
single vector α. We write the (p, q) values we need directly into this file. However,
if we wanted to implement a different gate model, we could easily either edit this
file or copy it to a new file and edit that. This gives us a more flexible way to do our
modeling. Our dynamics are given in the rewritten code simpleHH.m.
12.6 The Simple MatLab Implementation 423

Listing 12.12: HH Dynamics: simpleHH.m


function f = simpleHH ( t , y , IE )

% S t a n d a r d H o d g k i n − H u x l e y Model
% voltage mV
5 % current na
% time ms
% c o n c e n t r a t i o n mM
% conductance micro Siemens
% capacitance nF
10 % ===============================================
% y vector assignments
% ===============================================
% y (1) = V
% y ( 2 ) = m NA
15 % y ( 3 ) = h NA
% y (4) = m K
%
% set s i z e of f
%
20
f = zeros (1 ,4) ;

% ===============================================
% f vector assignments
25 % ===============================================
% y ( 1 ) = V dynamics
% y ( 2 ) = m NA d y n a m i c s
% y ( 3 ) = h NA d y n a m i c s
% y ( 4 ) = m K dynamics
30 %
% ================================================
% Constants for Equilibrium Voltage C a l c u l a t i o n s
% ===============================================
[ E K , E NA , T ] = I o n B a t t e r y V o l t a g e s ( 4 0 0 . 0 , 2 0 . 1 1 , 5 0 . 0 , 4 9 1 . 0 , 6 9 ) ;
35
% max c o n d u c t a n c e f o r NA
g NA bar = 1 2 0 . 0 ;
% max c o n d u c t a n c e f o r K
g K bar = 3 6 . 0 ;
40 %
a l p h a = GatesNAK ( ’ HHGates ’ , y ( 1 ) ) ;
%
% a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
% a l p h a ( 1 ) , a l p h a ( 2 ) a l p h a and b e t a f o r mna
45 % a l p h a ( 3 ) , a l p h a ( 4 ) a l p h a and b e t a f o r hna
% a l p h a ( 5 ) , a l p h a ( 6 ) a l p h a and b e t a f o r mk
% ================================================
% F a s t Sodium C u r r e n t
% ===============================================
50 %
m NA infinity = a l p h a ( 1 ) / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
t m NA = 1 . 0 / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
%
55 h NA infinity = a l p h a ( 3 ) / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
t h NA = 1 . 0 / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
I NA = g NA bar ∗ ( y ( 1 )−ENA) ∗y ( 2 ) ˆ3∗ y ( 3 ) ;
% ================================================
60 % Potassium Current
% ===============================================
%
m K infinity = a l p h a ( 5 ) / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
t m K = 1 . 0 / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
65 f (4) = ( m K i n f i n i t y − y ( 4 ) ) /t m K ;
I K = g K b a r ∗ ( y ( 1 )−EK) ∗y ( 4 ) ˆ 4 ;
424 12 The Basic Hodgkin–Huxley Model

%
% l e a k a g e c u r r e n t : run r e s t .m t o find appropriate g L value
%
70 g leak = .0084170;
E leak = −50.0;
%
% I L current
I l e a k = g l e a k ∗ ( y ( 1 )− E l e a k ) ;
75
%
% C e l l Capacitance
%
C M = 1.0;
80 s = f e v a l ( IE , t ) ;
% s = 0;
f ( 1 ) = ( s − I NA − I K − I l e a k ) /C M ;

12.6.3 Setting Ion Currents to Zero: Rest.m

The initial conditions for the activation and inactivation variables for this model
should be calculated carefully. When the excitable nerve cell is at equilibrium, with
no external current applied, there is no net current flow across the membrane. At this
point, the voltage across the membrane should be the applied voltage EM . Therefore,

0 = IT
= INA + IK1 + IL
= gNA
Max
(EM − ENA )(MNA )3∞ (HNA )∞ + gKMax (EM − EK ) (HNA )4∞
+ gL (EM − EL )

The two parameters, gL and EL , are used to take into account whatever ionic currents
flow across the membrane that are not explicitly modeled. We know this model does
not deal with various pumps, a variety of potassium gates, calcium gates and so
forth. We also know there should be no activity at equilibrium in the absence of an
external current. However, it is difficult to choose these parameters. So first, solve
to the leakage parameters in terms of the rest of the variables. Also, we can see that
the activation and inactivation variables for each gate at equilibrium will take on
the values that are calculated using the voltage EM . We can use the formulae given
in the Hodgkin–Huxley dynamics to compute the values of activation/inactivation
that occur when the membrane voltage is at rest, EM . We label these values with a
superscript r for notational convenience.

MNA
r
≡ (MNA )∞ (EM )
HNA ≡ (HNA )∞ (EM )
r

MKr ≡ (MK )∞ (EM )


12.6 The Simple MatLab Implementation 425

Then, we can calculate the equilibrium currents


r
INA = gNA
max
(EM − ENA ) (MNA
r 3
) HNA
r

IKr = gKMax (EM − EK ) (MKr )4

Thus, we see we must choose gL and EL so that

gL (EL − EM ) = INA
r
+ IKr

or

gL (EL − EM ) = INA
r
+ IKr

If we choose to fix EL , we can solve for the leakage conductance


r
INA + IKr
gL =
EL − EM

We do this in the function rest.m.

Listing 12.13: Initializing The Simulation: rest.m


f u n c t i o n [ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = r e s t ( E L , V R , g NA bar ,
g K bar , p , F )
%
3 % inputs :
% E L = leakage voltage
% g N A b a r = maximum sodium c o n d u c t a n c e
% g K b a r = maximum p o t a s s i u m c o n d u c t a n c e
% V R = rest voltage
8 % p = parameter v e c t o r
% p[1] = I n s i d e Potassium Concentration
% p[2] = Outside Potassium Concentration
% p[3] = I n s i d e Sodium C o n c e n t r a t i o n
% p[4] = O u t s i d e Sodium C o n c e n t r a t i o n
13 % p[5] = reference temperature
% F = name o f g a t e s f u n c t i o n
%
% outputs :
% g L = leakage conductance
18 % m NA0 = i n i t i a l v a l u e o f m NA
% h NA0 = i n i t i a l v a l u e o f h NA
% m K0 = i n i t i a l value of m K
% E K = potassium Nernst v o l t a g e
% E NA = sodium N e r n s t v o l t a g e
23 %
% ==================================================
% Constants f o r Ion E q u i l i b r i u m V o l t a g e C a l c u l a t i o n s
% ==================================================
KIn = p(1) ;
28 KOut = p ( 2 ) ;
NaIn = p ( 3 ) ;
NaOut = p ( 4 ) ;
TF = p(5) ;

33 [ E K , E NA ] = I o n B a t t e r y V o l t a g e s ( KIn , KOut , NaIn , NaOut , TF) ;


%
a l p h a = GatesNAK ( F , V R ) ;
%
% a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
426 12 The Basic Hodgkin–Huxley Model

38 % a l p h a ( 1 ) , a l p h a ( 2 ) a l p h a and b e t a f o r mna
% a l p h a ( 3 ) , a l p h a ( 4 ) a l p h a and b e t a f o r hna
% a l p h a ( 5 ) , a l p h a ( 6 ) a l p h a and b e t a f o r mk
%
m NA0 = a l p h a ( 1 ) / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
43 h NA0 = a l p h a ( 3 ) / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
m K0 = a l p h a ( 5 ) / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
% I NA c u r r e n t , I K c u r r e n t
I NA = g NA bar ∗ (V R−E NA) ∗m NA0ˆ3∗h NA0 ;
I K = g K b a r ∗ (V R−E K ) ∗m K0 ˆ 4 ;
48 %
numerator = −I NA − I K ;
denominator = V R − E L ;
%
% compute g L : Note we want
53 % I NA + I K + g L ∗ ( V R − E L ) = 0
% w h i c h g i v e s t h e e q u a t i o n b e l o w a s s u m i n g we a r e g i v e n E L .
%
g L = −(I NA + I K ) / ( V R − E L ) ;
end

12.6.4 The Runge–Kutta Manager: HHFixedRK.m

The code that manages the call to a fixed Runge–Kutta order method from an earlier
chapter has been modified to accept an argument which is the name of the function
which models the current injection.

Listing 12.14: The MatLab Fixed Runge–Kutta Method


f u n c t i o n [ t v a l s , y v a l s ] = HHFixedRK ( fname , iename , t0 , y0 , h , k , n )
%
3 % Gives approximate s o l u t i o n to
% y ’( t ) = f (t , y( t ))
% y ( t 0 ) = y0
% u s i n g a k t h o r d e r RK method
%
8 % t0 i n i t i a l time
% y0 initial state
% h stepsize
% k RK o r d e r 1<= k <= 4
% n Number o f s t e p s t o t a k e
13 %
% tvals t i m e v a l u e s o f form
% t v a l s ( j ) = t 0 + ( j −1)∗h , 1 <= j <= n
% yvals approximate s o l u t i o n
% y v a l s ( : j ) = approximate s o l u t i o n at
18 % tvals ( j ) , 1 <= j <= n
% fname name o f d y n a m i c s f u n c t i o n
% iename name o f c u r r e n t i n j e c t i o n f u n c t i o n
%
tc = t0 ;
23 yc = y0 ;
tvals = tc ;
yvals = zeros (4 ,n) ;
y v a l s ( 1 : 4 , 1 ) = t r a n s p o s e ( yc ) ;
f c = f e v a l ( fname , t c , yc , iename ) ;
28 f o r j =1:n−1
[ t c , yc , f c ] = HHRKstep ( fname , iename , t c , yc , f c , h , k ) ;
y v a l s ( 1 : 4 , j +1) = t r a n s p o s e ( yc ) ;
tvals = [ tvals tc ] ;
end
12.6 The Simple MatLab Implementation 427

12.6.4.1 The Runge–Kutta Implementation: HHRKstep.m

The actual Runge–Kutta code was also modified to allow the name of the current
injection function to be entered as an argument.

Listing 12.15: Adding Injection Current To The Runge–Kutta Code


f u n c t i o n [ tnew , ynew , fnew ] = HHRKstep ( fname , iename , t c , yc , f c , h , k )
%
3 % fname t h e name o f t h e r i g h t hand s i d e f u n c t i o n f ( t , y )
% t i s a s c a l a r u s u a l l y c a l l e d t i m e and
% y i s a vector of s i z e d
% yc a p p r o x i m a t e s o l u t i o n t o y ’ ( t ) = f ( t , y ( t ) ) a t t=t c
% fc f ( tc , yc )
8 % h The t i m e s t e p
% k The o r d e r o f t h e Runge−K u t t a Method 1<= k <= 4
%
% t ne w t c+h
% ynew a p p r o x i m a t e s o l u t i o n a t tn e w
13 % fnew f ( tnew , ynew )
%
i f k==1
k1 = h∗ f c ;
ynew = yc+k1 ;
18 e l s e i f k==2
k1 = h∗ f c ;
k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) , iename ) ;
ynew = yc + ( k1+k2 ) / 2 ;
e l s e i f k==3
23 k1 = h∗ f c ;
k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) , iename ) ;
k3 = h∗ f e v a l ( fname , t c+h , yc−k1+2∗k2 , iename ) ;
ynew = yc +(k1+4∗k2+k3 ) / 6 ;
e l s e i f k==4
28 k1 = h∗ f c ;
k2 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k1 / 2 ) , iename ) ;
k3 = h∗ f e v a l ( fname , t c +(h / 2 ) , yc +(k2 / 2 ) , iename ) ;
k4 = h∗ f e v a l ( fname , t c+h , yc+k3 , iename ) ;
ynew = yc +(k1+2∗k2+2∗k3+k4 ) / 6 ;
33 else
d i s p ( s p r i n t f ( ’ The RK method %2 d order is not allowed ! ’ , k ) ) ;
end
tnew = t c+h ;
fnew = f e v a l ( fname , tnew , ynew , iename ) ;

12.6.5 A Simple External Current: IE.m

Listing 12.16: The Injected Current Pulse


f u n c t i o n i e = IE ( t )
%
3 %
%
ts1 = 9.95;
te1 = 1 0 . 0 ;
ts2 = 10.62;
8 te2 = 1 0 . 6 7 ;
Imax1 = 1 0 0 . 0 ;
ie = 0;
428 12 The Basic Hodgkin–Huxley Model

if t >= t s 1 && t <= t e 1


i e = ( Imax1 / ( t e 1 − t s 1 ) ) ∗ ( t − t s 1 ) ;
13 e l s e i f t>t e 1 && t < t s 2
i e = Imax1 ;
e l s e i f t >= t s 2 && t < t e 2
i e = Imax1 −(Imax1 / ( t e 2 − t s 2 ) ) ∗ ( t − t s 2 ) ;
end

12.6.6 Runtime Results

For this simulation, we will use a Fahrenheit temperature of 69.0, a maximum sodium
conductance of 120.0 and a maximum potassium conductance of 36.0. There are a
few things we have to watch for when we run a simulation:
• The Celsius temperature is actually typed into the code files simpleHH.m and
rest.m. So changing this temperature means you have to edit and change a line in
both files.
• The maximum sodium and potassium conductances is hard coded into the file
simpleHH.m. So changing these values requires editing this files.
• Once values of temperature, maximum conductances and leakage voltage are cho-
sen, run rest.m to determine the value of gL that ensures no current flows across the
cell membrane when there is no external current. This function call also returns
the initial values for the Hodgkin–Huxley dynamical system. Lines like

Listing 12.17: Finding Hodgkin–Huxley model initial conditions


V R = −70;
E L = −50;
3 Kin = 4 0 0 . 0 ;
Kout = 2 0 . 1 1 ;
Nain = 5 0 . 0 ;
Naout = 4 9 1 . 0 ;
TF = 6 9 . 0 ;
8 p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
g NA bar = 1 2 0 ;
g K bar = 3 6 . 0 ;
F = ’ HHGates ’ ;
[ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = . . .
13 r e s t ( E L , V R , g NA bar , g K bar , p , F )
g L = 0.0084170
m NA0 = 0 . 0 1 5 3 8 5
h NA0 = 0 . 8 6 5 1 7
m K0 = 0 . 1 8 1 0 0
18 E K = −75.607
E NA = 5 7 . 7 6 0

allow us to find the initial condition for the Hodgkin–Huxley dynamical system
we want to solve. We find
12.6 The Simple MatLab Implementation 429
⎡ ⎤ ⎡ ⎤
y[1] V_R
⎢ y[2] ⎥ ⎢ m_NA0 ⎥
⎢ ⎥ ⎢ ⎥
⎣ y[3] ⎦ = ⎣ h_NA0 ⎦ .
y[4] m_K0

Then the value of gL returned must then be typed into the appropriate place in the
file simpleHH.m.
• Once the above steps have been done, we are ready to run the simulation.
We ran our simple simulation using this session (we edit a bit to shorten lines and so
forth):

Listing 12.18: Sample session to generate an action potential


1 [ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = . . .
r e s t ( E L , V R , g NA bar , g K bar , p , F )
g L = 0.0084170
m NA0 = 0 . 0 1 5 3 8 5
h NA0 = 0 . 8 6 5 1 7
6 m K0 = 0 . 1 8 1 0 0
E K = −75.607
E NA = 5 7 . 7 6 0
% we t h e n e d i t e d simpleHH .m t o add t h i s g L and our E L
fname = ’ simpleHH ’ ;
11 iename = ’IE ’ ;
t i n i t = 0;
t f i n a l = 30;
y0 = [ V R , m NA0 , h NA0 , m K0 ] ;
y0
16 y0 =

− 70. 000000 0.015385 0.865168 0.181001


[ t v a l s , g NA , g K , V, m NA, h NA , n K ] = . . .
SolveSimpleHHOrig ( fname , iename , t i n i t , t f i n a l , . . .
21 y0 , 0 . 0 1 , 4 , g NA bar , g K b a r ) ;

This result uses the applied current given by the code IE.m. This pulse applies
a constant current of 100 namps between on the time interval [10.0, 10.62]. On
the interval [9.95, 10.0], the current ramps up from 0 to 100 and on the interval
[10.62, 10.67], the current moves smoothly from 100 back to 0. Otherwise, it is zero.
Hence, this is a continuous current pulse. In Fig. 12.5, we see the membrane voltage
versus time curve that results from the application of this injected current. Note we
see a nice action potential here. We show the corresponding sodium and potassium
conductances during this pulse in Fig. 12.6. In Fig. 12.7 we show the activation and
inactivation variables for sodium and in Fig. 12.8, we show the activation variable
for potassium.
430 12 The Basic Hodgkin–Huxley Model

Fig. 12.5 Membrane voltage versus time: gL = 0.0084170, EL = −50, gNA


max = 120 and g max =
K
36.0

Fig. 12.6 Sodium and potassium conductances versus time for gNA
max = 120 and g max = 36 for
K
impulse current
12.6 The Simple MatLab Implementation 431

Fig. 12.7 Sodium activation and inactivation versus time

Fig. 12.8 Potassium activation versus time


432 12 The Basic Hodgkin–Huxley Model

It is also instructive to look at the ion currents and conductances during the pulses.
Simply compute and plot the currents with the following MatLab commands

Listing 12.19: Calculating and plotting ion currents


E NA = 5 8 . 0 8 4 0 ;
E K = −76.0304;
I NA = g NA bar ∗g NA . ∗ ( V−E NA) ;
I K = g K b a r ∗ g K . ∗ ( V− E K ) ;
5 p l o t ( t v a l s , I NA , t v a l s , I K ) ;
x l a b e l ( ’ Time ms ’ ) ;
y l a b e l ( ’ Current na ’ ) ;
t i t l e ( ’ Sodium and Potassium Currents vs Time ’ ) ;
l e g e n d ( ’ Sodium ’ , ’ Potassium ’ ) ;

In Fig. 12.9, we see the sodium and potassium currents plotted simultaneously. Note
that the sodium current is positive while the potassium current is negative. If you
look closely, you can see the potassium current lags behind the sodium one. Finally,
we can look at how the sodium and potassium gates action depends on voltage. They
are voltage dependent gates after all! The sodium conductance versus membrane
voltage is shown in Fig. 12.10 and the potassium conductance voltage curve is shown
in Fig. 12.11.

Fig. 12.9 Sodium and potassium currents versus time


12.6 The Simple MatLab Implementation 433

Fig. 12.10 Sodium conductance versus voltage

Fig. 12.11 Potassium conductance versus voltage


434 12 The Basic Hodgkin–Huxley Model

12.7 Printing Additional Variables


In order to plot the τmNA and mNA values and so forth for our simulation, we have to
rewrite some code. We need to return all of the time constants and asymptotic values
so that we can generate plots. First, we need to modify the dynamics function.

12.7.1 The New Dynamics Function: simpleHHnew.m

We add additional variables to the dynamics so we can return information on the


time constants and steady state values of the α–β gate functions.

Listing 12.20: Adding new variables to the dynamics to return more information:
simpleHHnew
1 f u n c t i o n [ f , z ] = simpleHHnew ( t , y , IE )
% S t a n d a r d H o d g k i n − H u x l e y Model
% voltage mV
% current na
% time ms
6 % c o n c e n t r a t i o n mM
% conductance micro Siemens
% capacitance nF
% ===============================================
% y vector assignments
11 % ===============================================
% y (1) = V
% y ( 2 ) = m NA
% y ( 3 ) = h NA
% y (4) = m K
16 % auxiliary variables
% z ( 1 ) = t m NA
% z (2) = m NA infinity
% z ( 3 ) = t h NA
% z (4) = h NA infinity
21 % z (5) = t m K
% z (6) = m K infinity
%
% set s i z e of f
%
26
f = zeros (1 ,4) ;

% ===============================================
% f vector assignments
31 % ===============================================
% y ( 1 ) = V dynamics
% y ( 2 ) = m NA d y n a m i c s
% y ( 3 ) = h NA d y n a m i c s
% y ( 4 ) = m K dynamics
36 %
% ================================================
% Constants for Equilibrium Voltage C a l c u l a t i o n s
% ===============================================
[ E K , E NA , T ] = I o n B a t t e r y V o l t a g e s ( 4 0 0 . 0 , 2 0 . 1 1 , 5 0 . 0 , 4 9 1 . 0 , 6 9 ) ;
41
% max c o n d u c t a n c e f o r NA
g NA bar = 1 2 0 . 0 ;
% max c o n d u c t a n c e f o r K
g K bar = 3 6 . 0 ;
12.7 Printing Additional Variables 435

46 %
a l p h a = GatesNAK ( ’ HHGates ’ , y ( 1 ) ) ;
%
% a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
% a l p h a ( 1 ) , a l p h a ( 2 ) a l p h a and b e t a f o r mna
51 % a l p h a ( 3 ) , a l p h a ( 4 ) a l p h a and b e t a f o r hna
% a l p h a ( 5 ) , a l p h a ( 6 ) a l p h a and b e t a f o r mk
% ================================================
% F a s t Sodium C u r r e n t
% ===============================================
56 %
m NA infinity = a l p h a ( 1 ) / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
t m NA = 1 . 0 / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
%
61 h NA infinity = a l p h a ( 3 ) / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
t h NA = 1 . 0 / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
I NA = g NA bar ∗ ( y ( 1 )−E NA) ∗y ( 2 ) ˆ3∗ y ( 3 ) ;
z (1) = m NA infinity ;
66 z (2) = t m NA ;
f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
z (3) = h NA infinity ;
z (4) = t h NA ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
71 % ================================================
% Potassium Current
% ===============================================
%
m K infinity = a l p h a ( 5 ) / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
76 t m K = 1 . 0 / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
z (5) = m K infinity ;
z (6) = t m K;
f (4) = ( m K i n f i n i t y − y ( 4 ) ) /t m K ;
I K = g K b a r ∗ ( y ( 1 )−E K ) ∗y ( 4 ) ˆ 4 ;
81 %
% l e a k a g e c u r r e n t : run r e s t .m t o f i n d a p p r o p r i a t e g L v a l u e
%
g leak = .0084170;
E leak = −50.0;
86 %
% I L current
I l e a k = g l e a k ∗ ( y ( 1 )− E l e a k ) ;

%
91 % C e l l Capacitance
%
C M = 1.0;

% external current
96 s = f e v a l ( IE , t ) ;
%
f ( 1 ) = ( s − I NA − I K − I l e a k ) /C M ;

12.7.2 The New Manager: SolveSimpleHHnew.m

We alter the SolveSimpleHH.m function to SolveSimpleHHnew.m as fol-


lows:
436 12 The Basic Hodgkin–Huxley Model

Listing 12.21: A new HH dynamics function: SolveSimpleHHnew


function [ t v a l s , g NA , g K , V, m NA, h NA , n K , . . .
t m NA , m N A i n f i n i t y , . . .
t h NA , h N A i n f i n i t y , . . .
t m K , m K infinity ] = . . .
5 SolveSimpleHHnew ( fname , iename , t i n i t , t f i n a l , y0 , h , k , g NAmax ,
g Kmax )
% f i n d number o f i n t e r a t i o n s t o do
n = c e i l ( ( t f i n a l − t i n i t ) /h ) +1;
%
m NA = zeros (1 ,n) ;
10 h NA = zeros (1 ,n) ;
n K = zeros (1 ,n) ;
g NA = zeros (1 ,n) ;
g K = zeros (1 ,n) ;
V = zeros (1 ,n) ;
15 t m NA = zeros (1 ,n) ;
m NA infinity = zeros (1 , n) ;
t h NA = zeros (1 ,n) ;
h NA infinity = zeros (1 ,n) ;
t m K = zeros (1 ,n) ;
20 m K infinity = zeros (1 ,n) ;

[ t v a l s , y v a l s , z v a l s ] = HHFixedRKnew ( fname , iename , t i n i t , y0 , h , k , n ) ;

%
25 % store values in physical variables
%
V = yvals (1 ,1: n) ;
m NA = yvals (2 ,1: n) ;
h NA = yvals (3 ,1: n) ;
30 n K = yvals (4 ,1: n) ;
t m NA = zvals (1 ,1: n) ;
m NA infinity = zvals (2 ,1: n) ;
t h NA = zvals (3 ,1: n) ;
h NA infinity = zvals (4 ,1: n) ;
35 t m K = zvals (5 ,1: n) ;
m K infinity = zvals (6 ,1: n) ;

%
% Compute g Na and g K
40 %
for i = 1:n
u = m NA( i ) ∗m NA( i ) ∗m NA( i ) ∗h NA ( i ) ;
g NA ( i ) = g NAmax∗u ;
end
45
for i = 1:n
u = n K ( i ) ∗n K ( i ) ∗n K ( i ) ∗n K ( i ) ;
g K ( i ) = g Kmax ∗ u ;
end

Note we are now returning all of the time constants and asymptotic values for
each time step. To do this, we have to alter HHFixedRK.m to the new code
HHFixedRKnew.m.
12.7 Printing Additional Variables 437

12.7.3 The New Runge–Kutta Manager: HHFixedRKnew.m

This code is quite similar to the original as you can see.

Listing 12.22: A new Runge–Kutta manager: HHFixedRKnew


f u n c t i o n [ t v a l s , y v a l s , z v a l s ] = HHFixedRKnew ( fname , iename , t0 , y0 , h , k , n )
%
% Gives approximate s o l u t i o n to
% y ’( t ) = f (t , y( t ))
5 % y ( t 0 ) = y0
% u s i n g a k t h o r d e r RK method
%
% t0 i n i t i a l time
% y0 initial state
10 % h stepsize
% k RK o r d e r 1<= k <= 4
% n Number o f s t e p s t o t a k e
%
% tvals t i m e v a l u e s o f form
15 % t v a l s ( j ) = t 0 + ( j −1)∗h , 1 <= j <= n
% yvals approximate s o l u t i o n
% y v a l s ( : j ) = approximate s o l u t i o n at
% tvals ( j ) , 1 <= j <= n
% zvals a u x i l i a r y dynamics v a r i a b l e s
20 % z v a l s ( : j ) = a u x i l i a r y v a r i a b l e s at
% tvals ( j ) , 1 <= j <= n
% fname name o f d y n a m i c s f u n c t i o n
% iename name o f c u r r e n t i n j e c t i o n f u n c t i o n
%
25 tc = t0 ;
yc = y0 ;
tvals = tc ;
yvals = zeros (4 ,n) ;
zvals = zeros (6 ,n) ;
30 y v a l s ( 1 : 4 , 1 ) = t r a n s p o s e ( yc ) ;
[ f c , z c ] = f e v a l ( fname , t c , yc , iename ) ;
z v a l s ( 1 : 6 , 1 ) = transpose ( zc ) ;
f o r j =1:n−1
[ t c , yc , f c ] = HHRKstep ( fname , iename , t c , yc , f c , h , k ) ;
35 y v a l s ( 1 : 4 , j +1) = t r a n s p o s e ( yc ) ;
[ f c , z c ] = f e v a l ( fname , t c , yc , iename ) ;
z v a l s ( 1 : 6 , j +1) = t r a n s p o s e ( z c ) ;
tvals = [ tvals tc ] ;
end

We leave the file HHRKstep.m alone as we don’t need to change that.

12.7.4 Runtime Results

To generate the plots, we set up a MatLab session like this:


438 12 The Basic Hodgkin–Huxley Model

Listing 12.23: A sample session


E L = −50;
V R = −70;
Kin = 4 0 0 . 0 ;
Kout = 2 0 . 1 1 ;
5 Nain = 5 0 . 0 ;
Naout = 4 9 1 . 0 ;
TF = 6 9 . 0 ;
p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
g NA bar = 1 2 0 . 0 ;
10 g K bar = 3 6 . 0 ;
F = ’ HHGates ’ ;
[ g L , m NA0 , h NA0 , m K0 ] = . . .
r e s t ( E L , V R , g NA bar , g K bar , p , F ) ;
g L
15 g L = 0.0084
[ t v a l s , g NA , g K , V, m NA, h NA , n K , . . .
t m NA , m N A i n f i n i t y , . . .
t h NA , h N A i n f i n i t y , . . .
t m K , m K infinity ] = . . .
20 SolveSimpleHHnew ( ’ simpleHHnew ’ , ’IE ’ , 0 , 3 0 , . . .
[ V R , m NA0 , h NA0 , m K0 ] , . . .
. 0 1 , 4 , g K bar , g NA bar ) ;
p l o t ( t v a l s , t m NA ) ;


The values of τmNA and mNA versus time are plotted simultaneously in Fig. 12.12.

We can also plot τm and mNA
NA
versus membrane voltage to see how they vary with
depolarization (Fig. 12.13).

Fig. 12.12 m time constant and asymptotic value versus time


12.8 Initiation of the Action Potential 439

Fig. 12.13 m time constant and asymptotic value versus membrane voltage

12.8 Initiation of the Action Potential

Let’s explore how much depolarization of the membrane at the axon hillock is needed
to initiate an action potential. For this experiment, we set the size of the pulse gener-
ated by IE.m to be zero and we solve the Hodgkin–Huxley equations for a series of
initial voltages that start at VR and slowly increase. In this Chapter, we have devel-
oped a simple model of how an action potential is generated when axon hillock of
the excitable nerve cell is depolarized. This is not much of a model, of course. Right
now, the depolarization is accomplished by setting the initial voltage to be VR + 
for some depolarization  or by injected a current IE into the membrane. We don’t
have a real model of an excitable nerve cell that consists of a dendritic cable, a soma
and an axon. That is the topic we address in Chap. 11 on neural processing.

Listing 12.24: Sample session to generate action potentials


E L = −50;
V R = −70;
Kin = 4 0 0 . 0 ;
Kout = 2 0 . 1 1 ;
5 Nain = 5 0 . 0 ;
Naout = 4 9 1 . 0 ;
TF = 6 9 . 0 ;
p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
F = ’ HHGates ’ ;
10 g NA bar = 1 2 0 . 0 ;
g K bar = 3 6 . 0 ;
440 12 The Basic Hodgkin–Huxley Model

[ g L , m N A i n f i n i t y , h N A i n f i n i t y , m K i n f i n i t y , E K , E NA ] = . . .
r e s t ( E L , V R , g NA bar , g K bar , p , f ) ;
% now s e t g L i n simpleHH .m
15 % s o l v e HH model f o r v a r i o u s axon h i l l o c k v o l t a g e s
% axon h i l l o c k = V R = −70
[ t v a l s , g NA0 , g K0 , V0 , m NA0 , h NA0 , n K0 ] = . . .
SolveSimpleHHOrig ( ’ simpleHH ’ , ’IE ’ , 0 , 1 0 0 . 0 , . . .
[ V R , m NA infinity , h NA infinity , m K infinity ] , . . .
20 0 . 0 1 , 4 , g NA bar , g K b a r ) ;
% axon h i l l o c k = V R = −69
[ t v a l s , g NA1 , g K1 , V1 , m NA1 , h NA1 , n K1 ] = . . .
SolveSimpleHHOrig ( ’ simpleHH ’ , ’IE ’ , 0 , 1 0 0 . 0 , . . .
[ V R+1 , m N A i n f i n i t y , h N A i n f i n i t y , m K i n f i n i t y ] , . . .
25 0 . 0 1 , 4 , g NA bar , g K b a r ) ;
% axon h i l l o c k = V R = −68
[ t v a l s , g NA2 , g K2 , V2 , m NA2 , h NA2 , n K2 ] = . . .
SolveSimpleHHOrig ( ’ simpleHH ’ , ’IE ’ , 0 , 1 0 0 . 0 , . . .
[ V R+2 , m N A i n f i n i t y , h N A i n f i n i t y , m K i n f i n i t y ] , . . .
30 0 . 0 1 , 4 , g NA bar , g K b a r ) ;
% axon h i l l o c k = V R = −67
...
% axon h i l l o c k = V R = −61
[ t v a l s , g NA9 , g K9 , V9 , m NA9 , h NA9 , n K9 ] = . . .
35 SolveSimpleHHOrig ( ’ simpleHH ’ , ’IE ’ , 0 , 1 0 0 . 0 , . . .
[ V R+9 , m N A i n f i n i t y , h N A i n f i n i t y , m K i n f i n i t y ] , . . .
0 . 0 1 , 4 , g NA bar , g K b a r ) ;
% axon h i l l o c k = V R = −60
[ t v a l s , g NA10 , g K10 , V10 , m NA10 , h NA10 , n K10 ] = . . .
40 SolveSimpleHHOrig ( ’ simpleHH ’ , ’IE ’ , 0 , 1 0 0 . 0 , . . .
[ V R+10 , m N A i n f i n i t y , h N A i n f i n i t y , m K i n f i n i t y ] , . . .
0 . 0 1 , 4 , g NA bar , g K b a r ) ;
% plot action potentials
p l o t ( t v a l s , V0 , t v a l s , V4 , . . .
45 t v a l s , V6 , t v a l s , V8 , . . .
t v a l s , V9 , t v a l s , V10 ) ;
% s e t l e g e n d , l a b e l s and s o f o r t h
% t h e l e g e n d i s one l i n e
l e g e n d ( ’ -70 mV ’ , ’ -66 mV ’ , ’ -64 mV ’ ,
50 ’ -62 mV ’ , ’ -61 mV ’ , ’ -60 mV ’ ) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Action Potential versus Time ’ ) ;

Fig. 12.14 Action potentials


generated by a series of
depolarizations starting from
none to 10 mV
12.8 Initiation of the Action Potential 441

Fig. 12.15 Action potentials


generated by a series of
depolarizations starting from
none to 11 mV

Now, in Fig. 12.14, you can see that the action potential is not initiated until the
depolarization is about 10 mV.
If we depolarize one more degree, we obtain Fig. 12.15. This shows clearly that
the additional degree causes the action potential to initiate much sooner.

12.9 Homework

Exercise 12.9.1 Run the Hodgkin–Huxley simulation as has been done in the work
above and write a complete report in your favorite editor which documents how an
action potential is generated using the plots and evidence obtained in the following
studies.
For all of these studies, we will use the current impulse defined by the code in
IE.m where you define the pulse appropriately.
Study One: maximum sodium conductance is 120 and maximum potassium con-
ductance is 36.0:

1. IE is as given in the text; a pulse of size 100.


2. The plots of voltage, m_NA, h_NA and m_K versus time for 100 mSec.
3. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus time.
4. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus voltage.
5. The plots of the sodium and potassium conductance versus time.
6. The plots of the sodium and potassium conductance versus voltage.
7. The plots of sodium and potassium current versus time.
442 12 The Basic Hodgkin–Huxley Model

Study Two: maximum sodium conductance is 120 and maximum potassium con-
ductance is 36.0:
1. IE is as given in the text but change the pulse size to 400.
2. The plots of voltage, m_NA, h_NA and m_K versus time for 100 mSec.
3. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus time.
4. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus voltage.
5. The plots of the sodium and potassium conductance versus time.
6. The plots of the sodium and potassium conductance versus voltage.
7. The plots of sodium and potassium current versus time.

Study Three: maximum sodium conductance is 120 and maximum potassium con-
ductance is 16.0:
1. IE is as given in the text but change the pulse size to 800.
2. The plots of voltage, m_NA, h_NA and m_K versus time for 100 mSec.
3. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus time.
4. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus voltage.
5. The plots of the sodium and potassium conductance versus time.
6. The plots of the sodium and potassium conductance versus voltage.
7. The plots of sodium and potassium current versus time.

Study Four: maximum sodium conductance is 20.0 and maximum potassium con-
ductance is 3.6:
1. IE is as given in the text but change the pulse size to 400.
2. The plots of voltage, m_NA, h_NA and m_K versus time for 100 mSec.
3. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus time overlaid on the plots from Study One and Study Two.
4. The plots of the time constant and the asymptotic value for m_NA, h_NA and m_K
versus voltage overlaid on the plots from Study One and Study Two.
5. The plots of the sodium and potassium conductance versus time overlaid on the
plots from Study One and Study Two.
6. The plots of the sodium and potassium conductance versus voltage overlaid on
the plots from Study One and Study Two.
7. The plots of sodium and potassium current versus time overlaid on the plots from
Study One and Study Two.
12.10 Another MatLab Implementation 443

12.10 Another MatLab Implementation

We are now ready to integrate the ball stick model and our Hodgkin–Huxley model
in Matlab. We modify the existing MatLab code to reflect the fact that we are now
going to allow our dendritic model to provide the axon hillock voltage. We will need
to rewrite many of our original Hodgkin–Huxley functions in order to take advantage
of the ball-stick model for dendritic inputs. We also will now move to a more efficient
ODE solver: RKF5 which has automatic step size adjustment algorithms.
Recall, we introduced the general mapping F to encode our gate dynamics more
efficiently as defined by

p0 (Vm + q0 ) + p1
F(Vm , p, q) = .
ep2 (Vm +q1 ) + p3

under some choices of the parameter vectors p and q, these functions may be unde-
fined. However, if the numerator and denominator are both 0, this occurs when the
numerator N = p0 (Vm + q0 ) + p1 = 0 and the denominator D = ep2 (Vm +q1 ) + p3 = 0.
This gives two equations in the one unknown Vm . If these equations are consistent
call this critical voltage value Vm∗ .
To understand what to do here, we need another idea from the calculus of one
variable called L’Hopital’s rule. We only need the easy form but you can read up
about other variations and we encourage you to do so. Let’s assume we have two
functions f (x) and g(x) both of which are differentiable and both of which vanish
f (x)
at the value x ∗ . If we are interested in knowing the value of limx→x∗ g(x) how can

we∗ find that out? The naive thing to do would be to plug x into the fraction getting
f (x )
g(x ∗ )
= 00 which is undefined. But we can figure this out by using the definition of
differentiability with error terms for both f and g. We have

f (x) f (x ∗ ) + f  (x ∗ )(x − x ∗ ) + Ef (x − x ∗ )
lim∗ = lim∗
x→x g(x) x→x g(x ∗ ) + g  (x ∗ )(x − x ∗ ) + Eg (x − x ∗ )

where we assume we are in the simplest case where both f  (x ∗ ) and g  (x ∗ ) are not
zero. We can still figure out what to do if one or both of them is zero, but we don’t
need that complication here. We know f (x ∗ ) and g(x ∗ ) are zero, so we have

f (x) f  (x ∗ )(x − x ∗ ) + Ef (x − x ∗ )
lim∗ = lim∗  ∗
x→x g(x) x→x g (x )(x − x ∗ ) + Eg (x − x ∗ )

Now divide top and bottom by x − x ∗ to get

Ef (x−x ∗ )
f (x) f  (x ∗ ) + (x−x ∗ )
lim = lim∗ Eg (x−x ∗ )
x→x ∗ g(x) x→x g  (x ∗ ) +
(x−x ∗ )

Ef (x−x ∗ ) Ef (x−x ∗ )
Since f and g are differentiable, we know (x−x ∗ )
→ 0 and (x−x ∗ )
→ 0 as x → x ∗ .
Hence, we have
444 12 The Basic Hodgkin–Huxley Model

f (x) f  (x ∗ )
lim∗ =  ∗
x→x g(x) g (x )

We can state this as a general theorem.

Theorem 12.10.1 (A Simple L’Hopital’s Rule)


If f (x) and g(x) are both differentiable in a circle defined about x ∗ and if f (x ∗ ) =
g(x ∗ ) = 0 with f  (x ∗ ) and g  (x ∗ ) both not zero, then

f (x) f  (x ∗ )
lim∗ =  ∗
x→x g(x) g (x )

Proof We worked out the argument in the lines above! 

Then, by L’Hopital’s rule, the limiting value at Vm∗ is

p0 −p0
lim F(Vm , p, q) = =
Vm →Vm∗ p2 ep2 (Vm +q1 ) p2 p3

as ep2 (Vm +q1 ) = −p3 . Since the axon hillock voltage is a voltage spike, the incoming
voltages may cross this critical voltage value Vm∗ . Hence, we will rewrite the α and
β computations to be more careful to avoid division by zero. Such a division by zero
would introduce a discontinuity into our numerical solution with potential loss of
accuracy. Here is a more careful version of our previous HHGates code.

Listing 12.25: A more careful gates function: HHGates


f u n c t i o n F = HHGates (V, p , q )
%
% V = incoming v o l t a g e
% p = p a r a m e t e r s f o r g a t e model
5 % q = p a r a m e t e r s f o r g a t e m odel
% gate value
%
t o l = 1 . 0 e −6;
Numerator = p ( 1 ) ∗ (V + q ( 1 ) ) + p ( 2 ) ;
10 Denominator = exp ( p ( 3 ) ∗ (V + q ( 2 ) ) ) + p ( 4 ) ;
i f a b s ( Denominator ) < t o l
i f a b s ( Numerator ) < t o l
F = −p ( 1 ) / ( p ( 3 ) ∗p ( 4 ) ) ;
e l s e i f s i g n ( Denominator ) == 0 && Numerator >= t o l
15 F = 100;
e l s e i f s i g n ( Denominator ) == 0 && Numerator <= − t o l
F = −100;
e l s e i f s i g n ( Denominator ) == 1 && Numerator >= t o l
F = 100;
20 e l s e i f s i g n ( Denominator ) == 1 && Numerator <= − t o l
F = −100;
e l s e i f s i g n ( Denominator ) == −1 && Numerator >= t o l
F = −100;
e l s e i f s i g n ( Denominator ) == −1 && Numerator <= − t o l
25 F = 100;
end
else
F = Numerator / Denominator ;
end
12.10 Another MatLab Implementation 445

In this code, we handle the 00 case carefully. If the numerator and denominator of
F are both in the interval (−, ) for  set equal to the tolerance tol = 1.0e-6,
we use the L’Hopital’s limiting value. Otherwise, depending on the signs of the
numerator and denominator values, we set the ±1 0
case to be 100 or −100. Finally,
if the numerator and denominator are both reasonable numbers, we simply calculate
the usual ratio. An incoming axon hillock voltage spike could easily be very large
and so we don’t want any of the α and β calculations to be undefined at some step
in the numerical process. We can then define α and β functions easily as follows.

Listing 12.26: Handling indeterminacies in the α/β calculations: HHGatesGraph


f u n c t i o n F = HHGatesGraph ( p , q )
%
% V = incoming v o l t a g e
% p = p a r a m e t e r s f o r g a t e model
5 % q = p a r a m e t e r s f o r g a t e m odel
%
% gate value

F = @(V) HHGates (V, p , q ) ;


10
end

This function returns the α or β function as F(V ) using Matlab/Octave’s ability


to define a function inline. Once this is done, we can easily write a function to
graph all the α and β functions for a typical simulation. This is done in the function
GatesNAKGraph which returns a set of handles to the plots, AlphaBetaPlot.

Listing 12.27: Graphing the α/β functions: GatesNAKGraph


f u n c t i o n A l p h a B e t a P l o t = GatesNAKGraph ( )
%
% We g r a p h t h e ( a l p h a , b e t a ) p a i r s i n HH model
%
5 % T h i s i s a s i m p l e Sodium , P o t a s s i u m model s o
% a l p h a , b e t a f o r mNA = F{1} , F{2}
% a l p h a , b e t a f o r hNA = F{3} , F{24
% a l p h a , b e t a f o r mK = F{5} , F{6}
%
10 % we n e e d p , q p a r a m e t e r v e c t o r s f o r e a c h o f t h e
% s i x alpha , beta p a i r s . T h e s e v a l u e s come from
% the l i t e r a t u r e .
%
p = zeros (6 ,4) ;
15 q = zeros (6 ,2) ;
p = [ −0.1 ,0.0 , −0.1 , −1.0;...
0.0 ,4.0 ,0.0556 ,0.0;...
0.0 ,0.07 ,0.05 ,0.0;...
0.0 ,1.0 , −0.1 ,1.0;...
20 −0.01 ,0.0 , −0.1 , −1.0;...
0.0 ,0.125 ,0.0125 ,0.0];
%
q = [35.0 ,35.0;...
60.0 ,60.0;...
25 60.0 ,60.0;...
30.0 ,30.0;...
50.0 ,50.0;...
60.0 ,60.0];
%
446 12 The Basic Hodgkin–Huxley Model

30 F= { } ;
message = {} ’
F{1} = HHGatesGraph ( p ( 1 , : ) ,q (1 ,:) ) ;
message {1} = ’ alphaMNA ’ ;
F{2} = HHGatesGraph ( p ( 2 , : ) ,q (2 ,:) ) ;
35 message {2} = ’ betaMNA ’ ;
F{3} = HHGatesGraph ( p ( 3 , : ) ,q (3 ,:) ) ;
message {3} = ’ alphaHNA ’ ;
F{4} = HHGatesGraph ( p ( 4 , : ) ,q (4 ,:) ) ;
message {4} = ’ betaHNA ’ ;
40 F{5} = HHGatesGraph ( p ( 5 , : ) ,q (5 ,:) ) ;
message {5} = ’ alphaMK ’ ;
F{6} = HHGatesGraph ( p ( 6 , : ) ,q (6 ,:) ) ;
message {6} = ’ betaMK ’ ;

45 V = l i n s p a c e ( −120 ,120 ,241) ;


Y = {};
S = {};
f o r i =1:6
%f i l e n a m e =[ m e s s a g e { i } , ’ . png ’ ] ;
50 % uncomment i f you want t o p r i n t r e s u l t s t o f i l e s
figure ;
for j = 1:241
Y{ i } ( j ) = F{ i } (V( j ) ) ;
end
55 p l o t (V,Y{ i } ) ;
AlphaBetaPlot{ i } = g c f ( ) ;
x l a b e l ( ’ Voltage mV ’ ) ;
y l a b e l ( ’ Gate Response ’ ) ;
t i t l e ( m e ss a ge { i } ) ;
60 %p r i n t ( ’ − dpng ’ , f i l e n a m e ) ;
%uncomment i f you want t o p r i n t r e s u l t s t o f i l e s
end
%
end

To make it easy to clean up these figures, we use the script CleanUpFigures


AlphaBeta.m. In the previous code, the ith plot was assigned the handle
AlphaBetaPlot{i} and so a simple delete call will remove the plot. This
is useful when there are a lot of plots to remove.

Listing 12.28: Cleanup figures


N = l e n g t h ( AlphaBetaPlot ) ;
f o r i =1:N
d e l e t e ( AlphaBetaPlot { i }) ;
end

To graph and then remove all these plots, a typical session would be as follows:

Listing 12.29: Removing plots


1 A l p h a B e t a P l o t = GatesNAKGraph ( ) ;
CleanUpFiguresAlphaBeta ;

The plots for our typical Hodgkin–Huxley model are shown in Figs. 12.16a, b,
12.17a, b and 12.18a, b for a voltage range of −200 to 200 mV. In the simulations to
come, we will be using these improved α–β calculations.
12.10 Another MatLab Implementation 447

Fig. 12.16 M α and β for


sodium. a αMNA . b βMNA

12.10.1 The Rewritten Dynamics

We now rewrite our previous HH dynamics function to accept a parameter vector.


This makes the code cleaner and easier to follow. This code uses the function IE2
to provide an external current input which can be shaped as we see fit. For example,
a two pulse external current might be IE2.m given below. This has two impulses:
pulse one is on maximum intensity 100 and lasts for 0.05 mS and pulse two is of
size 200 and lasts for 0.05 mS as well. Since we are now using RKF5 as our model
integrator, the errors due to a rapid discontinuous rise from 0 to the maximum value
in the pulses cause problems in the optimal step size calculations. Hence, we now
introduce a smooth linear rise from 0 to the maximum and then down again into
the functions. This creates continuous pulses although they are not differentiable at
two points. This allows for a more accurate error test. It would be even better to
448 12 The Basic Hodgkin–Huxley Model

Fig. 12.17 H α and β for


sodium. a αHNA . b βHNA

approximate the pulse with a six times differentiable function, but this suffices for
now.

Listing 12.30: Continuous Pulses: IE2.m


f u n c t i o n i e = IE2 ( t )
%
ts1 = 10.0;
ts2 = 10.05;
5 te1 = 1 0 . 1 0 ;
te2 = 1 0 . 1 5 ;
ts3 = 20.0;
ts4 = 20.05;
te3 = 2 0 . 1 0 ;
10 te4 = 2 0 . 1 5 ;
Imax1 = 1 0 0 . 0 ;
Imax2 = 3 0 0 . 0 ;
ie = 0;
i f t >= t s 1 & t <= t s 2
12.10 Another MatLab Implementation 449

15 i e = ( Imax1 / ( t s 2 − t s 1 ) ) ∗ ( t − t s 1 ) ;
e l s e i f t>t s 2 & t < t e 1
i e = Imax1 ;
e l s e i f t >= t e 1 & t < t e 2
i e = Imax1 −(Imax1 / ( t e 2 −t e 1 ) ) ∗ ( t −t e 1 ) ;
20 e l s e i f t >= t s 3 & t <= t s 4
i e = ( Imax2 / ( t s 4 − t s 3 ) ) ∗ ( t − t s 3 ) ;
e l s e i f t>t s 3 & t < t e 3
i e = Imax2 ;
e l s e i f t >= t e 3 & t < t e 4
25 i e = Imax2 −(Imax2 / ( t e 4 −t e 3 ) ) ∗ ( t −t e 3 ) ;
end

The new dynamics function is given in Listing 12.32. We are handling the para-
meter p differently here also. We now want to send in numerical data and string data.
We do this as follows. We create a data structure p having two parts, p.a for the
numerical data, and p.b for the string data. We can then access the elements of p.a

Fig. 12.18 M α and β for


potassium. a αMK . b βMK
450 12 The Basic Hodgkin–Huxley Model

as usual, p.a(1), p.a(2) and so forth. The syntax p.b will give us the string
name we need.

Listing 12.31: p structure


p . a = [ E K ; E NA ; E L ; g L ; g NA bar ; g K b a r ] ;
p . b = ’ HHGates ’ ;
p.a
ans =
5
−7.5607 e+01
5 . 7 7 6 0 e+01
−5.0000 e+01
8 . 4 1 7 0 e −03
10 1 . 2 0 0 0 e+02
3 . 6 0 0 0 e+01

p . a (1)
a n s = −75.607

Listing 12.32: A rewritten HH dynamic function using parameter arguments: HHdy-


namics.m
1 f u n c t i o n f = HHdynamics ( p , t , y )
% S t a n d a r d H o d g k i n − H u x l e y Model
% voltage mV
% current na
% time ms
6 % c o n c e n t r a t i o n mM
% conductance micro Siemens
% capacitance nF
%
% arguments
11 % p parameter v e c t o r
% t time
% y state vector
%
% ===============================================
16 % y vector assignments
% ===============================================
% y (1) = V
% y ( 2 ) = m NA
% y ( 3 ) = h NA
21 % y (4) = m K
%
% parameter assignments
% p comes i n a s a d a t a s t r u c t u r e .
%
26 % p . a i s t h e numeric d a t a
% p . a ( 1 ) = EK, t h e p o t a s s i u m b a t t e r y v o l t a g e
% p . a ( 2 ) = ENA i s t h e sodium b a t t e r y v o l t a g e
% p . a ( 3 ) = EL , t h e l e a k a g e v o l t a g e
% p . a ( 4 ) = GL, t h e l e a k a g e c o n d u c t a n c e
31 % p . a ( 5 ) = gNAmax , maximum sodium c o n d u c t a n c e
% p . a ( 6 ) = gKmax , maximum p o t a s s i u m c o n d u c t a n c e
%
% p . b i s the s t r i n g data
% To u s e
36 % p . a = [EK;ENA; EL ; GL ; gNAmax ; gKMax ] ;
% p . b = ’ string ’ ;
%

EK = p . a (1) ;
12.10 Another MatLab Implementation 451

41 ENA = p . a (2) ;
% l e a k a g e c u r r e n t : run r e s t .m t o f i n d a p p r o p r i a t e g L v a l u e
% d e f a u l t E l e a k = −50.0
E leak = p . a (3) ;
g leak = p . a (4) ;
46 % max c o n d u c t a n c e f o r NA: d e f a u l t i s 120
g NA bar = p . a ( 5 ) ;
% max c o n d u c t a n c e f o r K: d e f a u l t i s 3 6 . 0
g K bar = p . a (6) ;
gatename = p . b ;
51
f = zeros (4 ,1) ;

% ==============================================
% f vector assignments
56 % ==============================================
% y ( 1 ) = V dynamics
% y ( 2 ) = m NA d y n a m i c s
% y ( 3 ) = h NA d y n a m i c s
% y ( 4 ) = m K dynamics
61 %
a l p h a = GatesNAK ( gatename , y ( 1 ) ) ;
%
% a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
% a l p h a ( 1 ) , a l p h a ( 2 ) a l p h a and b e t a f o r mna
66 % a l p h a ( 3 ) , a l p h a ( 4 ) a l p h a and b e t a f o r hna
% a l p h a ( 5 ) , a l p h a ( 6 ) a l p h a and b e t a f o r mk
%
m NA infinity = a l p h a ( 1 ) / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
t m NA = 1 . 0 / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
71 f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
%
h NA infinity = a l p h a ( 3 ) / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
t h NA = 1 . 0 / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
76 I NA = g NA bar ∗ ( y ( 1 )−ENA) ∗y ( 2 ) ˆ3∗ y ( 3 ) ;
%
m K infinity = a l p h a ( 5 ) / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
t m K = 1 . 0 / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
f (4) = ( m K i n f i n i t y − y ( 4 ) ) /t m K ;
81 I K = g K b a r ∗ ( y ( 1 )−EK) ∗y ( 4 ) ˆ 4 ;
% I L current
I l e a k = g l e a k ∗ ( y ( 1 )− E l e a k ) ;
% C e l l Capacitance
C M = 1.0;
86 % f u l l dynamics
s 1 = IE2 ( t ) ;
f ( 1 ) = ( s 1 − I NA − I K − I l e a k ) /C M ;
end

12.10.2 A New SolveSimpleHH.m

The code to manage the solution of the ODE is then given below in Listing 12.33.
452 12 The Basic Hodgkin–Huxley Model

Listing 12.33: Managing The Hodgkin–Huxley Simulation


1 function [ t v a l s , y v a l s , f v a l s , h v a l s , g NA , g K , V, m NA, h NA , n K ] = . . .
SolveSimpleHH ( fname , q , p , t0 , t f , y i n i t , h i n i t )

%
% fname dynamics f u n c t i o n
6 % q p a r a m e t e r v e c t o r f o r RKF5 s e t t i n g s
% p p a r a m e t e r v e c t o r f o r HH d y n a m i c s
% t0 i n i t i a l time
% tf f i n a l time
% yinit initial state
11 % hinit initial stepsize
%
% We u s e RKF5
%
% p parameter assignments
16 %
% p . a ( 1 ) = EK, t h e p o t a s s i u m b a t t e r y v o l t a g e
% p . a ( 2 ) = ENA i s t h e sodium b a t t e r y v o l t a g e
% p . a ( 3 ) = EL , t h e l e a k a g e v o l t a g e
% p . a ( 4 ) = GL, t h e l e a k a g e c o n d u c t a n c e
21 % p . a ( 5 ) = g NA bar , maximum sodium c o n d u c t a n c e
% p . a ( 6 ) = g K b a r , maximum p o t a s s i u m c o n d u c t a n c e
%
% To u s e
% p . a = [ EK ;ENA; EL ; GL ; g N A b a r ; g K b a r ] ;
26 % p . b = ’ name o f t h e g a t e d y n a m i c s f u n c t i o n ’ ;
%
% q parameter assignments
%
% q (1) = errortol , step s i z e tolerance
31 % q (2) = steptol , step s iz e tolerance
% q ( 3 ) = m i n s t e p , minimum a l l o w a b l e s t e p s i z e
% q ( 4 ) = maxstep , maximum a l l o w a b l e s t e p s i z e
%
% To u s e
36 % q = [ e r r o r t o l ; s t e p t o l ; minstep ; maxstep ]
%
% i n i t i a l y values
%
% y (1) = V
41 % y ( 2 ) = m NA
% y ( 3 ) = h NA
% y (4) = m K
%
% To u s e
46 % y i n i t = [ V0 ; m NA0 ; h NA0 ; m K0 ]
%
EK = p . a (1) ;
ENA = p . a (2) ;
EL = p . a (3) ;
51 GL = p . a (4) ;
g NA bar = p . a ( 5 ) ;
g K bar = p . a ( 6 ) ;
%
errortol = q(1) ;
56 steptol = q(2) ;
minstep = q ( 3 ) ;
maxstep = q ( 4 ) ;

[ t v a l s , y v a l s , f v a l s , h v a l s ] = RKF5( e r r o r t o l , s t e p t o l , minstep , maxstep ,


fname , p , h i n i t , t0 , t f , y i n i t ) ;
61 %
% store values in p h y s i c a l v a r i a b l e s
%
V = yvals (1 ,:) ;
m NA = y v a l s ( 2 , : ) ;
66 h NA = y v a l s ( 3 , : ) ;
n K = yvals (4 ,:) ;

%
% Compute g Na and G K
71 %
g NA = g NA bar ∗m NA. ∗m NA. ∗m NA. ∗ h NA ;
g K = g K b a r ∗n K . ∗ n K . ∗ n K . ∗ n K ;
end
12.11 More Action Potentials 453

12.11 More Action Potentials

Let’s examine how an action potential is generated with this model. We can inject
both a current using the function IE2.m and apply an axon hillock voltage using the
techniques from Chap. 11. For our work in this section, we will not use an external
current so we will set IE2.m to be always 0. Then, for a given dendritic pulse at
some location, we use the function GetAxonHillock2 given in Listing 12.34.

Listing 12.34: Generate An Axon Hillock Voltage Curve


f u n c t i o n [ tau , lambda , V,AH, I n p u t ] = G e t A x o n H i l l o c k 2 (Q, L , TD, rho , Vmax ,
location )
%
% Q t h e number o f e i g e n v a l u e s we want t o f i n d
% L the l e n g t h of the dendrite in space constants
5 % rho t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% z eigenvalue vector
% D data vector
% Vmax s i z e of v o l t a g e impulse
% location l o c a t i o n of pulse
10 % M matrix o f c o e f f i c i e n t s f o r our approximate v o l t a g e
% model
% Input t h e s o l u t i o n a s ( z , 0 ) t o s e e i f match t o
% input voltage is reasonable
% AH the s o l u t i o n at (1 , t )
15 % V the solution at (z , t )
% tau d e n d r i t i c time
% lambda dendritic position
%
% get eigenvalue vector z
20 z = F i n d R o o t s (Q, L , rho , 1 . 0 , 1 . 0 ) ;
% get c o e f f i c i e n t matrix M
M = FindM (Q, L , rho , z ) ;
% compute d a t a v e c t o r f o r i m p u l s e
D = FindData (Q, L , rho , z , Vmax , l o c a t i o n ) ;
25 % S o l v e MB = D s y s t e m
[ Lower , Upper , p i v ] = GePiv (M) ;
y = L T r i S o l ( Lower ,D( p i v ) ) ;
B = U T r i S o l ( Upper , y ) ;
% check errors
30 E r r o r = Lower∗Upper∗B − D( p i v ) ;
D i f f = M∗B−D;
e = norm ( E r r o r ) ;
e2 = norm ( D i f f ) ;
d i s p l a y ( s p r i n t f ( ’ norm of LU residual = %12.7 f norm of MB - D = %12.7 f ’
, e , e2 ) ) ;
35 % s e t d e n d r i t i c s p a t i a l and t i m e b o u n d s
% d i v i d e d e n d r i t i c t i m e i n t o 100 p a r t s
tau = l i n s p a c e ( 0 ,TD, 1 0 1 ) ;
% d i v i d e d e n d r i t i c s p a c e L i n t o 300 p a r t s
lambda = l i n s p a c e ( 0 , L , 3 0 1 ) ;
40 %
V = zeros (301 ,101) ;
A = z e r o s (Q, 1 ) ;
f o r n = 1 :Q
A( n ) = B( n+1) ;
45 end
% f i n d v o l t a g e a t s p a c e p o i n t l a m b d a ( s ) and t i m e p o i n t t a u ( t )
for s = 1:301
for t = 1:101
w = z ∗ ( L−lambda ( s ) ) ;
454 12 The Basic Hodgkin–Huxley Model

50 u = −(1+ z . ∗ z ) ∗ t a u ( t ) ;
V( s , t ) = B( 1 ) ∗ exp (− t a u ( t ) )+ d o t (A, c o s (w) . ∗ exp ( u ) ) ;
end
end
% axon h i l l o c k i s a t l a m b d a = 1
55 AH = V ( 1 , : ) ;
% p u l s e i s modeled a t i n i t i a l time by
Input = V( : , 1 ) ;

A typical voltage trace generated by an impulse of size 1100 at location 3.0 is seen in
Fig. 12.19. This was generated by the following lines in MatLab. First, we generate
the axon hillock voltage trace.

Listing 12.35: Generating axon hillock voltage trace


Q = 40;
L = 5;
3 TD = 5 ;
rho = 1 0 ;
Vmax1 = 1 1 0 0 ;
location1 = 3;
[ tau , lambda , V,AH, I n p u t ] = G e t A x o n H i l l o c k 2 (Q, L , TD, rho , Vmax1 ,
location1 ) ;
8 norm o f LU r e s i d u a l = 0 . 0 0 0 0 0 0 0 norm o f MB−D = 0.0000000
p l o t ( t a u ( 2 : 1 0 1 ) ,AH( 2 : 1 0 1 ) ) ;
x l a b e l ( ’ Dendritic Time mS ’ ) ;
y l a b e l ( ’ Axon Hillock Voltage mV ’ ) ;
t i t l e ( ’ Axon Hillock Voltage : Pulse 1100 at 3.0 ’ ) ;

The transient axon hillock voltage is shown in Fig. 12.19. The axon hillock voltage
is then VR + AH which for us is −70 + AH(τ ).
Then, we calculate the action potential corresponding to various axon hillock
voltages. We choose a dendritic time, τ , and use the value of the axon hillock voltage,

Fig. 12.19 A voltage pulse


1100 at 3.0
12.11 More Action Potentials 455

AH(τ ), to be the initial value in the HH simulation. Here are the MatLab lines to do
that.

Listing 12.36: Calculating an action potential


E L = −50;
V R = −70;
3 g NA bar = 1 2 0 . 0 ;
g K bar = 3 6 . 0 ;
gatesname = ’ HHGates ’ ;
Kin = 4 0 0 . 0 ;
Kout = 2 0 . 1 1 ;
8 Nain = 5 0 . 0 ;
Naout = 4 9 1 . 0 ;
TF = 6 9 . 0 ;
p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
[ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = . . .
13 r e s t ( E L , V R , g NA bar , g K bar , p , gatesname ) ;
pp . a = [ E K ; E NA ; E L ; g L ; g NA bar ; g K b a r ] ;
pp . b = ’ HHGates ’ ;
e r r o r t o l = 1 . 0 e −6;
s t e p t o l = 1 . 0 e −8;
18 m i n s t e p = 1 . 0 e −4;
maxstep = 2 . 0 ;
q = [ e r r o r t o l ; s t e p t o l ; m i n s t e p ; maxstep ] ;
V 0 = V R + AH( 2 )
V 0 =
23
−59.7262
[ t v a l s , y v a l s , f v a l s , h v a l s , g NA , g K , V, m NA, h NA , m K ] = . . .
SolveSimpleHH ( ’ HHdynamics ’ , q , pp , 0 , 3 0 , . . .
[ V R+AH( 2 ) ; m NA0 ; h NA0 ; m K0 ] , . 4 ) ;
28 p l o t ( t v a l s ,V) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Voltage mV ’ ) ;
t i t l e ( ’ Action Potential vs Time using AH (2) : Pulse 1100 at 3.0 ’ )
;

As this current flows into the membrane, the membrane begins to depolarize. The
current flow of sodium and potassium through the membrane is voltage dependent and
so this increase in the voltage across the membrane causes changes in the ion gates.
Using V0 = −70 + AH(0), we generate the action potential shown in Fig. 12.20.
Recall that in the ion current equations the nonlinear conductance is modeled by

gNa (V, t) = gNa


Max
MNA 3 (V ) HNA (V )
gK (V, t) = gKMax MK 4 (V ).

The full current equations are then

INa = gNA (V, t)(V (t) − ENA )


IK = gK (V, t)(V (t) − EK )
IL = gL (V, t)(V (t) − EL )
456 12 The Basic Hodgkin–Huxley Model

Fig. 12.20 Action potential:


pulse 200 at 3.0

The conductance is in micro Siemens or units of 10−6 1/ohms. Time is in milliseconds


or 10−3 seconds and voltage is in millivolts or 10−3 volts. The currents here are thus
in units of 10−9 amps or nano amps. We show the plots of these currents versus
time in Fig. 12.21. Note the sodium current is negative and the potassium current is
positive. The MatLab commands are

Fig. 12.21 Sodium and


potassium current during a
pulse 1100 at 3.0
12.11 More Action Potentials 457

Fig. 12.22 Absolute sodium


and potassium current during
a pulse 1100 at 3.0

Listing 12.37: Generating currents


INA = g NA . ∗ ( V−E NA) ;
IK = g K . ∗ ( V−E K ) ;
IL = g L . ∗ ( V−E L ) ;
4 p l o t ( t v a l s , INA , ’-’ , t v a l s , IK , ’ --’ ) ;
x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Current nano Amps ’ ) ;
l e g e n d ( ’ Sodium Current ’ , ’ Potassium Current ’ ) ;
t i t l e ( ’ Sodium and Potassium Ion Gate Currents vs Time : Pulse
1100 at 3.0 ’ ) ;

To see how the sodium current activates first and then the potassium current, we can
plot the absolute value of INa and IK simultaneously. This is done in Fig. 12.22. The
time interval here is setup with a linspace command dividing 30 mS into 300 equal
parts. So to see the currents better, we will plot them on the time interval [3.5, 20.0]
which is time tick 35 to 200.

Listing 12.38: Plotting currents


p l o t ( t v a l s ( 3 5 : 2 0 0 ) , a b s (INA ( 3 5 : 2 0 0 ) ) , ’-’ , t v a l s ( 3 5 : 2 0 0 ) , a b s ( IK
( 3 5 : 2 0 0 ) ) , ’ --’ ) ;
2 x l a b e l ( ’ Time mS ’ ) ;
y l a b e l ( ’ Current nano Amps ’ ) ;
t i t l e ( ’ Absolute Sodium and Potassium Ion Gate Currents vs Time ’ )
;
l e g e n d ( ’| Sodium Current | ’ , ’| Potassium Current | ’ ) ;

We can study the activation and inactivation terms more closely using some carefully
chosen plots. We show the plot of MNA in Fig. 12.23 and HNA in Fig. 12.24.
Finally, the potassium activation MK is shown in Fig. 12.25.
458 12 The Basic Hodgkin–Huxley Model

Fig. 12.23 Sodium


activation MNA during a
pulse

Fig. 12.24 Sodium


inactivation HNA during a
pulse

Of even more interest is the products that are proportional to the sodium and
potassium current. We plot MNA 3 HNA versus time in Fig. 12.26 and MK 4 ’s time
trace in Fig. 12.27.
We note that if we apply a voltage pulse at a location further from the axon
hillock, say at location 3, we will not generate an action potential! In this chapter, we
have started to put together our models: we have a simple ball stick neuron model
which couples voltage pulses applied to the dendritic cable to a simple cell body.
We assume the resulting membrane voltage at the junction of the dendrite and the
cell body is available without change at the axon hillock which is potentially on the
other side of the cell body. From Fig. 12.19, we know the voltage we seen at the axon
hillock varies with time. In the simulations in this Chapter, we have chosen a time
(usually time tick 2 which corresponds to a time of 0.1 time constants) and used the
12.11 More Action Potentials 459

Fig. 12.25 Potassium


activation MK during a pulse

Fig. 12.26 The product


MNA 3 HNA during a pulse
1100 at 3.0 scaled by the
maximum sodium and
potassium conductance
values

axon hillock voltage there as our depolarizing input to the Hodgkin–Huxley model.
Clearly, we could use other starting values from the axon hillock voltage time trace.
Each of these values may or may not trigger an action potential. The neurobiology
of the axon sends a voltage wave backwards through the axon hillock at each time
also. If an action potential is generated, this backward potential hyperpolarizes the
dendritic cable and effectively shuts down depolarization for some time. This is the
well-known refractory period for an excitable neuron. We are not ready to model
these effects yet.
460 12 The Basic Hodgkin–Huxley Model

Fig. 12.27 The product


MK 4 during a pulse 1100 at
3.0 scaled by the maximum
sodium and potassium
conductance values

12.11.1 Exercise

Exercise 12.11.1 Run the Hodgkin–Huxley simulation as has been done in the work
above and write a complete report in your favorite editor which includes the following
things: For this study, we use the maximum sodium conductance is 120, the maximum
potassium conductance is 36, the leakage voltage is −50 with temperature 70 degrees
Fahrenheit. We will use IM is zero always. Then, find
1. The plots of voltage V , MNA , HNA and MK versus time for 20 milliseconds.
2. The plots of the time constant and the asymptotic value for MNA , HNA and MK
versus time.
3. The plots of MNA 3 HNA and MK 4 versus time.
4. The plots of sodium and potassium current versus time.
for the following applied voltage pulses on a cable of length 5 with ρ = 10. Use
suitable Q for the following pulses:
1. Pulse of size 300 at 1.5.
2. Pulse of size 200 at 2.0 and 100 at 1.0.
3. Pulse of size 300 at 4.0 and 200 at 1.0.

Exercise 12.11.2 Run the Hodgkin–Huxley simulation as has been done in the work
above and write a complete report in your favorite editor which includes the following
things: For this study, we use the maximum sodium conductance is 120, the maximum
potassium conductance is 36, the leakage voltage is −50 with temperature 70 degrees
Fahrenheit. We will still use IM is zero always. Then, find
1. The plots of voltage V , MNA , HNA and MK versus time for 20 milliseconds.
2. The plots of the time constant and the asymptotic value for MNA , HNA and MK
versus time.
12.11 More Action Potentials 461

3. The plots of MNA 3 HNA and MK 4 versus time.


4. The plots of sodium and potassium current versus time.
for the following applied voltage pulses on a cable of length 5 with ρ = 1. Use
suitable Q for the following pulses:
1. Pulse of size 300 at 1.5.
2. Pulse of size 200 at 2.0 and 400 at 1.0.
3. Pulse of size 500 at 4.0 and 300 at 1.0.

Exercise 12.11.3 Run the Hodgkin–Huxley simulation as has been done in the work
above and write a complete report in your favorite editor which includes the following
things: For this study, we use the maximum sodium conductance is 120, the maximum
potassium conductance is 36, the leakage voltage is −50 with temperature 70 degrees
Fahrenheit. We will still use IM is zero always. Then, find
1. The plots of voltage V , MNA , HNA and MK versus time for 20 milliseconds.
2. The plots of the time constant and the asymptotic value for MNA , HNA and MK
versus time.
3. The plots of MNA 3 HNA and MK 4 versus time.
4. The plots of sodium and potassium current versus time.
for the following applied voltage pulses on a cable of length 5 with ρ = 0.1. Use
suitable Q for the following pulses:
1. Pulse of size 300 at 1.5.
2. Pulse of size 200 at 2.0 and 100 at 1.0.
3. Pulse of size 300 at 4.0 and 200 at 1.0.

Exercise 12.11.4 Run the Hodgkin–Huxley simulation as has been done in the work
above and write a complete report in your favorite editor which includes the following
things: For this study, we use the maximum sodium conductance is 120, the maximum
potassium conductance is 36, the leakage voltage is −50 with temperature 70 degrees
Fahrenheit. We will still use IM is zero always. Then, find
1. The plots of voltage V , MNA , HNA and MK versus time for 20 milliseconds.
2. The plots of the time constant and the asymptotic value for MNA , HNA and MK
versus time.
3. The plots of MNA 3 HNA and MK 4 versus time.
4. The plots of sodium and potassium current versus time.
for the following applied voltage pulses on a cable of length 1 with ρ = 10.0. Use
suitable Q for the following pulses:
1. Pulse of size 300 at 1.0.
2. Pulse of size 200 at 1.0 and 100 at 0.6.
462 12 The Basic Hodgkin–Huxley Model

12.12 Action Potential Dynamics

Let’s redo our code to allow sequences of pulses to enter the dendritic system of an
excitable nerve cell. First, we will rewrite our GetAxonHillock code to return
our approximate solution to the ball-stick model as a function of the two variables
spatial distance along the dendrite and local dendrite time. Most of the code below
is standard and has been discussed already. However, in this code we do two new
things: first, as mentioned, we return the solution V as a function of two variables
and second, we generate a plot of this solution as a surface. The returned axon hillock
function is generated as follows:

Listing 12.39: Generating the axon hillock function


V = @( s , t ) B( 1 ) ∗ exp (− t ) ;
f o r n=1:Q
V = @( s , t ) (V( s , t ) + B( n+1)∗ c o s ( z ( n ) ∗ ( L − s ) ) . ∗ exp (−(1+ z ( n ) ˆ 2 )
∗t ) ) ;
end

The surface plot uses the mesh and meshgrid commands.

Listing 12.40: Drawing the surface


%
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 , 5 ]
% s e t up s p a c e and t i m e s t u f f
space = l i n s p a c e (0 ,L,101) ;
5 time = l i n s p a c e ( 0 , 5 , 1 0 1 ) ;
% s e t up g r i d o f x and y p a i r s ( s p a c e ( i ) , t i m e ( j ) )
[ Space , Time ] = m e s h g r i d ( s p a c e , t i m e ) ;
% s e t up s u r f a c e
Z = V( Space , Time ) ;
10
%p l o t s u r f a c e
figure
mesh ( Space , Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’ Dendrite Cable axis ’ ) ;
15 y l a b e l ( ’ Time axis ’ ) ;
z l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Dendritic Voltage ’ ) ;
p r i n t −dpng ’ DendriticVoltage . png ’ ;

Note, we print out the graph as a portable network graphic file for inclusion in our
documentation. The full code is then given below.
12.12 Action Potential Dynamics 463

Listing 12.41: GetAxonHillockThree


f u n c t i o n V = G e t A x o n H i l l o c k T h r e e (Q, L , rho , Vmax , l o c a t i o n )
2 %
% Arguments
%
% Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
7 % rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% Vmax = s i z e of v o l t a g e impulse
% location = l o c a t i o n of pulse
% z = eigenvalue vector
% D = data vector
12 %
% Computed Q u a n t i t i e s
%
% M = c o e f f i c i e n t m a t r i x f o r a p p r o x i m a t e v o l t a g e model
% AxonHillock = the s o l u t i o n at (0 , t )
17 % V = the solution at (z , t )
%
% get eigenvalue vector z
z = F i n d R o o t s (Q, L , rho , 1 . 0 , 1 . 0 ) ;
% get c o e f f i c i e n t matrix M
22 M = FindM (Q, L , rho , z ) ;
% compute d a t a v e c t o r f o r i m p u l s e
D = FindDataTwo (Q, L , rho , z , Vmax , l o c a t i o n ) ;
% S o l v e MB = D s y s t e m
[ Lower , Upper , p i v ] = GePiv (M) ;
27 y = L T r i S o l ( Lower ,D( p i v ) ) ;
B = U T r i S o l ( Upper , y ) ;
% check errors
E r r o r = Lower∗Upper∗B − D( p i v ) ;
D i f f = M∗B−D;
32 e = norm ( E r r o r ) ;
e2 = norm ( D i f f ) ;
normmessage = s p r i n t f ( ’ norm of LU residual = %12.7 f norm of MB - D =
%12.7 f ’ , e , e2 ) ;
d i s p ( normmessage ) ;

37 % s e t s p a t i a l and t i m e b o u n d s
V = @( s , t ) B( 1 ) ∗ exp (− t ) ;
f o r n=1:Q
V = @( s , t ) (V( s , t ) + B( n+1)∗ c o s ( z ( n ) ∗ ( L − s ) ) . ∗ exp (−(1+ z ( n ) ˆ 2 ) ∗ t ) ) ;
end
42
%
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 , 5 ]
% s e t up s p a c e and t i m e s t u f f
space = l i n s p a c e (0 ,L,101) ;
47 time = l i n s p a c e ( 0 , 5 , 1 0 1 ) ;
% s e t up g r i d o f x and y p a i r s ( s p a c e ( i ) , t i m e ( j ) )
[ Space , Time ] = m e s h g r i d ( s p a c e , t i m e ) ;
% s e t up s u r f a c e
Z = V( Space , Time ) ;
52
%p l o t s u r f a c e
figure
mesh ( Space , Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
x l a b e l ( ’ Dendrite Cable axis ’ ) ;
57 y l a b e l ( ’ Time axis ’ ) ;
z l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Dendritic Voltage ’ ) ;
p r i n t −dpng ’ D e n d r i t i c V o l t a g e . png ’ ;

62 end

To test this code, here is a sample session.


464 12 The Basic Hodgkin–Huxley Model

Fig. 12.28 Dendritic voltage surface approximation due to a spike of 300 mV at location 4.0 using
40 terms

Listing 12.42: GetAxonHillockThree test


Q = 40;
L = 5;
3 rho = 1 0 ;
V = G e t A x o n H i l l o c k T h r e e (Q, L , rho , 3 0 0 , 4 . 0 ) ;
norm o f LU r e s i d u a l = 0 . 0 0 0 0 0 0 0 norm o f MB−D = 0.0000000

We have oriented the surface you see in Fig. 12.28 so you can see the voltage solution
at spacial position 0; this is the axon hillock voltage as a function of space and time.
Note the separation of variables technique generates a voltage which has spurious
oscillations in it do the fact that we are calculating an approximate solution with
Q = 40 terms in the expansion.
We can focus on the axon hillock voltage by defining an axon hillock function
and plotting it as usual. To see the axon hillock voltage as a function of time, we
define an appropriate time axis and the compute the plot.

Listing 12.43: Axon hillock voltage time dependence


% d e f i n e t h e axon h i l l o c k function
AH = @( t ) V( 0 , t ) ;
% setup plot axis
time = l i n s p a c e ( 0 , 5 , 1 0 1 ) ;
5 y = AH( t i m e ) ;
% do t h e p l o t
p l o t ( time , y ) ;

The approximation to the dendritic pulse shows the oscillations we expect.


12.12 Action Potential Dynamics 465

Listing 12.44: Approximation to the dendritic pulse


space = l i n s p a c e (0 ,5 ,101) ;
DV = @( x ) V( x , 0 ) ;
3 z = DV( s p a c e ) ;
p l o t ( space , z ) ;

We next modify this function a bit to make it easier to use when there are multiple
pulses. This is the function GetAxonHillockFour.

Listing 12.45: GetAxonHillockFour arguments


function [ V, S u r f a c e ] = GetA xonHillockFour (Q, L , rho , Vmax , x0 , t0 , t f )

which returns the dendrite voltage function V as well as the handle of the surface we
plot, Surface. Most of this code is similar to that of the third version but this time,
we can specify the time the pulse is delivered; hence, the pulse is of magnitude Vmax
and is applied at time t0 and location x0. We also can choose how long we want to
time we want to use in the plot of the resulting surface by setting the variable tf as
we see fit. The new code for the surface plot is slightly different as we have to choose
the underlying linspace commands to we get a reasonable plot. We choose a time
and space step of .1 here as it works fairly well for many of our surfaces, but it is
possible it would be too coarse in some situations. So, you might have to alter this
in some simulations. We also change the voltage calculation to use absolute values
by changing to -abs(t-t0) in the code.

Listing 12.46: Adding absolute values


V = @( s , t ) B( 1 ) ∗ exp (− a b s ( t −t 0 ) ) + sum ( ( BB. ∗ c o s ( z ∗ ( L−s ) ) ) . ∗ exp
(EZ∗ a b s ( t −t 0 ) ) ) ;

We setup the surface plot in the usual manner.

Listing 12.47: Setup the surface plot


%
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 , t f ]
% s e t up s p a c e and t i m e s t u f f
4 sizetime = t f /.1+1;
s i z e s p a c e = L/.1+1;
space = l i n s p a c e (0 ,L , s i z e s p a c e ) ;
time = l i n s p a c e ( 0 . 3 , t f , s i z e t i m e ) ;
% s e t up g r i d o f x and y p a i r s ( s p a c e ( i ) , t i m e ( j ) )
9 [ Space , Time ] = m e s h g r i d ( s p a c e , t i m e ) ;

% rows o f Space a r e c o p i e s o f s p a c e
% a s many rows a r e t h e r e a r e t i m e p o i n t s
% c o l s o f Time a r e c o p i e s o f t i m e
466 12 The Basic Hodgkin–Huxley Model

14 % a s many c o l s a r e t h e r e a r e s p a c e p o i n t s
[ rowspace , c o l s p a c e ] = s i z e ( Space ) ;
[ rowstime , c o l t i m e ] = s i z e ( Space ) ;
%
% s e t up s u r f a c e
19 %
% f o r t h i s t o work
% rowspace = c o l t i m e
% c o l s p a c e = rowtime
f o r i =1: s i z e s p a c e
24 f o r j =1: s i z e t i m e
Z ( j , i ) = V( s p a c e ( i ) , t i m e ( j ) ) ;
end
end

After the construction of the surface points to plot, Z, is done, we do the plot itself.

Listing 12.48: Generating the plot


%Z = V( Space , Time ) ;
%p l o t s u r f a c e
figure
mesh ( Space , Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
5 Surface = gcf () ;
x l a b e l ( ’ Dendrite Cable axis ’ ) ;
y l a b e l ( ’ Time axis ’ ) ;
z l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Dendritic Voltage ’ ) ;

The only thing new here is that after we generate the plot with the mesh command,
we store its handle with the line Surface = gcf();. We can then refer to this
plot in later code by using the name Surface. The full code is then as follows:

Listing 12.49: GetAxonHillockFour


f u n c t i o n [ V, S u r f a c e ] = G e t A x o n H i l l o c k F o u r (Q, L , rho , Vmax , x0 , t0 , t f )
%
% Arguments
%
5 % Q = t h e number o f e i g e n v a l u e s we want t o f i n d
% L = the l e n g t h of the dendrite in space constants
% rho = t h e r a t i o o f d e n d r i t e t o soma c o n d u c t a n c e , G D/G S
% Vmax = s i z e of v o l t a g e impulse
% x0 = cable l o c a ti o n of pulse
10 % t0 = s t a r t time of p u l s e
% tf = end t i m e f o r a x o n a l p u l s e
%
% Computed Q u a n t i t i e s
%
15 % z = eigenvalue vector
% D = data vector
% M = c o e f f i c i e n t m a t r i x f o r a p p r o x i m a t e v o l t a g e model
% AxonHillock = the s o l u t i o n at (0 , t )
% V = the solution at (z , t )
20 %
% get eigenvalue vector z
z = F i n d R o o t s (Q, L , rho , 1 . 0 , 1 . 0 ) ;
% get c o e f f i c i e n t matrix M
M = FindM (Q, L , rho , z ) ;
25 % compute d a t a v e c t o r f o r i m p u l s e
D = FindDataTwo (Q, L , rho , z , Vmax , x0 ) ;
12.12 Action Potential Dynamics 467

% S o l v e MB = D s y s t e m
[ Lower , Upper , p i v ] = GePiv (M) ;
y = L T r i S o l ( Lower ,D( p i v ) ) ;
30 B = U T r i S o l ( Upper , y ) ;
% check errors
E r r o r = Lower∗Upper∗B − D( p i v ) ;
D i f f = M∗B−D;
e = norm ( E r r o r ) ;
35 e2 = norm ( D i f f ) ;

EZ = z e r o s (Q, 1 ) ;
f o r n = 1 :Q
EZ( n ) = −(1+ z ( n ) ˆ 2 ) ;
40 end

BB = z e r o s (Q, 1 ) ;
f o r n = 1 :Q
BB( n ) = B( n+1) ;
45 end

%
V = @( s , t ) B( 1 ) ∗ exp (− a b s ( t −t 0 ) ) + sum ( ( BB. ∗ c o s ( z ∗ ( L−s ) ) ) . ∗ exp (EZ∗
a b s ( t −t 0 ) ) ) ;
% 1 2 3 4 43 2 2
3 32 1
50
%
% draw s u r f a c e f o r g r i d [ 0 , L ] x [ 0 , t f ]
% s e t up s p a c e and t i m e s t u f f
sizetime = t f /.1+1;
55 s i z e s p a c e = L/.1+1;
space = l i n s p a c e (0 ,L , s i z e s p a c e ) ;
time = l i n s p a c e ( 0 . 3 , t f , s i z e t i m e ) ;
% s e t up g r i d o f x and y p a i r s ( s p a c e ( i ) , t i m e ( j ) )
[ Space , Time ] = m e s h g r i d ( s p a c e , t i m e ) ;
60
% rows o f S p a c e a r e c o p i e s o f s p a c e
% a s many rows a r e t h e r e a r e t i m e p o i n t s
% c o l s o f Time a r e c o p i e s o f t i m e
% a s many c o l s a r e t h e r e a r e s p a c e p o i n t s
65 [ rowspace , c o l s p a c e ] = s i z e ( Space ) ;
[ rowstime , c o l t i m e ] = s i z e ( Space ) ;
%
% s e t up s u r f a c e
%
70 % f o r t h i s t o work
% rowspace = c o l t i m e
% c o l s p a c e = rowtime
f o r i =1: s i z e s p a c e
f o r j =1: s i z e t i m e
75 Z ( j , i ) = V( s p a c e ( i ) , t i m e ( j ) ) ;
end
end

%Z = V( Space , Time ) ;
80 %p l o t s u r f a c e
figure
mesh ( Space , Time , Z , ’ EdgeColor ’ , ’ black ’ ) ;
Surface = gcf () ;
x l a b e l ( ’ Dendrite Cable axis ’ ) ;
85 y l a b e l ( ’ Time axis ’ ) ;
z l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Dendritic Voltage ’ ) ;
%p r i n t −dpng ’ D e n d r i t i c V o l t a g e . png ’ ;

90 end
468 12 The Basic Hodgkin–Huxley Model

12.12.1 Multiple Pulses

To handle multiple pulses occurring at different times, we will use the function
SetUpPulses. The function returns the a collection of handles to the surface plots
of each of the incoming pulses S{1}, S{2} and so forth; the handle of the plot of
the voltage for the cumulative pulses on the dendritic cable, DVplot, the handle of
the axon hillock voltage for the cumulative pulses, AHplot and finally, the summed
voltage function, Vin.

Listing 12.50: SetUpPulses arguments


f u n c t i o n [ S , DVplot , AHplot , Vin ] = S e t U p P u l s e s (VMax, x0 , td0 , s c a l e ,
xs , t s , t f )

The data structure we use here in the cell. The voltage pulses are sent in as the
cell VMax{1} to VMax{N} where N is the number of elements in the cell. We
store N in the variable NumberOfPulses and then we setup the summed dendritic
impulse function by calling the function GetAxonHillockFour repeatedly for
all N incoming pulses. This gives us a cell of handles to the individual surface plots
S{} and a cell of the individual pulse functions V{}. We also generate all of the
individual axon hillock potentials and save them in the cell AH{}. Since there are
multiple pulses, the locations of the pulses and their arrival times are also stored in
cells; here, x0{} and td0{}, respectively. Finally, we sum the response to the
incoming pulses in the function Vin.

Listing 12.51: Generating the response for an impulse sequence


% i n i t i a l i z e pulse c e l l
V = {};
% i n i t i a l i z e surface handle c e l l
S = {};
5 % initialize axon p o t e n t i a l c e l l
AV = { } ;
W = @( t ) 0 ;
f o r i = 1 : NumberOfPulses
[V{ i } , S{ i } ] = GetAxonHillockFour (Q, L , rho , VMax{ i } , x0 { i } , t d 0 { i } ,
tf ) ;
10 AV{ i } = @( t ) ( V{ i } ( . 2 , 0 . 2 + t )+ V{ i } ( . 2 , 0 . 2 + t+d e l t )+V{ i
} ( . 2 , 0 . 2 + t +2∗ d e l t ) ) / 3 ;
W = @( t ) W( t ) + AV{ i } ( t ) ;
end
Vin = @( t ) s c a l e ∗W( t ) ;

Note, we use the argument scale here. We may or may not want to use the gener-
ated pulse voltages unscaled. Our approximation strategies can generate really high
voltages at times; hence, we opt for prudence and allow ourselves a scaling choice.
If we set scale = 1.0 we use the full generated voltages. On the other hand, if
we set scale = 0.4 or anything less than 1, we artificially diminish the size of
the pulse. We then compute the summed dendritic voltage, DV, on the dendritic cable
12.12 Action Potential Dynamics 469

itself as a function. Also, to avoid irregularities with the approximation algorithms


at time 0 and dendritic cable location 0, we choose to start time at 0.2 and space at
0.2 rather than 0, respectively.

Listing 12.52: Constructing the summed dendritic pulse


DV = @( x ) 0 ;
f o r i = 1 : NumberOfPulses
DV = @( x ) DV( x ) + V{ i } ( x , t d 0 { i } ) ;
end

Next, we generate the plots of the summed dendritic voltage Vin and summed
axon hillock voltage and return their handles DVPlot{} and AHplot. There are
multiple handles for the dendritic voltage plots as their are multiple pulses. Here we
use the variables delx and delt to try to set up reasonable linspace commands for
our surface plots. These variables are set earlier in the code.

Listing 12.53: Generating plots


%
s i z e S p a c e = L/ d e l x + 1 ;
sizeTime = t f / d e l t + 1 ;
time = l i n s p a c e ( ts , t f , sizeTime ) ;
5 s p a c e = l i n s p a c e ( xs , L , s i z e S p a c e ) ;
%
figure ;
f o r n=1: s i z e T i m e
AH( n ) = Vin ( t i m e ( n ) ) ;
10 end
p l o t ( time ,AH) ;
AHplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
y l a b e l ( ’ Voltage ’ ) ;
15 t i t l e ( ’ Axon Hillock Voltage ’ ) ;
%
DVplot = { } ;
f o r i = 1 : NumberOfPulses
figure ;
20 f o r n=1: s i z e S p a c e
DVY( n ) = V{ i } ( s p a c e ( n ) , t d 0 { i } ) ;
end
p l o t ( s p a c e ,DVY) ;
DVplot { i } = g c f ( ) ;
25 x l a b e l ( ’ Space ’ ) ;
y l a b e l ( ’ Applied Input Voltage ’ ) ;
message = [ ’ Initial Voltage ’ , i n t 2 s t r ( i ’) ,on Dendrite ’ ] ;
t i t l e ( message ) ;
end

Here is the full code.


470 12 The Basic Hodgkin–Huxley Model

Listing 12.54: SetUpPulses


1 f u n c t i o n [ S , DVplot , AHplot , Vin ] = S e t U p P u l s e s (VMax, x0 , td0 , s c a l e , xs , t s ,
tf )
%
% VMax = c e l l o f d e n d r i t i c i m p u l s e s i z e s
% x0 = c e l l of d e n d r i t i c impulse l o c a t i o n s
% td0 = time d e n d r i t i c impulse a r r i v e s
6 % scale = multiplier for pulse
% ts = s t a r t time of p l o t
% tf = end t i m e o f p l o t
% xs = s t a r t p o s i t i o n of space in p l o t
%
11 % C a l c u l a t e dendritic pulse
%
Q = 48;
L = 5;
rho = 1 0 ;
16 NumberOfPulses = l e n g t h (VMax) ;
delt = .1;
delx = . 0 5 ;
V = {};
S = {};
21 AV = { } ;
W = @( t ) 0 ;
f o r i = 1 : NumberOfPulses
[V{ i } , S{ i } ] = G e t A x o n H i l l o c k F o u r (Q, L , rho , VMax{ i } , x0{ i } , t d 0 { i } , t f ) ;
AV{ i } = @( t ) ( V{ i } ( . 2 , 0 . 2 + t )+ V{ i } ( . 2 , 0 . 2 + t+d e l t )+V{ i } ( . 2 , 0 . 2 + t +2∗
delt ) ) /3;
26 W = @( t ) W( t ) + AV{ i } ( t ) ;
end
Vin = @( t ) s c a l e ∗W( t ) ;
%
% Applied Voltage
31 %
DV = @( x ) 0 ;
f o r i = 1 : NumberOfPulses
DV = @( x ) DV( x ) + V{ i } ( x , t d 0 { i } ) ;
end
36 %
s i z e S p a c e = L/ d e l x + 1 ;
sizeTime = t f / d e l t + 1 ;
time = l i n s p a c e ( ts , t f , sizeTime ) ;
s p a c e = l i n s p a c e ( xs , L , s i z e S p a c e ) ;
41 %
figure ;
f o r n=1: s i z e T i m e
AH( n ) = Vin ( t i m e ( n ) ) ;
end
46 p l o t ( time ,AH) ;
AHplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
y l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Axon Hillock Voltage ’ ) ;
51 %
DVplot = { } ;
f o r i = 1 : NumberOfPulses
figure ;
f o r n=1: s i z e S p a c e
56 DVY( n ) = V{ i } ( s p a c e ( n ) , t d 0 { i } ) ;
end
p l o t ( s p a c e ,DVY) ;
DVplot{ i } = g c f ( ) ;
x l a b e l ( ’ Space ’ ) ;
61 y l a b e l ( ’ Applied Input Voltage ’ ) ;
message = [ ’ Initial Voltage ’ , i n t 2 s t r ( i ) , ’ on Dendrite ’ ] ;
t i t l e ( message ) ;
end

66 end
12.12 Action Potential Dynamics 471

Let’s try out the code. We send in two pulses: one of magnitude 200 at time 5 and
location 2.3 and the other of size 400 at time 10.0 and location 2.5. We setup the
time axis to run from 0 to 15 and we choose to use full scaling; i.e., scale = 1.0.

Listing 12.55: Setting up pulses


[ S , DVplot , AHplot , Vin ] = S e t U p P u l s e s
({200;400} ,{2.3;2.5} ,{5.0;10.0} ,1.0 ,0 ,0 ,15.0) ;

This returns handles to our graphics and the summed axon hillock function Vin. We
then print out our plots. First, we find the handle numbers.

Listing 12.56: Getting handles for the plots


S
S =

{
5 [1 ,1] = 2
[1 ,2] = 3
}
AHplot
AHplot = 4
10
DVplot
DVplot =

{
15 [1 ,1] = 5
[1 ,2] = 6
}

Then, we do the plots.

Listing 12.57: Generating the plots


p r i n t ( ’-f2 ’ , ’- dpng ’ , ’ DendriticVoltageSurfaceOne . png ’ ) ;
p r i n t ( ’-f3 ’ , ’- dpng ’ , ’ DendriticVoltageSurfaceTwo . png ’ ) ;
3 p r i n t ( ’-f4 ’ , ’- dpng ’ , ’ AxonHillockVoltage . png ’ ) ;
p r i n t ( ’-f5 ’ , ’- dpng ’ , ’ DendriticPulseOne . png ’ ) ;
p r i n t ( ’-f6 ’ , ’- dpng ’ , ’ DendriticPulseTwo . png ’ ) ;

This gives us the two surface plots, Figs. 12.29 and 12.30.
The voltage trace for the two pulses along the cable are approximated as shown
in Figs. 12.31 and 12.32.
Finally, the generated axon hillock voltage is shown in Fig. 12.33.
We clean up our generated figures with the utility function CleanUpFigures-
Two given below. To use this, simply type CleanUpFiguresTwo.
472 12 The Basic Hodgkin–Huxley Model

Fig. 12.29 Voltage surface for one pulse

Fig. 12.30 Voltage surface for two pulses

Listing 12.58: Cleaning up the generated figures


%CleanUpFiguresTwo .m
N = length (S) ;
f o r i =1:N
d e l e t e ( S{ i } ) ;
5 d e l e t e ( DVplot { i } ) ;
end

d e l e t e ( AHplot ) ;
12.12 Action Potential Dynamics 473

Fig. 12.31 Approximation to pulse one on the dendritic cable

Fig. 12.32 Approximation to pulse two on the dendritic cable


474 12 The Basic Hodgkin–Huxley Model

Fig. 12.33 Axon hillock voltage for two pulses

12.12.2 Generating Action Potentials for Sequences of Pulses

We must alter the Hodgkin–Huxley dynamics to handle an incoming voltage. Most of


this code is similar to the code we have used previously for the dynamics. However,
we now want to pass in the name of the axon hillock voltage function. To do this,
we alter the data structure p which we pass in. In the code fragment below, note the
p.a and p.b portions of p are the same as usual, but we have added a new field
p.c to contain the name of our incoming voltage function.

Listing 12.59: The p.c field


% p comes i n a s a d a t a s t r u c t u r e .
%
% p . a (1) = EK, t h e p o t a s s i u m b a t t e r y v o l t a g e
% p . a (2) = ENA i s t h e sodium b a t t e r y v o l t a g e
5 % p . a (3) = EL , t h e l e a k a g e v o l t a g e
% p . a (4) = GL, t h e l e a k a g e c o n d u c t a n c e
% p . a (5) = gNAmax , maximum sodium c o n d u c t a n c e
% p . a (6) = gKmax , maximum p o t a s s i u m c o n d u c t a n c e
%
10 % p (1 ,2) i s the s t r i n g data
% To u s e
% p . a = [EK;ENA; EL ;GL; gNAmax ; gKMax ] ;
% p . b = ’ string ’ ; name o f HHGates f u n c t i o n
% p . c = ’ string ’ ; name o f i n p u t v o l t a g e
12.12 Action Potential Dynamics 475

We extract this information as usual, assigning the variable Pulse to the input
voltage function name.

Listing 12.60: Extracting information from the p structure


EK = p . a (1) ;
ENA = p . a (2) ;
% l e a k a g e c u r r e n t : run r e s t .m t o f i n d a p p r o p r i a t e g L v a l u e
% d e f a u l t E l e a k = −50.0
5 E leak = p . a (3) ;
g leak = p . a (4) ;
% max c o n d u c t a n c e f o r NA: d e f a u l t i s 120
g NA bar = p . a ( 5 ) ;
% max c o n d u c t a n c e f o r K: d e f a u l t i s 3 6 . 0
10 g K bar = p . a (6) ;
gatename = p . b ;
Pulse = p. c ;

We then evaluate the incoming voltage at the time t using feval(Pulse,t) and
add it to the current voltage y(1). Then we send this voltage into the α–β evaluation
function GatesNAK as we have done in the previous code.

Listing 12.61: Evaluating the gates functions


c u r r e n t V = y ( 1 )+f e v a l ( P u l s e , t ) ;
a l p h a = GatesNAK ( gatename , c u r r e n t V ) ;

Finally, we remove the external current IE2 as we no longer use it as a source of


depolarization. The full code is given below.

Listing 12.62: Using incoming depolarizations: HHdynamicsVin

f u n c t i o n f = HHdynamicsVin ( p , t , y )
% S t a n d a r d H o d g k i n − H u x l e y Model
% voltage mV
% current na
5 % time ms
% c o n c e n t r a t i o n mM
% conductance micro Siemens
% capacitance nF
%
10 % arguments
% p parameter v e c t o r
% t time
% y state vector
%
15 % ===============================================
% y vector assignments
% ===============================================
% y (1) = V
% y ( 2 ) = m NA
20 % y ( 3 ) = h NA
% y (4) = m K
%
% parameter assignments
% p comes i n a s a d a t a s t r u c t u r e .
476 12 The Basic Hodgkin–Huxley Model

25 %
% p . a (1) = EK, t h e p o t a s s i u m b a t t e r y v o l t a g e
% p . a (2) = ENA i s t h e sodium b a t t e r y v o l t a g e
% p . a (3) = EL , t h e l e a k a g e v o l t a g e
% p . a (4) = GL, t h e l e a k a g e c o n d u c t a n c e
30 % p . a (5) = gNAmax , maximum sodium c o n d u c t a n c e
% p . a (6) = gKmax , maximum p o t a s s i u m c o n d u c t a n c e
%
% p (1 ,2) i s the s t r i n g data
% To u s e
35 % p . a = [ EK ;ENA; EL ; GL ; gNAmax ; gKMax ] ;
% p . b = ’ string ’ ; name o f HHGates f u n c t i o n
% p . c = ’ string ’ ; name o f i n p u t v o l t a g e

EK = p . a (1) ;
40 ENA = p . a (2) ;
% l e a k a g e c u r r e n t : run r e s t .m t o f i n d a p p r o p r i a t e g L v a l u e
% d e f a u l t E l e a k = −50.0
E leak = p . a (3) ;
g leak = p . a (4) ;
45 % max c o n d u c t a n c e f o r NA: d e f a u l t i s 120
g NA bar = p . a ( 5 ) ;
% max c o n d u c t a n c e f o r K: d e f a u l t i s 3 6 . 0
g K bar = p . a (6) ;
gatename = p . b ;
50 Pulse = p. c ;

f = zeros (4 ,1) ;

% ==============================================
55 % f vector assignments
% ==============================================
% f ( 1 ) = V dynamics
% f ( 2 ) = m NA d y n a m i c s
% f ( 3 ) = h NA d y n a m i c s
60 % f ( 4 ) = m K dynamics
%
c u r r e n t V = y ( 1 )+f e v a l ( P u l s e , t ) ;
a l p h a = GatesNAK ( gatename , c u r r e n t V ) ;
%
65 % a c t i v a t i o n / i n a c t i v a t i o n p a r a m e t e r s f o r NA
% a l p h a ( 1 ) , a l p h a ( 2 ) a l p h a and b e t a f o r mna
% a l p h a ( 3 ) , a l p h a ( 4 ) a l p h a and b e t a f o r hna
% a l p h a ( 5 ) , a l p h a ( 6 ) a l p h a and b e t a f o r mk
%
70 m NA infinity = a l p h a ( 1 ) / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
t m NA = 1 . 0 / ( a l p h a ( 1 )+a l p h a ( 2 ) ) ;
f (2) = ( m N A i n f i n i t y − y ( 2 ) ) /t m NA ;
%
h NA infinity = a l p h a ( 3 ) / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
75 t h NA = 1 . 0 / ( a l p h a ( 3 )+a l p h a ( 4 ) ) ;
f (3) = ( h N A i n f i n i t y − y ( 3 ) ) / t h NA ;
I NA = g NA bar ∗ ( currentV −ENA) ∗y ( 2 ) ˆ3∗ y ( 3 ) ;
%
m K infinity = a l p h a ( 5 ) / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
80 t m K = 1 . 0 / ( a l p h a ( 5 )+a l p h a ( 6 ) ) ;
f (4) = ( m K i n f i n i t y − y ( 4 ) ) /t m K ;
I K = g K b a r ∗ ( currentV −EK) ∗y ( 4 ) ˆ 4 ;
% I L current
I l e a k = g l e a k ∗ ( currentV −E l e a k ) ;
85 % C e l l Capacitance
C M = 1.0;
% f u l l dynamics
f ( 1 ) = (− I NA − I K − I l e a k ) /C M ;
end
12.12 Action Potential Dynamics 477

We then write code to allow us to automate the generation of the action poten-
tial. This is the function SetUpHH. As part of the automation, we provide our
first attempt at determining if an action potential is generated. This is the function
ConvertToDigital. This is a simple sigmoidal switch. The switch, D(V ), is
defined by

1 1 V −O
D(V ) = (VT + VB ) + (VT − VB ) tanh
2 2 G

and provides a transfer from the bottom value VB to the top value VT using a stan-
dard sigmoid with offset O and gain parameter G. The membrane voltage must be
larger than the offset to allow the switch value to approach the top value of VT . The
implementation of the switch is given in the code below.

Listing 12.63: ConvertToDigital


f u n c t i o n D = C o n v e r t T o D i g i t a l (V, VT, VB, O f f s e t , Gain )
%
% V = voltage
% VR = Reference v o l t a g e
5 % VT = Top v o l t a g e
% VB = Bottomo v o l t a g e
% Offset = pulse switch point
% Gain = rate of t r a n s i t i o n
%
10 D = 0 . 5 ∗ (VT+VB) + 0 . 5 ∗ (VT−VB) ∗ tanh ( (V − O f f s e t ) / Gain ) ;
end

In the SetUpHH code, we begin by setting up the incoming pulses for the excitable
cell. Here Vmax{} is the cell of pulse magnitudes, x0{} is the cell of spatial
locations for the pulses and td0{} is the cell of the times at which the pulses are
applied.

Listing 12.64: Calculating a dendritic pulse


% Calculate dendritic pulse
[ S , DVplot , AHplot , Vin ] = S e t U p P u l s e s (Vmax , x0 , td0 , s c a l e , xs , t s , t f ) ;

Note, when we calculate the effects of the incoming pulses, we return the function
Vin. Then, we set the rest value for the excitable cell.

Listing 12.65: Setting up parameters


%
% Setup nerve c e l l parameters
%
E L = −50;
5 V R = −70;
g NA bar = 1 2 0 ;
g K bar = 3 6 ;
Kin = 4 0 0 ;
478 12 The Basic Hodgkin–Huxley Model

Kout = 2 0 . 1 1 ;
10 Nain = 5 0 . 0 ;
Naout = 4 9 1 ;
TF = 6 9 ;
p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
[ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = r e s t ( E L , V R , g NA bar , g K bar ,
p , ’ HHGates ’ ) ;

Next, we initialize the data structures pp and q which we need for the call to the
function SolveSimpleHH. We then compute the response of the excitable nerve
cell which may include action potentials.

Listing 12.66: Initialize the pp and q structures


pp . a = [ E K ; E NA ; E L ; g L ; g NA bar ; g K b a r ] ;
pp . b = ’ HHGates ’ ;
pp . c = Vin ;
e r r o r t o l = 1 . 0 e −3;
5 s t e p t o l = 1 . 0 e −5;
m i n s t e p = 1 . 0 e −2;
maxstep = 2 . 0 ;
q = [ e r r o r t o l ; s t e p t o l ; m i n s t e p ; maxstep ] ;

10 [ t v a l s , y v a l s , f v a l s , h v a l s , g NA , g K ,Vm, m NA, h NA , m K ] = . . .
SolveSimpleHH ( ’ HHdynamicsVin ’ , q , pp , 0 , t f , [ V R ; m NA0 ; h NA0 ; m K0
] ,.6) ;

We plot the results of the axon response next.

Listing 12.67: Plot the axon response


delt = .1;
s i z e T i m e = t f / d e l t +1;
time = l i n s p a c e ( ts , t f , sizeTime ) ;
4

figure ;
p l o t ( t v a l s ,Vm) ;
APplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
9 y l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Axon Response Voltage ’ ) ;

Finally, we plot the digitization of the axon response using the ConvertTo-
Digital function. We set this conversion using a top voltage of 40 mV and a
bottom voltage of VR = −70 mV. Since the offset is also VR and the gain is 20,
this function slowly transitions from the reference voltage to 40. Hence, all voltages
above 40 are output as 40.
12.12 Action Potential Dynamics 479

Listing 12.68: The digital response


figure
VT = 4 0 ;
VB = V R ;
O f f s e t = −70;
5 Gain = 2 0 ;
p l o t ( t v a l s , C o n v e r t T o D i g i t a l (Vm, VT, VB, O f f s e t , Gain ) ) ;
DPplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
y l a b e l ( ’ Digital Voltage ’ ) ;
10 t i t l e ( ’ Axon Digital Voltage ’ ) ;

The full code is listed below.

Listing 12.69: SetUpHH


f u n c t i o n [ S , DVplot , AHplot , APplot , DPplot ] = SetUpHH (Vmax , x0 , td0 , s c a l e ,
xs , t s , t f )
%
% VMax = c e l l o f d e n d r i t i c i m p u l s e s i z e s
% x0 = c e l l of d e n d r i t i c impulse l o c a t i o n s
5 % td0 = time d e n d r i t i c impulse a r r i v e s
% scale = multiplier for pulse
% ts = s t a r t time of p l o t
% tf = end t i m e o f p l o t
%
10 % Calculate dendritic pulse
[ S , DVplot , AHplot , Vin ] = S e t U p P u l s e s (Vmax , x0 , td0 , s c a l e , xs , t s , t f ) ;

%
% Setup nerve c e l l parameters
15 %
E L = −50;
V R = −70;
g NA bar = 1 2 0 ;
g K bar = 3 6 ;
20 Kin = 4 0 0 ;
Kout = 2 0 . 1 1 ;
Nain = 5 0 . 0 ;
Naout = 4 9 1 ;
TF = 6 9 ;
25 p = [ Kin ; Kout ; Nain ; Naout ; TF ] ;
[ g L , m NA0 , h NA0 , m K0 , E K , E NA ] = r e s t ( E L , V R , g NA bar , g K bar , p , ’
HHGates ’ ) ;

pp . a = [ E K ; E NA ; E L ; g L ; g NA bar ; g K b a r ] ;
pp . b = ’ HHGates ’ ;
30 pp . c = Vin ;
e r r o r t o l = 1 . 0 e −3;
s t e p t o l = 1 . 0 e −5;
minstep = 1 . 0 e −2;
maxstep = 2 . 0 ;
35 q = [ e r r o r t o l ; s t e p t o l ; m i n s t e p ; maxstep ] ;

[ t v a l s , y v a l s , f v a l s , h v a l s , g NA , g K ,Vm, m NA, h NA , m K ] = . . .
SolveSimpleHH ( ’ H H d y n a m i c s V i n ’ , q , pp , 0 , t f , [ V R ; m NA0 ; h NA0 ; m K0 ] , . 6 ) ;

40 delt = .1;
s i z e T i m e = t f / d e l t +1;
time = l i n s p a c e ( ts , t f , sizeTime ) ;

figure ;
45 p l o t ( t v a l s ,Vm) ;
APplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
y l a b e l ( ’ Voltage ’ ) ;
t i t l e ( ’ Axon Response Voltage ’ ) ;
480 12 The Basic Hodgkin–Huxley Model

50
figure
VT = 4 0 ;
VB = V R ;
O f f s e t = −70;
55 Gain = 2 0 ;
p l o t ( t v a l s , C o n v e r t T o D i g i t a l (Vm, VT, VB, O f f s e t , Gain ) ) ;
DPplot = g c f ( ) ;
x l a b e l ( ’ Time ’ ) ;
y l a b e l ( ’ Digital Voltage ’ ) ;
60 t i t l e ( ’ Axon Digital Voltage ’ ) ;

end

We clean up our generated figures with the script CleanUpFigures given below.
Use it by simply typing CleanUpFigures.

Listing 12.70: Clean up figures


C l e a n U p F i g u r e s .m
N = length (S) ;
f o r i =1:N
d e l e t e ( S{ i } ) ;
5 d e l e t e ( DVplot { i } ) ;
end
d e l e t e ( APplot ) ;
d e l e t e ( AHplot ) ;
d e l e t e ( DPplot ) ;

To use this code is straightforward. We will send in three pulses of various mag-
nitudes, locations and times using a scale of 1.0 and plot the results over 20 sec-
onds. For convenience, we will denote these pulses using a dirac delta notation:
Vmax δ(t − t0 , x − x0 ) is the pulse of magnitude Vmax at location x0 applied at time t0 .

Listing 12.71: Setup for multiple pulses


1 [ S , DVplot , AHplot , APplot , DPplot ] = . . .
> SetUpHH
({200;300;400} ,{1.5;2.0;3.0} ,{5.0;10.0;11.0} ,1.0 ,0 ,0 ,20) ;
ans = 144.65
ans = 43.640
ans = 215.33
6 ans = 30.054
ans = 298.15
a n s = −4.9560

The generated action potential is shown in Fig. 12.34 and the digitization of it is shown
in Fig. 12.35. Recall,
 the digitization here is performed by the function D(V ) =
V +70
−15 + 55 tanh 20
which has a bottom threshold for −70 mV and an upper
threshold of 40 mV. Since the axon potential never goes above about 20 mV, the
digital value does not stay near the top value for long.
Of course, by altering the parameters that shape the digitization sigmoid, we can
change this signal. To change the bottom threshold to 0 mV and the top to 1, we
12.12 Action Potential Dynamics 481

Fig. 12.34 Generated action potential for pulses 200δ(t − 5, x − 1.5), 300δ(t − 10, x − 2.0) and
400δ(t − 11, x − 3.0)

Fig. 12.35 −70 to 40 digitization of action potential for pulses 200δ(t − 5, x − 1.5),
300δ(t − 10, x − 2.0) and 400δ(t − 11, x − 3.0)

would set VB = 0 and VT = 1 and rerun the example. We also can change the offset
value so that the pulse assigns a value of 0 to voltages close to VR . In this run, we set
O = −40; this givesa value of about 0.05 to VR . The new switch is then defined by
V +40
D(V ) = 0 + 1 tanh 20
and the new digitization is shown in Fig. 12.36.
482 12 The Basic Hodgkin–Huxley Model

Fig. 12.36 0 to 1 digitization of action potential for pulses 200δ(t − 5, x − 1.5),


300δ(t − 10, x − 2.0) and 400δ(t − 11, x − 3.0)

12.12.3 Simulating Second Messenger Activity

Second messenger systems alter the axon potential generated from the inputs to
the dendritic system by generating proteins which change the excitable nerve cell
itself. Thus, a second messenger signal takes the existing hardware of the cell and
replaces it in various ways. These systems are discussed more thoroughly in Peterson
(2015) where we model generalized triggers that cause a cascade of reactions inside
the cell which culminate in the production of proteins. These proteins could be
additional sodium gates (increasing or decreasing gNa Max
), potassium gates (increasing
or decreasing gNa ) and/or proteins that alter the hyperpolarization phase of the
Max

action potential. For example, the value of gL could be altered leading to increased or
decreased current flux across the membrane. This would change how easy it is for an
action potential to be generated for a given voltage input sequence to the dendrite. We
can simulate this by altering the value of gL in the simulation. In the code SetUpHH,
we return the value of gL that sets up zero current flow across the membrane initially.
Add this code to the function after the call to rest. This will print out the rest
determined gL value, and the changed value we get by adding 2.5.

Listing 12.72: Simulating second messenger activity


g L
g L = g L + 2.5
12.12 Action Potential Dynamics 483

Fig. 12.37 Generated action potential for pulses 200δ(t − 5, x − 1.5), 300δ(t − 10, x − 2.0) and
400δ(t − 11, x − 3.0) with increased gL

Fig. 12.38 −70 to 40 digitization of action potential for pulses 200δ(t − 5, x − 1.5),
300δ(t − 10, x − 2.0) and 400δ(t − 11, x − 3.0) with increased gL

The new action potential, Fig. 12.37, is significantly different from the first as the
increased leakage current allows for the depolarization effects to be more pronounced.
The digitized potential now has a much higher hyperpolarization phase and a
wider digitized action potential. This is shown in Fig. 12.38.
484 12 The Basic Hodgkin–Huxley Model

References

A. Hodgkin, The components of membrane conductance in the giant axon of Loligo. J. Physiol.
(Lond.) 116, 473–496 (1952)
A. Hodgkin, The ionic basis of electrical activity in nerve and muscle. Biol. Rev. 26, 339–409
(1954)
A. Hodgkin, A. Huxley, Currents carried by sodium and potassium ions through the membrane of
the giant axon of Loligo. J. Physiol. (Lond.) 116, 449–472 (1952)
D. Johnston, S. Miao-Sin Wu, Foundations of Cellular Neurophysiology (MIT Press, Cambridge,
1995)
J. Peterson, BioInformation Processing: A Primer on Computational Cognitive Science. Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015 in press)
T. Weiss, Cellular Biophysics: Volume 1, Transport (MIT Press, Cambridge, 1996a)
T. Weiss, Cellular Biophysics: Volume 2, Electrical Properties (MIT Press, Cambridge, 1996b)
Part V
Summing It All Up
Chapter 13
Final Thoughts

In this book, we have learned a lot about how to model an excitable neuron and
we have seen how many approximations we must make to find models we can solve
mathematically. It is important to realize that we always make error when we abstract
from reality a tentative map of how variables of interest to us relate. Our choice for
constructing these relationship maps here is the language of mathematics and we
supplement that with another expressive language known as computer modeling. Our
choice of language for that has been MatLab/Octave but that is merely convenient.
Much of this material we have taught to a mixture of undergraduates and graduate
students who have either taken one or two courses based on Peterson (2015a, b)
or have a traditional mathematics degree where they have learned that material—
without the modeling and computer work though—in other courses. On most college
campuses in today’s world, few students know other computer languages and so these
books were written for the common denominator language MatLab which is readily
available.
However, it is easy enough to do all of the computer modeling in Python or other
languages. We encourage you to start exploring other programming viewpoints. In
the next volume, we begin the process of setting up our tools for building network
of computational nodes which interact and although all of the code is still within the
MatLab/Octave family, it is clear we could perhaps do better if we started learning
how to program in other choices. To start you off with Python, we recommend
working through Langtangen (2012). This is a big book and will take a lot of time
to process, but being able to model ideas from computational cognitive processing
in both MatLab/Octave and Python will help you grow as a modeler. Another thing
to do is to start learning about programming paradigms when the value of a variable
can not be changed. This completely alters the way you program but it is very helpful
when you try to model things using many cores on a laptop. It is easy to see why
having a variable not be changeable is good in the case that you models using many
processes that can access that variable. If each process can change the value, it is
very easy to get into situations where the value of the variable loses meaning as
it is not well defined. A good choice to begin studying this approach is to start
reading about Erlang in Hébert (2013), Armstrong (2013) and Logan et al. (2011).
© Springer Science+Business Media Singapore 2016 487
J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_13
488 13 Final Thoughts

For computational speed, programming in C or C++ is very helpful and in Chap. 14


we mention books that can help you with learning those languages.
And of course, continue to learn about cognitive systems.

References

J. Armstrong, Programming Erlang Second Edition: Software for a Concurrent World (The Prag-
matic Bookshelf, Dallas, 2013)
F. Hébert, Learn You Some Erlang for Great Good (No Starch Press, San Francisco, 2013)
H. Langtangen, A Primer of Scientific Programming with Python (Springer, New York, 2012)
M. Logan, E. Merritt, R. Carlsson, Erlang and OTP in Actions (Manning, Stamford, 2011)
J. Peterson, Calculus for Cognitive Scientists: Derivatives, Integration and Modeling, Springer
Series on Cognitive Science and Technology (Science+Business Media Singapore Pte Ltd.,
Singapore, 2015a in press)
J. Peterson, Calculus for Cognitive Scientists: Higher Order Models and Their Analysis, Springer
Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015b in press)
Part VI
Advise to the Beginner
Chapter 14
Background Reading

We have written these notes to help you if want to learn some of the basic principles of
chemistry, biology and neuroscience that underlie the study of biological information
processing. Perhaps you also wish to develop software models of cognition or learn
better the material that underlies detailed mathematical models of neurons and other
biological cells. We have been inspired by many attempts by people in disparate
fields to find meaning and order in the vast compilations of knowledge that they
must assimilate. Like them, we have done a fair bit of reading and study to prepare
ourselves for necessary abstractions we need to make in our journey. We have learned
a lot from various studies of theoretical biology and computation and so forth. You
will need to make this journey too, so to help you, here are some specific comments
about the sources we have used to learn from.

14.1 Biology and Physiology

It is clear that the regulation of information processing depends on many agents.


These can be hormones and multiple neurotransmitters all interacting on vastly dif-
ferent time scales in mutually dependent ways. It is important to gain an overview
understanding of these areas. The references below were how we have gotten started
in this process:
• Animal physiology in Eckert et al. (1998). You will need some basic reference on
animal physiology, just to see how all things fit together. This is a good source.
This is also intended for browsing when you need to look something up. It has less
technical detail than some of the other books in this section and because of that, it
has more of an overview character that is quite useful at times.

© Springer Science+Business Media Singapore 2016 491


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9_14
492 14 Background Reading

• General Neurobiology in Hall (1992). This is a standard introductory textbook to


this area. It has all the requisite detail. We have read a lot of this—much of it gives
needed background flavor and a useful feel for the subject.
• Ion Channels in Hille (1992a). This is an acknowledged source of material on the
structure of the channels through which neurotransmitters (and other things) flow
in and out of membranes. There are times when this book was a useful adjunct
to our learning process. In “Classical Biophysics of the Squid Giant Axon” (Hille
1992b), we see a particular chapter devoted to the biophysics of the squid axonal
fiber.
• The book Foundations of Cellular Neurophysiology by Johnston and Wu
(1995a), is a detailed reference to cellular physiology. In “Hodgkin and Hux-
ley’s Analysis of the Squid Giant Axon” (Johnston and Wu 1995b), we note the
particular chapter devoted to the Hodgkin and Huxley analysis of the giant squid
axon.
• Cellular BioPhysics in Weiss (1996a, b). In the chapter “The Hodgkin–Huxley
Model” Weiss (1996c), we reference a particular treatment of the Hodgkin–Huxley
models.
• Essential Psychopharmacology in Stahl (2000).
• The chapter “Multiple Channels and Calcium Dynamics”, in Methods of Neu-
ronal Modeling edited by Koch and Segev (Yamada et al. 1987) is a reference
to a very detailed mathematical model for the generation of the output pulse of a
neuron that does include second messenger effects. Although quite old, it is still
very useful to read.
• Neuropharmacology in Stone (1995).
• Endrocrinology in Hadley (1996).
• Immunology in Austyn and Wood (1993).

14.2 Theoretical Biology

• The connections between genes, developmental biology and evolution from Raff
and Kaufman (1983). This is the older version of his ideas, but it is very useful
to a beginner to read. A more mature version of his ideas appears in Raff (1996).
This is a more mature version of Raff’s ideas on the connections between genes,
development and evolution using more contemporary evidence.
• Neuromodulation and its importance in information processing in Katz (1999).
• The neurobiology of memory in Dudai (1989). This is a useful book that was our
first introduction to theories of how nervous systems handle information process-
ing. It is very speculative and for that reason, extremely interesting. There is much
food for thought on software design buried in here!
• A theoretical approach to cell signaling, embryonic development and much more
is presented in Gerhart and Kirschner (1997a). This book has influenced our
14.2 Theoretical Biology 493

thinking enormously about generic triggers that initiate information exchange


in cellular pathways. Specific chapters include Regulatory Linkage (Gerhart and
Kirschner 1997b, Chap. 3) and Conditionality and Compartmentalization (Gerhart
and Kirschner 1997c, Chap. 6).

14.3 Software

Out of the many books that are available for self-study in all of the areas above,
some have proved to be invaluable, while others have been much less helpful. The
following annotated list consists of the real gems. To learn to program effectively in
an object oriented way in Python, it is helpful to know how to program in a procedural
language such as C. Then, learning how to program objects within the constraints of
the class syntax of C++ is very useful. This is the route we took in learning how to
program in an object oriented way. The final step is to learn how to use a scripting
glue language such as Python to build application software. Finally, don’t be put off
by the publication date of these resources! Many resources are timeless.
C++
The following books need to be on your shelf. Lippman will get you started, but
you’ll also need Deitel and Deitel and Olshevsky and Ponomarev for nuance.

1. C++ Primer (Lippman 1991).


This book is the most basic resource for this area. While very complete, it has
shortcomings; for example, it’s discussion of call by reference is very unclear
and its treatment of dynamic binding in its chapters on OOD is also murky.
Nevertheless, it is a good basic introduction. It’s biggest problem for us is that all
of its examples are so simple (yes, even the zoo class is just too simple to give us
much insight)
2. C++ : How to Program (Deitel and Deitel 1994).
We have found this book to be of great value. It intermingles excellent C++
coverage with ongoing object oriented design (OOD) material. It is full of practical
advice on software engineering aspects of OOD design.
3. The Revolutionary Guide to OOP Using C++ (Olshevsky and Ponomarev 1994).
This book has a wonderful discussion of call by reference and equally good
material on dynamic binding.
4. Compiler Design (Wilhem and Maurer 1995).
This book has already been mentioned in the text as the source of technical
information on how an object-oriented compiler is built. This is an essential
resource.

Object Oriented Programming and Design

1. Object-Oriented Analysis and Design with Applications (Booch 1994).


This is a classic reference to one method of handling large scale OOD. As the
494 14 Background Reading

number of objects in your design grows there is a combinatorial explosion in


the number of interaction pathways. The Booch method gives a popular software
engineering tool. This is best to read on a surface level, for impressions and ideas.
2. Designing Object-Oriented C++ Applications Using the Booch Method (Martin
1995).
If you decide to use the Booch method, this book is full of practical advice. It has
many code examples, but it has a very heavy reliance on templates. This is a C++
language feature we have been avoiding because it complicates the architectural
details. Hence, the translation of Martin’s code fragments into useful insight is
sometimes difficult, but nonetheless, there is much meat here.
3. Design Patterns for Object-Oriented Software Development (Pree 1995).
The design of classes and objects is very much an art form. To some extent, like
all crafts, you learn by doing. As you get more skilled, you realize how little of the
real knowledge of how to write good classes is written down! This book is full of
hard won real-world wisdom that comes out of actually being in the programming
trenches. It is best to surface read and sample.
4. Taming C++ : Pattern Classes and Persistence for Large Projects (Soukup 1994).
We have similar comments for this book. Since our proposed neural objects OOD
project will be a rather massive undertaking, useful insight into the large scale
OOD is most welcome!
5. Design Patterns: Elements of Reusable Object-Oriented Software (Gamma et al.
1995).
As you program, you realize that many classes are essential building blocks of
many disparate applications. This wonderful book brings together a large num-
ber of already worked out OOD solutions to common problems. It is extremely
important to look at this book carefully. All of the different classes are presented
in code sketches (not easy to follow, but well worth the effort!).
Neural Simulation Software: To model these things, we can use
1. the Genesis modeling language as discussed in The Book of Genesis: Exploring
Realistic Neural Models with the GEneral NEural SImulation System, by
Bower and Beeman (1998)
2. home grown code written in C++
3. home grown code written in MatLab.

References

J. Austyn, K. Wood, Principles of Cellular and Molecular Immunology (Oxford University Press,
Oxford, 1993)
G. Booch, Object-Oriented Analysis and Design with Applications, 2nd edn. (Benjamin/Cummings
Publishing Company Inc, Redwood City, 1994)
J. Bower, D. Beeman, The Book of Genesis: Exploring Realistic Neural Models with the GEneral
NEural SImulation System, 2nd edn. (Springer TELOS, New York, 1998)
H. Deitel, P. Deitel, C ++ : How to Program (Prentice Hal, Upper Saddle River, 1994)
References 495

Y. Dudai, The Neurobiology of Memory: Concepts, Findings, Trends (Oxford University Press,
Oxford, 1989)
R. Eckert, D. Randall, G. Augustine, Animal Physiology: Mechanisms and Adaptations, 3rd edn.
(W. H. freeman and Company, New York, 1998)
E. Gamma, R. Helm, R. Johnson, J. Vlissides, Design Patterns: Elements of Reusable Object -
Oriented Software (Addison - Wesley Publishing Company, Reading, 1995)
J. Gerhart, M. Kirschner, Cells, Embryos and Evolution: Towards a Cellular and Developmen-
tal Understanding of Phenotypic Variation and Evolutionary Adaptability (Blackwell Science,
Oxford, 1997a)
J. Gerhart, M. Kirschner, Regulatory linkage, Cells, Embryos, and Evolution: Towards a Cellu-
lar and Developmental Understanding of Phenotypic Variation and Evolutionary Adaptability
(Blackwell Science, Oxford, 1997b), pp. 90–145
J. Gerhart, M. Kirschner, Conditionality and compartmentalization, Cells, Embryos, and Evolution:
Towards a Cellular and Developmental Understanding of Phenotypic Variation and Evolutionary
Adaptability (Blackwell Science, Oxford, 1997c), pp. 238–295
M. Hadley, Endocrinology (Prentice Hall, Upper Saddle River, 1996)
Z. Hall, An Introduction to Molecular Neurobiology (Sinauer Associates Inc., Sunderland, 1992)
B. Hille, Ionic Channels of Excitable Membranes (Sinauer Associates Inc, Sunderland, 1992a)
B. Hille, Classical biophysics of the squid giant axon, Ionic Channels of Excitable Membranes
(Sinauer Associates Inc, Sunderland, 1992b), pp. 23–58
D. Johnston, S. Miao-Sin Wu, Foundations of Cellular Neurophysiology (MIT Press, Cambridge,
1995a)
D. Johnston, S. Miao-Sin Wu, Hodgkin and Huxley’s Analysis of the Squid Giant Axon, Foundations
of Cellular Neurophysiology (MIT Press, Cambridge, 1995b), pp. 143–182
P. Katz (ed.), Beyond Neurotransmission: Neuromodulation and its Importance for Information
Processing (Oxford University Press, Oxford, 1999)
S. Lippman, C ++ Primer, 2nd edn. (Addison–Wesley Publishing Company, Reading, 1991)
R. Martin, Designing Object – Oriented C ++ Applications Using the Booch Method (Prentice Hall,
Upper Saddle River, 1995)
V. Olshevsky, A. Ponomarev, The Revolutionary Guide to OOP Using C ++ (WROX Publishers,
Birmingham, 1994)
W. Pree, Design Patterns for Object-Oriented Software Development, ACM Press Books (Addison-
Wesley Publishing Company, Reading, 1995)
R. Raff, T. Kaufman, Embryos, Genes, and Evolution (Macmillan Publishing Co., Inc, New York,
1983)
R. Raff, The Shape of Life: Genes, Development, and the Evolution of the Animal Form (The
University of Chicago Press, Chicago, 1996)
J. Soukup, Taming C ++ : Pattern Classes and Persistence for Large Projects (Addison–Wesley
Publishing Company, Reading, 1994)
S. Stahl, Essential Psychopharmacology: Neuroscientific Basis and Practical Applications, 2nd
edn. (Cambridge University Press, Cambridge, 2000)
T. Stone, Neuropharmacology (W. H. Freeman, Oxford, 1995)
T. Weiss, Cellular Biophysics: Transport, vol. 1 (MIT Press, Cambridge, 1996a)
T. Weiss, Cellular Biophysics: Electrical Properties, vol. 2 (MIT Press, Cambridge, 1996b)
T. Weiss, The Hodgkin - Huxley model, Cellular Biophysics: Electrical Properties, vol. 2 (MIT
Press, Cambridge, 1996c), pp. 163–292
R. Wilhem, D. Maurer, Compiler Design (Addison-Wesley Publishing Company, Reading, 1995)
W. Yamada, C. Koch, P. Adams, Multiple channels and calcium dynamics, in Methods of Neuronal
Modeling, ed. by C. Koch, I. Segev (MIT Press, Cambridge, 1987), pp. 97–134
Glossary

Amino acid An α amino acid consists of the following things: an amide group
NH2 , a carbonyl group COOH, a hydrogen atom H and a distinctive residue R.
These groups are all attached to a central carbon atom which is called the α
carbon. There are many common residues. An amino acid occurs in two different
3D forms. To keep it simple, look at this simple representation

R + y axis

H ← Cα → NH2 + x axis

COOH

The R, H, NH2 and COOH are in the xy plane and the Cα carbon is along the
positive z axis above the side groups. The NH2 is on the positive x axis and the R
is on the positive y axis. This is the L form as if you take your right hand, line
up the fingers along the NH2 line and rotate your fingers left towards the residue
R. Note your thumb points out of the page towards the positive z axis location of
Cα . Also, it is easy to visualize by just imaging grabbing the Cα and pulling it up
out of the page that the other groups lie in. The other form is called the R form
and looks like this:

H

COOH ← Cα → NH2 + x axis

R − y axis

The R, NH2 , H and COOH are in the xy plane and the Cα carbon is along the
negative z axis below the side groups. Here the NH2 is on the positive x axis but
the R is on the negative y axis. This is the R form as if you take your right hand,
line up the fingers along the NH2 line and rotate your fingers right towards the

© Springer Science+Business Media Singapore 2016 497


J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9
498 Glossary

residue R. Hence, we pull the Cα down below the page determined by the other
groups here. Now there are a total of twenty amino acids which we show below
in a table, p. 72.

Amino acid Abbreviation Amino acid Abbreviation


Glycine G, Gly Methionine M, Met
Alanine A, Ala Serine S, Ser
Valine V, Val Lysine K, Lys
Leucine L, Leu Threonine T, Thr
Isoleucine I, Ile Arginine R, Arg
Proline P, Pro Histidine H, His
Phenylalanine F, Phe Aspartate D, Asp
Tyrosine Y, Tyr Glutamate E, Glu
Tryptophan W, Trp Asparagine N, Asn
Cysteine C, Cys Glutamine G, Gln

Ball stick The salient features of the ball stick model are

• Axonal and dendritic fibers are modeled as two concentric membrane cylinders.
• The axon carries action potentials which propagate without change along the
fiber once they are generated. Thus if an axon makes 100 synaptic contacts, we
assume that the depolarizations of each presynaptic membrane are the same.
• Each synaptic contact on the dendritic tree generates a time and space localized
depolarization of the postsynaptic membrane which is attenuated in space as
the pulse travels along the fiber from the injection site and which decrease in
magnitude the longer the time is since the pulse was generated.
• The effect of a synaptic contact is very dependent on the position along the
dendritic fiber that the contact is made–in particular, how far was the contact
from the axon hillock (i.e., in our model, how far from the soma)? Contacts made
in essentially the same space locality have a high probability of reinforcing each
other and thereby possibly generating a depolarization high enough to trigger
an action potential.
• The effect of a synaptic contact is very dependent on the time at which the
contact is made. Contacts made in essentially the same time frame have a high
probability of reinforcing each other and thereby possibly generating a depo-
larization high enough to trigger an action potential.

We extend the simple dendritic cable model to what is called the ball and stick
neuron model by using isopotential sphere to model the soma and coupling it to a
single dendritic fiber input line. We model the soma as a simple parallel resistance/-
capacitance network and the dendrite as a finite length cable. In Fig. 11.2, you see
the terms I0 , the input current at the soma/dendrite junction starting at τ = 0; ID ,
the portion of the input current that enters the dendrite (effectively determined by
Glossary 499

the input conductance to the finite cable, GD ); IS , the portion of the input current
that enters the soma (effectively determined by the soma conductance GS ); and CS ,
the soma membrane capacitance. We assume that the electrical properties of the
soma and dendrite membrane are the same; this implies that the fundamental time
and space constants of the soma and dendrite are given by the same constant (we
will use our standard notation τM and λC as usual). It is possible to show that with
a reasonable zero-rate left end cap condition the appropriate boundary condition
at λ = 0 is given by
 
∂ v̂m ∂ v̂m
ρ (0, τ ) = tanh(L) v̂m (0, τ ) + (0, τ ) ,
∂λ ∂τ

where we introduce the fundamental ratio ρ = GGDS , the ratio of the dendritic
conductance to soma conductance. The full system to solve is therefore:

∂ 2 v̂m ∂ v̂m
= v̂m + , 0 ≤ λ ≤ L, τ ≥ 0.
∂λ 2 ∂τ
∂ v̂m
(L, τ ) = 0,
∂λ  
∂ v̂m ∂ v̂m
ρ (0, τ ) = tanh(L) v̂m (0, τ ) + (0, τ ) .
∂λ ∂τ

which we solve using separation of variables, p. 362.

Cable model There are many variables are needed to describe what is happening
inside and outside the membrane for a standard cable model. These variables
include
Variable Meaning Units
Vm Membrane potential mV
Km Membrane current per length nA/cm
Ke Externally applied current nA/cm
Ii Inner current nA
Io Outer current nA
Ie External current nA
Im Membrane current nA
Vi Inner voltage mV
Vo Outer voltage mV
ri Resistance inner fluid per length µohms/cm
ro Resistance outer fluid per length µohms/cm
gm Membrane conductance per length µSiemens/cm
cm Membrane capacitance per length nano Fahrads/cm
GM Membrane conductance µSiemens/cm
CM Membrane capacitance nano Fahrads/cm
500 Glossary

The variables needed to describe what is happening inside and outside the cellular
membrane and to some extent, inside the membrane are then
• Vm0 is the rest value of the membrane potential.
• Km0 is the rest value of the membrane current per length density.
• Ke0 is the rest value of the externally applied current per length density.
• Ii0 is the rest value of the inner current.
• Io0 is the rest value of the outer current.
• Vi0 is the rest value of the inner voltage.
• Vo0 is the rest value of the outer voltage.
• ri is the resistance of the inner fluid of the cable.
• ro is the resistance of the outer fluid surrounding the cable.
• gm is the membrane conductance per unit length.
• cm is the membrane capacitance per unit length.
The membrane voltage can be shown to satisfy the first order partial differential
equations

∂Ii
= −Km (z, t)
∂z
∂Io
= Km (z, t) − Ke (z, t)
∂z
∂Vi
= −ri Ii (z, t)
∂z
∂Vo
= −ro Io (z, t)
∂z
Vm = Vi − V0

which we can then use to derive the standard second order partial differential
equation

∂ 2 Vm
= (ri + ro )Km − ro Ke
∂z2

This equation can be solved in many ways. First, we can look at cables that are
infinitely long or finitely long assuming there is no dependence on time. Then,
we can add time as a variable which forces us to use new tools for finding the
solution. The cable equation, time dependent or independent, provides a model
for the input side of a neuron. It is part of a full neuron model called the ball stick
model, p. 149.
Complimentary nucleotides the purine and pyrimidine nucleotides can bond
together in the following ways: A to T or T to A and C to G or G to C. We say that
adenine and thymine and cytosine and guanine are complementary nucleotides.
This bonding occurs because hydrogen bonds can form between the adjacent nitro-
gen or between adjacent nitrogen and oxygen atoms. For example, look at the T –A
Glossary 501

bond in Fig. 4.40. Note the bases are inside and the sugars outside. Finally, note
how the bonding is done for the cytosine and guanine components in Fig. 4.41.
Now as we have said, nucleotides can link into a long chain via the phosphate
bond. Each base in this chain is attracted to a complimentary base. It is energeti-
cally favorable for two chains to form: chain one and its complement chain 2. Each
pair of complimentary nucleotides is called a complimentary base pair. The forces
that act on the residues of the nucleotides and between the nucleotides themselves
coupled with the rigid nature of the peptide bond between two nucleotides induce
the two chains to form a double helix structure under cellular conditions which
in cross-section (see Fig. 4.42) has the bases inside and the sugars outside. The
double helix is called DNA when deoxy-ribose sugars are used on the nucleotides
in our alphabet. The name DNA stands for deoxy-ribose nucleic acid. A chain
structure closely related to DNA is what is called RNA, where the R refers to the
fact that oxy-ribose sugars or simply ribose sugars are used on the nucleotides
in the alphabet used to build RNA. In RNA, thymine is replaced by Uracil. The
RNA alphabet is slightly different as the nucleotide Thymine, T, in the DNA
alphabet is replaced by the similar nucleotide Uracil, U. The chemical structure
of uracil is shown in Fig. 4.44 right next to the formula for thymine. Note that
the only difference is that carbon 5 C  holds a methyl group in thymine and just a
hydrogen in uracil. Despite these differences, uracil will still bond to adenine via
a complimentary bond, p. 91.

Einstein’s Relation There is a relation between the diffusion coefficient D and


the mobility μ of an ion which is called Einstein’s Relation. It says

κT
D= μ
q

where

• κ is Boltzmann’s constant which is 1.38 × 10−23 joule


◦K .

• T is the temperature in degrees Kelvin.


• q is the charge of the ion c which has units of coulombs.

Further, we see that Einstein’s Law says that diffusion and drift processes are
additive because Ohm’s Law of Drift says Jdrift is proportional to μ which by
Einstein’s Law is proportional to D and hence Jdiff , p. 101.
Excitable cell There are specialized cells in most living creatures called neurons
which are adapted for generating signals which are used for the transmission
of sensory data, control of movement and cognition through mechanisms we
don’t fully understand. A neuron has a membrane studded with many voltage
502 Glossary

gated sodium and potassium channels. In terms of ionic permeabilities, the GHK
voltage equation for the usual sodium, potassium and chlorine ions gives
 
PK [K + ]out + PNa [Na+ ]out + PCl [Cl]in
V0m = 25.32 (mV ) ln
PK [K + ]in + PNa [Na+ ]in + PCl [Cl− ]out

which is about −60 mV at rest but which can rapidly increase to +40 mV upon a
large shift in the sodium and potassium permeability ratio. We can also write the
rest voltage in terms of conductances as
gK gNa gCl
V0m = EK + ENa + ECl
gK + gNa + gCl gK + gNa + gCl gK + gNa + gCl

Either the conductance or the permeability model allows us to understand there


is a sudden increase in voltage across the membrane in terms of either sodium to
potassium permeability or conductance ratio shifts. Given the right inputs into the
neuron, the potential across the membrane suddenly rises and is then followed by
a sudden drop below the equilibrium voltage and then ended by a slow increase
back up to the rest potential. The shape of this wave form is very characteristic
and is shown in Fig. 5.10. This type of wave form is called an action potential and
is a fundamental characteristic of excitable cells. It occurs because the sodium
and potassium ions move through the cell in voltage dependent gates, p. 142.

Ficke’s Law of Diffusion is an empirical law which says the rate of change of the
concentration of molecule b is proportional to the diffusion flux and is written in
mathematical form as follows:
∂ [b]
Jdiff = −D
∂x
where

• Jdiff is diffusion flux which has units of molecules


cm2 −second
.
cm2
• D is the diffusion coefficient which has units of second .
• [b] is the concentration of molecule b which has units of molecules
cm3
.

The minus sign implies that flow is from high to low concentration; hence diffusion
takes place down the concentration gradient. Note that D is the proportionality
constant in this law, p. 100.

Fourier Series A general trigonometric series S(x) has the following form
Glossary 503

∞     
iπ iπ
S(x) = b0 + an sin x + bn cos x
i=1
L L

for any numbers an and bn . Of course, there is no guarantee that this series will
converge at any x! If we start with a function f which is continuous on the interval
[0, L], we can define the trigonometric series associated with f as follows

1
S(x) = < f,1 >
L
∞           
2 iπ iπ 2 iπ iπ
+ f (x), sin x sin x + f (x), cos x cos x .
L L L L L L
i=1

This series is called the Fourier Series for f and the coefficients in the Fourier
series for f are called the Fourier coefficients of f . Since these coefficients are
based on inner products with the normalized sin and cos functions, they are called
normalized Fourier coefficients. The nth Fourier sin coefficient, n ≥ 1, of f is as
follows:
 
2 L iπ
an (f ) = f (x) sin x dx
L 0 L

The nth Fourier cos coefficient, n ≥ 0, of f are defined similarly, p. 243:


L
1
b0 (f ) = f (x) dx
L 0
L  
2 iπ
bn (f ) = f (x) cos x dx, n ≥ 1.
L 0 L

Goldman–Hodgkin–Huxley The GHK model is based on several assumptions


about how the substance c behaves in the membrane:

1. [cm ] varies linearly across the membrane as discussed in the previous subsec-
tion.
2. The electric field in the membrane is constant.
3. The Nernst–Planck equation holds inside the membrane.

After much work and some approximations, we obtain another current equation
zFVcm
z2 PF 2 Vcm [c]in − [c]out e− RT
I0m = zFVcm
RT 1 − e− RT
504 Glossary

where P is the permeability of the ion which is a measure of how ions flow across
the membrane. In an equilibrium situation, this current is zero and we obtain the
GHK voltage equation. If the cell is permeable to say sodium, potassium and
chlorine, we find the GHK currents must sum to zero:

IK + INa + ICl = 0

Further, the associated Nernst potentials for the ions should all match because
otherwise there would be current flow:

V0m = VKm+ = VNa+ = VCl


m

where we denote this common potential by V0m . After manipulation, we have


 
RT PK [K + ]out + PNa [Na+ ]out + PCl [Cl]in
V0m = ln
F PK [K + ]in + PNa [Na+ ]in + PCl [Cl − ]out

where to actually compute the GHK voltage, we would need the three ion perme-
abilities, p. 132.

Graham–Schmidt Orthogonalization Graham–Schmidt orthogonalization is a


tool for taking linearly independent objects and using them to construct a new
set of linearly independent objects that are mutually orthogonal. This, of course,
requires that the objects are from a vector space with an inner product, p. 13.

Hodgkin–Huxley gates Hodgkin and Huxley modeled the sodium and potassium
gates as

gNa (V ) = gNa
Max
MNA 3 (V ) HNA (V )
gK (V ) = gKMax MK 4 (V )

where the two activation variables, MNA and MK , and the one inactivation vari-
able, HNA , all satisfy the first order kinetics

τMNA MNA (t) = (MNA )∞ − MNA

τHNA HNA (t) = (HNA )∞ − HNA
τMK MK (t) = (MK )∞ − MK
Glossary 505

with
1
τMNA =
αMNA + βMNA
αMNA
(MNA )∞ =
αMNA + βMNA
1
τHNA =
αHNA + βHNA
αHNA
(HNA )∞ =
αHNA + βHNA
1
τMK =
αMK + βMK
αMK
(MK )∞ =
αMK + βMK

Further, the coefficient functions, α and β for each variable required data fits as
functions of voltage. These were determined to be

V + 35.0
αMNA = −0.10
e−0.1 (V +35.0) − 1.0
−(V +60.0)
βMNA = 4.0 e 18.0

αHNA = 0.07 e−0.05 (V +60.0)


1.0
βHNA = −0.1 (V +30.0) )
(1.0 + e
0.01 ∗ (V + 50.0)
αMK = − −0.1(V +50.0)
(e − 1.0)
βMK = 0.125 e−0.0125 (V +60.0)

Of course these data fits were obtained at a certain temperature. The model of the
membrane dynamics thus consists of the following differential equations:

dMNA
τMNA = (MNA )∞ − MNA
dt
dHNA
τHNA = (HNA )∞ − HNA
dt
dMK
τMK = (MK )∞ − MK
dt
dV IM − IK − INa − IL
=
dt CM

where the leakage current IL is handled more simply by choosing a leakage con-
ductance and leakage voltage that is relevant to the simulation. The model has the
initial conditions
506 Glossary

MNA (0) = (MNA )∞ (V0 , 0)


HNA (0) = (HNA )∞ (V0 , 0)
MK (0) = (MK )∞ (V0 , 0)
V (0) = V0

We note that at equilibrium there is no current across the membrane. Hence,


the sodium and potassium currents are zero and the activation and inactivation
variables should achieve their steady state values which would be m∞ , h∞ and
n∞ computed at the equilibrium membrane potential which is here denoted by
V0 , p. 410.
Hodgkin–Huxley model The standard Hodgkin–Huxley model of an excitatory
neuron consists of the equation for the total membrane current, KM , obtained from
Ohm’s law
∂Vm
Km = cm + KK + KNa + KL ,
∂t
where we have expanded the Kion term to include the contributions from the
sodium and potassium currents and the leakage current. The new equation for the
membrane voltage is thus

∂ 2 Vm
= (ri + ro )Km − ro Ke
∂z2
∂Vm
= (ri + ro ) cm + (ri + ro ) KK + (ri + ro ) KNa + (ri + ro ) KL − ro Ke
∂t

which can be simplified to

1 ∂ 2 Vm ro
= Km − Ke
ri + ro ∂z2 ri + ro
∂Vm ro
= cm + KK + KNa + KL − Ke
∂t ri + ro

where the ion current terms are modeled using Hodgkin and Huxley’s model of
the voltage dependent gates, p. 405.
Hydrocarbons Hydrocarbons are molecules made up of strings of carbons. Since
each carbon can make four bonds, these strings can be quite complex. Any of
the four binding sites of a carbon can be filled with an arbitrarily large complex
which we often called a residue and these in turn can have other residues bound
to them. Hence, a hydrocarbon chain could be linear if there are no side chains
or bushy if the chain has multiple side chains due to the attached residues. Also,
five carbons can combine together into a cyclical structure called a ring which is a
potent molecular component that occurs in many biologically reactive molecular
assemblies, p. 71.
Glossary 507

Hydrogen bonds these occur when a hydrogen atom is shared between two other
atoms: The atom to which the hydrogen is held more tightly is called the hydro-
gen donor and the other one which is less tightly linked is called the hydrogen
acceptor, p. 65.

Infinite series The simplest one is a series of positive terms which we write as

n=1 an where each an is a positive number. If we add up a finite number at
a time starting from the beginning, we get a sequence of what are called partial
sums of the form SN = Nn=1 an , We say the series converges if this sequence
of partial sums converges and as usual, this need not be true. The sequence of
partial sums could blow up to infinity if we sum terms that do not decay very
fast. For example, the series ∞ n=1 1 has partial sums SN = N which go off to
infinity as we add more terms in. We can show other series such as ∞ 1
n=1 n also
add up to infinity although that is a bit harder. The point is that just having the nth
term an go to zero is not enough to insure the series adds up to a finite number.
In this simple case, we are always adding positive numbers, so the partial sums
are always increasing. But if the terms an can have different algebraic signs, the
behavior of these partial sums can get quite complicated. To study this behavior
properly naturally enough requires a lot of mathematical analysis which we only
do some of in the text. So you should feel free to read more! A general series
is then of the form ∞ n=1 an where the an ’s can have differing algebraic signs.
We can make it even more general, by looking at series of functions such as

n=1 fn (x). The idea of partial sums is still the same but we have to think about
whether or not the series sums to a finite number (we say the series converges) at
each x in the domain of our functions. This gets more difficult fast and requires
more intellectual effort to master. When the series contains functions like fn (x),
there a many new types of convergence to consider such as convergence at a
given value of x but not necessarily at another value of x. This is called pointwise
convergence. Convergence ideas on an entire interval such as [0, 1] of possible x
values are called uniform convergence notions and they imply the pointwise ideas
but the implication does not go the other way. Finally, there is an idea called L2
convergence which is also different from those. There are many details in Chap. 9
you should study, p. 235.

Linear partial differential equation These are models where the variable u sat-
isfies an equation involving the function u, its partial derivatives, second order
partial derivatives and so forth. The relationship between these terms can be very
508 Glossary

nonlinear but here we will just mention a few common linear PDE which we
discuss in Chap. 10.
The Wave Equation: We seek functions (x, t) so that

∂2 2∂ 
2
− c = 0
∂t 2 ∂x 2
(x, 0) = f (x), for 0 ≤ x ≤ L
∂
(x, 0) = g(x), for 0 ≤ x ≤ L
∂t
(0, t) = 0, for 0 ≤ t
(L, t) = 0, for 0 ≤ t

for some positive constant c. The solution of this equation approximates the motion
of a nice string with no external forces applied. The domain here is the infinite
rectangle [0, L] × [0, ∞).
Laplace’s Equation: The solution (x, y) of this equation is a time independent
solution to a problem such as the distribution of heat on a membrane stretch over
the domain given that various heat sources are applied to the boundary. Here, the
domain is the finite square [0, L]×[0, L]. In the problem below, three of the edges
of the square are clamped to 0 and the remaining one must follow the heat profile
given by the function f (x).

∂2 ∂2
+ =0
∂x 2 ∂y2
∂
(0, y) = 0, for 0 ≤ y ≤ L
∂x
∂
(L, y) = 0, for 0 ≤ y ≤ L
∂x
(x, L) = 0, for 0 ≤ x ≤ L
(x, 0) = f (x), for 0 ≤ x ≤ L

The Heat/Diffusion Equation: The solution of this equation, (x, t), is the time
dependent value of heat or temperature of a one dimensional bar which is having
a heat source applied to it initially. It can also model a substance moving through
a domain using diffusion with diffusion constant D as discussed in Chap. 5. The
domain is again half infinite: [0, L] × [0, ∞).

∂ ∂2
− D =0
∂t ∂x 2
(0, t) = 0, for 0 < t
(L, t) = 0, for 0 < t
(x, 0) = f (x), for 0 < x < L
Glossary 509

This equation is very relevant to our needs. Indeed, in Peterson (2015), we derive
this equation using a random walk model and learn how to interpret the diffusion
constant D in terms of the space constant λC and the time constant τM . However,
we will not discuss that here.
The Cable Equation: The solution (x, t) of this equation for us is usually the
membrane voltage in a dendrite model for an excitable neuron. Here the domain
is the infinite rectangle [0, L] × [0, ∞) where the space variable represents the
position on the cable. In the problem below, fluxes in the spatial direction at the
endcaps of the fiber are zero and there is an imposed voltage input function over
the entire cable when time is zero, p. 309.

∂2 ∂
β2 −  − α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
(x, 0) = f (x).

Molecular bond Molecular bonds between molecules generally involve an attrac-


tion between the negative charge on one molecule and the positive charge on
another. There are many types of these bonds; for example, hydrogen bonds,
disulfide bonds, Vanderwaals bonds and covalent bonds. A nice high level look
at this process is to think of a given atom like carbon as having some electrons
available for sharing. If carbon could add 4 electrons, it would have all of its
higher locations for electron populations be completely filled which is a preferred
energy state. So carbon finds other atoms it can share an electron with. A simple
example is methyl CH4 where each of the 4 hydrogens shares an electron with
carbon. Another example is CO2 where each of the two oxygens share 2 electrons
with the carbon. Sharing 2 electrons gives what is called a double bond, p. 65.

Nernst The current form of the Nernst–Planck equation given in Eq. 5.10 describes
ionic current flow driven by electro-chemical potentials (concentration gradients
and electric fields). When the net current due to all of these contributions is zero,
we have I = 0 and after suitable manipulations, we can derive the Nernst equation
in terms of the inner and outer concentration of the ion c.
510 Glossary

RT [c]out
Ec = ln
zF [c]in

If we have more than one ion, say sodium, potassium and chlorine, at equilibrium,
the currents would sum to zero and we would find
gK gNa gCl
Vm = EK + ENa + ECl
gK + gNa + gCl gK + gNa + gCl gK + gNa + gCl

where the terms gK and so forth are the conductances of the ions, p. 106.
Nernst Planck Under physiological conditions, ion movement across the mem-
brane is influenced by both electric fields and concentration gradients. Let J denote
the total flux, then we will assume that we can add linearly the diffusion due to
the molecule c and the drift due to the ion c giving

J = Jdrift + Jdiff

Thus, applying Ohm’s Law 5.3 and Ficke’s Law 5.1, we have

∂V ∂[c]
J = −μ z [c] − D
∂x ∂x
Next, we use Einstein’s Relation 5.4 to replace the diffusion constant D to obtain
what is called the Nernst–Planck Equation

∂V κT ∂[c]
J = −μ z [c] − μ
∂x q ∂x
 
∂V κT ∂[c]
= −μ z [c] +
∂x q ∂x

We can rewrite this result by moving to units that are cm2moles


−second
and using a
known relationship between charge and moles given by Faraday’s Constant F. In
addition, we can convert between joules and calories using the gas constant R.
We obtain a current equation
 
J μ ∂V ∂[c]
I= zF = − z F [c]
2
+ z RT
NA NA ∂x ∂x

where the symbol I denotes this current density amps cm2


that we obtain with this
equation. The current I is the ion current that flows across the membrane per unit
area due to the forces acting on the ion c, p. 103.
Nucleic acids Two important sugars are formed from cyclic hydrocarbons and are
called furans and pyrans. A pyran’s schematic is shown in Fig. 4.30b and the
furan’s in Fig. 4.30d. All the carbons in these ring structures are labeled and the
3D geometry of these sugars is important. A three dimensional version of the
Glossary 511

furan molecule is the 2 C  endo form shown in Fig. 4.31b. Here, 2 C  and 5 C  are
out of the plane formed by O–1 C  –3 C  –4 C  . Another version is the one where 3 C 
and 5 C  are out of the plane formed by O–1 C  –2 C  –4 C  which is called the 3 C 
endo form. DNA uses the 2 C  endo and RNA, the 3 C  endo form. The particular
sugar of interest is ribose which comes in an oxygenated and non oxygenated
form; ribose (Fig. 4.32a) and deoxyribose (Fig. 4.32b), respectively. There are
also four special nitrogenous bases which are important. They come in two flavors:
purines and pyrimidines. The purines have the form shown in Fig. 4.33a while
the pyrimidines have the one shown in Fig. 4.33b. There are two purines and two
pyrimidines we need to know about: the purines adenine (A) and guanine (G)
and the pyrimidines thymine (T) and cytosine (C). Figure 4.34a (Adenine is a
purine with an attached amide on 6 C  ), 4.34b (Guanine is a purine with an attached
oxygen on 6 C  ), 4.34d (Cytosine is a pyrimidine with an attached amide on 4 C  ),
and 4.34c (Thymine is a pyrimidine with an attached oxygen on 4 C  ). These four
nitrogenous bases can bond to the ribose or deoxyribose sugars to create what are
called nucleotides. In general, a sugar plus a purine or pyrimidine nitrogenous
base give us a nucleoside. If we add phosphate to the 5 C  of the sugar, we get
a new molecule called a nucleotide. This level of detail is far more complicated
and messy than we typically wish to show; hence, we generally draw this in the
compact form shown in Fig. 4.37. There, we have replaced the base with a simple
shaded box and simply labeled the primed carbons with the numerical ranking.
In Fig. 4.38 we show how nucleotides can link up into chains: bond the 5 C  of
the ribose on one nucleotide to the 3 C  of the ribose on another nucleotide with
a phosphate or PO3− bridge. Symbolically this looks like Fig. 4.38. This chain of
three nucleotides has a terminal OH on the 5 C  of the top sugar and a terminal OH
on the 3 C  of the bottom sugar. We often write this even more abstractly as shown
in Fig. 4.39 or just OH− Base 3 P Base 2 P Base 1 P −OH, where the P denotes a
phosphate bridge. For example, for a chain with bases adenine, adenine, cytosine
and guanine, we would write OH–A–p–A–p–C–p–G–OH or OHApApCpGOH.
Even this is cumbersome, so we will leave out the common phosphate bridges
and terminal hydroxyl groups and simply write AACG. It is thus understood the
left end is an OH terminated 5 C  and the right end an hydroxyl terminated 3 C  ,
p. 85.

Ohm’s Law of Drift relates the electrical field due to an charged molecule, i.e. an
ion, c, across a membrane to the drift of the ion across the membrane where drift is
the amount of ions that moves across the membrane per unit area. In mathematical
form

Jdrift = − ∂el E
512 Glossary

where

• Jdrift is the drift of the ion which has units of cmmolecules


2 −second .

• ∂el is electrical conductivity which has units of volt−cm−second


molecules
.

From basic physics, we know an electrical field is the negative gradient of the
potential so if V is the potential across the membrane and x is the variable that
measures our position on the membrane, we have

∂V
E=−
∂x
Let the valence of the ion c be denoted by z. It is possible to show

∂el = μ z [c]

where dimensional analysis shows us that the proportionality constant μ, called


cm2
the mobility of ion c, has units volt−second . Hence, we can rewrite Ohm’s Law of
Drift as, p. 100.

∂V
Jdrift = −μz[c]
∂x

Peptide bond Amino acids can link up in chains because the COOH on one can
bond with the NH2 on another. The two amino acids that pair are connected by a
rigid planar bond. There is a Cα1 atom from amino acid one and another Cα2 from
amino acid two attached to this bond. The COOH and NH2 bond looks like this
in block diagram form. The COOH loses an OH and the NH2 loses an H to form
the bond. Think of bond as forming a rigid piece of cardboard and attached on
the left is the amino acid built around Cα1 and attached on the right is the amino
acid build around Cα2 .

O (+y local axis)



Cα1 →← C → N(+x local axis) →← Cα2

H

Now think of Cα1 as attached to a pencil which is plugged into the side of the
peptide bond. The Cα1 to CO bond is an axis that amino acid one is free to rotate
about. Call this angle of rotation 1 . We can do the same thing for the other side
and talk about a rotation angle 2 for the NH to Cα2 bond. In Fig. 4.21, R1 is the
residue or side chain for the first amino acid and R2 is the side chain for the other.
Glossary 513

Note amino acid one starts with an N2 H group on the left and amino acid two
ends with a COOH group on the right

O (+y local axis)



Cα1 → 1 ← C → N(+x local axis) → 2 ← Cα2

H

The peptide bond allows amino acids to link into chains as we show in the next
block diagram, p. 80.

O (+y local axis)



N2 H ← Cα1 → 1 ← C → N(+x local axis) → 2 ← Cα2 → COOH

H

Protein transcription When a protein is built, certain biological machines are


used to find the appropriate place in the DNA double helix where a long string of
nucleotides which contains the information needed to build the protein is stored.
This long chain of nucleotides which encodes the information to build a protein
is called a gene. Biological machinery unzips the double helix at this special
point into two chains as shown in Fig. 4.45. A complimentary copy of a DNA
single strand fragment is made using complimentary pairing but this time adenine
pairs to uracil to create a fragment of RNA. This fragment of RNA serves to
transfer information encoded in the DNA fragment to other places in the cell
where the actual protein can be assembled. Hence, this RNA fragment is given
a special name—Messenger RNA or mRNA for short. This transfer process is
called transcription. For example, the DNA fragment 5 ACCGTTACCGT 3 has the
DNA complement 3 TGGCAATGGCA5 although in the cell, the complimentary
RNA fragment
3
UGGCAAUGGCA5

is produced instead. Note again that the 5 pairs with a 3 and vice versa. From what
we said earlier, there are 64 different triplets that can be made from the alphabet
{A, C, U, G} and it is this mapping that is used to assemble the protein chain a
little at a time. For each chain that is unzipped, a complimentary chain is attracted
to it in the fashion shown by Table 4.7. This complimentary chain will however be
built from the oxygenated deoxy-ribose or simply ribose nucleotides. Hence, this
complimentary chain is part of a complimentary RNA helix. As the amino acids
encoded by mRNA are built and exit from the ribosome into the fluid inside the
cell, the chain of amino acids or polypeptides begins to twist and curl into its three
dimensional shape based on all the forces acting on it. We can write this whole
process symbolically as DNA → mRNA → ribosome → Protein. This is known
as the Central Dogma of Molecular Biology. Hence to decode a particular gene
514 Glossary

stored in DNA which has been translated to its complimentary mRNA form all
we need to know are which triplets are associated with which amino acids. These
triplets are called DNA Codons. The DNA alphabet form of this mapping is given
in Table 4.8. For example, the DNA sequence,

TAC|TAT|GTG|CTT|ACC|TCG|ATT

is translated into the mRNA sequence

AUG|AUA|CAC|GAA|UGG|AGC|UAA

which corresponds to the amino acid string, p. 94.

Start|Isoleucine|Histidine|Glutamic Acid|Tryptophan|Serine|Stop

Runge–Kutta a method for the numerical solution of a system of differential


equations. The basic idea is to approximate the true solution using first order
linear approximations—i.e. tangent lines—constructed at various time and space
points based on the current time and space location. The details are in the text.
We typically use RK 4 which uses four such tangent line approximations to build
an estimate of the true solution which has local error proportional to h5 where
h is the step size. The global error is the error made in approximating the true
solution over the entire time domain of interest and it is proportional to h4 . RK4 is
a nice trade off between computation and accuracy. We use 4 dynamics function
evaluations at each time step but we gain h4 accuracy. Thus, in general we can
get by with a larger step size, p. 47.

Runge–Kutta–Fehlberg This method adds an additional tangent line approxima-


tion at each time step which we use to estimate how much error we have made
in approximating the true solution. As long as a true solution does exist, this is
a great tool as it helps us believe the numerical solution we are constructing is
indeed reasonable. We typically use RKF45 which is a base RK4 method with an
additional approximation step to estimate the global error in approximating the
true solution. Thus, the method is proportional to h5 globally. The fact that we
can estimate how much error we make in tracking the true solution means we can
decide if the current step size is too small or too large and use that information
to double or half the current step size. This allow us to start with a large step size
and the method will cut that size down to a good size so we do not make too much
error initially, p. 53.
Glossary 515

Separation of Variables Method A common PDE model is the general cable


model which is given below is fairly abstract form.

∂2 ∂
β2 −  − α = 0, for 0 ≤ x ≤ L, t ≥ 0,
∂x 2 ∂t
∂
(0, t) = 0,
∂x
∂
(L, t) = 0,
∂x
(x, 0) = f (x).

The domain is the usual half infinite [0, L] × [0, ∞) where the spatial part of the
domain corresponds to the length of the dendritic cable in an excitable nerve cell.
We won’t worry too much about the details of where this model comes from as
we will discuss that in another volume. The boundary conditions ux (0, t) = 0 and
ux (L, t) = 0 are called Neumann Boundary conditions. The conditions u(0, t) = 0
and u(L, t) = 0 are known as Dirichlet Boundary conditions. One way to find
the solution is to assume we can separate the variables so that we can write
(x, t) = u(x)w(t). We assume a solution of the form (x, t) = u(x) w(t) and
compute the needed partials. This leads to a the new equation

d2u dw
β2 w(t) − u(x)w(t) − αu(x) = 0.
dx 2 dt
Rewriting, we find for all x and t, we must have
 2 
2d u dw
w(t) β − u(x) = αu(x) .
dx 2 dt

This tells us
2
β 2 ddxu2 − u(x) α dw
= dt , 0 ≤ x ≤ L, t > 0.
u(x) w(t)

The only way this can be true is if both the left and right hand side are equal
to a constant that is usually called the separation constant . This leads to the
decoupled equations

dw
α =  w(t), t > 0,
dt
d2u
β 2 2 = (1 + ) u(x), 0 ≤ x ≤ L,
dx
516 Glossary

We also have boundary conditions.

du
(0) = 0
dx
du
(L) = 0.
dx
This gives us a second order ODE to solve in x and a first order ODE to solve in
t. We have a lot of discussion about this in the text which you should study. In
general, we find there is an infinite family of solutions that solve these coupled
ODE models which we can label un (x) and wn (t). Thus, any finite combination
n (x, t) = Nn=0 an un (x)wn (t) will solve these ODE models, but we are still left
with satisfying the last condition that (x, 0) = f (x). We do this by finding a
series solution. We can show that the data function f can be written as a series
f (x) = ∞ n=0 bn un (x) for a set of constants {b0 , b1 , . . .} and we can also show
that the series (x, t) = ∞ n=0 an un (x)wn (t) solves the last boundary condition
(x, 0) = ∞ a
n=0 n n u (x)w n (0) = f (x) as long as we choose an = bn for all n.
The idea of a series and the mathematical machinery associated with that takes a
while to explain, so Chap. 9 is devoted to that, p. 229.

Triplet code There are 20 amino acids and only 4 nucleotides. Hence, our alphabet
here is {A, C, T , G} The number of ways to take 3 things out of an alphabet of 4
things is 64. To see this, think of a given triplet as a set of three empty slots; there
are 4 ways to fill slot 1, 4 independent ways to fill slot 2 (we know have 4 × 4
ways to fill the first two slots) and finally, 4 independent ways to fill slot 3. This
gives a total of 4 × 4 × 4 or 64 ways to fill the three slots independently. Since
there are only 20 amino acids, it is clear that more than one nucleotide triplet
could be mapped to a given amino acid! In a similar way, there are 64 different
ways to form triplets from the RNA alphabet {A, C, U, G}. We tend to identify
these two sets of triplets and the associated mapping to amino acids as it is just a
matter of replacing the T in one set with an U to obtain the other set. The triplet
code is shown in Table 4.8, p. 93.

Voltage dependent gate A typical sodium channel as shown in Fig. 5.11 and it is
a typical voltage dependent gate. When you look at the drawing of the sodium
channel, you’ll see it is drawn in three parts. Our idealized channel has a hinged
cap which can cover the part of the gate that opens into the cell. We call this the
Glossary 517

inactivation gate. It also has a smaller flap inside the gate which can close off the
throat of the channel. This is called the activation gate. As you see in the drawing,
these two pieces can be in one of three positions: resting (activation gate is closed
and the inactivation gate is open); open (activation gate is open and the inactivation
gate is open); and closed (activation gate is closed or closed and the inactivation
gate is closed). Since this is a voltage activated gate, the transition from resting
to open depends on the voltage across the cell membrane. We typically use the
following terminology:

• When the voltage across the membrane is above the resting membrane voltage,
we say the cell is depolarized.
• When the voltage across the membrane is below the resting membrane voltage,
we say the cell is hyperpolarized.

These gates transition from resting to open when the membrane depolarizes. In
detail, the probability that the gate opens increases upon membrane depolarization.
However, the probability that the gate transitions from open to closed is NOT
voltage dependent. Hence, no matter what the membrane voltage, once a gate
opens, there is a fixed probability it will close again. Hence, an action potential can
be described as follows: when the cell membrane is sufficiently depolarized, there
is an explosive increase in the opening of the sodium gates which causes a huge
influx on sodium ions which produces a short lived rapid increase in the voltage
across the membrane followed by a rapid return to the rest voltage with a typical
overshoot phase which temporarily keeps the cell membrane hyperpolarized. The
opening of the potassium gates lags the sodium gates and as the sodium gates
begin to close, the influx of potassium ions is on the rise which brings the membrane
voltage down actually below equilibrium and as the potassium gates close, there
is the slow rise back up to equilibrium, p. 143.

Reference

J. Peterson, BioInformation Processing: A Primer On Computational Cognitive Science. Springer


Series on Cognitive Science and Technology (Springer Science+Business Media Singapore Pte
Ltd., Singapore, 2015, in press)
Index

A Th‘evenin conductance terms, 366


Advice on MatLab and Octave, 8 the Mb = D system to solve to
approximate the initial voltage, 379
the approximation to the initial volt-
B age leads to a linear system of equa-
Ball Stick Model tions, 376
the basic dendrite—soma—axon the ball stick model separation con-
approximation stant, 372
a review of action potential genera- the cable equations, 365
tion, 361 the cable time constant and space
a sample problem with Q = 5, 379 constant, 365
applying separation of variables to the core conductor equation, 365
the ball stick model, 372 the definition of ρ, the dendritic to
basic features of the model, 362 soma conductance ratio, 372
conductance variables, 366 the dendrite model, 363
defining the matrix M and the vectors the dendrite model variables, 364
B and D for the approximate initial the eigenvalues of the ball stick model
voltage solution, 377 are approximately orthogonal, 373
finite cable model review, 368 the family of functions cos(ωn λ) and
finite cable model Th‘evenin conduc- the scalars ωn are known as the
tances, 368 eigenfunctions and eigenvalues of
it is permissible to do a Fourier like the model u with zero boundary
expansion of the input voltage data conditions, 370
for the family of ball stick eigen- the family of functions cos(ωn λ) are
functions, 375 an orthonormal sequence, 370
modifying the Newton method for the the general solution of the ball stick
ball stick eigenvalue problem, 381 model, 373
resistivity, 366 the initial voltage is a pulse, 379
satisfying the boundary condition at the normalized dendritic voltage
L, 372 model, 369
satisfying the initial voltage condi- the transcendental equation for the
tion, 374 eigenvalues of the ball stick model,
satisfying the initial voltage condi- 373
tion approximately, 375 the transient variable approach, 365
separation of variables solution, 369 the zero-rate left end cap condition,
solving the MB = D system numeri- 371
cally, 388 there are two initial pulses, 380
© Springer Science+Business Media Singapore 2016 519
J.K. Peterson, Calculus for Cognitive Scientists, Cognitive Science
and Technology, DOI 10.1007/978-981-287-880-9
520 Index

time independent solutions to the the residue R determines the chemical


cable equation, 367 and optical activity, 80
to find eigenvalues, root finding tools the tertiary and quatenary structure of
are needed, 380 the chain reflect increasingly com-
transient cable equation, 365 plicated looping and formation of
we can compute terms in M to make 3D structural motifs, 84
it easier to implement in code, 377 the twenty amino acids, 79
what we need to implement ball stick Tryptophan and Cysteine, 77
solutions in MatLab, 380 Valine and Leucine, 75
Basics Covalent bonds, 65
Maximum of a set, 240 bond distance comparisons, 68
Supremum of a set, 240 bond energy comparisons, 68
Biological Molecules electrostatic force between two mole-
Amino acids cules, 65
a first chain abstraction, 84 force between molecule with car-
a methyl with carboxyl and amide boxyl and another with an amide
residues showing electron shells, 76 group, 65
a methyl with some common hydrogen bonds, 65
residues, 72
the Vanderwaals force is based on
Arganine and Histidine, 78 charge distributions, 67
Asparagine and Glutamine, 79
these bonds are highly directional, 66
Asparate and Glutamate, 79
water cages, 69
can be in ionized or non ionized
water encourages the splitting or
forms, 76
disassociating of a molecule into
classification of amino acid chains is
charge pieces, 69
usually done by length, 84
water interactions with molecules in
details of a chain seen at a higher
the cell, 69
level, 82
drawing chains as beads on a string, Hydrocarbons
84 carbon forms four bonds, 71
Glycine and Alanine, 75 the central carbon can have many side
Isoleucine and Proline, 76 chains, 71
longer chains are usually called pro- Nucleic acids and Sugars, 85
teins and long chains can interact a higher level look at the nucleic acids
with themselves via S − S bonds and sugars, 88
called disulfide bonds, 84 a symbolic representation of
Lysine and Threonine, 78 nucleotide bonding, 89
Methionine and Serine, 77 a three nucleotide chain, 89
peptide bond details, 81 amino acids are coded using
peptide bonds, 80 nucleotides with the triplet code,
peptide bonds allow amino acids to 93
form chains, 82 an overview of protein transcription,
Phenylalanine and Tyrosine, 76 94
the cartoon way of looking at carbon complimentary nucleotide pairing: A
bonding is very helpful, 73 to T or T to A and C to G or G to
the central carbon is called the α car- C, 91
bon, 73 complimentary nucleotides fit nicely
the general structure, 72 into a spiral called a helix. One side
the primary structure is the sequence is the 5 pairs with 3 bonds and the
of amino acids in the chain and the other is the reverse, 92
secondary structure is what is seen DNA uses the 2 C  endo form and
after folding of the chain, 84 RNA uses the 3 C  endo form, 86
Index 521

four nitrogenous bases are important: core model assumptions, 158


two purines and two pyrimidines, core model geometric parameters,
87 159
frame shifts in reading the triplets, 96 current conversions, 150
if ribose sugars instead of deoxyri- if current is injected into the mem-
bose sugars are used, the chain is brane, the resulting voltage across
called RNA. In RNA, thymine is the membrane depends on spatial
replaced by Uracil, 92 position. At this point, the cable
nucleotide chaining: 5 pairs with a 3 model does not handle this depen-
and vice versa, 91 dence, 157
nucleotides link into chains by the it is a right circular cylinder filled with
bond formed between the 5 C  of the conducting solution and it is sur-
ribose on one nucleotide to the 3 C  rounding by another cylinder which
of the ribose on another nucleotide, has a very thin wall, 150
89 let z go to zero to get the Core Equa-
sugar and nitrogenous base gives tions, 162
a nucleoside; adding a phosphate
longitudinal currents come in differ-
to the 5 C  of the sugar gives a
ent flavors, 152
nucleotide, 88
longitudinal slice conventions, 158
the A to T or T to A bond, 91
the C to g or G to C bond, 91 modeling radial current, 149
the 3D geometry of a furan sugar: the modeling resistance in terms of elec-
2 C  and 3 C  endo forms, 86 trical field density E with propor-
the chemical formulae for adenine, tionality constant σe called the con-
guanine, thymine and cytosine, 88 ductivity, 151
the four nitrogenous bases bond to Ohm’s Law helps us interpret what
either ribose or deoxyribose sugars, should be called the resistance of
88 the cable R . This also comes in dif-
the nucleotide double helix is called ferent flavors, 153
DNA, 92 resistivity units, 151
the purines adenine and guanine, 87 the 2z slice of the cable gives
the pyrimidines thymine and cyto- an electrical circuit representation,
sine, 87 160
the ribose sugar and its form without the cable membrane is thin and cur-
the oxygen on 2 C  , the deoxyribose rents move in and out of it, 153
form, 86 the core conductor equations rewrit-
the sugar furan, 86 ten in terms of transient variables,
the sugar pyran, 86 165
the triplet code: note is it redundant the core model variables, 158
in that many amino acids are coded the definition of resistance per unit
for by multiple nucleotide triplets, length r, 156
96 the derivation of the transient cable
equation. To do this the membrane
is modeled as an RC circuit, 164
C the electrical field in the membrane
Cable Equation wall is modeled as the derivative of
Time Independent the potential., 154
Limiting Current Densities, 186 the equation modeling the voltage
Cell Models across the thin membrane wall is
Dendrites as Cables, 149 derived using first order approxima-
2D cross-section, 150 tions, 155
building the core model starts with a the fundamental membrane transient
2z slice of the cable, 160 current equation, 165
522 Index

the radial currents come in different Th‘evenin Input Conductance look-


flavors, 154 ing into the cable, GT (L), 205
the space constant, 167 the full solution, 205
the time constant, 167 the full solution rewritten in terms of
the transient core equation variables, Z = (L − z)/λc , H = Ge /G∞ and
163 D = sinh(L ) + Hcosh(L ), 206
there is current and voltage balance using the applied current in the solu-
at each node in the circuit, 160 tion, 203
time and space constants for a cable, current into the front face of the cable and
166 at different spatial positions on cable,
214
finding the limiting solution, 220
D finding the particular solution of the
Definition part with the pulse applied using
Linear Independence, 23 variation of parameters, 216
Series forcing continuity in the solution and
Least Squares Convergence of a its derivative, 218
Series of functions, 285 implications, 222
Pointwise Convergence of a model pulse as a family and find solu-
Sequence and a Series of functions, tions for the three submodels, 216
283 particular solution for one member of
Uniform Convergence of a Sequence the pulse family, 218
and a Series of functions, 284 satisfying the boundary conditions,
Vector Spaces, 27 221
A Basis For A Vector Space, 29 solve using linear superposition, 215
Linear Independence For Non Finite solving for one pulse, 216
Sets, 28 some sample calculations, 222
Real Inner Product, 29 the continuity equations, 218
The Span Of A Set Of Vectors, 28
the limiting solution, 221
DNA
specifying an initial voltage across the
an amino acid string, 96
front face of the cable
conductance Ge = G∞ , 213
conductance of end cap is infinite,
F 213
Finite Cables conductance of the endcap is zero,
current injection into the front face of the 213
cable full solution, 212
GT∗ (L) varies as a function of Ge /G∞ ,
general solution, 211
207
Finite Space Cable
attenuation of the initial voltage as a
a sample session for calculating finite
function of position, 207
membrane voltages, 210
conductance of end cap is infinite,
206 Fourier Series
conductance of end cap is the same cos functions orthogonal on [0, L], 250
as G∞ , 206 sin and cos functions orthogonal on
conductance of end cap is zero, 206 [0, 2L], 254
general solution, 202 sin functions orthogonal on [0, L], 248
output load conductance Ge , 202 Convergence
sample calculations, 209 f has a derivative at x, 260
Th‘evenin Input Conductance f has one-sided derivative at x, 260
approaches the half infinite Depends on the continuity of H, 259
Th‘evenin Equivalent Conductance The integrand H in Sn (x) − f (x), 259
as the cable length increases, 206 The integrand h in Sn (x) − f (x), 259
Index 523

Cosine functions are orthogonal to each Newton interpolating polynomial for


other, 250 the function f on uniform partition,
Cosine functions are orthogonal to the 14
constant functions, 251 Specific Smk calculations, 18
Extending f to be periodic, 257 the interpolating polynomials are
Fourier Cosine Coefficients for f : nor- called Newton Interpolants, 17
malized, 244 Using Newton interpolants requires
b k
Fourier Cosine Series Convergence, 264 computing a i=1 (x − xi )dx
Fourier Series for f , 243 which are the Smk numbers, 17
Fourier Sine and Cosine coefficients for Using Newton interpolants to
f : non normalized version, 253 approximate Riemann integrals,
Fourier Sine Coefficients for f : normal- 17
ized, 243 Riemann integrals using quad in MatLab,
Fourier Sine Series Convergence, 263 21
Full series for functions on [0, 2L], 254 Function Approximation in MatLab
a comparison between function approx-
Full series for functions on [0, L], 254
imation using quad and the Newton–
Normalized sin and cos functions orthog-
Cotes methods, 21
onal on [0, 2L], 255
running some Newton–Cotes approxi-
Normalized Cosine functions, 251 mation examples, 21
Normalized Sine functions, 249 Storing Newton–Cotes weight vectors,
Partial sums of Fourier coefficients are 20
bounded above, 252 the Newton–Cotes code implementation,
Periodic extension example, 257 20
Rewriting | SN (x) − f (x) |, 258
Rewriting f (x) Step One, 258
Rewriting f (x) Step Two, 258
G
Rewriting SN (x) Step One, 255
Graham–Schmidt Orthogonalization
Rewriting SN (x) Step Three, 257
a 3D GSO example: using Draw3DGSO,
Rewriting SN (x) Step Two, 257 40
Sine functions are orthogonal to each a newton cotes session, 21
other, 249 a sample 2DGSO session, 36
the nth Fourier coefficients go to zero, constructing an anonymous function as a
253 loop, 42
Trigonometric Identity Two: integral of drawing the plane between V1 and V2 , 38
sum of cosines is one, 258 drawing the two dimensional GSO
Trigonometric Identity: Sum of cosines results: Draw2DGSO, 33
equals ratio of two sines, 256 finding and plotting the new basis, 38
Function Approximation graphing the new basis vectors, 34
Newton–Cotes, 13 GSO with Newton–Cotes Order 3, 44
a step by step explanation of the dif- GSO with Newton–Cotes Order 4, 44
ference code, 16 GSO with Newton–Cotes Order 6, 44
interpolating polynomial gives set of GSO with quadl, 46
equations to solve, 14 implementing differences in MatLab, 16
interpolating polynomial solution inner products using quad, 45
gives coefficients, 16 nested inner product code, 43
interpolating polynomial system is plotting all the lines, 37
easier to solve in MatLab: differ- plotting lines, 37
ences are not hard to compute, 16 setting the aspect ratio for the 2D GSO
interpolating polynomials, 13 plot, 35
Newton interpolating polynomial for setting up coordinates to plot a line, 37
the function f , 14 setting up two vectors, 32
524 Index

H drawing the surface plot of the voltage


Half Infinite Cables function, 462
current injection into the front face of the encoding the dynamics
cable, 199 compute τ , M∞ and H∞ terms for the
G∞ is a function of the cable geome- sodium and potassium gates, 411
try, 202 compute M and H terms for the
defining the Th‘evenin Equivalent sodium and potassium gates, 411
Conductance of the half infinite compute the conductances for the
cable, G∞ , 201 sodium and potassium models, 412
general solution, 200 compute the sodium and potassium
general solution satisfying the con- potentials, 412
straint that current is injected into compute the sodium, potassium and
the front face, 201 leakage currents, 412
Handling multiple pulses, 465 compute the total current, 413
Hodgkin–Huxley Models set the dynamics of the system, 413
a fuller test of the new code to generate set the maximum sodium and potas-
and plot the voltages, 463 sium conductances, 412
a sample session to calculate a action the corresponding dynamics for each
potential, 437 component are placed in the vector
a sample session to generate action f , 413
potential for various amounts of depo- the voltage and the M and H variables
larization, 439 for the sodium and potassium con-
a sample session to generate an action ductances form a four dimensional
potential, 429 vector y, 413
a setup for multiple pulses, 480 evaluating the gates function for the
a simple Hodgkin–Huxley dynamics pulses, 475
function, 417 extracting the information from the new
a simulation of second messenger activ- p structure, 475
ity, 482 finding the handles for the plots for the
a typical session where graphs are plotted sample dendritic pulses, 471
and then removed, 446 finding the Hodgkin–Huxley model ini-
altering the argument p to have two parts: tial conditions, 428
p.a, p.b and p.c to separate how the data generating an axon hillock voltage trace,
is used more efficiently, 474 454
analyzing the current flows in the mem- generating more ion currents, 456
brane model using circuit theory, 405 generating the axon hillock function as
approximating a dendritic pulse, 464 a function of spatial distance and time,
basic cable model variables and conven- 462
tions, 401 generating the plots of the summed den-
calculate the potassium current, 419 dritic pulses, 469
calculate the sodium current, 418 generating the plots using the handles,
calculating a dendritic pulse, 477 471
calculating and plotting sodium and generating the response for an impulse
potassium currents, 432 sequence, 468
calculating the action potential for vari- generating the surface plot of the absolute
ous axon hillock voltages, 455 value of the voltage, 466
changing the voltage calculations to get the ion battery voltages, 418
absolute values, 465 initializing the pp and q structures, 478
cleaning up figure again, 480 ion current models, 404
cleaning up the generated plots, 471 ion currents are proportional to their ion
constructing the summed dendritic pulse, conductance which is not constant but
469 a function of time and voltage, 406
Index 525

plotting the axon hillock voltage as a rest.m sets the initial conditions and
function of time, 464 makes sure the leakage current
plotting the axon response again, 478 starts at zero, 415
plotting the generating ion currents, 457 setting up an more abstract model of
set the cell capacitance and cable dynam- the ion gates, F, 420
ics, 420 SimpleHH.m computes the dynamics
set the dimension of the Hodgkin– at the a given time, 415
Huxley dynamics, 418 SolveSimpleHHOrig.m manages the
action potential simulation, 415
set the leakage current, 420
the altered SolveSimpleHHnew.m,
setting up parameters for the excitable
435
cell the pulse goes into, 477
the leakage conductance and leakage
setting up pulse arguments, 468 voltage must be chosen, 425
setting up some dendritic pulses, 471 the full dynamic model requires four
setting up the new absolute value surface variables, 410
plot of the voltage, 465 the ion current equation, 407
the α and β curve fits for the sodium and the ionic conductance is assumed to
potassium conductance models, 410 have a specific form: Gc (V , t) =
the m is called the activation variable and G0 mp (V , t)hq (V , t), 407
the h is called the inactivation variable the leakage current model, 407
and they follow first order kinetics, 408 the membrane and gate circuit model,
the activation and inactivation variables 402
rate equation, 408 the membrane model replaced by a par-
the cable equation with the current terms allel circuit model, 402
specified, 405 the membrane voltage equation in terms
the digital response associated with an of the Hodgkin–Huxley ion gate mod-
axonal output, 478 els, 407
the first MatLab implementation the membrane voltage model under the
clamped voltage protocol, 409
F used to setup all the needed α and
β functions, 420 the second MatLab implementation with
RKF5, 443
A HH model has a set of nominal p
a simple attempt to convert an action
and q values encoded in 0 , 421
potential into a digital pulse, 477
a sample simulation, 428
a simple attempt to simulate second
alterations to return time constants messenger activity, 482
and asymptotic values: HHfixe- adding a sequence of pulses to the
dRKnew.m, 436 dendritic arbor, 462
an example action potential, activa- altering the gates function to avoid
tion and inactivation variable plot division by zero problems, 443
and ion conductances and currents, altering the HH dynamics function to
429 accept an axon hillock voltage func-
each α and β function uses two para- tion, 474
meters, p and q which give the altering the incoming parameter p to
specific values needed to set their have additional parts, 474
forms, 421 rewriting the HH dynamics function
Finding the proper initial conditions, to accept a parameter vector, 447
424 the sodium and potassium activation and
HHFixedRK.m handles the Runge– inactivation rate equations, 409
Kutta for each needed time step, the sodium and potassium activation and
415 inactivation time constants and asymp-
modifying simpleHH.m to return totic values, 409
extra information: simpleHH- the sodium and potassium conductance
new.m, 434 models, 409, 504
526 Index

the standard units for the model, 410 the four continuity conditions give
the structure of the parameter p which we rise to four conditions, 185
use to simplify the argument lists, 450 the inner and outer voltage solutions,
the time constant and asymptotic value 196
for the rate equations, 408 the inner and outer voltage solutions
the total membrane current is a sum of a for the idealized pulse, 195
capacitative current and the individual the limit as C → 0 away from the site
ion currents, 405 of the current injection at 0, 186,
the voltage clamped protocol, 408 188
using a script to remove unwanted figures the solution for multiple idealized
after a MatLab session, 446 current pulses, 190
the solution to the current injection
on [−C, C], 185
I the continuity conditions in the derivative
Infinite Cables with No Time Dependence of the solution at ±C, 183
a particular solution to the time indepen- the continuity conditions in the solution
dent cable model, 176 at ±C, 182
applying the initial conditions to get the the current injection problem implies
solution, 177 we solve three related ODEs and then
examples of the Variation of Parameters splice the solutions together so the
method, 178 solution is continuous in the first deriv-
Handling Current Injections ative, 181
families of currents give rise to fam- the derivation of the second condition in
ilies of solutions: defining the cur- Variation of Parameters, 174
rent families, 181 the general solution to the time indepen-
rewriting the general solution in terms of dent cable model, 176
hyperbolic sin’s and cos’s, 177 the inner and outer current solutions, 192
solving the Variation of Parameters sys- the solution and its derivative depend on
tem using Cramer’s Rule, 175 C where the current injection is applied
summarizing the infinite cable solutions, on [−C, C], 182
196 the solution is a combination of the
the basic model to solve, 171 homogeneous solution and a particular
the continuity conditions at ±C solution, 172
a discussion of idealized currents: the system of equations the particular
defining a delta function, 189 solution must satisfy in Variation of
defining some auxiliary variables to Parameters, 175
make the exposition simpler to read,
the time independent cable model is a
183
standard ODE, 172
defining the signum and unit step
Variation of Parameters
function and writing the inner and
the derivation of the first condition in
outer current solutions in terms of
Variation of Parameters, 173
them, 195
the current injection to an idealized Ion Movement
pulse: i.e. the limiting value as C → finding the membrane voltage using con-
0, 185 ductances, 118
the derivation of the inner current for finding the potassium voltage, 109
the solution, 193 increasing the sodium to potassium con-
the derivation of the outer current for ductance ratio, 118
the solution, 194 Nernst output for potassium, 109
the evaluation of integrals of delta Ion Movement in Cells
functions, 192 A simple two compartment models: there
the four continuity condition equa- are sodium and chlorine gates between
tions, 184 the compartments, 125
Index 527

qualitative analysis is not enough; with two gates, Ohm’s law for simple
need to use Donnan’s Equilibrium circuits applies: I = R1 V or since
and a little algebra to solve for final G = 1/R, I = GV ., 114
equilibrium values, 126 the environment inside a cell
Active transport with pumps, 124 how many uncompensated ions on
biological membrane structure, 97 one side of a membrane are needed
a typical phospholipid spontaneously to maintain a one volt difference
assembles into membranes and across the membrane, 102
spheres, 98 inside a typical cell with a 0.5 Molar
Ion channels, 120 concentration of ions, there are
Donnan’s Law of Equilibrium, 123 about 2 × 1016 ions and to maintain
a 100 mV difference, only about
Donnan’s Law of Equilibrium: an
2.5 × 10−7 % of them need to be
example with three ions, 124
uncompensated, 103
Membrane transport mechanisms, 119
the environment inside the cell
Simple Cell Membrane Calculations space charge neutrality, 102
100 mM KCl inside and 10 mM KCl The Goldman–Hodgkin–Katz Equa-
outside and 100 mM NaCl outside tions, 128
and 10 mM NaCl inside with potas-
a qualitative description of what hap-
sium gates, 112
pens when an excitable nerve cell
100 mM KCl inside and 10 mM generates an action potential, 144
KCl outside and 100mM NaCl out- a typical sodium voltage activated
side and 10 mM NaCl inside with gate, 143
sodium and potassium gates, 113
adding a model for the concentration
100 mM KCl inside and 10 mM of the ion c in the membrane itself,
KCl outside and 100mM NaCl out- 129
side and 10 mM NaCl inside with
an expression for permeability in
sodium gates instead of potassium
terms of fundamental constants,
gates, 113
131
100 mM KCl inside and 10 mM KCl assumptions, 132
outside with potassium gates, 111
each GHK current equation can be
100 mM KCl inside and outside expressed in terms of permeabili-
before adding potassium gates, 110 ties for their respective ion, 137
100 mM KCl inside and outside with electrical field in terms of the deriva-
potassium gates, 111 tive of the potential, 132
a simple RC circuit model for multi- Examples of voltage calculations
ple ions, 115 using the GHK equations, 138
comments on the equation for the Excitable Nerve Cells, 142
membrane voltage with multiple for multiple ions, the individual GHK
ions, 116 currents sum to zero and equilib-
equilibrium membrane voltage with rium, 136
two gates in terms of conductances, How conductance and membrane
114 voltages change with time under a
ion c current and voltage relationship, depolarization in an action poten-
114 tial, 142
Sodium and Potassium current equa- ion current in membrane satisfies the
tions if there are two gates, 114 Nernst–Planck equation, 132
the Nernst equation for more than two Large change in permeability ratio
ions, 115 between potassium and sodium
what happens if there is an xplosive triggers a huge change in the equi-
change in the sodium to potassium librium membrane voltage, 139
conductance ratio?, 118 membrane permeability, 128
528 Index

the definition of permeability can be assume voltage and concentration are


written in two ways depending on functions of position x across the
the choice of constants used, 134 membrane, 106
the effects of an electrogenic pump, at equilibrium I is zero, 105
140 the equilibrium condition gives a first
the final equilibrium current equa- order ODE in terms of voltage and
tion, 136 concentration, 106
the final GHK current equation, 136 the final form of the Nernst equation,
the GHK voltage equation for multi- 106
ple ions, 138 the physical laws of ion movement
Einstein’s Relation between diffusion
the linear membrane concentration
and mobility, 101
model, 130
Ficke’s Law of Diffusion, 99
the membrane current equation, 133
Ohm’s Law of Drift, 100
the membrane current equation Ohm’s Law of Drift rewritten in terms
analysis, 133 of μ, 101
the membrane current equation, after relationship between concentration
a change of variables, gives a sim- [c] and electrical conductivity ∂el
pler ODE to solve, 133 determined by proportionality con-
using Einstein’s relation in the per- stant μ, 100
meability expression, 131 units analysis for Einstein’s relation,
The Nernst Equation 101
another conversion: R
F = units analysis of Ficke’s Law of Dif-
mV fusion, 100
0.0861 degrees Kelvin , 107
examples of equilibrium concentra- units analysis of Ohm’s Law of Drift,
tions, 107 100
standard equilibrium voltage for an
ion c for 70 ◦ F, 107
The Nernst–Planck Equation L
converting calories to joules and vice Limits
versa in the total drift equation Continuity Definition, 235
using the gas constant R, 104 Derivative Definition, 237
in the total drift equation κT /q = Example of jump discontinuity, 236
RT /F leading to another form of the Example of Nontrivial removeable dis-
total drift, 105 continuity, 237
Example of removeable discontinuity,
incorporating the relationship
236
between charge and moles using
Faraday’s constant in total drift, Example where derivative exists but is
104 not continuous, 237
Function Limit, 236
one degree kelvin gives R/F =
Linear Independence of Objects
8, 614 × 10−5 joules/coulomb, 104
Independence of 2D vectors, 22
rewriting total drift again in terms
2D vectors that lie on the same line
of moles using Avogadro’s number,
satisfy αE + βF = 0 for nonzero
104
α and β. This is called the linear
rewriting total drift using Einstein’s dependence equation., 23
relation, 103 two vectors that lie on same line are
rewriting total drift using Ohm’s Law multiples, 22
and Ficke’s Law, 103 linear dependence of two functions, 24
the current density equation I, 105 showing cos(t) and sin(t) are linearly
total drift of ion c, 103 independent on any interval, 24
The Nernst–Planck Equation at Equilib- showing t, sin(t) and e2t are linearly inde-
rium pendent, 25
Index 529

the development of the idea of the Wron- The Wave equation with Neumann BC:
skian of two differentiable functions, testing on saw data, 340
24 Wave equation Dirichlet BC: setup sine
Linear Partial Differential Equations functions, 333
a typical pulse function, 353 Wave Equation Dirichlet Boundary Con-
setting up two pulses, 356 ditions: altering WaveDirichletApprox
the fourier cosine approximation to the to return partial derivative approxima-
double pulse, 356 tions, 336
the Heat equation with Dirichlet BC: a Wave Equation Dirichlet Boundary Con-
sample solution for square wave data, ditions: construct the approximate
358 solution, 333
the Heat equation with Dirichlet BC: a Wave Equation Dirichlet Boundary Con-
third sample solution for square wave ditions: get fourier sine coefficients,
data, 358 333
Wave Equation Dirichlet Boundary Con-
the Heat equation with Dirichlet BC:
ditions: plot the approximate solution
another sample solution for square
surface, 334
wave data, 358
Wave Equation Dirichlet Boundary Con-
the Heat Equation with Dirichlet data: a
ditions: sample wave equation approx-
pulse input solution with 40 terms, 353
imate solution, 335
The Laplace equation with Dirichlet BC:
Wave Equation Dirichlet Boundary Con-
a sample solution with 10 terms, 345
ditions: setting up the partial derivative
The Laplace equation with Dirichlet BC: approximations, 336
a sample solution with 20 terms, 346 Wave Equation Dirichlet Boundary Con-
The Laplace equation with Dirichlet BC: ditions: setup cosine functions, 333
build the approximate solution, 344 Wave Equation Dirichlet Boundary Con-
The Laplace equation with Dirich- ditions: setup the plot domain, 333
let BC: LaplaceDirichletApprox argu- Wave Equation Dirichlet Boundary Con-
ments, 343 ditions: testing the boundary condi-
The Laplace equation with Neumann tions, 337
BC: LaplaceNeumannApprox argu- Wave Equation Dirichlet Boundary Con-
ments, 348 ditions: the wave solution for saw func-
The Laplace equation with Neumann tion inputs, 336
BC: sample solution with 10 terms, 352 Linear PDE
The Laplace equation with Neumann Fourier Series Approximations, 331
BC: sample solution with 5 terms, 349 Models
The Wave equation with Neumann BC: Laplace’s Equation, 310, 508
altering the WaveNeumannApprox to Neumann and Dirichlet Boundary
return partial derivative information, Conditions, 229
340 The Cable Equation, 229
The Wave equation with Neumann BC: The Heat/Diffusion Equation, 310
getting fourier cosine approximations, The Wave Equation, 309, 508
338 Separation of Variables
The Wave equation with Neumann BC: Definition, 230
setting up the partial derivative approx- Linear PDE Fourier Series Approximations
imations, 340 Laplace’s Equation with Dirichlet
The Wave equation with Neumann BC: Boundary Conditions, 343
setup approximate solutions, 339 Code Implementation, 344
The Wave equation with Neumann BC: Coefficient Matching, 343
setup cosine functions, 338 Sample Code Session, 345
The Wave equation with Neumann BC: Series Solution, 343
solving and returning the partial deriv- Laplace’s Equation with Neumann
ative information, 342 Boundary Conditions, 347
530 Index

Code Implementation, 348 Cable Neumann Data Fourier Series


Coefficient Matching, 348 Approximation, 279
Sample Code Session, 349 Calculating Ion Voltages: IonBattery-
Series Solution, 347 Voltages.m, 416
The Heat Equation with Dirichlet Bound- Calculating the Nernst voltage: Nernst-
ary Conditions, 350 MemVolt, 117
Code Implementation, 351 checking orthogonality of the GSO:
Coefficient Matching, 351 CheckOrtho, 268
Sample Code Session, 352 Classical HH Gate Model, 422
Series Solution, 350 Compute the error vector, 54
The Heat Equation with Neumann computing the finite cable voltage:
Boundary Conditions, 354 FiniteMembraneVoltage.m, 209
Code Implementation, 355 Computing the infinite cable voltage:
Coefficient Matching, 354 InfiniteMembraneVoltage.m, 209
Sample Code Session, 356 computing the Nernst voltage simply:
Series Solution, 354 Nernst.m, 108
The Wave Equation with Dirichlet Continuous Pulses: IE2.m, 448
Boundary Conditions, 331 ConvertToDigital, 477
Code Implementation, 334 drawing a three dimensional Graham–
Coefficient Matching, 332 Schmidt orthogonalization result:
Sample Code Session, 335 Draw3DGSO, 38
Series Solution, 332 drawing a two dimensional Graham–
Verifying Boundary Conditions, 335 Schmidt orthogonalization result:
The Wave Equation with Neumann Draw2DGSO, 35
Boundary Conditions, 337 Ending the loops, 55
Code Implementation, 339 Finding Ball and Stick Eigenvalues, 382
Coefficient Matching, 338 Finding Q, 387
Sample Code Session, 340 Finding The Approximate Solution, 389
Series Solution, 338 Finding the Axon Hillock Voltage, 389
Verifying Boundary Conditions, 340 Finding the Ball and Stick Coefficient
Matrix, 384
Finding the Ball and Stick Data Vector,
M 388
MatLab FourierCosineApprox, 270
a more careful gates function: HHGates, FourierSineApprox, 275
444 Gate Dynamics Function, 421
a new HH dynamics function: SolveSim- Generate An Axon Hillock Voltage
pleHHnew, 435 Curve, 453
a new Runge–Kutta manager: HHFixe- generic powers of t function: powers.m,
dRKnew, 437 42
A Newton–Cotes GSO Code: Graham– GetAxonHillock2, 392
SchmidtNC.m, 43 GetAxonHillockThree, 462
a rewritten HH dynamic function using Graham–Schmidt Orthogonalization
parameter arguments: HHdynamics.m, With quadl: GrahamSchmidt.m, 45
450 graphing the α/β functions: GatesNAK-
adding a handle to the surface plot: Graph, 445
GetAxonHillockFour, 466 handling indeterminacies in the α/β cal-
Adding Injection Current To The Runge– culations: HHGatesGraph, 445
Kutta Code, 427 HeatDirichletApprox, 351
adding new variables to the dynamics HeatNeumannApprox, 355
to return more information: simpleHH- HH Dynamics: simpleHH.m, 422
new, 434 Initializing The Simulation: rest.m, 425
Ball and Stick Eigenvalues, 381 Integrand Function I, 21
Index 531

Integrand Function II, 21 expression of Tn+1 in terms of the


Is step size too small?, 55 derivatives of f , 50
Is step too big?, 55 general sources of error in numerical
LaplaceDirichletApprox, 344 solutions, 51
LaplaceNeumannApprox, 348 generic recursion function F, 48
Managing The Hodgkin–Huxley Simu- minimizing the h and h2 error in Tn+1 ,
lation, 451 50
Managing The MatLab Hodgkin– rewriting the derivatives of the solu-
Huxley Simulation One, 416 tion x in terms of f , 48
Modified Finite Difference Newton rewriting the error term Tn+1 using
Method, 381 Taylor expansions of the f terms,
Newton–Cotes Implementation, 20 49
Numerical Integration Script, 20 Taylor expansions of the dynamics
RKF5 Algorithm With Parameters, 58 function f , 48
RKF5 function evaluations, 54 the error term Tn+1 , 48
RKF5 with No Parameters, 56 Runge-Kutta-Fehlberg
Runge–Kutta Codes, 52 how the RKF method works, 53
See if step size is acceptable, 55 the general recursion equation, 53
SetUpCosines, 267 typical step size changing history for
SetUpHH, 479 the tunnel diode problem, 60
SetUpOrthogCos, 268 Runge-Kutta-Fehlberg Flowchart
SetUpOrthogSin, 268 check if the stepsize h is acceptable,
SetUpPulses, 469 55
SetUpSines, 267 check to see if the stepsize h is too
Storing Newton–Cotes Weight Vectors, big, 55
20 check to see if the stepsize h is too
The Injected Current Pulse, 427 small, 55
The MatLab Fixed Runge–Kutta compute the error at this step size h,
Method, 426 54
The Runge–Kutta Solution, 52 the function evaluations, 54
Tunnel Diode Dynamics With Parame-
ters, 57
using incoming depolarizations: HHdy- S
namicsVin, 475 Separation of Variables
using Riemann sums for GSOs: Graham- Laplace’s Equation, 318
SchmidtTwo, 266 Determining the Separation Con-
WaveDirichletApprox, 334 stant, 319
WaveNeumannApprox, 339 Handling the Applied Boundary Data
Functions, 324
Series Coefficient Matching, 324
N Summarizing the Approach, 324
Nonlinear ODE The Family Of Nonzero Solutions for
solving the tunnel diode model, 59 u, Separation Constant is Negative,
Numerical ODE 322
Runge-Kutta The Family Of Nonzero Solutions for
a general discussion of approxima- u, Separation Constant is zero, 321
tion codes based on recursive eval- The Family Of Nonzero Solutions for
uations, 47 w, Separation Constant is zero, 321
comments on applying RK methods The Infinite Series Solution, 323
to vector systems, 51 The Separated ODEs, 319
different choices for α, β, γ1 and γ2 The Separation Constant, 319
give the average slope, the trape- The Separation Constant is Negative,
zoidal and Euler’s methods, 50 321
532 Index

The Separation Constant is Positive, The Series Solution, 247


320 Transient Version, 246
The Separation Constant is Zero, 320 The membrane Voltage Cable Equation
The Cable Equation Series Coefficient Matching, 247
1+ the Separation Constant is Zero, The Wave Equation, 310
232 Determining the Separation Con-
1+ the Separation Constant is Nega- stant, 312
tive, 233 Handling the Applied Boundary Data
Determining the Separation Con- Functions, 315
stant, 231 Series Coefficient Matching, 316
Handling the Applied Boundary Data Summarizing the Approach, 317
Function, 244 The Family Of Nonzero Solutions for
Series Coefficient Matching, 245 u, Separation Constant is Negative,
The 1+ the Separation Constant is 314
Positive, 231 The Family Of Nonzero Solutions for
The Family Of Nonzero Solutions for w, Separation Constant is Negative,
u, 1+ Separation Constant is Neg- 314, 323
ative, 233 The Infinite Series Solution, 314
The Family Of Nonzero Solutions for The Separated ODEs, 311
w, 1+ Separation Constant is Neg- The Separation Constant, 311
ative, 234 The Separation Constant is Negative,
The Family Of Nonzero Solutions for 313
w, Separation Constant is −1, 233 The Separation Constant is Positive,
The Infinite Series Solution, 244 312
The Separated ODEs, 230 The Separation Constant is Zero, 312
The Separation Constant, 230 Sequences
The Heat Equation Convergence of a sequence of real num-
The Family Of Nonzero Solutions for bers, 239
u, Separation Constant is −1, 232 Definition, 238
The Heat/ Diffusion Equation Divergence of a sequence of real num-
Determining the Separation Con- bers, 239
stant, 327 Examples, 238
Handling the Applied Boundary Data Series
Functions, 330 Trigonometric Series, 243
Series Coefficient Matching, 330 a general pulse function, 281
The Family Of Nonzero Solutions for a sample Graham - Schmidt 2D run, 266
u, Separation Constant is Negative, an example convergence analysis of a
329 Fourier series expansion
The Family Of Nonzero Solutions for the derivative series, 288
w, Separation Constant is Negative, approximating the solution to the
329 cable equation with Neumann BC:
The Infinite Series Solution, 330 CableNeumannApprox, 278
The Separated ODEs, 326 Bounded partial sums of nonnegative
The Separation Constant, 326 terms converge, 241
The Separation Constant is Negative, building a sawtooth and a square wave
328 function, 272
The Separation Constant is Positive, Cable equation with Neumann BC:
327 CableNeumannApprox
The Separation Constant is Zero, 328 a cable solution for a pulse, 281
The Heat/Diffusion Equation, 326 define the needed exponential func-
The Membrane Voltage Cable Equation, tions, 279
246 generate the approximation to the
Scaled Version, 247 series solution, 279
Index 533

generate the plot and end, 279 Convergence of a sequence of sums of


getting the Fourier cosine approxima- functions, 242
tion to f , 278 Convergence of the General Cable Solu-
setup the time and space domain, 279 tion, 300
checking cos orthogonality when the estimate coefficients, 303
number of terms in the Riemann sum show the series solution satisfies the
approximations to the inner products is boundary conditions, 305
200, 269 showing the partial derivatives of the
checking cos orthogonality when the solution are continuous, 304
number of terms in the Riemann sum showing the solution is continuous,
approximations to the inner products is 303
50, 269 Convergence of the Most General Cable
Code Implementation Solution
Checking orthogonality of a set of showing the partial derivatives of the
functions, 268 solution are continuous, 306
Checking orthogonality of orthogo- showing the solution is continuous,
nal cosines, 269 306
GSO example runs, 266 Finite sums of sine and cosine functions,
GSO using Riemann sum inner prod- 241
ucts, 266 GSO orthogonality results for the first 3
Inner product using Riemann sums, powers of t, 266
265 GSO orthogonality results for the first 5
Setting up cosine function handles, powers of t, 267
267 
Infinite Series notation for the remainder 
Setting up orthogonal cosine function after n terms, ∞
a sin iπ
x ,
i=n+1 i L 0
handles, 268
Setting up orthogonal sine function 242
handles, 268 Infinite Series notation for the remainder
Setting up sine function handles, 267 after n terms, ∞ i=n+1 ai , 241
Code Implementations Infinite Series notation, ∞ n=1 an , 241
Cable Membrane Approximations, Partial sums, 243
277 Partial sums of non negative terms con-
Convergence analysis for the cable equa- verge to their supremum, 240
tion, 283 Partial sums of positive terms, 240
convergence analysis of a Fourier series running GSO on the first 5 powers of t,
expansion 266
a bounded coefficients results for the setting up code to build a function with a
derivative series, 289 two part definition, 271
essentially we can differentiate the setting up code to build a sawtooth func-
Fourier series term by term, 289 tion, 272
the Fourier cos series and its deriva- the code to check cos orthogonality, 269
tive series, 298 the Fourier cosine approximation to a
the Fourier sin series and its deriva- sawtooth function, 273
tive series, 296 the Fourier cosine approximation to a
uniform convergence, 289 square wave with 11 terms, 274
uniform convergence of Fourier the Fourier cosine approximation to a
series details, 294 square wave with 6 terms, 273
uniform convergence of Fourier sin the Fourier sine approximation to a
and cos series, 296 square wave with 22 terms, 276
convergence analysis of a fourier series the Riemann sum inner product, 265
expansion, 286 Writing limit S(x0 ) using the series nota-
a bounded coefficients result, 286 tion ∞ i=1 , 242
534 Index

T Tests for Derivative Uniform Conver-


The Ball Stick Model gence, 302
a plot of the model approximation to a Tests for Uniform Convergence, 292
pulse, 391 Three Functions are Linearly Indepen-
a sample axon hillock voltage computa- dent if and only if their Wronskian is
tion, 390 not zero, 25
A sample M matrix calculation, 379 Two Functions are Linearly Independent
a simple axon hillock voltage plot, 394 if and only if their Wronskian is not
a typical axon hillock response, 396 zero, 25
adding responses together, 396 Uniform Convergence of Continuous
another M matrix calculation, 385 Functions Implies a Continuous Limit,
finding the first Q eigenvalues using 285
FindRoots, 385
finding the first 20 eigenvalues, 384
V
finding the first two ball stick eigenval-
Vector Spaces
ues, 383
a discussion of the vector space C[0, 1],
finding the minimal number of eigenval-
29
ues to compute in order to get near
an orthonormal basis, 30
orthogonality, 387
deriving Graham–Schmidt Orthogonal-
plotting the results of two pulses, 395
ization for 2D vectors, 32
what happens when when we increase
examples of vector spaces, 28
the number of eigenvalues to use in our
going through a GSO for three vectors in
expansions, 393 3 , 37
Theorem implications of the scalar multiplication
A Simple L’Hopital’s rule, 444 and object addition laws in a vector
Best Finite Dimensional Approximation space, 27
Theorem, 31 inner product notations, 30
Cauchy–Schwartz Inequality, 30 the angle between two objects, 30
Cauchy–Schwartz Integration Inequali- the biggest set of linearly independent
ties, 291 vectors in n is n, 29
Fourier Series the general GSO method implemented in
Uniform Convergence, 296 MatLab, 42
Leibnitz’s Rule, 177 the general GSO procedure, 41
Series the√ measure or size of an object V is
Cauchy–Schwartz Inequalities, 289 < V , >, 30
Common Convergent Series, 300 the norm of an object V , 30

You might also like