News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

The calculator

Started by RuiLoureiro, May 31, 2012, 10:59:09 PM

Previous topic - Next topic

HSE

#105
Hi Rui!

Have you thinked in symbolic solution of partial derivatives?

For example:     

             input box=> [a+b*x^c]'

             solution box1=> der.a =1
             solution box2=> der.b =x^c
             solution box3=> der.c = b*c*x^(c-1)  <- this, at least partially, explain Rui smile
             solution box3=> der.c = b*x^c* ln(x)      <- I think!
                                                                                    (more easy remember Rui calculator
                                                                                      that this things)

Regards, HSE


Equations in Assembly: SmplMath

RuiLoureiro

 :biggrin:
Hi HSE,
       Thanks for your post.
       The answer is NO. I have no time now to do it
       and my main computer is not working.
       It needs to be repaired.
       Meanwhile, we can see that the calculator
       solves [3+5.34^x]' =ln(5.34)*5.34^x
       but doesn't solve [3+2*5.34^x]'= Expression error.
       So, i need to do some more work about derivatives because
       it doesn't solve some cases yet.

      Note: The calculator uses x or X as the variable (not a,b or c)

Regards  :t
Rui

RuiLoureiro

Hi HSE,
       First of all, thanks for your question about partial derivatives.

       Now, you need to correct your example because you made an error
       in the third solution.

       In your example, it is given a function of 3 variables a, b and c (x is a constant)

       f(a,b,c)=[a+b*x^c]. And we want the partial derivative of f(a,b,c)

       1.   with respect to the variable a ( which means that b*x^c is a constant );
       2.   with respect to the variable b ( which means that a and x^c are constants );
       3.   with respect to the variable c ( which means that a, b and x are constants ).

       This means that your two first solutions

             solution box1=> der.a =1
             solution box2=> der.b =x^c

       are correct. But the third - solution box3=> der.c =b*c*x^(c-1) -
       is not correct because x^c is not a power function
       but an exponential function g(c)=x^c (c is a variable and x is a constant).

       In this way, g'(c)=[e^(c*ln(x))]'= ln(x) * e^(c*ln(x)) = ln(x) * x^c

       Particular cases:
                         1. If x= e   then g'(c)= e^c ;
                         2. If x=10  then g'(c)=ln(10) * 10^c

       So, the third solution is, in general:

                         solution box3=> der.c = b * ln(x) * x^c
       EDIT:
                 or     solution box3=> der.c = ln(x) * x^c * b  etc


       I will post the new version calcula68 to solve functions like f'(x)=[C1+...+C2*K^x]'
       as soon as possible.

       Good luck  :t

       Regards,
       Rui Loureiro

EDIT:  you say that «...this, at least partially, explain Rui smile».
           No, it has nothing to do with it but with the question itself.
           Thanks HSE  :t

HSE

Thanks Rui!!

I change my post when I think in your smile! (just in time)

Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on June 02, 2016, 08:43:37 AM
Thanks Rui!!

I change my post when I think in your smile! (just in time)

Thanks HSE.
As i said before i need to do some more work about derivatives. My last post was in 2014 - September 05, 2014.

RuiLoureiro

Hi HSE,
             If we try to get [x-cos(x)]'  the calculator gives 1-[-sin(x)].
             Do you like the solution ? I dont like ! In the next version
             the solution will be 1+sin(x) and NOT -[- ... ].
:t

HSE

Hi Rui!
           I have tried [2.5+3*sin(2*3.14*x/5+4)]', of course very complex.

           But also is too complex [3+2*sin(x)]' . You have a lot of work to do!  :biggrin:

           Regards. HSE
Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on June 07, 2016, 10:21:41 PM
Hi Rui!
           I have tried [2.5+3*sin(2*3.14*x/5+4)]', of course very complex.

           But also is too complex [3+2*sin(x)]' . You have a lot of work to do!  :biggrin:

           Regards. HSE
Hi HSE
             Thanks for your reply  :t
             I am working in a new version: calcula68 v2016.01
             If we use calcula67 we cannot get the solution of  [3+2*sin(x)]'. But
             using the new version we get  2*cos(x)
              and this (for example):

[-x-x^2-1/x-e^x -x^x -ln(x)-log(x)-sqr(x)-sin(x)-cos(x)- arcsin(x) -arccos(x) -arctan(x) -arccsc(x)  -arcsec(x) -arccot(x) ]'

