hello_world/hello_world.rs
1// SPDX-License-Identifier: BSL-1.0
2// Distributed under the Boost Software License, Version 1.0.
3// See LICENSE or https://www.boost.org/LICENSE_1_0.txt.
4
5use cauchy_ode::{OdeSystem, Solver};
6
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let system = OdeSystem::autonomous(&["x", "y"], &["cos(y)", "sin(x)"])?;
9 // Start at (x, y) = (0, 0) and integrate from t = 0 to t = 10.
10 let trajectory = Solver::default().solve_problem(&system, 0.0, &[0.0, 0.0], 10.0)?;
11
12 println!("t,x,y");
13 for (t, state) in trajectory.times.iter().zip(&trajectory.states) {
14 println!("{t:.6},{:.6},{:.6}", state[0], state[1]);
15 }
16 Ok(())
17}