class11 - PHYS 5900 Class 11 (9/18/2009Fri) Zi-Wei Lin...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
PHYS 5900 Class 11 (9/18/2009Fri) Zi-Wei Lin FindRoot NSolve may not solve equations such as transcendental equations: In[1]:= NSolve @ Sin @ x D m x^2, x D Solve::tdep : The equations appear to involve the variables to be solved for in an essentially non - algebraic way. à Out[1]= NSolve A Sin @ x D m x 2 ,x E FindRoot can find numerical solutions to arbitrary equations if the starting point is close to the solution. In[2]:= ? FindRoot FindRoot @ f , 8 x , x 0 <D searches for a numerical root of f , starting from the point x = x 0 . FindRoot @ lhs == rhs , 8 x , x 0 <D searches for a numerical solution to the equation lhs == rhs . FindRoot @8 f 1 , f 2 , < , 88 x , x 0 < , 8 y , y 0 < , <D searches for a simultaneous numerical root of all the f i . FindRoot @8 eqn 1 , eqn 2 , < , 88 x , x 0 < , 8 y , y 0 < , <D searches for a numerical solution to the simultaneous equations eqn i . à
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example 2.3.9 Find the numerical solutions of x*tan(x)= 16 - x 2 that are positive. 1) Plot lhs and rhs together in a proper range so that you can see all the solutions: (sometimes we need to rearrange the equation to get simpler lhs and rhs) In[3]:= myplot = Plot @8 x Tan @ x D , Sqrt @ 16 x^2 D< , 8 x, 0, 10 <D Out[3]= 2 4 6 8 10 - 15 - 10 - 5 5 10 15 2) Zoom in on the intersection points, we can use the option: PlotRange -> {{ x min , x max }, { y min , y max }} In[4]:= Show @ myplot, PlotRange 88 0, 4 < , 8 0, 5 <<D Out[4]= 1 2 3 4 1 2 3 4 5 3) give the approximate value of each intersection x-value as the starting point: In[5]:= myEqn = x Tan @ x D == Sqrt @ 16 x^2 D ; In[6]:= FindRoot @ myEqn, 8 x, 1. <D Out[6]= 8 x 1.25235 < In[7]:= FindRoot @ myEqn, 8 x, 3.9 <D Out[7]= 8 x 3.5953 < 2 class11.nb
Background image of page 2
Or 3) Use the more interactive tool to get the approximate value of each intersection x-value: In[8]:= ClickPane @ Plot @8 x Tan @ x D , Sqrt @ 16 x^2 D< , 8 x, 0, 8 < , PlotRange 88 0, 5 < , 8 0, 5 <<D , H xycoord L D Out[8]= 0 1 2 3 4 5 1 2 3 4 5 In[9]:= Dynamic @ xycoord D Out[9]= 8 3.65854, 1.86607 < Click on the curve at each intersection point, and write down the corresponding x-values as the following list: In[10]:= startValues = 8 1.25, 3.6 < ; In[11]:= Table @ FindRoot @ myEqn, 8 x, startValues @@ i DD<D , 8 i, Length @ startValues D<D Out[11]= 88 x 1.25235 < , 8 x 3.5953 << In[12]:= Clear @ myEqn, myplot, xycoord, startValues D FindMinimum and FindMaximum Example Find the third largest maximum of the following equation for a damped harmonic oscillator: x''+0.4x'|x'|+4x=0, x(t=0)=-1,x'(0)=0. In[13]:= NDSolve @8 x'' @ t D + 0.4 x' @ t D Abs @ x' @ t DD + 4 x @ t D m 0, x @ 0 D m− 1., x' @ 0 D m 0 < ,x, 8 t, 0, 15 <D ; In[14]:= xt @ t_ D = x @ t . % @@ 1 DD Out[14]= InterpolatingFunction @88 0., 15. << , <> D@ t D class11.nb 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
In[15]:= ClickPane @ Plot @ xt @ t D , 8 t, 0, 15 <D , H txcoord L D Out[15]= 2 4 6 8 10 12 14 - 1.0 - 0.5 0.5 Click on the curve at the third largest maximum point, then evaluate
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course PHYS 5900 taught by Professor Lin during the Fall '09 term at East Carolina University .

Page1 / 25

class11 - PHYS 5900 Class 11 (9/18/2009Fri) Zi-Wei Lin...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online