Hello,

This shows one way of interpreting the derivative for strictly +ve numbers.

    public static void main(final String[] args) {
        final double x = 1d;
        DerivativeStructure dsA = new DerivativeStructure(1, 1, 0, x);
        System.out.println("Derivative of |a|^x wrt x");
        for (int p = 10; p < 21; p++) {
            double a;
            if (p < 20) {
                a = 1d / Math.pow(2d, p);
            } else {
                a = 0d;
            }
            final DerivativeStructure a_ds = new DerivativeStructure(1, 1,
a);
            final DerivativeStructure out = a_ds.pow(dsA);
            final double calc = (Math.pow(a, x + EPS) - Math.pow(a, x)) /
EPS;
            System.out.format("Derivative@%f=%f  %f\n", a, calc,
out.getPartialDerivative(new int[]{1}));
        }
    }

At this point I"m explicitly substituting the rule that derivative(|a|^x) =
0 for |a|=0.

Thanks,
Ajo.



On Fri, Aug 23, 2013 at 9:39 AM, Luc Maisonobe <luc.maison...@free.fr>wrote:

> Hi Ajo,
>
> Le 23/08/2013 17:48, Ajo Fod a écrit :
> > Try this and I'm happy to explain if necessary:
> >
> > public class Derivative {
> >
> >     public static void main(final String[] args) {
> >         DerivativeStructure dsA = new DerivativeStructure(1, 1, 0, 1d);
> >         System.out.println("Derivative of constant^x wrt x");
> >         for (int a = -3; a < 3; a++) {
>
> We have chosen the classical definition which implies c^x is not defined
> for real r and negative c.
>
> Our implementation is based on the decomposition c^r = exp(r * ln(c)),
> so the NaN comes from the logarithm when c <= 0.
>
> Noe also that as explained in the documentation here:
> <
> http://commons.apache.org/proper/commons-math/userguide/analysis.html#a4.7_Differentiation
> >,
> there are no concepts of "constants" and "variables" in this framework,
> so we cannot draw a line between c^r as seen as a univariate function of
> r, or as a univariate function of c, or as a bivariate function of c and
> r, or even as a pentavariate function of p1, p2, p3, p4, p5 with both c
> and r being computed elsewhere from p1...p5. So we don't make special
> cases for the case c = 0 for example.
>
> Does this explanation make sense to you?
>
> best regards,
> Luc
>
>
> >             final DerivativeStructure a_ds = new DerivativeStructure(1,
> 1,
> > a);
> >             final DerivativeStructure out = a_ds.pow(dsA);
> >             System.out.format("Derivative@%d=%f\n", a,
> > out.getPartialDerivative(new int[]{1}));
> >         }
> >     }
> > }
> >
> >
> >
> > On Fri, Aug 23, 2013 at 7:59 AM, Gilles <gil...@harfang.homelinux.org
> >wrote:
> >
> >> On Fri, 23 Aug 2013 07:17:35 -0700, Ajo Fod wrote:
> >>
> >>> Seems like the DerivativeCompiler returns NaN.
> >>>
> >>> IMHO it should return 0.
> >>>
> >>
> >> What should be 0?  And Why?
> >>
> >>
> >>
> >>> Is this worthy of an issue?
> >>>
> >>
> >> As is, no.
> >>
> >> Gilles
> >>
> >>
> >>> Thanks,
> >>> -Ajo
> >>>
> >>
> >>
> >>
> ------------------------------**------------------------------**---------
> >> To unsubscribe, e-mail: dev-unsubscribe@commons.**apache.org<
> dev-unsubscr...@commons.apache.org>
> >> For additional commands, e-mail: dev-h...@commons.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>

Reply via email to