codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
class limit { public static void main (String[] args) { double res = limit( 2 ); System.out.println(" O limite é : " + res ); } public static double f (double x) { return ( x / ( x*x + 1) ); //return 4 * ( ((x*x) - 4 ) / (x - 2)); } public static double poslimit( double a ) { int a_n = (int) Math.round(a * 1000); double minn = 999999; for(int x=a_n+20;x>a_n;x--) { minn = Math.min(minn, f(x/1000.0)); } System.out.println("LimPos: " + minn ); return minn; } public static double neglimit( double a ) { int a_n = (int) Math.round(a * 1000); double maxn = -999999; for(int x=a_n-20;x<a_n;x++) { maxn = Math.max(maxn, f(x/1000.0)); } System.out.println("LimNeg: " + maxn ); return maxn; } public static double limit( double a ) { double neg = Math.round(neglimit(a)*100)/100.0; double pos = Math.round(poslimit(a)*100)/100.0; return ( neg==pos ) ? neg : Double.NaN; } }
Private
[
?
]
Run code
Submit