Hello.

Le jeu. 4 avr. 2019 à 17:23, Matthew Rowles <rowle...@gmail.com> a écrit :
>
> I'm having difficulty even beginning to solve this problem. All examples
> that I have found are either too simple or way too complex to digest.

What did you try?
Did you at the Javadocs for the "optim" and "fitting" package?
The unit tests could also help.

>
> I want to to find the value S given a series of inputs. The function is
> univariate but non-linear. S will always be between -3 .. 3.
>
> I would like to use the Apache Commons library, as I have had prior
> experience in other sections of the code.
>
> For each time I want to solve my problem, I know the following information:
>
>     double R     =250.0;
>     double om1   =  5.0;
>     double om2   = 15.0;
>     double th21  = 29.07965;
>     double th22  = 29.69008;
>     double D_obs = th21 - th22;
>
> The actual values will change between solutions, but they are fixed for any
> one particular solution.
>
> The value I want to find is:
>
>     double S   = 0.0;

So, you have it. ;-)

>
> such that
>
>     double d1     = delta(R,om1,th21,S);
>     double d2     = delta(R,om2,th22,S);
>     double D_calc = d1 - d2;
>
> have values to make
>
>     double minme = Math.abs(D_obs - D_calc);
>
> a minimum. (ideally zero, but a minimum).

So, a least-squares problem (with 1 observation?).

> The function delta is defined as
>
> public static double delta(double R, double om, double th2, double s)
> {
>     if(Math.abs(s) <= 0.0001) //is the displacement == 0?
>     {
>         return 0.0;
>     }
>     else
>     {
>         return 
> Math.toDegrees((-1*Cos(th2)*s-R*Sin(om)+Sqrt(-1*Math.pow(Cos(th2),2)*Math.pow(s,2)+2*Cos(th2)*Sin(om)*R*s-Math.pow(Cos(om),2)*Math.pow(R,2)+Math.pow(R,2)+2*Math.pow(s,2)))/(Sin(th2)*s));
>     }
> }

You could improve readability and performance by
* not calling "pow" to get the square,
* not compute the same value multiple times,
* perform the computation with radians throughout (i.e. only convert
  the inputs and outputs from and to degrees)

HTH,
Gilles

>
> where, for example, Cosis defined elsewhere as Math.cos(Math.toRadians(val))
>
> Where/what can I read/do to get a start on this problem?
>
>
> Thanks
>
>
> Matthew

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to