Balancing Chemical Reactions: Photosynthesis

Burak Aksoylu, Texas A&M University-San Antonio, Computational, Engineering and Mathematical Sciences (CEMS)

Author Profile
Initial Publication Date: October 6, 2026
DOI | Cite this

Summary

This third-year linear algebra project uses photosynthesis, a chemical process essential to life, to give students practice solving systems of linear equations in MATLAB. Building on a worked example, students complete two scaffolded scripts to balance reactions producing glucose and then glucose with sucrose, using row reduction, free variables, and the rank–nullity theorem. Students learn to translate chemical conservation laws into homogeneous systems, interpret their solution spaces, and verify chemically meaningful solutions.

Share your modifications and improvements to this activity through the Community Contribution Tool »

Learning Goals

By completing this activity, students will develop the following knowledge and skills:

Linear algebra concepts: Formulate and solve homogeneous systems using matrix representations and reduced row echelon form; identify pivot and free variables; and connect rank, nullity, and the number of independent solution parameters.

Mathematical modeling: Translate conservation of carbon, hydrogen, and oxygen into linear equations and interpret null-space vectors as coefficients of balanced chemical reactions.

Critical thinking and synthesis: Compare the one-parameter glucose model with the two-parameter glucose-and-sucrose model, explaining how an additional product changes the solution space. Distinguish general mathematical solutions from chemically meaningful, nonnegative integer coefficients.

Verification and computational skills: Complete MATLAB scripts, use symbolic parameters and substitution, diagnose errors, and verify solutions through matrix residuals and atom counts.

Written communication: Explain modeling choices, present parametric solutions and balanced equations, and justify conclusions using mathematical reasoning and computational evidence.

Context for Use

This activity is designed for a third-year undergraduate linear algebra course at a college or university. It is suitable for small or large classes as an individual or paired homework project, or as a guided computer laboratory exercise. Allow approximately two to three hours for both projects, depending on students' MATLAB experience; this is an initial estimate to be refined after classroom use.

The activity fits after instruction on homogeneous systems, row reduction, pivot and free variables, null spaces, and the rank–nullity theorem. Students should be familiar with basic MATLAB syntax, matrix entry, and script execution. A worked propane-combustion example provides preparation. No advanced chemistry background is required beyond interpreting molecular formulas and understanding conservation of atoms.

For the supplied symbolic sections, students need MATLAB Symbolic Math Toolbox. The activity can be adapted for introductory courses by providing more of the matrix setup, or for more advanced courses by requiring independent model construction and deeper analysis of the solution space. It can also be completed through hand calculations or adapted to other computational software by replacing the MATLAB-specific commands.

Description and Teaching Materials

Students begin by reviewing a worked MATLAB live script that demonstrates how to balance propane combustion using a homogeneous system of linear equations. They then complete two partially written photosynthesis scripts. The first considers glucose production; the second adds sucrose, allowing students to explore how an additional product changes the number of free variables and the solution space.

In each project, students construct the chemical system matrix, compute its reduced row echelon form, identify pivot and free variables, and express the general solution. They calculate rank and nullity, complete symbolic coefficient formulas, and substitute parameter values to obtain balanced reactions. Finally, they verify conservation of atoms and explain the relationship between mathematical solutions and chemically meaningful coefficients. Numbered prompts identify the missing code and required written responses; symbolic declarations and substitution syntax are supplied as scaffolding.

The teaching materials are:

1. Worked propane example, propane.m: A complete demonstration used for instructor explanation and student reference.

2. Photosynthesis Project 1, photosynthesis1.m: A scaffolded glucose-production activity emphasizing a one-parameter solution and integer scaling.

3. Photosynthesis Project 2, photosynthesis2.m: An extension involving glucose and sucrose, emphasizing two independent parameters and combinations of null-space basis vectors.

Implementation requires MATLAB with Symbolic Math Toolbox. Students submit both completed scripts with generated outputs and written explanations. Before distribution, instructors should run the materials in their local MATLAB installation to confirm execution and Live Editor formatting.

Teaching Notes and Tips

Begin with the worked propane example, emphasizing how atom counts become matrix entries and why reactant and product columns have opposite signs. Have students complete the glucose project before the glucose-and-sucrose extension. Briefly introduce the supplied symbolic MATLAB commands, and encourage students to explain how free variables, rank, and nullity relate to the possible balances.

Common errors include incorrect atom counts, inconsistent signs, and confusing mathematical solutions with chemically meaningful coefficients. Ask students to verify both the matrix residual and the atom counts. Students should run completed scripts from a cleared workspace. Distribute only the propane example and student templates, retaining the full solutions and grading guide for instructor use.


Assessment

Assess students' completed MATLAB scripts, outputs, and explanations using the 100-point rubric. Grade matrix setup, row reduction, rank and nullity, general solutions, and verification of balanced reactions.

Check understanding through students' explanations of free variables and chemically meaningful coefficients. Their comparison of the two projects should explain why one has a one-dimensional solution space and the other has a two-dimensional solution space.

References and Resources

The propane.m example was inspired by the "Balancing Chemical Equations" discussion in Section 1.6 of Lay, Lay, and McDonald's Linear Algebra and Its Applications. The photosynthesis projects were created by the author, who also wrote the MATLAB Live Scripts.

Textbook: Lay, David C., Steven R. Lay, and Judi J. McDonald. Linear Algebra and Its Applications. Pearson, Section 1.6. Introduces chemical balancing as an application of systems of linear equations.

MATLAB row reduction: MathWorks rref documentation. Explains the command students use to compute reduced row echelon forms.

Symbolic substitution: MathWorks subs documentation. Explains how students substitute parameter values into symbolic solutions to obtain specific chemical balances.