facebookresearch / SymbolicMathematics

Deep Learning for Symbolic Mathematics
Other
527 stars 116 forks source link

Power of variables #14

Open psinha30 opened 3 years ago

psinha30 commented 3 years ago

Is there any parameter which can restrict the power of the variables being generated for an equation?

f-charton commented 3 years ago

--operators will do this for you. You need to specify a comma separated list of the operators you want and their frequency (how often they are sampled when generating expressions), e.g. "add:10,sub:3,mul:10,div:5,sqrt:4,pow2:4,pow3:2,pow4:1,pow5:1,ln:4,exp:4,sin:4,cos:4,tan:4,asin:1,acos:1,atan:1,sinh:1,cosh:1,tanh:1,asinh:1,acosh:1,atanh:1"

This would generate powers from 2 to 5 (and trigs, and hyperbolics, and their inverses), but you could remove pow5 and pow4, to have only squares and cubes. Right now, only pow2 to pow5 are defined, but you can add larger powers by defining them in OPERATORS and adding a case in write_infix() (both in char_sp.py).

If you feel bold, you can also use binary 'pow' (pow(x,y), already defined in OPERATORS), but this might lead to Sympy overflows which will slow data generation