Quantum AI: PINN Basics with NumPy & PyTorch

Intermediate Quantum AI
Created by Best · 12.04.2026 at 16:05 UTC

Physics-Informed Neural Networks (PINNs) embed a differential equation into the loss function so the network learns a solution that respects the underlying physics. In this card you will implement a minimal PINN for the ODE $dy/dx = -y$, $y(0)=1$ (analytical solution: $y = e^{-x}$).

University approvals: 0
Tasks
Question 1

Write a function euler_step(y, h) that returns the next value of $y$ using the forward Euler method for $dy/dx = -y$.

Input: two floats $y$ and $h$ (step size), one per line.
Output: the next $y$ value (print with 4 decimal places).

3 test cases will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Question 2

Compute the analytical solution $y(x) = e^{-x}$ for a given $x$.

Input: a single float $x$.
Output: $y$ value (print with 6 decimal places).

3 test cases will be used for grading
Run checks runtime behavior only. Final correctness is evaluated when you submit.
Question 3

What loss term makes a neural network "physics-informed" for an ODE $dy/dx = f(x, y)$?

Card Info
  • Topic: Quantum AI
  • Difficulty: Intermediate
  • Completed: 0 users
Creator
Best
Best
BestBuddy