@@ -333,6 +333,7 @@ algorithm
333333 DAE . ReductionIterators iters;
334334 DAE . CallAttributes attr;
335335 BackendDAE . VarKind kind;
336+ Real r;
336337
337338 case (DAE . ICONST (integer = _),_) then DAE . RCONST (0 . 0 );
338339 case (DAE . RCONST (real = _),_) then DAE . RCONST (0 . 0 );
@@ -515,14 +516,25 @@ algorithm
515516 then
516517 DAE . IFEXP (DAE . RELATION (exp,DAE . GREATER (DAE . T_REAL_DEFAULT ),DAE . RCONST (0 . 0 ),-1 ,NONE ()), e1_1, DAE . UNARY (DAE . UMINUS (DAE . T_REAL_DEFAULT ),e1_1));
517518
518- case (e0 as DAE . BINARY (exp1 = e1,operator = DAE . POW (tp),exp2 = (e2 as DAE . RCONST (_))),inVariables) /* ax^(a-1) */
519+ // x^r
520+ case (e0 as DAE . BINARY (exp1 = e1,operator = DAE . POW (tp),exp2 = (e2 as DAE . RCONST (real= r))),inVariables) /* ax^(a-1) */
519521 equation
520522 d_e1 = differentiateExpTime(e1, inVariables) "e^x => xder(e)e^x-1" ;
521523 // false = Expression.expContains(e2, Expression.makeCrefExp(tv,tp));
522524 // const_one = differentiateExp(Expression.makeCrefExp(tv,tp), tv);
525+ r = r -. 1 . 0 ;
523526 exp = DAE . BINARY (
524527 DAE . BINARY (d_e1,DAE . MUL (tp),e2),DAE . MUL (tp),
525- DAE . BINARY (e1,DAE . POW (tp),DAE . BINARY (e2,DAE . SUB (tp),DAE . RCONST (1 . 0 ))));
528+ DAE . BINARY (e1,DAE . POW (tp),DAE . RCONST (r)));
529+ then
530+ exp;
531+
532+ // r^x
533+ case (e0 as DAE . BINARY (exp1 = (e1 as DAE . RCONST (real= r)),operator = DAE . POW (tp),exp2 = e2),inVariables) /* r^x*ln(r)*der(x) */
534+ equation
535+ d_e1 = differentiateExpTime(e2, inVariables);
536+ r = realLn(r);
537+ exp = DAE . BINARY (DAE . BINARY (e0,DAE . MUL (tp),DAE . RCONST (r)),DAE . MUL (tp),d_e1);
526538 then
527539 exp;
528540
@@ -724,7 +736,7 @@ algorithm
724736 e1_1 = differentiateExpTime(e1, inVariables);
725737 then
726738 DAE . REDUCTION (reductionInfo,e1_1,iters);
727-
739+
728740 /* We need to expect failures for example for shared array-equations
729741 case (e,_)
730742 equation
0 commit comments