CodeGraderBench/CodeGraderBench huggingface dataset:
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y,sum=0;
	cin>>y;
	double term=y;
	sum=y;
	for (int i=2; i<100; i++){
		term=(term*y*y*(-1))/((i)*(i+1));
		sum+=term;}
	cout<<fixed;
	cout.precision(3);
	cout << sum;

}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y,x=1;
	cin>>y;
	while(abs(sin(x)-y)!=0){
		x=x-tan(x)+y/cos(x);
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{ double k;  double x=0.75;
	cin>>k;
	repeat(20)
	{ x= x-(sin(x)-k)/cos(x);
	}//using newton raphson method to calculate sin inverse k
  cout<<fixed; cout.precision(3);
  cout<<x;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>

main_program{
	double y;
	cin >> y;
	double xn = PI / 4, xn1 = 0;
	//initializing values xn = pi/4 as it is in the middle of the function and can cover the range of 0 to pi/2 during the iterations
	while(abs(xn - xn1) >= 0.0001){
	//usage of more precise boundary condition so that rounding errors do not take place near 0 and pi/2 as derivative there is zero
		xn1 = xn;
		xn = xn - tan(xn) + (y / cos(xn));
		//Newton-Rhapson method
	}
	cout << fixed;
	cout.precision(3);
	cout << (xn) << endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program {
	double y;
	cin>>y;
	double xl=0,xr=PI/2, xm;
	bool xl_pos=sin(xl)-y>0;
	while (abs(sin(xl)-y)>0.0001) {
	xm=(xl+xr)/2;
	bool xm_pos=sin(xm)-y>0;
	if(xm_pos==xl_pos) xl=xm;
	else xr=xm;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xr;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y,x=0;
	cin>>y;
	if(y<=1 && y>=0)    {for(int i=0;i<100;i++){
				x=x-((sin(x)-y)/cos(x));}
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;}
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y;
	double x = 0;
	cin>>y;
	//bisection method f(x) = sin(x) - y
	double x1 = 0;
	double x2 = PI/2;
	while(x2 - x1 > 0.0001){
		double x3 = (x1+x2)/2; //finding midpoint
		//switching the loop
		if (sin(x3) - y > 0){x2 = x3;}
		else if(sin(x3) == y){x1 = x2= x3;}
		else{x1 = x3;}
	}
	//final value to be outputted.
	x = (x1+x2)/2;
	cout<<fixed;
	cout.precision(3);
	cout<<x;

}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>

//creating function fx:= y = sinx - n, where n is whose 1/root we need
double f(double x, double n){
	double y = sin(x) - n;
	return y;
}

main_program{
	double y; cin >> y;
	double epsilon = pow(10,-15);// permissible error
	double pi = 3.1415926,a = 0,b = pi/2, m = 0;
	//we are using bisection algorithm here, So:
	//a,b are end points of domain
	//m acts as the middle point

	while(epsilon < abs(f(a,y))){
		m = (a+b)/2;
		if(f(m,y) > 0){
			b = m;// b,m have same sign
			      // and m is closer to ans than b
		}
		else{
			a = m;// similarly for a
		}
	}
	double ans = (a+b)/2;

	// for 3 digit precision
	// Approximation
	int temp = ans*pow(10,3);
	if(ans*pow(10,3) >= temp + 0.5){
		temp = temp + 1;
	}
	ans = temp/pow(10,3);
	
	//precision
	cout << fixed;
	cout.precision(3);
	cout << ans << endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>
main_program{
	double y;
	cin>>y;

	float x;
	x= 0;
	repeat(1000){
		x= x- (sin(x)-y)/cos(x);



	}
	cout<<fixed;
	cout.precision(3);
	cout<< x;



}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y;
	cin >> y;
	double w,x=0;
	w = y/100000000;
	for(double k=0;k<100000000;k++){
		x+= w/sqrt(1-((k)*(k)*w*w));
	}
	cout << fixed;
	cout.precision(3);
	cout << x;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
//we will solve this by rienman integration
// we would divide 1 to y into  500000000 divisions for acuracy otherwise at 1 it will show 1.56... for 100000 iterations .
// due to this it will take time to compute value at 1.
	double y;
	cin>>y;
	long double x=0,w=y/500000000.0;
	 long  int i=0;
	repeat(500000000){
	x+=(1.0/(sqrt(1-i*i*w*w)))*w;
	i++;}
cout<<fixed;
cout.precision(3);
cout<<x;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float y;
	cin>>y;
	float a,b;
	a=0;
	b=PI/2;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	double y;
	cin>>y;
	double x=y,a=y,i=1;
	repeat(100000000){
		a=a*pow(y,2)*(2*i-1)*(2*i-1)/((2*i+1)*2*i);
		x=x+a;
		i=i+1;
	}


	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program {
	float y,espi;
	cin>>y;
	espi = 0.000000001;
	float x=0;
	while ((sin(x)-y)>=espi) {
		x += ((sin(x)-y)/cos(x));
		y += espi;
	}
	cout<<x<<endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{
	double y;
	cin>>y;
	double x=0;
	double n=1;
	for (int i=0;i<=100000000;i++)
	{
		
		x=x+(pow(y,2*i+1)*n)/(2*i+1);
		n=n*(float((2*i+1))/((i+1)*2));
		
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program
{
	double y,xr=PI/2.0,xl=0,xm=(xl+xr)/2.0,delta=0.00001;
	cin>>y;
	bool xlpos = sin(xl)-y>0,xmpos = sin(xm)-y>0;
	while((xm-xl)>=delta)
	{
		xm=(xl+xr)/2;
		if(xmpos)
		{
			if(xlpos){xl=xm;}
			else{xr=xm;}
		}
		else{if(xlpos){xr=xm;}
			else{xl=xm;}
		
		}
		xm=(xl+xr)/2;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<xm;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>

main_program
{
	// We use the Bisection method to solve the function
	// f(x) = sin(x) - y
	// We wish to find the root of this function to three decimal spaces
	// Since y is between 0 and 1
	// f(0) <= 0 and f(PI/2) >= 0.
	// Also only one root of the function will exist between 0 and Pi/2
	// So we let  x_l = 0, x_r = Pi/2 Initially
	
	// Taking input
	double y;
	cin >> y;
	double x_l, x_r, x_m;

	// Initializing x_l and x_r
	x_l = 0;
	x_r = M_PI / 2;

	// After n iterations x_r - x_l = PI/(2 ^ (n + 1))
	// And the root always lies between x_r and x_l
	// After 15 iterations x_r - x_l < 10^(-4)
	// So x_l will be withinn 10^(-4) of the root
	// Hence x_l will approximate to root upto three decimal points properly
	for (int i = 0; i < 15; i++)
	{
		x_m = (x_l + x_r) / 2;
		if (sin(x_m) - y > 0)
		{
			x_r = x_m;
		}
		else
		{
			x_l = x_m;
		}
	}

	// Printing the calculated root
	cout << fixed;
	cout.precision(3);
	cout << x_l << endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<iostream>
using namespace std;
float pow(float x, int y){
for(int i=1;i<y;i++){
 x=x*x;}
return x;
}
int main(){
  float y;
  cin>>y;
  float x= y+ pow(y,3)/6 + 9*pow(y,5)/120 + 225*pow(y,7)/5040;
  cout<<fixed;
  cout.precision(3);
  cout<<x;
  }

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: B
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>
main_program{
	double y;
	cin>>y;
	double x;
	x = (arcsine(y))*(PI/180);
	cout<<fixed;
	cout.precision(3);
	cout<<x<<endl;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{
	float  y;
	cin>>y;
	double x = 0;
	while(sin(x)!=y){
		x+= 1E-10;
		if( x>PI/2) break;
	}
	cout<<fixed;
	cout.precision(3);
	cout<<x;
	
	

}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>
main_program{
	float y;
	cin >> y;
	double n = 10000000;
	long int i = 0;
	double w = y/n;
	double value = 0;
	while (i < n)
	{
		double term = w/(sqrt(1 - pow(i*w, 2)));
		value += term;
		i++;
	}
	cout.precision(3);
	cout << value << endl;

}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include<simplecpp>
main_program{

	double y;
	double x;
	cin>>y;

	for(x=0;x<=(1.571);x=x+(0.001))
	{
	double z=sin(x);

	if(((y-z)<=0.0000001)){
/*		cout << fixed; // uses fixed floating point representation
cout.precision(3); // print three digits after the decimal point
*/	cout<<x<<endl;
		
	}}}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: C
Problem: Given a real number y   [0,1], find the value of x, in radians, such that sin(x) = y, without using any trigonometric-inverse function. The value x should lie within the interval [0, pi(3.14) /2]. Write an iterative program that prints the value of x. Do NOT use a brute-force search at all.

Constraints

0 <= y <= 1

0 <= x <=  pi (3.14) /2

Student submission:
#include <simplecpp>

main_program {
	double eps = 1e-12;
	double x; cin >> x;
	double term = x;
	double sum = x;
	double counter =-1;
	while(term > eps) {
		counter += 1;
		term *= (x)*(x)*(counter + 0.5)*(2*counter + 1) / ((counter + 1)*(2*counter + 3));
		sum += term;
	
	}
	cout << fixed;
	cout.precision(3);
	cout << sum;
}

Grading criterion: Implementation of binary search, gradient descent or any appropriate iterative method.
Rating A: Correctly using binary search correct query / Correct iterative update
Rating B: Slight mistake in update of binary search / iterative method
Rating C: Used linear search or completely incorrect search
Rating D: 0
Assigned grade: A