Solver Min/Max of a Quadratic Function
Algebra
->
Graphs
-> Solver Min/Max of a Quadratic Function
Log On
Algebra: Graphs, graphing equations and inequalities
Section
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Min/Max of a Quadratic Function'
This Solver (Min/Max of a Quadratic Function)
was created by by
hummingbird(0)
:
View Source
,
Show
,
Put on YOUR site
About hummingbird
:
==section input Find min/max *[input v=x] this equation: *[input a=1]x<SUP>2</SUP>+*[input b=-1]x+*[input c=-2] = 0. You can put negative numbers if you need to use a negative coefficient. The variable that you specify will be used instead of x. ==section solution perl if( $a == 0 ) { print "Come on, this is not a quadratic equation!\n"; return; } print "The min/max of a quadratic equation is always at a point where its first differential is zero. This means that in our case, the value of {{{$v}}} at which the given equation has a <A HREF=Maxima_and_minima.wikipedia>maxima/minima</A> must satisfy the following equation:"; my $soln = -$b/(2*$a) ; my $mm = "maxima"; my $x=(-$b)/2; if($a>0) { $mm = "minima"; } print "{{{2*$a*$v+$b=0}}} => {{{$v = -$b/(2*$a) = $soln}}} This point is a minima if value of coefficient of $v<sup>2</sup> is positive and vice versa. For our function the point $v=$soln is a {{{$mm}}} "; print "The graph of the equation is :\n\n{{{graph( 500, 500, -10, 10, -20, 20, $a*x^2+$b*x+$c )}}}"; print " Alternate method In this method, we will use the <A HREF=Perfect_square.wikipedia>perfect square</A> method. Step one: Make the coefficient of {{{x^2}}} positive by multiplying it by {{{-1}}} in case{{{a<0}}}. Maxima / Minima is decided from the sign of 'a'. If 'a' is positive then we have Minima and for 'a'negative we have Maxima."; my $x=(-$b)/2; if($a>0) { $V=$v; $B=$b; $a=$a; } else { $V=-$v; $B=-$b; $a=-$a; } my $A=sqrt($a); my $Sol =-($B/2)/$A; print " Step two: Now make the perfect square with the same {{{x^2}}} and {{{x}}} coefficient. "; print " {{{($A*x + ($B/2))^2}}} Maxima / Minima lies at the point where this squared term is equal to zero. Hence, =>{{{x=(-($B/2)/$A)= $Sol}}}"; print" This point is a minima if value of coefficient of $v<sup>2</sup> is positive and vice versa. For our function the point $v=$soln is a {{{$mm}}}. For more on this topic, refer to <A HREF=Quadratic_equation.wikipedia>Min/Max of a Quadratic equation</A>."; ==section output soln, mm ==section check a=1 b=-1 c=3 soln=0.5 mm="minima"