void deriv705a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a,bc,bd,c; do { a = rndr(r); bc = rndr(r); bd = rndr(r); c = rndr(r); } while (!(a!=0 && bc<bd && bc>0 && bd>0 && (bc*bc)%(bd*bd)!=0)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny(x)=((%s)/(%s)^2)*arcsin(%s)", polynomial(buf[0],2, 1, chprintf(buf[1],"arctg(%s)", memb(buf[2], 1,a,1,1,"x",false)), c, "" ), polynomial(buf[3],2, a*a,"",1,"x^2"), fraction(buf[4], bc,1,bd) ); sprintf(src, "y(x)=((arctg(x/a))/((a^2+x^2)^2))*arcsin(b)"); sprintf(answ[0], "y(x)`=((%s)/((%s)^3))*arcsin(%s)", polynomial(buf[0],2, a,"", -4,polynomial(buf[1],2, 1,chprintf(buf[2],"x*arctg(%s)", memb(buf[3],1,a,1,1,"x",false)), -c,"x" ) ), polynomial(buf[4],2, a*a,"", 1,"x^2"), fraction(buf[5], bc,1,bd) ); sprintf(answ[1], "y(x)`=((%s)/((%s)^4))*arcsin(%s)", polynomial(buf[0],2, a,"", -2,polynomial(buf[1],2, 1,chprintf(buf[2],"x*arctg(%s)", memb(buf[3],1,a,1,1,"x",false)), -c,"x") ), polynomial(buf[4],2, a*a,"", 1,"x^2"), fraction(buf[5], bc,1,bd) ); sprintf(answ[2], "y(x)`=((%s)/((%s)^3))*arcsin(%s)", polynomial(buf[0],2, a*a,"", -4,polynomial(buf[1],2, 1,chprintf(buf[2],"x^2*arctg(%s)", memb(buf[3],1,a,1,1,"x",false)), -c,"x^2") ), polynomial(buf[4],2, a*a,"", 1,"x^2"), fraction(buf[5], bc,1,bd) ); sprintf(answ[3], "y(x)`=((%s)/(sqrt(1-%s)*(%s)^4))", polynomial(buf[0],2, a,"", -2,polynomial(buf[1],2, 1,chprintf(buf[2],"x*arctg(%s)", memb(buf[3],1,a,1,1,"x",false)), -c,"x") ), fraction(buf[5], bc*bc,1,bd*bd), polynomial(buf[4],2, a*a,"", 1,"x^2") ); }
void deriv702a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, b, c, k; do { a = rndr(r); b = rndr(r); c = rndr(r); k = rndr(r); } while (!(a!=0 && b!=0 && k!=0 && k!=2 && k!=1)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny=(sin(%s)/(%s))*tg(%s)", polynomial(buf[0],2, a,"x^2",b,""), polynomial(buf[1],2, 1,"cos(x)^2", c,""), memb(buf[2], 1,k,1,1,"pi", false) ); sprintf(src, "y=(sin(a*x^2+b)/(cos(x)^2+c))*tg(pi/k)"); sprintf(answ[0], "y(x)`=tg(%s)*(((%s)*cos(%s)*(%s)+!(sin(2*x))*sin(%s))/((%s)^2))", memb(buf[0], 1,k,1,1,"pi", false), polynomial(buf[1],1, 2*a,"x"), polynomial(buf[2],2, a,"x^2",b,""), polynomial(buf[3],2, 1,"cos(x)^2", c,""), polynomial(buf[4],2, a,"x^2",b,""), polynomial(buf[5],2, 1,"cos(x)^2", c,"") ); sprintf(answ[1], "y(x)`=tg(%s)*((%s)*cos(%s)-!(sin(2*x))*sin(%s))/((%s)^2))", memb(buf[0], 1,k,1,1,"pi", false), polynomial(buf[1],2, 1,"cos(x)^2", c,""), polynomial(buf[2],2, a,"x^2",b,""), polynomial(buf[3],2, a,"x^2",b,""), polynomial(buf[4],2, 1,"cos(x)^2", c,"") ); sprintf(answ[2], "y(x)`=(pi/(%s))*(%s)/((%s)^2))", polynomial(buf[0],1, k*k,chprintf(buf[1],"cos(%s)^2", memb(buf[2], 1,k,1,1,"pi", false))), polynomial(buf[3],2, 1,chprintf(buf[4], "sin(2*x)*sin(%s)", polynomial(buf[5],2, a,"x^2",b,"")), -2*a, chprintf(buf[6], "x*(%s)*cos(%s)", polynomial(buf[7],2, 1,"cos(x)^2", c,""), polynomial(buf[8],2, a,"x^2", b,"") ) ), polynomial(buf[9],2, 1,"cos(x)^2", c,"") ); sprintf(answ[3], "y(x)`=tg(%s)*(((%s)*cos(%s)*(%s)-2*cos(x)*sin(%s))/((%s)^2))", memb(buf[0], 1,k,1,1,"pi", false), polynomial(buf[1],1, 2*a,"x"), polynomial(buf[2],2, a,"x^2",b,""), polynomial(buf[3],2, 1,"cos(x)^2", c,""), polynomial(buf[4],2, a,"x^2",b,""), polynomial(buf[5],2, 1,"cos(x)^2", c,"") ); }
P serialize_member_name( const T& , P end, M memb ) { const char* name = memb(); *(end++)='"'; for (; *name!='\0'; ++name) *(end++) = *name; *(end++)='"'; *(end++) = ':'; return end; }
void deriv701a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, b, m, n, c, d; do { a = rndr(r); b = rndr(r); c = rndr(r); d = rndr(r); m = rndr(range(2, 4)); n = rndr(range(2, 4)); } while (!(c>0 && d>0 && m*n>2 && a!=b && a!=0 && b!=0)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny=(%s)/(%s)", memb(buf[0], 1,1,m,1, polynomial(buf[1],2, a,"x", b,""), false), memb(buf[2], 1,1,1,n, polynomial(buf[3],2, c,"x", d,""), false) ); sprintf(src, "y=((a*x+b)^m)/root(n,c*x+d)"); sprintf(answ[0], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], 1,1,m-1,1, polynomial(buf[1],2, a,"x",b,""), false), polynomial(buf[2],2, a*c*(m*n-1),"x", a*m*n*d-c*b,""), memb(buf[3], n,1,n+1,n, polynomial(buf[4],2, c,"x",d,""), false) ); sprintf(answ[1], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], m,1,m-1,1, polynomial(buf[1],2, a,"x",b,""), false), polynomial(buf[2],2, a*c,"x", -c*b,""), memb(buf[3], n,1,2,n, polynomial(buf[4],2, c,"x",d,""), false) ); sprintf(answ[2], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], m,1,m-1,1, polynomial(buf[1],2, a,"x",b,""), false), polynomial(buf[2],2, m*a-c,"x", d*b,""), memb(buf[3], n,1,n+1,n, polynomial(buf[4],2, c,"x",d,""), false) ); sprintf(answ[3], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], 1,1,m-1,1, polynomial(buf[1],2, a,"x",b,""), false), polynomial(buf[2],2, a*c,"x", a*d-c*b,""), memb(buf[3], n,1,2,n, polynomial(buf[4],2, c,"x",d,""), false) ); }
void deriv703a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, b, c; do { a = rndr(r); b = rndr(r); c = rndr(r); } while (!(a!=0 && c!=0)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny=((%s)/sqrt(%s))*arctg(%d)", polynomial(buf[0],2, 1,chprintf(buf[1], "arcsin(%s)", memb(buf[2], 1,a,1,1,"x", false)), c,"" ), polynomial(buf[3],2, a*a,"", -1,"x^2"), b ); sprintf(src, "y(x)=((arcsin(x/a)+c)/sqrt(a^2-x^2))*arctg(b)"); sprintf(answ[0], "y(x)`=((%s)/sqrt((%s)^3))*arctg(%d)", polynomial(buf[0],2, a,chprintf(buf[1],"sqrt(%s)", polynomial(buf[2],2, a*a,"", -1,"x^2")), -1,chprintf(buf[3],"x*(%s)", polynomial(buf[4],2, 1,chprintf(buf[5],"arcsin(%s)",memb(buf[6],1,a,1,1,"x")), c,"")) ), polynomial(buf[7],2, a*a,"", -1,"x^2"), b ); sprintf(answ[1], "y(x)`=((%s)/sqrt((%s)^3))*arctg(%d)", polynomial(buf[0],2, a,chprintf(buf[1],"sqrt(%s)", polynomial(buf[2],2, a*a,"", -1,"x^2")), -1,chprintf(buf[3],"x*(%s)", polynomial(buf[4],2, 1,chprintf(buf[5],"arcsin(%s)",memb(buf[6],1,a,1,1,"x")), c,"")) ), polynomial(buf[7],2, a*a,"", -1,"x^2"), b ); sprintf(answ[2], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a,chprintf(buf[1],"sqrt(%s)", polynomial(buf[2],2, a*a,"", -1,"x^2")), -1,chprintf(buf[3],"x*(%s)", polynomial(buf[4],2, 1,chprintf(buf[5],"arcsin(%s)",memb(buf[6],1,a,1,1,"x")), c,"")) ), polynomial(buf[7],2, a*a*(1+b*b),"", -(1+b*b),"x^2") ); sprintf(answ[3], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a,chprintf(buf[1],"sqrt(%s)", polynomial(buf[2],2, a*a,"", -1,"x^2")), 2,chprintf(buf[3],"x*(%s)", polynomial(buf[4],2, 1,chprintf(buf[5],"arcsin(%s)",memb(buf[6],1,a,1,1,"x")), c,"")) ), polynomial(buf[7],2, a*a*(1+b*b),"", -(1+b*b),"x^2") ); }
void deriv707a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, b, c; do { a = rndr(r); b = rndr(r); c = rndr(r); } while (!(a!=0 && b>1)); char arctgxac[BUFSZ]; polynomial(arctgxac,2, 1,chprintf(buf[0],"arctg(%s)", memb(buf[1], 1,a,1,1, "x", false)), c,"" ); char xarctgxac[BUFSZ]; sprintf(xarctgxac, "x*(%s)", arctgxac); char a2x2[BUFSZ]; polynomial(a2x2,2, a*a,"",1,"x^2"); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny(x)=((%s)/sqrt(%s))*ln(%d)", arctgxac, a2x2, b); sprintf(src, "y(x)=((arctg(x/a)+c)/sqrt(a*x^2+b))*ln(b)"); sprintf(answ[0], "y(x)`=((%s)/sqrt((%s)^3))*ln(%d)", polynomial(buf[0],2, a,"", -1,xarctgxac), a2x2, b ); sprintf(answ[1], "y(x)`=((%s)/sqrt((%s)^3))*ln(%d)", polynomial(buf[0],2, a,"", -2,xarctgxac), a2x2, b ); sprintf(answ[2], "y(x)`=((%s)/(%s))*ln(%d)", polynomial(buf[0],2, a,"", -1,xarctgxac), a2x2, b ); sprintf(answ[3], "y(x)`=((%s)/(%s))", polynomial(buf[0],2, a,"", -1,xarctgxac), polynomial(buf[1],1, b,a2x2) ); }
bool OsiConicCut::consistent (const OsiConicSolverInterface & si) const { // check whether the members are actually existing variables in si int max_index = si.getNumCols()-1; for (int i=0; i<size_; ++i) { if (members_[i]>max_index) { return false; } } // return false if a member is repeating std::set<int> memb (members_, members_+size_); if (memb.size()!=size_) { memb.clear(); return false; } memb.clear(); // todo(aykut): consistency of other data elements? return true; }
P unserialize_member_name( T& , P beg, P end, M memb, bool& unserialized ) { const char* name = memb(); P start = beg; if ( !parser::is_string(beg, end) ) throw expected_of("\"", std::distance(beg, end)); ++beg; unserialized = true; for ( ; beg!=end && *name!='\0' && *beg==*name && *beg!='"'; ++name, ++beg) { if (*name!=*beg) { unserialized = false; break; } } if (beg==end) throw unexpected_end_fragment(); if (*beg!='"' || *name!='\0') unserialized = false; if ( !unserialized ) return start; ++beg; beg = parser::parse_space(beg, end); if (beg==end) throw unexpected_end_fragment(); if (*beg!=':') throw expected_of(":", std::distance(beg, end)); ++beg; beg = parser::parse_space(beg, end); if (beg==end) throw unexpected_end_fragment(); return beg; }
void deriv706a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, n; do { a = rndr(r); n = rndr(r); } while (!(a!=0 && n>0)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny(x)=arctg(%s)/(%s)", memb(buf[0], 1,a,1,1,"x", false), memb(buf[1], 1,1,n,1, polynomial(buf[2],2, a*a,"",1,"x^2"), false) ); sprintf(src, "y(x)=arctg(x/a)/(a^2+x^2)^n"); char xarctg[BUFSZ]; sprintf(xarctg, "x*arctg(%s)", memb(buf[0], 1,a,1,1, "x", false)); sprintf(answ[0], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a,"", -2*n,xarctg), memb(buf[1], 1,1,n+1,1, polynomial(buf[2],2, a*a,"", 1,"x^2"), false) ); sprintf(answ[1], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a*a,"", -4*n,xarctg), memb(buf[1], 1,1,n+1,1, polynomial(buf[2],2, a*a,"", 1,"x^2"), false) ); sprintf(answ[2], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a,polynomial(buf[1],2, a*a,"", 1,"x^2"), -2*n,xarctg), memb(buf[2], 1,1,n,1, polynomial(buf[3],2, a*a,"", 1,"x^2"), false) ); sprintf(answ[3], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, a*a,"", -2*n,xarctg), memb(buf[1], 1,1,n,1, polynomial(buf[2],2, a*a,"", 1,"x^2"), false) ); }
void deriv704a (const range &r, char *task, char answ[][BUFSZ], char *src) { char buf[20][BUFSZ]; int a, n; do { a = rndr(r); n = rndr(r); } while (!(a!=0 && n>1)); strcpy(task, ""); catprintf(task, "String(\"Найдите производную указанной функции:\")"); catprintf(task, "\ny=(%s)/sqrt(%s)", memb(buf[0], 1,1,n,1, chprintf(buf[1],"arccos(%s)", memb(buf[2], 1,a,1,1, "x", false)), false), polynomial(buf[3],2, a*a,"", -1,"x^2") ); sprintf(src, "y(x)=arccos(x/a)^n/sqrt(a^2-x^2)"); sprintf(answ[0], "y(x)`=((%s)*(%s))/sqrt((%s)^3)", memb(buf[0], 1,1,n-1,1, chprintf(buf[1],"arccos(%s)", memb(buf[2], 1,a,1,1, "x", false)), false), polynomial(buf[3],2, 1,chprintf(buf[4], "x*arccos(%s)", memb(buf[5], 1,a,1,1,"x", false)), -n, chprintf(buf[6], "sqrt(%s)", polynomial(buf[7],2,a*a,"",-1,"x^2")) ), polynomial(buf[7],2, a*a,"", -1,"x^2") ); sprintf(answ[1], "y(x)`=(%s)/(%s)", polynomial(buf[0],2, 2*a, chprintf(buf[1], "x*(%s)", memb(buf[2], 1,1,n,1, chprintf(buf[3],"arccos(%s)", memb(buf[4],1,a,1,1,"x", false)), false)), -n,chprintf(buf[5], "sqrt(%s)*(%s)", polynomial(buf[6],2, a*a,"", -1,"x^2"), memb(buf[7], 1,1,n-1,1, chprintf(buf[8],"arccos(%s)", memb(buf[9],1,a,1,1,"x", false)), false) ) ), polynomial(buf[10],2, a*a,"", -1,"x^2") ); sprintf(answ[2], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], 1,1,n-1,1, chprintf(buf[1], "arccos(%s)", memb(buf[2], 1,a,1,1,"x", false)), false), polynomial(buf[3],2, n,chprintf(buf[4],"sqrt(%s)", polynomial(buf[5],2, a*a,"", -1,"x^2")), -1,chprintf(buf[6],"x*arccos(%s)", memb(buf[7], 1,a,1,1,"x", false)) ), memb(buf[8], a,1,1,1, chprintf(buf[9],"sqrt((%s)^3)", polynomial(buf[10],2,a*a,"",-1,"x^2")), false) ); sprintf(answ[3], "y(x)`=((%s)*(%s))/(%s)", memb(buf[0], 1,1,n-1,1, chprintf(buf[1], "arccos(%s)", memb(buf[2], 1,a,1,1,"x", false)), false), polynomial(buf[3],2, -n*a, polynomial(buf[5],2, a*a,"", -1,"x^2"), 1,chprintf(buf[6],"x*arccos(%s)", memb(buf[7], 1,a,1,1,"x", false)) ), polynomial(buf[10],2,a*a,"",-1,"x^2") ); }