# Solve/Reduce not working on a function with a condition/domain restriction?

I'm working with a trigonometric function, so I thought it would be convenient to set a condition to restrict the domain so I wouldn't have to specify it in the solve function each time. Here is a simplified example:

h[t_ /; 0 <= t <= 24] := 20 + 20 Sin[\[Pi]/12 t];


Plotting seems to work just fine, however when I try to solve it using this simple code:

Solve[h[t] == 10, t]


{{t -> h^(-1) }}


The normal way works, but as you can see, it is inconvenient to specify the domain every time:

Solve[20 + 20 Sin[\[Pi]/12 t] == 10 && 0 <= t <= 24, t]
(*Output: {{t -> 14}, {t -> 22}} *)


Can anyone please help point out the problem? I would like to define a function with a restricted domain, so that there is no need to specify the domain within solve.

• is ClearAll[h]; h[t_] := ConditionalExpression[20 + 20 Sin[\[Pi]/12 t], 0 <= t < 24]; Solve[h[t] == 10, t] an acceptable alternative? – kglr Aug 10 '18 at 1:08
• @kglr Sure, I mistakenly thought that /; was some shorthand notation for it, but it appears to be different. – WeavingBird1917 Aug 10 '18 at 1:10
• h[t_]:=Piecewise[{{20+20 Sin[Pi/12 t],0<=t<24}},Indeterminate] – matrix89 Aug 10 '18 at 2:45

An alternative way to impose a condition on the argument of the function:

ClearAll[h]
h[t_] := ConditionalExpression[20 + 20 Sin[π/12 t], 0 <= t < 24]
Solve[h[t] == 10, t]


{{t -> 14}, {t -> 22}}

Reduce[h[t] == 10, t]


t == 14 || t == 22