=-1-2*x+1/(x^2)-e^x-(1+ln(x))*exp(x*ln(x))-1/x-1/(ln(10)*x)-1/(2*sqr(x))-cos(x)+sin(x)-1/sqr(1-x^2)-1/sqr(1-x^2)-1/(1+x^2)
-1/(abs(x)*sqr(x^2-1))-1/(abs(x)*sqr(x^2-1))-1/(1+x^2)


Yes, i have a lot of work to do. I need to test a lot of expressions. But i dont want to solve 2*3.14*x/5 but only C * x where C= 2*3.14/5
Thanks :t

HSE

Hi Rui!

    Perhaps the equation parser that qWord developed for SmplMath is usefull for parenthesis problem.

   In practice, most of the equations are short but with parenthesis. Now I trying to write derivatives that are used in Levenberg-Marquardt method to solve non linear models:

Equation:
Quote
Y = a+b*sin(c+2*3.14159*(X/d));
First partial derivatives:
Quote
DER.a = 1;
DER.b = sin(c+(2*3.14159*X/d));
DER.c = b*cos(c+(2*3.14159*X/d));
DER.d = b*cos(c+(2*3.14159*X/d))*(2*3.14159*X*(-1)/d**2);

Second partial derivatives:
Quote
DER.a.a=0;
DER.a.b=0;
DER.a.c=0;
DER.a.d=0;
DER.b.a=0;
DER.c.a=0;
DER.d.a=0;
DER.b.b=0;
DER.b.c=cos(c+ (2*3.14159*X/d))*((2*3.14159*X/d)+1);
DER.b.d=cos(c+(2*3.14159*X/d))*2*3.14159*-1/d**2;
DER.c.b=cos(c+ (2*3.14159*X/d))*((2*3.14159*X/d)+1);
DER.d.b=cos(c+(2*3.14159*X/d))*2*3.14159*-1/d**2;
DER.c.c=b*(-1)*sin(c+(2*3.14159*X/d));
DER.c.d= b*-sin(c+(2*3.14159*X/d))*(2*3.14159*X*(-1)/d**2);
DER.d.c= b*-sin(c+(2*3.14159*X/d))*(2*3.14159*X*(-1)/d**2);
DER.d.d=b*2*3.14159*X*(-1)*( -sin(c+2*3.14159*X/d**2)*(2*3.14159*X*(-1)/d**2)+cos(c+2*3.14159*X/d**2)*-2*d**-3);

I can find the solution, but the convergence is very slow, perhaps some error. At least I'm learning a litlle of derivation (because I have my old notes, but I think another person write them  :biggrin:)   
Equations in Assembly: SmplMath

qWord

Quote from: HSE on June 09, 2016, 12:32:59 AM
    Perhaps the equation parser that qWord developed for SmplMath is usefull for parenthesis problem.
Please DON'T - he should use something well known, e.g. the Shunting-yard algorithm.

Whatever the case may be, seems like that his current problem is to bring the equation into a canonical form before applying  derivation rules.
MREAL macros - when you need floating point arithmetic while assembling!

HSE

Quote from: qWord on June 09, 2016, 02:32:26 AM
Please DON'T - ... the Shunting-yard algorithm.
Just an idea. Very nice, that idea lead to other idea.

Next week I will try to find what is a canonical form. 8) 
Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on June 09, 2016, 05:13:37 AM
Quote from: qWord on June 09, 2016, 02:32:26 AM
Please DON'T - ... the Shunting-yard algorithm.
Just an idea. Very nice, that idea lead to other idea.

Next week I will try to find what is a canonical form. 8)
Hi qWord, how are you ?
Hi HSE
               I think that if we have a procedure that solves [c+K*x/d]' for any variable c OR x OR d
               we have the problem solved for f(c+K*x/d). In this way, if the argument is in this "canonical form"
               it is solved: sin(c+K*x/d)'= [c+K*x/d]' cos(c+K*x/d).

Force

Hi Rui it's Good work :t

HSE

I have the concept!! (I think)

Thanks.
Equations in Assembly: SmplMath

RuiLoureiro

Quote from: Force on June 10, 2016, 08:37:07 AM
Hi Rui it's Good work :t
Thanks  :t
          My problem now is not only to solve the derivative of but to show it.
          For example i dont want to show solutions like [...]'= 2*1/(...)  but 2/(...)
          Or 2*[-1/(...)] but -2/(...).
          And i have no problems to solve expressions like C1*C2*C3/C4/C5*X/C6*C7 etc
          where Cn are constants and X is the variable. But may be The calculator will solve it soon.
          Don't Know now.
          Thanks for your reply  :t