java trigonometric solver

G

Guntius.GIBLI

Hi all,
I'm trying to implement in Java a solver for this kind of
trigonometric system...

k * sin( a1 * f ) = b1
k * sin( a2 * f ) = b2

my job is to find "f" whenever is possible.

Can you please help in finding an algorithm or a java implementation...
thanks in advance
GG
 
M

M.J. Dance

yeah of course
I was meaning a value for "f" not really "f" itself!!!

Oh! Well, in that case, you know, of course, that life's complex, don't you? It
has both real and imaginary components. So, do you mind telling us moe about
your k, a1, a2, f, b1 and b2? Are they really ;-) nasty? Or 'merely' complex?
Functions even? What kind of functions? Whatever they may be, however, I don't
think that the solution is Java dependent.
 
G

Guntius.GIBLI

k is calculated in order to force
-1 <= ai/k <= 1 for every i
-1 <= bi/k <= 1 for every i

ai and bi are integers (I mean they are stored in java integers)
in general ai != aj for every i != j and
the same condition should be verified for bi ...
so they seems not to be nasty nor complex...

The solution I'm looking for is a java one, if eventually someone
already implemented it,
otherwise I have to implement it in java ... thus I need some help.

In fact I read something about sin(x) = alpha
on condition -1 <= a <= 1
that is absolutely my case.

it seems the solution to be:
x = alpha + 2 k pi
x = pi - alpha + 2 k pi

but since I have
x = ai * f
and
alpha = bi / k
I get:
f = (bi / k + 2 k pi) / ai
f = pi - (bi / k + 2 k pi) / ai

that it is not exacly what I was expecting... so I am a little bit
stuck!!!
please help!!!

thanks in advance for your help
GG
 
P

Peter Van Weert

Hi all,
I'm trying to implement in Java a solver for this kind of
trigonometric system...

k * sin( a1 * f ) = b1
k * sin( a2 * f ) = b2

my job is to find "f" whenever is possible.

Can you please help in finding an algorithm or a java implementation...
thanks in advance
GG

Maybe you can ask on comp.constraints for ideas about suited constraint
solvers, algorithms, ... They will now better whether suited
implementations exists (maybe even in Java, but I doubt it), or how to
implement it yourself in Java. I would first look for existing solvers
and let them do the hard work, even if this is outside our beloved Java.

Cheers,
Peter
 
M

M.J. Dance

k is calculated in order to force
-1 <= ai/k <= 1 for every i

You mean for both of them. ;-) But really, sin(x) \in [-1, 1]? Wow! ;-)
-1 <= bi/k <= 1 for every i

ai and bi are integers (I mean they are stored in java integers)
in general ai != aj for every i != j and
the same condition should be verified for bi ...
so they seems not to be nasty nor complex...

Hey, Gunitus, how much do you know about trigonometry? Or math for that matter?
Specifically... forget the solution for a moment: do you understand the problem
(t.i. "question")?
The solution I'm looking for is a java one, if eventually someone
already implemented it,
otherwise I have to implement it in java ... thus I need some help.

In fact I read something about sin(x) = alpha

Trying to explain those said:
on condition -1 <= a <= 1
that is absolutely my case.

it seems the solution to be:
x = alpha + 2 k pi
x = pi - alpha + 2 k pi

but since I have
x = ai * f
and
alpha = bi / k
I get:
f = (bi / k + 2 k pi) / ai
f = pi - (bi / k + 2 k pi) / ai

Here you go! All you have to do now is translate these two lines into Java. :)
that it is not exacly what I was expecting... so I am a little bit
stuck!!!

What _were_ you expecting? Just curious...
 
P

Patricia Shanahan

Hi all,
I'm trying to implement in Java a solver for this kind of
trigonometric system...

k * sin( a1 * f ) = b1
k * sin( a2 * f ) = b2

my job is to find "f" whenever is possible.

Can you please help in finding an algorithm or a java implementation...
thanks in advance
GG

The only really Java-specific information that seems relevant to the
problem is that Math.asin(x) returns an angle, in radians, whose sine is
x. See the API documentation for details.

Patricia
 
G

Guntius.GIBLI

I was expecting a
single function capable of giving me all values of "f"
and not two distinct functions...
GG
 
G

Guntius.GIBLI

Well anyway I don't really understand the problem...
and I'm not very well suited in math ...

the fact is that I should deliver this function as a small part of a
bigger project
I'm not allowed to know about?!
weird thing I know but the fact is that I only know the input, the
output and the CPU time I have to do the trick...

oooh yes and I have to do the whole thing in a nice java function...

thanks you very much anyway
you really helped me.
GG
 
G

Guntius.GIBLI

Thanks you very much... it seems that an approach could be:

fi =Math.asin(bi/A)/ai
fi =pi - Math.asin(bi/A)/ai

at this point I have just to solve the system and find the only
possible values for "fi"...

well I hope it will work I'll keep you post it,
just in case you are interested in any positive result.
GG
 
D

Dale King

Thanks you very much... it seems that an approach could be:

fi =Math.asin(bi/A)/ai
fi =pi - Math.asin(bi/A)/ai

at this point I have just to solve the system and find the only
possible values for "fi"...

well I hope it will work I'll keep you post it,
just in case you are interested in any positive result.


It seems to me that there is an infinite number of values for fi, if I
understand the problem correctly (and your explanation so far has not been
very clear).
 
M

M.J. Dance

Well anyway I don't really understand the problem...
and I'm not very well suited in math ...

the fact is that I should deliver this function as a small part of a
bigger project
I'm not allowed to know about?!
weird thing I know but the fact is that I only know the input, the
output and the CPU time I have to do the trick...

oooh yes and I have to do the whole thing in a nice java function...

thanks you very much anyway
you really helped me.

I can't help you if I don't know (exactly) what the problem is. As you obviously
don't know either, I suggest you ask your tutor.

And of course, there's the proverbial Usenet reluctance of doing someone elses
homework. In order to get help, the least you should do is show some effort of
trying to solve the problem yourself.

Now, as you found out in another post, your f = f(ai, bj, k). A few additional
conditions (ai and bi being integers and so on) puts a few additional
restrictions on your solution, but that's about it.

Oh, and, "translating" that into Java is the least of your problems.
 
P

Patricia Shanahan

Thanks you very much... it seems that an approach could be:

fi =Math.asin(bi/A)/ai
fi =pi - Math.asin(bi/A)/ai

at this point I have just to solve the system and find the only
possible values for "fi"...

well I hope it will work I'll keep you post it,
just in case you are interested in any positive result.
GG

Don't forget that any pair of angles separated by 2*pi radians have the
same sine.

Patricia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top