Physics with Mathematica

Third Class

Reminder: Have you chosen a “homework problem” yet?

Today: Derivatives, Integrals, and Series

We will work with expressions today, leave functions for a later time

Remove["Global`*"]

Derivatives are simple. The syntax is pretty flexible.

D[a x^2+b x,x]

D[a x^2+b x,{x,2}]

Derivatives are really partial derivatives.

D[a x^2+b x y,x]

D[a x^2+b x y,x,y]

D[a x^2+b x y,y,x]

Summary Example: Recall Exercise #1

Remove["Global`*"]

Also a couple of new things about plotting

cosine=x/Sqrt[x^2+a^2];
force=2 k q Q cosine/(x^2+a^2);

vals={k->1,q->1,Q->1,a->1};
Plot[force/.vals,{x,-3,3}]

Find the points where the force is min/max, and use this to make a better plot

sol=Solve[D[force,x]==0,x]

x1=x/.sol[[1]];x2=x/.sol[[2]];
f1=force/.x->x1;f2=force/.x->x2;

Show[
Plot[force/.vals,{x,-3,3}],
ListLinePlot[{{x1,0},{x1,f1}}/.vals],
ListLinePlot[{{x2,0},{x2,f2}}/.vals]]

Integration

Remove["Global`*"]

Indefinite integrals are simple, but no “integration constant” appears

Integrate[a x^2+b x+c,x]

Integrate[Cos[a x],x]

Integrate[a/x,x]

Definite integrals are simple, too

Integrate[a x^2+b x+c,{x,0,1}]

Integrate[a/x,{x,1,E}]

Some integrals are special

$Assumptions={a>0};
Integrate[Exp[-(a x)^2],{x,-∞,t}]

Numerical Integration

Remove["Global`*"]

A lot of integrals can’t be done, but many times all you need is the numerical result

Integrate[Exp[- x^2],{x,-∞,0}]

NIntegrate[Exp[- x^2],{x,-∞,0}]

$Assumptions={a>0};
Integrate[1/Sqrt[1-a Sin[x]^2],x]

NIntegrate[1/Sqrt[1- Sin[x]^2],{x,0,Pi/4}]

Power series

Remove["Global`*"]

You can expand pretty much anything in a Taylor series

ser=Series[(1+x)^a,{x,0,2}]

Normal[ser]

ser=Series[Sin[x],{x,0,2}]

ser=Series[Sin[x],{x,Pi/2,2}]

Expand[ser]

Expand[Normal[ser]]