okay. how would i un sin and un tan somting, if i somting , if TAN(2) is 0.034920769491747730500402625773725, how would i get 2 back, same with sin, is this possable?
Printable View
okay. how would i un sin and un tan somting, if i somting , if TAN(2) is 0.034920769491747730500402625773725, how would i get 2 back, same with sin, is this possable?
arcsine etc:
x == acos(cos(x));
(except for rounding)
asin/sin
atan/tan
Don't forget that those functions work with radians.
sin, cos and tan are not injective, tan has a periodicity of pi, while sin and cos have 2pi but are symmetric at 1/2*pi + n*pi respective 0+n*2pi. Usually you can find a workaround for full 2*pi angles trough using the euler transformation and atn2, X=atn2(sin(X),cos(X))
Huh?
He's saying - some values are invalid as arguments for arc-whatever functions. The results are undefined.
But the result of a sin, cos or tan is guaranteed to be valid input for asin, acos or atan, respectivly. Except if the input wasn't valid in the first place (e.g. PI/2 to tan).
But yeah, you're not guaranteed to get out what you put in first. asin(sin(2*PI)) will result in 0.
im talking about SIN(TAN(y*X^z))
i want to get y back from knowing X^z
basicly i want to use it for a weak! encription, however if you know how to make it STRONG using sin,cos, and tan help would be apreciated!...
The problem, as keda pointed out, lies in the wraparound effect of sin and cos.
You can find one possible value of (x*y^z), it is
atan(asin(result))
but there are infinite possible values (in theory, not for pcs), therefore x is not clearly defined either.
Trigonometry functions are not a good choice for encryption as they are lossy.
trigonometric functions are reversible at certain periodic intervals, when playing around with math functions you always have to take into account their domain and range, and if you want an inverse, uniqueness as well. Don't think using floating point functions are useful for encryption, they tend to be inaccurate if you want to reverse them.
hmm ok well as this code proves that none repeat themselfs i thought i could use it as a encription.
Code:#define ncm 30000000
void main()
{
//SIN(TAN(3*X^3))
long double X = 1.0,RESULT = 0,xcubed,Xcubedtried,XTANNED,somewheree,J = 1;
unsigned int gtc1 = 0,gtc2 = 0;
long double* siz = new long double[30080000];//allocate memory
{
int y = 1;
do
{
J = X;
do
{
xcubed = ((X * X) * X);
Xcubedtried = xcubed * (3);
XTANNED = tan(Xcubedtried);
RESULT = sin(XTANNED);
// if(RESULT == 0)
// {
// std::cout << " 0 FOUND!\n";
// std::cin >> somewheree;
// }
//std::cout.precision(24);
siz[y] = RESULT;
X = X + 1.0;
y = X;
}while(X <J+10000);
std::cout << "#:"<< y << "\n";
}while(X <= ncm);
}
int y = 0,z = 1,repititionc = 0;
std::cout << "Input starting #:";std::cin >> y ;
do
{
std::cout << y <<" Time:"<<(gtc1 - gtc2) <<"\n";
gtc2 = GetTickCount();
z = 1;
do {
if (siz[y] == siz[z+y])
{
repititionc++;
}
//z = z + 1;
__asm INC z
}while(z <= (ncm - y));
//y = y + 1;
__asm INC y
gtc1 = GetTickCount();
}while(y <= ncm);
std::cout << " \n" << repititionc << "\n";
Are you aware that your code allocates 240 to 300 MB RAM?
And this:
__asm INC z
Why not
++z;
? It's shorter, easier to read, more portable and the compiler can optimize better.
yea i have alot of ram hehe,and also i code in assembly(2nd lang and i know more of it than my first and 3rd). Like learning english then moving to spain, then studying german.. as i still think in assembly. i can beat the c++ compiler, i beat 500mhz of a loop in one my program., c++ will almost never use inc wich takes 1 clock and even 2 incs 1 clock on p4s, and 4 incs on 1 clock on amd(thats why amd will always be the best) as add will take more than 1 as if i wanted to add 500, then i could not use inc, so if your doing just adding one or 2, use __asm INC, ~~~ msvc++6 compiler sucks at optimizing.
inc only takes that short if executed for the eax register. Same for add.
But it doesn't really matter. This single statement ensures that your app will not compile on any compiler beside VC++, and not run on any computers except x86. Of course you might not mind.
The other problems is that no compiler can optimize properly past an asm statement.
i could code that loop in assembly and i gaurentee that it will be at least 1/3 faster. but i dont want to; this is now a 'junk' project.
I don't doubt it. But I think that a loop that is one third highly optimized assembly and the other two thirds normal C++ code will be slower than a pure C++ loop because the compiler can't optimize the C++ part properly.