Electromagnetic theory is central to physics. An undergraduate major in physics typically takes a semester or a year of electromagnetic theory as a junior or senior, and a graduate student in physics typically takes an additional semester or year at a more advanced level. In fall 2023, the author taught his undergraduate electricity and magnetism class using numerical methods in Haskell in parallel with traditional analytical methods. This article describes what functional programming has to offer to physics in general, and electromagnetic theory in particular. We give examples from vector calculus, the mathematical language in which electromagnetic theory is expressed, and electromagnetic theory itself.
翻译:电磁理论是物理学的核心。物理学本科生通常在大学三、四年级修读一学期或一学年的电磁理论课程,而物理学研究生通常会在更高阶水平上额外修读一学期或一学年。2023年秋季学期,作者在本科电磁学课程教学中,采用Haskell语言的数值计算方法与传统解析方法并行授课。本文阐述了函数式编程对物理学(特别是电磁理论)的潜在贡献。我们通过矢量微积分(电磁理论的数学表述语言)及电磁理论本身的具体案例进行说明。