[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 57 KB, 480x480, 1289890310944.jpg [View same] [iqdb] [saucenao] [google]
2500698 No.2500698 [Reply] [Original]

so /sci/ i am now in calc 2 and need to figure out how to use a computer algebra system... anybody know how?

i am trying to figure out the integral of cos(x^2) from 0 to 1 and the error must be <= 10^-6... i have found that N=409 but don't know where to go from there to calculate the definite integral

>> No.2500755
File: 312 KB, 975x1120, 1260056589994.jpg [View same] [iqdb] [saucenao] [google]
2500755

tits bump

>> No.2500771

>need to figure out how to use a computer algebra system

Step 1) http://www.wolframalpha.com
Step 2) type problem into box
Step 3) Hit enter
Step 4) Write down answer

>> No.2500779

> that N=409
for what methode?

http://www.mathworks.com/help/techdoc/ref/trapz.html

>> No.2500790

http://www.mathworks.com/help/techdoc/ref/quad.html

>> No.2500791

>>2500779

midpoint rule

>>2500771
>>2500771

dont know what the syntax is to calculate f(1) thru f(409)

>> No.2500793

http://www.wolframalpha.com/input/?i=integrate+cos%28x^2%29+from+0+to+1

>> No.2500818

>> quad(@(x)sin(x).^2,0,1)
ans =
0.272675645306192

>> No.2500825

>>2500793
>>2500793

doesn't help me calculate the error

>> No.2500857

What kind of faggot uses midpoint? are you even trying?

#include <stdio.h>
#include <math.h>

double f(double x){
return sin(x)*sin(x);
}

double rectangle_integrate(double a, double b, int subintervals){
double result;
double interval;
int i;

interval=(b-a)/subintervals;
result=0;

for(i=1;i<=subintervals;i++){
result+=f(a+interval*(i-0.5));
}
result*=interval;

return result;
}

int main(void){
double integral;
integral=rectangle_integrate(0,1,409);
printf("The value of the integral is: %f \n",integral);
return 0;
}

>> No.2500878
File: 31 KB, 398x241, girls_laughing.jpg [View same] [iqdb] [saucenao] [google]
2500878

>>2500857
>he doesn't pass a function pointer into the rectangle_integrate function!

>> No.2500889

function [F] = rectangle( a, b, n )
%*******************************************************
% This function computes an approximation to a definite
% integral using rectangle method. Input variables are
% a=initial value, b=end value, n=number of iterations.
% Author: Anonymous Thief
%*******************************************************
h = ( b - a ) / n ;
F = 0 ;
% x = [0 , h*[1 : n-1]]; % for the left corner: O(h)
x = [.5*h,.5*h+h*[1:n-1]]; % for the center:O(h²)
% x = [1:n]*h; % for the right corner: O(h)
for i = 1 : n
F = F + f( x(i) ) * h ;
end
function [func] = f( x )
func = sin(x).^2 ; %specify your function here
end
end

>> No.2500966 [DELETED] 

>>2500878
>happy?

#include <stdio.h>
#include <math.h>

double f(double x){
return sin(x)*sin(x);
}

double rectangle_integrate(double a, double b, int subintervals, double (*f)(double,double) ){
double result;
double interval;
int i;

interval=(b-a)/subintervals;
result=0;

for(i=1;i<=subintervals;i++){
result+=f(a+interval*(i-0.5));
}
result*=interval;

return result;
}

int main(void){
double integral;
integral=rectangle_integrate(0,1,409,f);
printf("The value of the integral is: %f \n",integral);
return 0;
}

>> No.2500973

>>2500878
>happy?

#include <stdio.h>
#include <math.h>

double f(double x){
return sin(x)*sin(x);
}

double rectangle_integrate(double a, double b, int subintervals, double (*f)(double) ){
double result;
double interval;
int i;

interval=(b-a)/subintervals;
result=0;

for(i=1;i<=subintervals;i++){
result+=f(a+interval*(i-0.5));
}
result*=interval;

return result;
}

int main(void){
double integral;
integral=rectangle_integrate(0,1,409,f);
printf("The value of the integral is: %f \n",integral);
return 0;
}