|
-
Dec 16th, 2002, 11:35 PM
#1
Thread Starter
Hyperactive Member
TAN AND SIN math problem
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?
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Dec 17th, 2002, 06:02 AM
#2
arcsine etc:
x == acos(cos(x));
(except for rounding)
asin/sin
atan/tan
Don't forget that those functions work with radians.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 17th, 2002, 08:09 AM
#3
transcendental analytic
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))
Last edited by kedaman; Dec 17th, 2002 at 08:13 AM.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 17th, 2002, 10:08 AM
#4
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 17th, 2002, 12:08 PM
#5
Frenzied Member
He's saying - some values are invalid as arguments for arc-whatever functions. The results are undefined.
-
Dec 17th, 2002, 01:11 PM
#6
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 17th, 2002, 05:41 PM
#7
Thread Starter
Hyperactive Member
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!...
Last edited by Cmdr0Sunburn; Dec 17th, 2002 at 05:47 PM.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Dec 17th, 2002, 08:14 PM
#8
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 18th, 2002, 08:56 AM
#9
transcendental analytic
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.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Dec 18th, 2002, 04:05 PM
#10
Thread Starter
Hyperactive Member
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";
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Dec 18th, 2002, 04:42 PM
#11
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 18th, 2002, 04:46 PM
#12
Thread Starter
Hyperactive Member
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.
Last edited by Cmdr0Sunburn; Dec 18th, 2002 at 04:53 PM.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Dec 18th, 2002, 04:55 PM
#13
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 18th, 2002, 05:53 PM
#14
Thread Starter
Hyperactive Member
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 know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Dec 19th, 2002, 02:39 AM
#15
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|