<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Calculate sensitivities with the derivnum add-on for CO2SYS-Matlab
James Orr<br>
<img align="left" width="50%" src="http
Step1:  List all avaiable magics
Step2:  Specify the directory where you have put the Matlab routines CO2SYS.m, errors.m, and derivnum.m.
Step3:  Note
Step4:  Hint
Step5:  2.2 Partial derivatives with respect to par1 (specified above as ALK)
Step6:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step7:  2.2 Partial derivatives with respect to par2 (specified above as DIC)
Step8:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step9:  2.3 Partial derivatives with respect to Temperature
Step10:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step11:  2.4 Partial derivatives with respect to Salinity
Step12:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step13:  2.1 Partial derivatives with respect to $K_1$
Step14:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step15:  2.6 Partial derivatives with respect to $K_A$ (solubility product for aragonite)
Step16:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step17:  3. Compute sentitivities with derivnum for a 2nd input pair (pH-$A_\text{T}$)
3.1 Specify input variables and choices
Step18:  3.2 Partial derivatives with respect to H+ (since par1 is pH)
Step19:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step20:  3.3 Partial derivatives with respect to par2 (specified above as ALK)
Step21:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step22:  3.4 Partial derivatives with respect to T
Step23:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step24:  4. Compute sentitivities with derivnum for a 3rd input pair (pCO2-$C_\text{T}$)
4.1 Specify input variables and choices
Step25:  4.2 Partial derivatives with respect to par1 (specified as pCO2 above)
Step26:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step27:  4.3 Partial derivatives with respect to par2 (specified above as DIC)
Step28:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step29:  4.4 Partial derivatives with respect to T
Step30:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step31:  4.5 Partial derivatives with respect to S
Step32:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step33:  5. Compute sentitivities with derivnum for a 4th input pair (pCO2-$A_\text{T}$)
5.1 Specify input variables and choices
Step34:  5.2 Partial derivatives with respect to par1 (specified as pCO2 above)
Step35:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step36:  5.3 Partial derivatives with respect to par2 (specified above as ALK)
Step37:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step38:  5.4 Partial derivatives with respect to T
Step39:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step40:  5.5 Partial derivatives with respect to S
Step41:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step42:  6. Compute sentitivities with derivnum for a 4th input pair (pCO2-pH)
6.1 Specify input variables and choices
Step43:  6.2 Partial derivatives with respect to par1 (specified as pCO2 above)
Step44:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step45:  6.3 Partial derivatives with respect to par2 (specified above as pH)
Step46:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step47:  6.4 Partial derivatives with respect to T
Step48:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
Step49:  6.5 Partial derivatives with respect to S
Step50:  Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
<ASSISTANT_TASK:>
Python Code:
%load_ext oct2py.ipython
Explanation: Calculate sensitivities with the derivnum add-on for CO2SYS-Matlab
James Orr<br>
<img align="left" width="50%" src="http://www.lsce.ipsl.fr/Css/img/banniere_LSCE_75.png"><br><br>
LSCE/IPSL, CEA-CNRS-UVSQ, Gif-sur-Yvette, France
27 February 2018 <br><br>
updated: 29 June 2020 
Abstract: This notebook shows how to use the new derivnum add-on of CO2SYS-Matlab to calculate sensitivities, i.e. partial derivatives that express rates changes of computed CO2 system variables (e.g., [H+], $p$CO$2$, $\Omega_A$) per change in the selected input variable (e.g., $A\text{T}$, $C_\text{T}$, T, S, $K_1$, $K_2$). It uses CO2SYS-Matlab in octave, GNU's clone of Matlab. You can either inspect the HTML version of this file or execute its commands interactively in your browser. But for the latter, you'll need to install jupyter notebook, octave, and oct2py, which includes the python-octave interface called octavemagic. Fortunately, that installation is very easy (see below).
Table of Contents:
1. Basics (install octave &amp; oct2py and load octave)
2. Compute sensitivities with `derivnum` add-on for CO2SYS (use ALK-DIC input pair)
3. same but for pH-ALK
4. same but for pCO2-DIC
5. same but for pCO2-ALK
6. same but for pCO2-pH
1. Basics
Run interactively
If you are visualizing this after clicking on the link to this file on github, you are seeing the HTML version of a jupyter notebook. Alternatively, you may run cells interactively and modify them if you have jupyter notebook installed on your machine.  To install that software, just download the anaconda open software installer for your computing platform (Windows, OS X, or Linux) from https://www.anaconda.com/ and then follow the easy install instructions at
https://docs.anaconda.com/anaconda/install/
Then just download this jupyter notebook file as well as the 3 routines in the src directory (CO2SYS.m, errors.m, and derivnum.m).  Afterwards, you'll only need to install octave and oct2py using the 1-line command in the following section.
Install octavemagic
To install the octavemagic funtionality, we must install oct2py, with the following command at the Unix prompt:
conda install -c conda-forge octave oct2py
That command also installs octave. Then launch the notebook as usual with the following command:
jupyter notebook
A new window or tab should then appear in your browser, showing the files in the directory from where you launched the above command. Then just click on one of the .ipynb files, such as this one.
Once the notebook file appears in your browser, move to any of its cells with your mouse. Run a cell by clicking on it and hitting Ctrl-Return.  Alternatively, type Shift-Return to run a cell and then move to the next one. More information on all the interactive commands is available in the Jupyter Notebook Quick Start Guide: http://jupyter-notebook-beginner-guide.readthedocs.io/en/latest/execute.html
At the top of the notebook, you'll see a number of Tabs (File, Edit, View, Insert, ...). Those tabs provide commands that will allow you to do whatever you like. Under the Help tab you'll find keyboard shortcuts for commands. Alternatively, a cheat sheet for short cuts to commands within jupyter notebook is available at https://zenodo.org/record/44973/files/ipynb-cheat-sheet.pdf . Or use the command palette after typing Ctrl-Shift-P.
Documentation for octavemagic
Details on using octavemagic are here: https://ipython.org/ipython-doc/2/config/extensions/octavemagic.html
Load octave magic function
Because octavemagic is now in conda's oct2py module, it is loaded with a slight modification to what is given on the above web page, i.e., now with the command below
End of explanation
%lsmagic
Explanation: List all avaiable magics
End of explanation
%%octave
addpath ("~/Software/MATLAB/CO2SYS-MATLAB/src")
Explanation: Specify the directory where you have put the Matlab routines CO2SYS.m, errors.m, and derivnum.m.
End of explanation
%%octave 
help derivnum
Explanation: Note: any notebook cell whose 1st line is %%octave means that all subsequent lines in that cell are in octave, not python
Get the documentation for using the derivnum routine
End of explanation
%%octave
# Standard input for CO2SYS:
# --------------------------
    # Input Variables:
    PAR1 = 2300;        % ALK
    PAR2 = 2000;        % DIC
    PAR1TYPE = 1;       % 1=ALK, 2=DIC, 3=pH, 4=pCO2, 5=fCO2
    PAR2TYPE = 2;       % Same 5 choices as PAR1TYPE
    SAL = 35;           % Salinity
    TEMPIN = 18;        % Temperature (input)
    TEMPOUT = 25;       % Temperature (output)
    PRESIN = 0;         % Pressure (input)
    PRESOUT = PRESIN;   % Pressure (output)
    SI = 60;            % Total dissolved inorganic silicon (Sit)
    PO4 = 2;            % Total dissoloved inorganic Phosphorus (Pt)
