# Using Min & Max of an Interval in a replacement [closed]

I want to use a replacement rule to transform a list of equations. The following works as expected:

eqns = {x'[t] == 2 y[t], y'[t] == -3 x[t]};
eqns /. (var_'[t] == rhs_) -> {var, rhs}
(* {{x, 2 y[t]}, {y, -3 x[t]}} *)


Now I want to use the same idea to get the Min and Max of an Interval associated with each variable.

range[x] = Interval[{-1, 1}]; range[y] = Interval[{-2, 2}];
eqns /. (var_'[t] == rhs_) -> {Min[range[var]], Max[range[var]]}


Since {Min[range[x]], Max[range[x]]} = {-1 ,1}, I expected to get

(* {{-1, 1}, {-2, 2}} *)


(* {{Interval[{-1, 1}], Interval[{-1, 1}]}, {Interval[{-2, 2}], Interval[{-2, 2}]}} *)


What am I doing wrong and how to fix it?

## closed as off-topic by Bob Hanlon, m_goldberg, Henrik Schumacher, MarcoB, xzczdFeb 11 at 4:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, m_goldberg, Henrik Schumacher, MarcoB, xzczd
If this question can be reworded to fit the rules in the help center, please edit the question.

• Use :> instead of ->. Notice Min@aaaa evaluates to aaaa. :) – xzczd Feb 10 at 15:26
• @xzczd Yep, it was that easy. Thanks! – Chris K Feb 10 at 15:27
• @xzczd Any rule of thumb when to use :> vs. -> in this context? – Chris K Feb 10 at 15:31
• Well, personally I don't recommend deciding it based on rule of thumb. Just think about if the right hand side can be/should be evaluate before pattern matching. -> evaluates the right hand side instantly, while in this case, Min[range[var]] will evaluate to range[var], so the right hand side should not be evaluated before the pattern matches. You may use Trace to check the evaluation order. – xzczd Feb 10 at 15:36