# Piecewise function [closed]

I have the differential equation

$$\omega'(t)= \begin{cases} \frac{1}{J_t}\left(\frac{B}{2}(F_l-F_r)-B_l\omega\right) & \text{if turning=true}\\ 0 & \text{if turning=false} \end{cases}$$

and I want to solve it. I have written

w[t_] = Piecewise[{{1/J(B/2(F1(t)-F2(t))-Bw(t)), turning=1}, {0, turning=0}]
D[w[t], t]


but I think it's not correct. Could anyone help me please???

## closed as off-topic by Bob Hanlon, Michael E2, C. E., MarcoB, ÖskåAug 11 at 16:12

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, Michael E2, C. E., MarcoB, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

• You are missing a right parentheses in the definition of w. Functions must always use square brackets around the arguments, e.g., F1[t] Also, the conditions must use Equal ( == ) rather than Set ( = ). – Bob Hanlon Aug 6 at 18:45

It depends a bit on what you are doing with the differential equation. Are you using DSolve or NDSolve?

ω'[t] == 1/Jt*(B/2*(Fl[t] - Fr[t]) - Bl*ω[t]) * Boole[turning[t]]


could be a way of specifying this differential equation.

Once you have definitions for $$J_t$$, $$F_l(t)$$, $$F_r(t)$$, $$B_l$$, $$\text{turning}(t)$$, and an initial value for $$\omega(t)$$, you can solve this differential equation with DSolve or NDSolve: something like

NDSolve[{ω'[t] == 1/Jt*(B/2*(Fl[t] - Fr[t]) - Bl*ω[t]) * Boole[turning[t]],
ω[t0] == ω0}, ω[t], {t, t0, t1}]

• This is the equation I'm talking about. Thank you ibb.co/ch8cv05 – Evina Jul 7 at 13:47