113 - Topic 07 - Solving Equations Visually

351 days ago by Professor102

John Travis

Mississippi College

This would be a nice single cell "hint" for a corresponding WebWork problem.

%auto var('x') html('Where do $\sin(bx)$ and $\sin(bx+a)$ have the same y-value?') html('<BR><BR>Adjust the x value on the slider below to see when the points have the same y values.') @interact(layout=dict(top=[['b','a'],['x0']])) def _(b=input_box(.5,width=5),a=[1/4,1/2,3/4,1,5/4,3/2,7/4,2],x0=slider(1.57-1.5,1.58+1.5,0.025,label='$x_0$')): G = plot(sin(b*x),(x,0,pi/b)) s0 = sin(b*x0) s1 = sin(b*x0+a) s2 = min(s0,s1)*0.9 d = b/a G += point2d((x0,s0),size=20,color='red') G += point2d((x0+a/b,s1),size=20,color='red') G += line([(0,s0),(pi/b,s0)],alpha=0.1) G += line([(0,s1),(pi/b,s1)],alpha=0.1) G += arrow2d((x0,s2),(x0+a/b,s2),color='green',head=2) G += text('$\\frac{\pi}{%s}$'%str(b.n(digits=3)),(pi/(b),-0.1),fontsize=20) G += text('$%s$'%str(d.n(digits=3)),(x0+a/(2*b),s2+0.02),fontsize=10) G += text('sin(bx)',(x0,s0))+text('sin(bx+a)',(x0+a/b,s1)) show(G) 
       
$x_0$ 

Click to the left again to hide and once more to show the dynamic interactive window

%hide %auto var('x') html('Solving $f(x) = g(x)$ visually') @interact(layout=dict(top=[['f','g']],right=[['x0'],['zoom']],bottom=[['a','b']])) def _(f=input_box(default=sin(x),label='$f(x)$',width=40),g=input_box(default=sin(x+1),label='$g(x)$',width=40),a=input_box(0,width=10),b=input_box(pi,width=10),x0=slider(0,3,0.01,label='$x_0$'),zoom=(false)): if zoom: G = plot(f,(x,x0-0.2,x0+0.2),color='green')+plot(g,(x,x0-0.2,x0+0.2),color='purple') else: G = plot(f,(x,a,b),color='green')+plot(g,(x,a,b),color='purple') G += point2d((x0,f(x=x0)),size=20,color='red') G += point2d((x0,g(x=x0)),size=20,color='red') show(G) 
       
$f(x)$  $g(x)$ 
$x_0$ 
zoom 

Click to the left again to hide and once more to show the dynamic interactive window

var('x,a,b') b=pi solve(sin(b*x)==sin(b*x+a),x) 
       
[sin(pi*x) == sin(pi*x + a)]
[sin(pi*x) == sin(pi*x + a)]
n(sin(2.07)-sin(1.07)) 
       
0.000763558724396485
0.000763558724396485