Question: How to Solve and Visualize Newton’s Law of Cooling More Efficiently?

Hello,

I am working on a problem involving Newton's Law of Cooling in Maple, I want to:

  1. Solve for the cooling constant k,
  2. Find how long it takes for the pizza to cool to 300 F,

Here is the code I am currently using:

with(plots):

T__s := 75;  # Surrounding temperature
ode := diff(T(t), t) = k*(T(t) - T__s);

# General solution
general_solution := dsolve(ode, T(t));

# Initial condition: T(0) = 350
T := t -> 75 + exp(k*t)*c__1;
C := solve(350 = 75 + exp(0)*C__1, C__1);

# Solve for k using T(5) = 340
k := solve(340 = 75 + 275*exp(5*k), k);
k := evalf(k);

# Solve for time to reach T = 300
time_to_reach := solve(300 = 75 + 275*exp(k*t), t);
time_to_reach := evalf(time_to_reach);

# Define T(t) with solved constants
T := t -> 75 + 275*exp(k*t);

# Plot temperature over time
temp := plot(T, t = 0 .. 280, 75 .. 360, title = "Exponential Decay of Pizza Temperature", labels = ["t (minutes)", "T(t) (°F)"], color = blue);

# Plot T__s as a horizontal line
T__sur := plot(T__s, t = 0 .. 280, color = red, linestyle = dash);

# Combine and display plots
display([temp, T__sur]);

The code works, but I am wondering if there is a more efficient or genuine way.

I would greatly appreciate any advice or alternative approaches to solving and visualizing this in Maple.

Thank you in advance for your insights!

Please Wait...