4
$\begingroup$

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]

I get an inverse function (?) instead of the usual answer:

{{t -> h^(-1) [10]}}

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.

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

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

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy