ChatGPT for Programming Numerical Methods
Authors:
Ali Kashefi,
Tapan Mukerji
Abstract:
ChatGPT is a large language model recently released by the OpenAI company. In this technical report, we explore for the first time the capability of ChatGPT for programming numerical algorithms. Specifically, we examine the capability of GhatGPT for generating codes for numerical algorithms in different programming languages, for debugging and improving written codes by users, for completing misse…
▽ More
ChatGPT is a large language model recently released by the OpenAI company. In this technical report, we explore for the first time the capability of ChatGPT for programming numerical algorithms. Specifically, we examine the capability of GhatGPT for generating codes for numerical algorithms in different programming languages, for debugging and improving written codes by users, for completing missed parts of numerical codes, rewriting available codes in other programming languages, and for parallelizing serial codes. Additionally, we assess if ChatGPT can recognize if given codes are written by humans or machines. To reach this goal, we consider a variety of mathematical problems such as the Poisson equation, the diffusion equation, the incompressible Navier-Stokes equations, compressible inviscid flow, eigenvalue problems, solving linear systems of equations, storing sparse matrices, etc. Furthermore, we exemplify scientific machine learning such as physics-informed neural networks and convolutional neural networks with applications to computational physics. Through these examples, we investigate the successes, failures, and challenges of ChatGPT. Examples of failures are producing singular matrices, operations on arrays with incompatible sizes, programming interruption for relatively long codes, etc. Our outcomes suggest that ChatGPT can successfully program numerical algorithms in different programming languages, but certain limitations and challenges exist that require further improvement of this machine learning model.
△ Less
Submitted 26 April, 2023; v1 submitted 21 March, 2023;
originally announced March 2023.
Additive estimates of the permanent using Gaussian fields
Authors:
Tantrik Mukerji,
Wei-Shih Yang
Abstract:
We present a randomized algorithm for estimating the permanent of an $M \times M$ real matrix $A$ up to an additive error. We do this by viewing the permanent $\mathrm{perm}(A)$ of $A$ as the expectation of a product of centered joint Gaussian random variables with a particular covariance matrix $C$. The algorithm outputs the empirical mean $S_{N}$ of this product after sampling $N$ times. Our alg…
▽ More
We present a randomized algorithm for estimating the permanent of an $M \times M$ real matrix $A$ up to an additive error. We do this by viewing the permanent $\mathrm{perm}(A)$ of $A$ as the expectation of a product of centered joint Gaussian random variables with a particular covariance matrix $C$. The algorithm outputs the empirical mean $S_{N}$ of this product after sampling $N$ times. Our algorithm runs in total time $O(M^{3} + M^{2}N + MN)$ with failure probability \begin{equation*}
P(|S_{N}-\text{perm}(A)| > t) \leq \frac{3^{M}}{t^{2}N} \prod^{2M}_{i=1} C_{ii}. \end{equation*} In particular, we can estimate $\mathrm{perm}(A)$ to an additive error of $ε\bigg(\sqrt{3^{2M}\prod^{2M}_{i=1} C_{ii}}\bigg)$ in polynomial time. We compare to a previous procedure due to Gurvits. We discuss how to find a particular $C$ using a semidefinite program and a relation to the Max-Cut problem and cut-norms.
△ Less
Submitted 13 February, 2024; v1 submitted 20 December, 2022;
originally announced December 2022.