Numerical integration: Difference between revisions

Content deleted Content added
m Using lang tags now.
m A couple little mess ups
Line 205: Line 205:
{{trans|Java}}
{{trans|Java}}


<lang basic> FUNCTION leftRect(a, b, n)
<lang qbasic> FUNCTION leftRect(a, b, n)
h = (b - a) / n
h = (b - a) / n
sum = 0
sum = 0
Line 699: Line 699:
inter n [] = x : inter (n-1) xs
inter n [] = x : inter (n-1) xs
inter n [y] = (x+y) : inter (n-1) xs
inter n [y] = (x+y) : inter (n-1) xs
inter n (y:ys) = y : inter n ys</lang>>
inter n (y:ys) = y : inter n ys</lang>


And now we can just define
And now we can just define
Line 730: Line 730:
=={{header|Java}}==
=={{header|Java}}==
The function in this example is assumed to be <tt>f(double x)</tt>.
The function in this example is assumed to be <tt>f(double x)</tt>.
<lang java> public class Integrate{
<lang java5> public class Integrate{
public static double leftRect(double a, double b, double n){
public static double leftRect(double a, double b, double n){
double h = (b - a) / n;
double h = (b - a) / n;
Line 777: Line 777:
}
}
//assume f(double x) elsewhere in the class
//assume f(double x) elsewhere in the class
}>/lang>
}</lang>


=={{header|Logo}}==
=={{header|Logo}}==