Lab 4 Mini: ODE Solver Checks
Goal
Solve a first-order initial-value problem with ode45 and record the checks that make the numerical solution credible.
Setup
Work in your week04 folder. Start from a clean workspace:
clear; clc; close all;Part A: Run The Script
Open week04_ode_solver_check.m.
Run the script and identify:
- the derivative function
f; - the time interval
tspan; - the initial value
y0; - the line that checks the initial condition.
Part B: Change The Initial Condition
Change:
y0 = 1;to:
y0 = 0;Run the script again. Record:
- the new first value of
y; - the new final value of
y; - whether the initial-condition check still passes.
Part C: Request Output Times
The script includes a second solve with:
t_requested = linspace(0, 10, 21);Change the number of requested output times to 6, then to 101.
Answer:
- Does the plotted curve become easier to read?
- Does requesting more output points prove that the solver used smaller internal steps?
- Why should we be careful when interpreting the plotted markers?
Deliverable
Submit a short note containing:
- the ODE you solved;
- the values of
tspanandy0; - one plot;
- the initial-condition check;
- one sentence about what the requested output grid does and does not prove.
AI Use
If you ask an LLM for ODE help, include the prompt and the check you used before trusting the generated code.