#   SI =  0;            % Total dissolved inorganic silicon (Sit)
    # Input Parameters:
    pHSCALEIN = 1;      % pH scale (1=total, 2=seawater, 3=NBS, 4=Free)
    K1K2CONSTANTS = 10; % set for K1 & K2: 10=Lueker et al. (2000); 14=Millero (2010); 15= Waters et al. (2014)
    KSO4CONSTANTS = 1;  % KSO4 of Dickson (1990a) & Total dissolved boron (Bt) from Uppstrom (1974)
Explanation: Hint:
double click on left of box above to hide above output
single click to show it again 
2. Compute sentitivities with derivnum add-on for CO2SYS-Matlab ($A_\text{T}$-$C_\text{T}$ pair)
2.1 Specify input variables and choices
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.2 Partial derivatives with respect to par1 (specified above as ALK)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.2 Partial derivatives with respect to par2 (specified above as DIC)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.3 Partial derivatives with respect to Temperature
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.4 Partial derivatives with respect to Salinity
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
     printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('K1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.1 Partial derivatives with respect to $K_1$
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('K1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('Kspa', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 2.6 Partial derivatives with respect to $K_A$ (solubility product for aragonite)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('Kspa', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
# Standard input for CO2SYS:
# --------------------------
    # Input Variables:
    PAR1 = 8.1;         % pH
    PAR2 = 2300;        % ALK
    PAR1TYPE = 3;       % 1=ALK, 2=DIC, 3=pH, 4=pCO2, 5=fCO2
    PAR2TYPE = 1;       % Same 5 choices as PAR1TYPE
    SAL = 35;           % Salinity
    TEMPIN = 18;        % Temperature (input)
    TEMPOUT = 25;       % Temperature (output)
    #TEMPOUT = TEMPIN;
    PRESIN = 0;         % Pressure (input)
    PRESOUT = PRESIN;   % Pressure (output)
    SI = 60;            % Total dissolved inorganic silicon (Sit)
    PO4 = 2;            % Total dissoloved inorganic Phosphorus (Pt)
    # Input Parameters:
    pHSCALEIN = 1;      % pH scale (1=total, 2=seawater, 3=NBS, 4=Free)
    K1K2CONSTANTS = 15; % set for K1 & K2: 10=Lueker et al. (2000); 14=Millero (2010); 15=Waters et al. (2014)
    KSO4CONSTANTS = 1;  % KSO4 of Dickson (1990a) & Total dissolved boron (Bt) from Uppstrom (1974)
Explanation: 3. Compute sentitivities with derivnum for a 2nd input pair (pH-$A_\text{T}$)
3.1 Specify input variables and choices
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 3.2 Partial derivatives with respect to H+ (since par1 is pH)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 3.3 Partial derivatives with respect to par2 (specified above as ALK)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, PRESIN, PRESOUT,... 
                                   SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 3.4 Partial derivatives with respect to T
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
# Standard input for CO2SYS:
# --------------------------
    # Input Variables:
    PAR1 = 400;         % pCO2
    PAR2 = 2300;        % DIC
    PAR1TYPE = 4;       % 1=ALK, 2=DIC, 3=pH, 4=pCO2, 5=fCO2
    PAR2TYPE = 2;       % Same 5 choices as PAR1TYPE
    SAL = 35;           % Salinity
    TEMPIN = 18;        % Temperature (input)
    TEMPOUT = 25;       % Temperature (output)
    PRESIN = 0;         % Pressure (input)
    PRESOUT = PRESIN;   % Pressure (output)
    SI = 60;            % Total dissolved inorganic silicon (Sit)
    PO4 = 2;            % Total dissoloved inorganic Phosphorus (Pt)
    # Input Parameters:
    pHSCALEIN = 1;      % pH scale (1=total, 2=seawater, 3=NBS, 4=Free)
    K1K2CONSTANTS = 15; % set for K1 & K2: 10=Lueker et al. (2000); 14=Millero (2010); 15=Waters et al. (2014)
    KSO4CONSTANTS = 1;  % KSO4 of Dickson (1990a) & Total dissolved boron (Bt) from Uppstrom (1974)
Explanation: 4. Compute sentitivities with derivnum for a 3rd input pair (pCO2-$C_\text{T}$)
4.1 Specify input variables and choices
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
  printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
  printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
  printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 4.2 Partial derivatives with respect to par1 (specified as pCO2 above)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 4.3 Partial derivatives with respect to par2 (specified above as DIC)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 4.4 Partial derivatives with respect to T
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 4.5 Partial derivatives with respect to S
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
# Standard input for CO2SYS:
# --------------------------
    # Input Variables:
    PAR1 = 400;         % pCO2
    PAR2 = 2300;        % ALK
    PAR1TYPE = 4;       % 1=ALK, 2=DIC, 3=pH, 4=pCO2, 5=fCO2
    PAR2TYPE = 1;       % Same 5 choices as PAR1TYPE
    SAL = 35;           % Salinity
    TEMPIN = 18;        % Temperature (input)
    TEMPOUT = 25;       % Temperature (output)
    PRESIN = 0;         % Pressure (input)
    PRESOUT = PRESIN;   % Pressure (output)
    SI = 60;            % Total dissolved inorganic silicon (Sit)
    PO4 = 2;            % Total dissoloved inorganic Phosphorus (Pt)
    # Input Parameters:
    pHSCALEIN = 1;      % pH scale (1=total, 2=seawater, 3=NBS, 4=Free)
    K1K2CONSTANTS = 10; % set for K1 & K2: 10=Lueker et al. (2000); 14=Millero (2010); 15=Waters et al. (2014)
    KSO4CONSTANTS = 1;  % KSO4 of Dickson (1990a) & Total dissolved boron (Bt) from Uppstrom (1974)
Explanation: 5. Compute sentitivities with derivnum for a 4th input pair (pCO2-$A_\text{T}$)
5.1 Specify input variables and choices
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 5.2 Partial derivatives with respect to par1 (specified as pCO2 above)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 5.3 Partial derivatives with respect to par2 (specified above as ALK)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 5.4 Partial derivatives with respect to T
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 5.5 Partial derivatives with respect to S
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
# Standard input for CO2SYS:
# --------------------------
    # Input Variables:
    PAR1 = 400;         % pCO2
    PAR2 = 8.0;         % pH
    PAR1TYPE = 4;       % 1=ALK, 2=DIC, 3=pH, 4=pCO2, 5=fCO2
    PAR2TYPE = 3;       % Same 5 choices as PAR1TYPE
    SAL = 35;           % Salinity
    TEMPIN = 18;        % Temperature (input)
    TEMPOUT = 25;       % Temperature (output)
    PRESIN = 0;         % Pressure (input)
    PRESOUT = PRESIN;   % Pressure (output)
    SI = 60;            % Total dissolved inorganic silicon (Sit)
    PO4 = 2;            % Total dissoloved inorganic Phosphorus (Pt)
    # Input Parameters:
    pHSCALEIN = 1;      % pH scale (1=total, 2=seawater, 3=NBS, 4=Free)
    K1K2CONSTANTS = 10; % set for K1 & K2: 10=Lueker et al. (2000); 14=Millero (2010); 15=Waters et al. (2014)
    KSO4CONSTANTS = 1;  % KSO4 of Dickson (1990a) & Total dissolved boron (Bt) from Uppstrom (1974)
Explanation: 6. Compute sentitivities with derivnum for a 4th input pair (pCO2-pH)
6.1 Specify input variables and choices
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 6.2 Partial derivatives with respect to par1 (specified as pCO2 above)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par1', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 6.3 Partial derivatives with respect to par2 (specified above as pH)
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('par2', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN, ...
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 6.4 Partial derivatives with respect to T
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('T', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPOUT,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{1:9});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{1:9});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(1:9));
Explanation: 6.5 Partial derivatives with respect to S
End of explanation
%%octave
    [b, bhead, bunits] = derivnum ('S', PAR1, PAR2, PAR1TYPE, PAR2TYPE, SAL, TEMPIN, TEMPIN,... 
                                   PRESIN, PRESOUT, SI, PO4,...
                                   pHSCALEIN, K1K2CONSTANTS, KSO4CONSTANTS);
# Print (nicely formatted):
    printf("%s %s %s %s %s %s %s %s %s \n", bhead{10:18});
    printf("%s %s %s %s %s %s %s %s %s \n", bunits{10:18});
    printf("%f  %f   %f    %f    %f    %f   %f         %f       %f \n", b(10:18));
Explanation: Test to see if same results for OUT conditions when TEMPOUT = TEMPIN
End of explanation
<END_TASK>