CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include <iostream>
using namespace std;
int main()
{
int num , rev=0 , digit ;
cin >> n;

do{

digit=num%10
rev = (rev*10) + digit
num = num/10
} while(num !=0);

if(num==rev)
cout<<"1";

else 
cout<< "0"


}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: D
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<simplecpp>
main_program{
int p,n,i,facval;
float a,x,sum,t,l,q;
cin >>a>>x>>n;
i=1;
facval=1;
p=1;
sum=0.0;
repeat(n){
repeat(p){
facval=facval*i;
i=i+1;
}
q=pow((x-a),p)/facval;
sum=sum+q*sin(x+p*1.5705);
p=p+1;
}
t=sin(a)+sum;
l=sum/sin(a);
cout<<fixed;
cout.precision(6);
cout<<t<<" "<<l;
}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: C
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<iostream>
#include<math.h>

using namespace std;

int factorial(int num){
	if(num==0||num==1){
		return 1;
	}
	int i=num;
	int fact_value=1;
	while(i>=1){
		fact_value=fact_value*i;
		i--;
	}
	return(fact_value);
}

int main(){
	float a,x;
	int n;
	cin>>a>>x;
	cin>>n;
	float value=sin(x);
	float taylor=0;
	float k=x-a;
	cout<<k;
	float h=1;;
	cout<<fixed;
	cout.precision(6);
	float alpha;
	for(int i=1;i<=n;i++){
		h=h*k;
	
		

		
		
		if(i%4==0){
			taylor=taylor+(sin(a)*h)/factorial(i);
			
		}
		else if(i%4==1){
			taylor+=cos(a)*h/factorial(i);
		}
		else if(i%4==2){
			taylor+=(-sin(a))*h/factorial(i);
		}
		else{
			taylor+=(-cos(a))*h/factorial(i;
	cout<<taylor;

	float error=abs(taylor-value)/abs(value);
	cout<<error;
	
}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<simplecpp>
int fact(int n){
int pdt = 1 ;
for(int i=n ; i>=0 ; i = i-1){
pdt=pdt*i;}
return pdt ;
}

main_program{
int a , x , d,s ,n;


cin>>a>>x>>n;

p=sin(x);
for(int i = 0 ; i<= n ; i++){
if(i=0) {pow((x-a),i)*sin(a)/fact(i)}
else if(i=1){pow((x-a),i)*cos(a)/fact(i)}
else if(i=2){-pow((x-a),i)*sin(a)/fact(i)}
else if(i=3){-pow((x-a),i)*cos(a)/fact(i)}
else if(i=4){pow((x-a) ,i)*sin(a)/fact(i)}
}



cout<<a;










}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include <iostream>
#include <cmath>
using namespace std;
int main(){
	double a, x;
	int n;
	cin >> a >> x >> n;
	double taylor_series = sin(a);
	double p = 1;
	for (int i = 1; i <= n; i++){
		p *= (x - a)/i;
		if (i % 4 == 1) taylor_series += cos(a)*p;
		else if (i % 4 == 2) taylor_series += -sin(a)*p;
		else if (i % 4 == 3) taylor_series += -cos(a)*p;
		else taylor_series += sin(a)*p;
	}
	cout << fixed;
	cout.precision(6);
	cout << taylor_series << " ";
	cout << fabs((taylor_series - sin(a))/sin(a));
}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include <iostream>
#include <cmath>
using namespace std;

int main() {
float a , x , n ,s ,m ,e;
const float pi = 3.14;
cin >> a >> x >> n;
s = sin(a);
m = sin(x) ;
e = (m - sin(a))/sin(a);
cout << fixed ;
cout.precision(6);
cout << m << " " << e;}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: D
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double a,x,ea; int n;
cin>>a;
cin>>x;
cin>>n;
ea=0;
for(int i=0;i<=n;i++){
    if(i%4==0){
        int k=i;
        int l;
        for(int j=k-1;j>1;j--){
        if(k!=0){k*=j; l=k;}
        else if(k==0){l=1;}
        }
        ea+=(sin(a)*pow((x-a),i))/l	;
    }
    if(i%4==1){
        int k=i;
        for(int j=k-1;j>1;j--){
        k*=j;
        }
        ea+=(cos(a)*pow((x-a),i))/k;
        }
     if(i%4==2){
        int k=i;
        for(int j=k-1;j>1;j--){
        k*=j;
        }
        ea+=-1*(sin(a)*pow((x-a),i))/k;
    }
     if(i%4==3){
        int k=i;
        for(int j=k-1;j>1;j--){
        k*=j;
        }
        ea+=-1*(cos(a)*pow((x-a),i))/k;
        }


    }

double error=fabs(ea-sin(a))/fabs(sin(a));
cout<<fixed;
cout.precision(6);
cout<<ea;
cout<<" ";
cout<<fixed;
cout.precision(6);
cout<<error;
return 0;
}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: A
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
#include<iostream>
#include<cmath>
using namespace std;

int fact (int x){
int i=1, j=1;
if ( x==0 || x==1 )
{
	return 1;
}
else{

for ( int it=0; it<x; it+=1 )
{
	i=j*i;
	j++;
}
return i;

}

}
int main(){
long double a, x, n, fx, L=1, i=2, j=1;
cin>>a>>x>>n;
cout<<fixed;
cout.precision(6);
fx= sin(a);

while(i<n+1)
{
	if (int(i)%2==1 && int(i)%3!=0)
	{
		long double k = sin(a), z;
		for(int it=0; it<i; it+=1 )
		{
			j=j*(x-a);
		}

		z= (j*k)/ fact(i);
		fx=fx+z;
		j==1;
	}

		if (int(i)%2==0 &&int(i)%4!=0)
	{
		long double k = cos(a), z;
		for(int it=0; it<i; it+=1 )
		{
			j=j*(x-a);
		}

		z= (j*k)/ fact(i);
		fx=fx+z;
		j=1;
	}

		if (int(i)%2==1 && int(i)%3==0)
	{
		long double k = -sin(a), z;
		for(int it=0; it<i; it+=1 )
		{
			j=j*(x-a);
		}

		z= (j*k)/ fact(i);
		fx=fx+z;
		j=1;

	}

		if (int(i)%2==0 && int(i)%4==0)
	{
		long double k = -cos(a), z;
		for(int it=0; it<i; it+=1 )
		{
			j=j*(x-a);
		}

		z= (j*k)/ fact(i);
		fx=fx+z;
		j=1;

	}
	i++;
}

L= fabs(fx-sin(a))/fabs(sin(a));
cout<<fx<<" "<<L;

}

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: C
Problem: The Taylor series of a function f(x) about a is given by f(x) = f(a) + (x-a) f(1)(a) + [(x-a)2/2! ] f(2)(a) + [(x-a)3/3! ] f(3)(a) + ... + (x-a)n/n! f(n)(a) + ...Here n is the number of terms of the Taylor series expansion and f(n)(a)is the n-th derivative of the function f(x) evaluated at x = a. This formula (with only finitely many terms) is very accurate for x close to a.Write a C++ program that takes a, x, and n as inputs from the user and evaluates the Taylor expansion of f(x) = sin x about a up to n terms. The program should also compute the relative absolute error between the value of the Taylor expansion (let us call it ea) w.r.t. the true value which is sin(a). The formula for this is |ea - sin (a)| / |sin(a)|.The program should print the value of the Taylor expansion as well as the relative absolute error. 

Input Format - a - non zero real number, x,and an integer n
Output Format - 
Floating point numbers for the values of the Taylor expansion and the relative error
Please use before printing the approximated value and the error.
cout << fixed;      // uses fixed floating point representation
cout.precision(6);  // print six digits after the decimal point

Constraints
a not equal to zero
n is a positive integer
For higher accuracy, it is advisable for x to be close to a

Sample input and output a = pi/3 , x = pi/3 + 0.001, sin(x) is approximately 0.8

Input           1.047 1.048 100
Output            0.866426 0.000577

Note:Do not write any C++ statements for printing general messages. For example, the following should NOT be present in your program:cout << "Enter a number:",cout << "The computed answer is", etc.cout should be used to print only the computed final output. In addition, do not print unnecessary spaces unless specified in the questionPlease use cout << fixed; before printing the approximated value and the error.The solution file name should be an A_Q1.cpp

Student submission:
# include<simplecpp>

Grading criterion: Nth derivative computed correctly
Rating A: Fully correct
Rating B: Almost correct
Rating C: Tried something in somewhat right direction.
Rating D: Totally wrong
Assigned grade: D