java trigonometric solver

Discussion in 'Java' started by Guntius.GIBLI, Sep 7, 2006.

  1. 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
    Guntius.GIBLI, Sep 7, 2006
    1. Advertisements

  2. Guntius.GIBLI

    M.J. Dance Guest

    M.J. Dance, Sep 7, 2006
    1. Advertisements

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

    Guntius.GIBLI, Sep 7, 2006
  4. Guntius.GIBLI

    M.J. Dance Guest

    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.
    M.J. Dance, Sep 7, 2006
  5. 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
    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
    please help!!!

    thanks in advance for your help
    Guntius.GIBLI, Sep 7, 2006
  6. 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.

    Peter Van Weert, Sep 7, 2006
  7. Guntius.GIBLI

    M.J. Dance Guest

    You mean for both of them. ;-) But really, sin(x) \in [-1, 1]? Wow! ;-)
    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")?
    Here you go! All you have to do now is translate these two lines into Java. :)
    What _were_ you expecting? Just curious...
    M.J. Dance, Sep 7, 2006
  8. 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 Shanahan, Sep 7, 2006
  9. I was expecting a
    single function capable of giving me all values of "f"
    and not two distinct functions...
    Guntius.GIBLI, Sep 7, 2006
  10. 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.
    Guntius.GIBLI, Sep 7, 2006
  11. 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.
    Guntius.GIBLI, Sep 7, 2006
  12. Guntius.GIBLI

    Dale King Guest

    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).
    Dale King, Sep 8, 2006
  13. Guntius.GIBLI

    M.J. Dance Guest

    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.
    M.J. Dance, Sep 8, 2006
  14. Don't forget that any pair of angles separated by 2*pi radians have the
    same sine.

    Patricia Shanahan, Sep 8, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.