Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

java trigonometric solver

Thread view: 
Guntius.GIBLI@gmail.com - 07 Sep 2006 13:04 GMT
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.J. Dance - 07 Sep 2006 13:19 GMT
> Hi all,
>  I'm trying to implement in Java a solver for this kind of
[quoted text clipped - 4 lines]
>
> my job is to find "f" whenever is possible.

It's always possible. Here's the solution: use an x-f substitution on this example:
http://users.secsme.org.au/~prbarnes/wikka/uploads/MrTrickFiles/find-x.PNG
Guntius.GIBLI@gmail.com - 07 Sep 2006 13:38 GMT
yeah of course
I was meaning a value for "f" not really "f" itself!!!

GG
M.J. Dance - 07 Sep 2006 13:52 GMT
> 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.
Guntius.GIBLI@gmail.com - 07 Sep 2006 14:12 GMT
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
M.J. Dance - 07 Sep 2006 15:28 GMT
> 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 <khm/> unknowns, you introduce new ones. That's helpful!

> on condition -1 <= a <= 1
> that is absolutely my case.
[quoted text clipped - 10 lines]
>  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...
Guntius.GIBLI@gmail.com - 07 Sep 2006 17:19 GMT
I was expecting a
single function capable of giving me all values of "f"
and not two distinct functions...
GG
Guntius.GIBLI@gmail.com - 07 Sep 2006 17:22 GMT
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
M.J. Dance - 08 Sep 2006 07:45 GMT
> Well anyway I don't really understand the problem...
> and I'm not very well suited in math ...
[quoted text clipped - 9 lines]
> 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.
Peter Van Weert - 07 Sep 2006 14:31 GMT
> Hi all,
>  I'm trying to implement in Java a solver for this kind of
[quoted text clipped - 8 lines]
> 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
Patricia Shanahan - 07 Sep 2006 15:50 GMT
> Hi all,
>  I'm trying to implement in Java a solver for this kind of
[quoted text clipped - 8 lines]
> 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
Guntius.GIBLI@gmail.com - 07 Sep 2006 17:32 GMT
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
Dale King - 08 Sep 2006 01:42 GMT
> Thanks you very much... it seems that an approach could be:
>
[quoted text clipped - 6 lines]
> 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).

Signature

Dale King

Patricia Shanahan - 08 Sep 2006 13:56 GMT
> Thanks you very much... it seems that an approach could be:
>
[quoted text clipped - 7 lines]
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.