-- Take the first derivative of the function with respect to the variable.
-- Set the derivative equal to zero.
-- Solve the equation [ first derivative = 0 ] for the variable.
-- The solution for the variable, along with the value of the function for that value of
the variable, gives you a point that is either a minimum or a maximum of the function.
By looking at another point just before or just after that value of the variable, you
should be able to decide whether it's a max or a min. If you still can't tell which it
is, then there's a way to do it that involves the second derivative of the function,
but I don't think I want to go there just now.
* * * * *
The above is an excellent answer for basic calculus but there are some limitations. The method requires the function to be differentiable throughout its domain. As a result it cannot deal effectively with discontinuities.
Also, it cannot deal with the extrema being at either end of the domain. This can happen in two ways which are illustrated below:
Consider f(x) = 2x+3 for 0<x<1. Trivially, the minimum and maximum values, (3 and 5) are limiting values of the function over its domain and are never actually attained. It is easy enough to sketch the graph and conclude that the minimum value of 3 is attained when x = 0 and the maximum value, of 5 is attained at x = 1. Except that these values of x are in the domain for x. But the derivative of f(x) is 2, and f'(x) = 0 simply gives 2 = 0 and THAT has no solution!
But I saved the biggest problem to the last. Consider f(x) = x3 - x where the domain is the whole of the real line. Differentiating it gives f'(x) = 3x2 - 1. And solving f'(x) = 0 gives x = ±sqrt(1/3). Substituting these values of x in f(x) you can evaluate the "maximum" and "minimum". Why the quotation marks? Because what you have calculated are the local extrema, not the global extrema. The true minimum for the function is "minus infinity" and the maximum is "plus infinity". The cubic curve starts at "minus infinity", its gradient gradually deceases until, at x = -sqrt(1/3) it levels off and starts falling. It falls until it reaches +sqrt(1/3) and then starts rising again and keeps rising - forever. So x = -sqrt(1/3) was only a turning point: a local extremum, not a global one. Likewise the local minimum at x = +sqrt(1/3).
Chat with our AI personalities
take the max plus the min and divide the anser by to
max=number min=number counter=1 start while(counter<=3) read number start if max<number max=number else if min>number min=number end while write max write min /*modify the counter switch according to the number of values being compared if required*/
#include<stdio.h> #include<conio.h> void main(void) { int max=0,min=0; int temp; int n,i; clrscr(); printf("what is the lenght of number set?\n"); scanf("%d",&n); printf("\n\nNow enter the numbers\n"); for(i=1;i<=n;i++) { scanf("%d",&temp); if(temp>max)max=temp; if(i==1)min=temp; if(temp<min)min=temp; } printf("\n\nThe range of set is %d",max-min); getch(); }
Add the min and max numbers and divide that sum by two. Here is an example: The data is {1, 1, 3, 50,60} The midrange is 30.5 since that is is (1 + 60) / 2 = 30.5.
You would calculate 2.3/7 . That number will be the rate in km per min.