# Plotting solution to an oscillation

I have a simple task of plotting the solution to a differential equation under different conditions and can't figure it out.

The solution is

x(t)=Exp(-bt)[cos(wt)+(b/w)*sin(wt)]


and I need to plot it for 0

f[t_, b_] := [(e^(-b*t))[Cos[t] + b*Sin[t]],
t, {t, 0, 20}]


and I think something is wrong in my syntax. I will appreciate any guidance!

• You have to use brackets instead of parentheses for arguments. Moreover, you might want Sin and Cos instead of sin and cos. Mathematica is case sensitive. – Henrik Schumacher Oct 22 '17 at 0:13

Maybe you are looking for something like this:

x[t_, b_, w_] := Exp[-b t] (Cos[w t] + b t Sinc[w t])
Manipulate[
Plot[x[t, b, w], {t, 0, 20}, PlotRange -> {-2, 2}],
{{b, .1}, -2, 2},
{{w, 1.}, -2 Pi, 2 Pi}
]


If you have specific values for b to plot, you can use, e.g.,

Plot[{f[t,0],f[t,0.1],f[t,1.]}, {t, 0, 20}]

• So I did this, f[t_, b_] := Exp[b t] (Cos[t] + b*Sin[t]) which worked great for my function, but them plotting I don't get anything on the plot. I don't want to use the manipulate function because I want to pick specific values for b. – K. Schneider Oct 22 '17 at 0:39
• How did you plot then? Note that b needs a specific value if want to use Plot[f[t,b],{t,0,20}]. – Henrik Schumacher Oct 22 '17 at 0:40
• Plot[f[t], {t, 0, 20}] – K. Schneider Oct 22 '17 at 1:02
• I am trying to figure out how to include b; I need it at specific values of 0, 0.1, and 1. – K. Schneider Oct 22 '17 at 1:04

If you just want plots for b from 0 to 1, you can do this

f[t_, b_] := Exp[-b t] (Cos[t] + b*Sin[t])

Table[Plot[f[t, b], {t, 0, 20}, PlotRange -> All,
PlotLabel -> "b=" + b], {b, 0, 1, .1}]


but as above, Manipulate works too if you just want to vary b.

Manipulate[Plot[f[t, b], {t, 0, 20}, PlotRange -> {-1, 1},
PlotLabel -> "b=" + b], {b, 0, 1, .1}]