Solver Graphing Linear Equations
Algebra
->
Algebra
->
Linear-equations
-> Solver Graphing Linear Equations
Log On
Ad:
Algebra Solved!™
: algebra software solves algebra homework problems with step-by-step help!
Ad:
Algebrator™
solves your algebra problems and provides step-by-step explanations!
Algebra: Linear Equations, Graphs, Slope
Solvers
Lessons
Problems, free tutors
Quiz
In Depth
Source code of 'Graphing Linear Equations'
This Solver (Graphing Linear Equations)
was created by by
jim_thompson5910(13794)
:
View Source
,
Show
,
Put on YOUR site
About jim_thompson5910
:
==section input Please choose which form you will use *[choice form standard slope-intercept]. For instance if you have a problem similar to {{{2x+3y=5}}} then choose "standard". If you have something similar to {{{y=2x+5}}} then choose "slope-intercept" Input the equation in standard form {{{Ax+By=C}}} *[input a=1]x+ *[input b=2]y= *[input c=3] or Enter your equation in slope-intercept form ({{{y=mx+b}}} form) y=*[input m_input=2]x + *[input b_input=1] note: make sure you choose the correct form from the drop box above. Also, if you have decimal coefficients, convert them to fractions. For instance, if you have {{{.2x+.1y=10}}}, then input it as {{{(1/5)x+(1/10)y=10}}} ==section solution perl sub clean{ @array=(); @hold=@array; @array=split(//,$string); $size=@array; for($i=0;$i<3;$i++) { for($count=0;$count<$size;$count++) {if(($array[$count]=~/\+/)&&($array[$count+1]=~/\-/)) { delete $array[$count]; }} for($count=0;$count<$size;$count++) {if((($array[$count]=~/\+/)&&($array[$count+1]=~/\(/))&&($array[$count+2]=~/\-/)) {delete $array[$count]; delete $array[$count+1]; }} for($count=0;$count<$size;$count++) {if(($array[$count]=~/\-/)&&($array[$count+1]=~/\+/)) { delete $array[$count+1]; }} for($count=0;$count<$size;$count++) {if(($array[$count]=~/\-/)&&($array[$count+1]=~/\-/)) {delete $array[$count]; $array[$count+1]="+";}} for($count=0;$count<$size;$count++) {if((($array[$count]=~/\-/)&&($array[$count+1]=~/\(/))&&($array[$count+2]=~/\-/)) {delete $array[$count+2]; $array[$count]="+"; }} for($count=0;$count<$size;$count++) {if((($array[$count]=~/\//)&&($array[$count+1]=~/1/))&&(($array[$count+2]=~/\)/)&&($array[$count+3]=~/\*/))) {delete $array[$count]; delete $array[$count+1]; delete $array[$count+2]; for($count1=$count+2;$count1>=0;$count1--) {if($array[$count1]=~/\(/) {delete $array[$count1]; $count1=-1;} } }} for($count=0;$count<$size;$count++) {if((($array[$count]=~/\//)&&($array[$count+1]=~/1/))&&($array[$count+2]=~/\+/)) {delete $array[$count]; delete $array[$count+1]; }} for($count=0;$count<$size;$count++) {if((($array[$count]=~/\//)&&($array[$count+1]=~/1/))&&($array[$count+2]!~/\d/)) {delete $array[$count]; delete $array[$count+1]; }} } #$string=@array; $string=@hold; } sub invert{ $temp=$arr1[0]; $arr1[0]=$arr1[2]; $arr1[2]=$temp; return ($arr1[0], "/", $arr1[2]); } sub mult{ $temp1=$arr1[0]*$arr2[0]; $temp2=$arr1[2]*$arr2[2]; #$temp1=$numer1*$numer2; #$temp2=$denom1*$denom2; return ($temp1,"/",$temp2); } sub add{ if(($arr1[2]!=$arr2[2])&&(($arr1[2]!=0)&&($arr2[2]!=0))) { for($count=1;$count<abs($arr1[2]*$arr2[2]);$count++) {if(($arr1[2]%$count==0)&&($arr2[2]%$count==0)) {$gcf=$count;} } $lcm=($arr1[2]*$arr2[2])/$gcf; $temp=$lcm/$arr1[2]; $arr1[0]=($lcm/$arr1[2])*$arr1[0]; $arr2[0]=($lcm/$arr2[2])*$arr2[0]; $arr1[2]=($lcm/$arr1[2])*$arr1[2]; $arr2[2]=($lcm/$arr2[2])*$arr2[2]; } $tempfrac1[0]=$arr1[0]+$arr2[0]; $tempfrac2[0]=$arr1[2]; return ($tempfrac1[0],"/",$tempfrac2[0]); } sub subtract{ if(($arr1[2]!=$arr2[2])&&(($arr1[2]!=0)&&($arr2[2]!=0))) { for($count=1;$count<abs($arr1[2]*$arr2[2]);$count++) {if(($arr1[2]%$count==0)&&($arr2[2]%$count==0)) {$gcf=$count;} } $lcm=($arr1[2]*$arr2[2])/$gcf; $temp=$lcm/$arr1[2]; $arr1[0]=($lcm/$arr1[2])*$arr1[0]; $arr2[0]=($lcm/$arr2[2])*$arr2[0]; $arr1[2]=($lcm/$arr1[2])*$arr1[2]; $arr2[2]=($lcm/$arr2[2])*$arr2[2]; } $tempfrac1[0]=$arr1[0]-$arr2[0]; $tempfrac2[0]=$arr1[2]; return ($tempfrac1[0],"/",$tempfrac2[0]); } sub reduce{ if($arr1[2]!=0) { $store=$arr1[0]/$arr1[2]; if($store>0) { $arr1[0]=abs($arr1[0]); $arr1[2]=abs($arr1[2]); } if(($store<0)&&($arr1[2]<0)) { $arr1[0]=0-$arr1[0]; $arr1[2]=abs($arr1[2]); } if($arr1[0]%$arr1[2]==0) { $quotient=$arr1[0]/$arr1[2]; return ($quotient,"/",1); } } for ($i=abs($arr1[0]*$arr1[2]); $i>1; $i--) { if (($arr1[0]%$i==0)&&($arr1[2]%$i==0)) { $arr1[0]/=$i; $arr1[2]/=$i; $j=$i; } } return ($arr1[0],"/",$arr1[2]); } if($form eq 'standard') { @a, @b, @c; if($a=~/\//) {@a=split(/\//,$a); $a[2]=$a[1]; $a[1]="/";} if($a!~/\//) {$a[0]=$a; $a[1]="/"; $a[2]=1;} if($b=~/\//) {@b=split(/\//,$b); $b[2]=$b[1]; $b[1]="/";} if($b!~/\//) {$b[0]=$b; $b[1]="/"; $b[2]=1;} if($c=~/\//) {@c=split(/\//,$c); $c[2]=$c[1]; $c[1]="/";} if($c!~/\//) {$c[0]=$c; $c[1]="/"; $c[2]=1;} if($b[2]!=0) {$b2=$b[0]/$b[2];} if($a[2]!=0) {$a2=$a[0]/$a[2];} if($c[2]!=0) {$c2=$c[0]/$c[2];} if($b==0) {@arr1=($c,"/",$a); @fraction=reduce(); $string="@fraction"; $string=clean(); print "Since we have the equation {{{$a*x+$b*y=$c}}} we really have {{{$a*x=$c}}} {{{$a*x=$c}}} Start with the given equation {{{x=$c/$a}}} Divide both sides by $a {{{x=@array}}} Reduce So this means we have a vertical line at {{{x=@array}}} {{{ graph( 300, 200, -6, 5, -10, 10, 1000(x-$c/$a)) }}}"; return undef; } $string="(@a)*x+(@b)*y=@c"; $string=clean(); @initial=@array; print " {{{@array}}}Start with the given equation "; @abs=@a; $abs[0]=abs($abs[0]); $string="(@abs)*x"; $string=clean(); @abs=@array; $string="(@b)*y=@c-(@a)*x"; $string=clean(); $size=@array; print " {{{@array}}} ", ($a[0]>0) ? "Subtract {{{@abs}}} from both sides": "Add {{{@abs}}} to both sides"; @arr1=@b; @temp_b=invert(); @arr1=@temp_b; @temp_b=reduce(); $string="y=(@temp_b)(@c-(@a)*x)"; $string=clean(); print " {{{@array}}} Multiply both sides by "; $string="@temp_b"; $string=clean(); @distribute=@array; print "{{{@distribute}}}"; $string="y=(@temp_b)(@c)-(@temp_b)(@a)x)"; $string=clean(); print " {{{@array}}} Distribute {{{@distribute}}}"; @arr1=@temp_b; @arr2=@c; @temp_c=mult(); @arr1=@temp_b; @arr2=@a; @temp_a=mult(); $string="y=@temp_c-(@temp_a)x"; $string=clean(); print " {{{@array}}} Multiply"; @arr1=("0","/",$temp_a[2]); @arr2=@temp_a; @temp_a=subtract(); $string="y=(@temp_a)*x+@temp_c"; $string=clean(); print " {{{@array}}} Rearrange the terms"; @arr1=@temp_a; @temp_a=reduce(); @arr1=@temp_c; @temp_c=reduce(); $string="y=(@temp_a)*x+@temp_c"; $string=clean(); print " {{{@array}}} Reduce any fractions"; @final=@array; print " So the equation is now in slope-intercept form ({{{y=mx+b}}}) where "; $string="@temp_a"; $string=clean(); $slope1="@temp_a"; if($slope1=~/\//) {@slope=split(/\//,$slope1);} if($slope1!~/\//) {$slope .="/1"; @slope=split(/\//,$slope1);} @slope=($slope[0],"/",$slope[1]); print "{{{m=@array}}} (the slope) and "; $string="@temp_c"; $string=clean(); @arr1=@temp_c; @y_int=reduce(); print "{{{b=@array}}} (the y-intercept)"; print " So to graph this equation lets plug in some points"; $m=$temp_a[0]/$temp_a[2]; $int=$temp_c[0]/$temp_c[2]; $xint=(0-$int)/($m); @arr1=@temp_a; @m=invert(); @arr1=("0","/",$temp_c[2]); @arr2=@temp_c; @x_int=subtract(); @arr1=@x_int; @arr2=@m; @x_int=mult(); @arr1=@x_int; @x_int=reduce(); $tick=0; if(($temp_a[0]%$temp_a[2]!=0)&&($temp_c[0]%$temp_c[2]!=0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } #abs($y_temp1[0]+$y_temp1[1])/2 if(($temp_a[0]%$temp_a[2]!=0)&&($temp_c[0]%$temp_c[2]==0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } if(($temp_a[0]%$temp_a[2]==0)&&($temp_c[0]%$temp_c[2]!=0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } $tick=0; if(($temp_a[0]%$temp_a[2]==0)&&($temp_c[0]%$temp_c[2]==0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } $store=abs($x_max-$x_min); $store1=($y_max-$y_min); $rad=$store/150; if(length($x[0])==0) {$x[0]=0;} if((length($x[1])==0)&&($x[0]!=1)) {$x[1]=1;} if((length($x[1])==0)&&($x[0]==1)) {$x[1]=0;} if($x[0]<$x[1]) {$x_min=$x[0]-10; $x_max=$x[1]+10; } if($x[1]<$x[0]) {$x_min=$x[1]-10; $x_max=$x[0]+10; } $y_temp1[0]=$m*$x[0]+$int; $y_temp1[1]=$m*$x[1]+$int; if($y_temp1[0]<$y_temp1[1]) {$y_min=$y_temp1[0]-10; $y_max=$y_temp1[1]+10; } if($y_temp1[1]<$y_temp1[0]) {$y_min=$y_temp1[1]-10; $y_max=$y_temp1[0]+10; } print " Plug in x=$x[0]"; $string="y=(@temp_a)*($x[0])+@temp_c"; $string=clean(); print " {{{@array}}}"; @mult_a=($x[0], "/",1); @arr1=@temp_a; @arr2=@mult_a; @mult_a=mult(); $string="y=@mult_a+@temp_c"; $string=clean(); print " {{{@array}}} Multiply"; @arr1=@mult_a; @arr2=@temp_c; @add_c=add(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Add"; if($add_c[2]!=1) { @arr1=@add_c; @add_c=reduce(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Reduce";} $size=@add_c; if($size>1) {$y[2]=$add_c[0]/$add_c[2];} if($size==1) {$y[2]=$add_c[0]/$add_c[2];} print " So here's one point ($x[0],$y[2]) {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} "; print "Now lets find another point Plug in x=$x[1]"; $string="y=(@temp_a)*($x[1])+@temp_c"; $string=clean(); print " {{{@array}}}"; @mult_a=($x[1], "/",1); @arr1=@temp_a; @arr2=@mult_a; @mult_a=mult(); $string="y=@mult_a+@temp_c"; $string=clean(); print " {{{@array}}} Multiply"; @arr1=@mult_a; @arr2=@temp_c; @add_c=add(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Add"; if($add_c[2]!=1) { @arr1=@add_c; @add_c=reduce(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Reduce";} $size=@add_c; if($size>1) {$y[4]=$add_c[0]/$add_c[2];} if($size==1) {$y[4]=$add_c[0]/$add_c[2];} print " So here's another point ($x[1],$y[4]). Add this to our graph {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} Now draw a line through these points"; #$store=$m*(-10)+$int; #$store=$m*(10)+$int; print " {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} So this is the graph of {{{@final}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) So from the graph we can see that the slope is {{{@slope}}} (which tells us that in order to go from point to point we have to start at one point and ", ($slope[0]>0) ? "go up $slope[0] units and to the right $slope[2] units to get to the next point)": "go down $slope[0] units and to the right $slope[2] units to get to the next point),"; print " the y-intercept is (0,{{{$int}}})"; if($y_int[2]!=1) {print " ,or (0,{{{@y_int}}}), ";} print "and the x-intercept is ({{{$xint}}},0) "; if($x_int[2]!=1) {print " ,or ({{{@x_int}}},0) "}; print ". So all of this information verifies our graph."; $string="@y_int"; $string=clean(); @b_array=@array; $x[0]=0; $y[2]=$m*(0)+$int; $x[1]=$slope[2]; $y[4]=$slope[0]+$y[2]; $x_min=$x[0]-10; $x_max=$x[1]+10; if($y[2]>$y[4]) {$y_min=$y[4]-10; $y_max=$y[2]+10;} if($y[4]>$y[2]) {$y_min=$y[2]-10; $y_max=$y[4]+10;} $store=abs($x_max-$x_min); $store1=($y_max-$y_min); $rad=$store/150; $temp_abs=abs($slope[0]); print " We could graph this equation another way. Since {{{b=@b_array}}} this tells us that the y-intercept (the point where the graph intersects with the y-axis) is (0,{{{@b_array}}}). So we have one point (0,{{{@b_array}}}) {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} Now since the slope is {{{@slope}}}, this means that in order to go from point to point we can use the slope to do so. So starting at (0,{{{@b_array}}}), we can go ", ($slope[0]>0)? "up $temp_abs units ":"down $temp_abs units "; print " {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ), blue( arc( 0, $y[2]+($slope[0]/2), 2, $slope[0], 90, 270 ) ) )}}}"; $x[1]=$slope[2]; $y[4]=$slope[0]+$y[2]; if($slope[0]>0) {print " and to the right $slope[2] units to get to our next point {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( arc( 0, $y[2]+($slope[0]/2), 2, $slope[0], 90, 270 ) ), blue( arc( ($slope[2]/2), $y[4], $slope[2], 2, 180, 360 ) ) )}}}"; print " Now draw a line through those points to graph {{{@final}}} {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ), blue( arc( 0, $y[2]+($slope[0]/2), 2, $slope[0], 90, 270 ) ), blue( arc( ($slope[2]/2), $y[4], $slope[2], 2, 180, 360 ) ) )}}} So this is the graph of {{{@final}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) "; } if($slope[0]<0) {print " and to the right $slope[2] units to get to our next point {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( arc( 0, $y[2]+($slope[0]/2), 2, $slope[0], 90, 270 ) ), blue( arc( ($slope[2]/2), $y[4], $slope[2], 2, 0, 180 ) ) )}}}"; print " Now draw a line through those points to graph {{{@final}}} {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ), blue( arc( 0, $y[2]+($slope[0]/2), 2, $slope[0], 90, 270 ) ), blue( arc( ($slope[2]/2), $y[4], $slope[2], 2, 0, 180 ) ) )}}} So this is the graph of {{{@final}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) "; } } if($form eq 'slope-intercept') { @m_input, @b_input; if($m_input=~/\//) {@m_input=split(/\//,$m_input); $m_input[2]=$m_input[1]; $m_input[1]="/";} if($m_input!~/\//) {$m_input[0]=$m_input; $m_input[1]="/"; $m_input[2]=1;} if($b_input=~/\//) {@b_input=split(/\//,$b_input); $b_input[2]=$b_input[1]; $b_input[1]="/";} if($b_input!~/\//) {$b_input[0]=$b_input; $b_input[1]="/"; $b_input[2]=1;} @temp_a=@m_input; @temp_c=@b_input; $string="y=(@m_input)*x+@b_input"; $string=clean(); @initial=@array; print "In order to graph {{{@initial}}} we only need to plug in two points to draw the line So lets plug in some points"; $m=$temp_a[0]/$temp_a[2]; $int=$temp_c[0]/$temp_c[2]; $xint=(0-$int)/($m); @arr1=@temp_a; @m=invert(); @arr1=("0","/",$temp_c[2]); @arr2=@temp_c; @x_int=subtract(); @arr1=@x_int; @arr2=@m; @x_int=mult(); @arr1=@x_int; @x_int=reduce(); $tick=0; $y_temp1[0]=$m*$x[0]+$int; $y_temp1[1]=$m*$x[1]+$int; if(($temp_a[0]%$temp_a[2]!=0)&&($temp_c[0]%$temp_c[2]!=0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } if(($temp_a[0]%$temp_a[2]!=0)&&($temp_c[0]%$temp_c[2]==0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } if(($temp_a[0]%$temp_a[2]==0)&&($temp_c[0]%$temp_c[2]!=0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } $y_temp1[0]=$m*$x[0]+$int; $y_temp1[1]=$m*$x[1]+$int; $tick=0; if(($temp_a[0]%$temp_a[2]==0)&&($temp_c[0]%$temp_c[2]==0)) {for($i=-9;$i<=9;$i++) { $temp=$m*$i+$int; if(($temp!~/\./)&&(abs($temp)<10)) {$x[$tick]=$i; $tick++;} } } if(length($x[0])==0) {$x[0]=0;} if((length($x[1])==0)&&($x[0]!=1)) {$x[1]=1;} if((length($x[1])==0)&&($x[0]==1)) {$x[1]=0;} if($x[0]<$x[1]) {$x_min=$x[0]-10; $x_max=$x[1]+10; } if($x[1]<$x[0]) {$x_min=$x[1]-10; $x_max=$x[0]+10; } $y_temp1[0]=$m*$x[0]+$int; $y_temp1[1]=$m*$x[1]+$int; if($y_temp1[0]<$y_temp1[1]) {$y_min=$y_temp1[0]-10; $y_max=$y_temp1[1]+10; } if($y_temp1[1]<$y_temp1[0]) {$y_min=$y_temp1[1]-10; $y_max=$y_temp1[0]+10; } $store=abs($x_max-$x_min); $store1=($y_max-$y_min); $rad=$store/150; print " Plug in x=$x[0]"; $string="y=(@temp_a)*($x[0])+@temp_c"; $string=clean(); print " {{{@array}}}"; @mult_a=($x[0], "/",1); @arr1=@temp_a; @arr2=@mult_a; @mult_a=mult(); $string="y=@mult_a+@temp_c"; $string=clean(); print " {{{@array}}} Multiply"; @arr1=@mult_a; @arr2=@temp_c; @add_c=add(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Add"; if($add_c[2]!=1) { @arr1=@add_c; @add_c=reduce(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Reduce";} $size=@add_c; if($size>1) {$y[2]=$add_c[0]/$add_c[2];} if($size==1) {$y[2]=$add_c[0]/$add_c[2];} print " So here's one point ($x[0],$y[2]) {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} "; print "Now lets find another point Plug in x=$x[1]"; $string="y=(@temp_a)*($x[1])+@temp_c"; $string=clean(); print " {{{@array}}}"; @mult_a=($x[1], "/",1); @arr1=@temp_a; @arr2=@mult_a; @mult_a=mult(); $string="y=@mult_a+@temp_c"; $string=clean(); print " {{{@array}}} Multiply"; @arr1=@mult_a; @arr2=@temp_c; @add_c=add(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Add"; if($add_c[2]!=1) { @arr1=@add_c; @add_c=reduce(); $string="y=@add_c"; $string=clean(); print " {{{@array}}} Reduce";} $size=@add_c; if($size>1) {$y[4]=$add_c[0]/$add_c[2];} if($size==1) {$y[4]=$add_c[0]/$add_c[2];} print " So here's another point ($x[1],$y[4]). Add this to our graph {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} Now draw a line through these points"; #$store=$m*(-10)+$int; #$store=$m*(10)+$int; print " {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], .15, 1.5 )), blue( circle( $x[1],$y[4], .1, 1.5 ) ), blue( circle( $x[0],$y[2], .15, 1.5 )), blue( circle( $x[0],$y[2], .1, 1.5 ) ) )}}} So this is the graph of {{{@initial}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) So from the graph we can see that the slope is {{{@m_input}}} (which tells us that in order to go from point to point we have to start at one point and ", ($m_input[0]>0) ? "go up $m_input[0] units and to the right $m_input[2] units to get to the next point)": "go down $m_input[0] units and to the right $m_input[2] units to get to the next point),"; print " the y-intercept is (0,{{{$int}}})"; if($b_input[2]!=1) {print " ,or (0,{{{@b_input}}}), ";} print "and the x-intercept is ({{{$xint}}},0) "; if($x_int[2]!=1) {print " ,or ({{{@x_int}}},0) "}; $string="@b_input"; $string=clean(); @b_array=@array; $string="@m_input"; $string=clean(); @m_array=@array; $y[2]=$b_input[0]/$b_input[2]; $x[0]=0; $x[1]=$m_input[2]; $y[4]=$m_input[0]+$y[2]; $x_min=$x[0]-10; $x_max=$x[1]+10; if($y[2]>$y[4]) {$y_min=$y[4]-10; $y_max=$y[2]+10;} if($y[4]>$y[2]) {$y_min=$y[2]-10; $y_max=$y[4]+10;} $store=abs($x_max-$x_min); $store1=($y_max-$y_min); $rad=$store/150; $temp_abs=abs($m_input[0]); print " We could graph this equation another way. Since {{{b=@b_array}}} this tells us that the y-intercept (the point where the graph intersects with the y-axis) is (0,{{{@b_array}}}). So we have one point (0,{{{@b_array}}}) {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ) )}}} Now since the slope is {{{@m_input}}}, this means that in order to go from point to point we can use the slope to do so. So starting at (0,{{{@b_array}}}), we can go ", ($m_input[0]>0)? "up $temp_abs units ":"down $temp_abs units "; print " {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ) blue( arc( 0, $y[2]+($m_input[0]/2), 2, $m_input[0], 90, 270 ) ) )}}}"; if($m_input[0]>0) {print " and to the right $m_input[2] units to get to our next point {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[1],$y[4], $rad)), blue( circle( $x[1],$y[4], $rad-0.05 ) ), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ), blue( arc( 0, $y[2]+($m_input[0]/2), 2, $m_input[0], 90, 270 ) ), blue( arc( ($m_input[2]/2), $y[4], $m_input[2], 2, 180, 360 ) ) )}}}"; print " Now draw a line through those points to graph {{{@initial}}} {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], $rad)), blue( circle( $x[1],$y[4], $rad-0.05 ) ), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ), blue( arc( 0, $y[2]+($m_input[0]/2), 2, $m_input[0], 90, 270 ) ), blue( arc( ($m_input[2]/2), $y[4], $m_input[2], 2, 180, 360 ) ) )}}} So this is the graph of {{{@initial}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) "; } if($m_input[0]<0) {print " and to the right $m_input[2] units to get to our next point {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid(1), blue( circle( $x[1],$y[4], $rad)), blue( circle( $x[1],$y[4], $rad-0.05 ) ), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ), blue( arc( 0, $y[2]+($m_input[0]/2), 2, $m_input[0], 90, 270 ) ), blue( arc( ($m_input[2]/2), $y[4], $m_input[2], 2, 0, 180 ) ) )}}}"; print " Now draw a line through those points to graph {{{@initial}}} {{{drawing( 600, 600, $x_min,$x_max, $y_min, $y_max, grid( 1 ), line($x_min-10,$m*($x_min-10)+$int,$x_max+10,$m*($x_max+10)+$int), blue( circle( $x[1],$y[4], $rad)), blue( circle( $x[1],$y[4], $rad-0.05 ) ), blue( circle( $x[0],$y[2], $rad)), blue( circle( $x[0],$y[2], $rad-0.05) ), blue( arc( 0, $y[2]+($m_input[0]/2), 2, $m_input[0], 90, 270 ) ), blue( arc( ($m_input[2]/2), $y[4], $m_input[2], 2, 0, 180 ) ) )}}} So this is the graph of {{{@initial}}} through the points ($x[0],$y[2]) and ($x[1],$y[4]) "; } } ==section output ==section check angle=40 angle1=50