Skip to content

Commit

Permalink
Merge pull request #768 from KPCCoiL/fix-C14-example
Browse files Browse the repository at this point in the history
Correct physics of C14 example
  • Loading branch information
ChrisRackauckas authored Jan 22, 2025
2 parents d11016b + e391c41 commit f034149
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/src/examples/classical_physics.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ using OrdinaryDiffEq, Plots
gr()
#Half-life of Carbon-14 is 5,730 years.
C₁ = 5.730
= 5.730
#Setup
u₀ = 1.0
tspan = (0.0, 1.0)
tspan = (0.0, 30.0)
#Define the problem
radioactivedecay(u, p, t) = -C₁ * u
radioactivedecay(u, p, t) = -log(2) / t½ * u
#Pass to solver
prob = ODEProblem(radioactivedecay, u₀, tspan)
sol = solve(prob, Tsit5())
#Plot
plot(sol, linewidth = 2, title = "Carbon-14 half-life",
xaxis = "Time in thousands of years", yaxis = "Percentage left",
xaxis = "Time in thousands of years", yaxis = "Ratio left",
label = "Numerical Solution")
plot!(sol.t, t -> exp(-C₁ * t), lw = 3, ls = :dash, label = "Analytical Solution")
plot!(sol.t, t -> 2^(-t / t½), lw = 3, ls = :dash, label = "Analytical Solution")
```

## Second Order Linear ODE
Expand Down

0 comments on commit f034149

Please sign in to comment.