News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

The calculator

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

Previous topic - Next topic

HSE

Hi Rui!!

Remember the original problem:

    [a+b*x^c]'    http://masm32.com/board/index.php?topic=175.msg57776#msg57776

The idea is: calling object.solution(x, a+b*x^c) solve der.x, calling object.solution(c, a+b*x^c) solve der.c , etc.

Regards. HSE
Equations in Assembly: SmplMath

RuiLoureiro

#166
Quote from: HSE on September 13, 2016, 10:03:12 AM
Hi Rui!!

Remember the original problem:

    [a+b*x^c]'    http://masm32.com/board/index.php?topic=175.msg57776#msg57776

The idea is: calling object.solution(x, a+b*x^c) solve der.x, calling object.solution(c, a+b*x^c) solve der.c , etc.

Regards. HSE
Hi HSE,
             Ok i hope you have something done as soon as possible.  :t
I want to try it .

Now iam working in some previous procedures to clean some cases.
If we write something like this:

[(-x)*2    +   (-x)/2      +(-x+2)       -x-2       +2*(-x)      *(+x)^2 ]'
the expression to solve is this (not the previous)

[ -x*2    -x/2    -x+2    -x-2    -2*x     *x^2 ]'
Now i am testing it.
:icon14:

RuiLoureiro

Hi
        These are the results of the last test.
        The expression used has a lot of brackets.
        They are cleaned before used by the procedure
        that replace x by expression and all procedures
        used after that operation.
       
Here one sample
Quote
input box=> [x^+x-x^(-x)+x^(x)-x^(+X)+((sin(x)+2))]'


expression cleaned: [x^x              -x^-x               +x^x               -x^X               +sin(x)   +2 ]'

Replace by sin(x)
Replace by x/e^x
Replace by x-2

solution box1=>     sin(x)^sin(x)    -sin(x)^-sin(x)     +sin(x)^sin(x)     -sin(x)^sin(x)     +sin(sin(x))+2
                   +(x/e^x)^(x/e^x)    -(x/e^x)^-(x/e^x)   +(x/e^x)^(x/e^x)   -(x/e^x)^(x/e^x)   +sin(x/e^x)+2
                   +(x-2)^(x-2)      -(x-2)^-(x-2)       +(x-2)^(x-2)       -(x-2)^(x-2)       +sin(x-2)+2

Replace by -sin(x)
Replace by -x/e^x
Replace by -x+2

                   +(-sin(x))^-sin(x)  -(-sin(x))^sin(x)   +(-sin(x))^-sin(x) -(-sin(x))^-sin(x) +sin(-sin(x))+2
                   +(-x/e^x)^-(x/e^x)  -(-x/e^x)^(x/e^x)  +(-x/e^x)^-(x/e^x) -(-x/e^x)^-(x/e^x) +sin(-x/e^x)+2
                   +(-x+2)^(-x+2)     -(-x+2)^-(-x+2)    +(-x+2)^(-x+2)     -(-x+2)^(-x+2)     +sin(-x+2)+2
Good luck

HSE

Hi Rui!!

In a couple of weeks this thing perhaps work.



input:
2*x^35e-1*arctg(sin(x+2))

output:
2*(35e-1*x^(35e-1-1)*arctg(sin(x+2))+x^35e-1*1/(1+(sin(x+2))^2)*((cos(x+2)*(+(1)+0))))

Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on September 28, 2016, 08:41:13 AM
Hi Rui!!

In a couple of weeks this thing perhaps work.



input:
2*x^35e-1*arctg(sin(x+2))

output:
2*(35e-1*x^(35e-1-1)*arctg(sin(x+2))+x^35e-1*1/(1+(sin(x+2))^2)*((cos(x+2)*(+(1)+0))))


Hi HSE

Good work! Go on !

About your output result, you may:

(1)    Simplify brackets (there are too much brackets)

(2)    Remove things like (+(1)+0)      ( is =1 )

(3)    This: x^35e-1*1 / could be x^35e-1/

Quote
input:
2*x^35e-1*arctg(sin(x+2))

output:
          2*(    35e-1*x^( 35e-1-1)   * arctg(sin(x+2))

         +x^35e-1*1 / ( 1+(sin(x+2) )^2 ) *  (  (cos(x+2)* (+(1)+0)  ) )    )
Good luck !  :t

HSE

Thanks Rui!!

Right now I'm adding parenthesis  :biggrin:.  It's almost the last task to complete derivator.

The idea is to make an indepent process that "clean" the result, even obtain common factor or some other operation (that I not imagine now) for a nicer solution.

Regards. HSE
Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on October 04, 2016, 10:11:06 AM
Thanks Rui!!

Right now I'm adding parenthesis  :biggrin: .  It's almost the last task to complete derivator.

The idea is to make an indepent process that "clean" the result, even obtain common factor or some other operation (that I not imagine now) for a nicer solution.

Regards. HSE
Hi HSE,
        Nothing at all, HSE.

        About your last answer (to make an independent process that "clean" the result )
        «The calculator» do it also. But it starts to clenning same cases too as i
        said before.
Quote
        About the procedure to solve an expression of simple functions of X
        - without function names or polynomials-
        like « C +x +C*x - x^C + x^x - x/C + x/C - C +...»
        you may start the output string result as a null string and add each
        particular result until we get the end. But before adding, test the result
        and don't add if it is 0 - if it is 0 it is done and go to the next.
        Each result must have sign (+ or -) unless it is the first
        or any equivalent procedure ( this is only one hint! ). In
        this way we dont need to clean zeros.
See you !
Good luck, (i have a lot of work to do!).  :t

HSE

Hi Rui!

   You can see in http://masm32.com/board/index.php?topic=5725.0 the present state of my project. Opinions are welcome (mostly nice and encouraging ones  :biggrin: )

Regards. HSE
Equations in Assembly: SmplMath

RuiLoureiro

Hi HSE

Correct this:
Quote
EXPRESSION:

2*sin(3*x+5)+x^-0.0

RESULT:

+2*(cos(3*x+5)*(+3*(1)+0))+((-0.0)*x^(-0.0-1))

der.x = 2*(3(cos(5+3*x)))+-0.000000*(x^-1.000000)
Good work !  :t

HSE

Thanks Rui!!

I'm working in the interface, but next week I have another round with the cleaner  :t
Equations in Assembly: SmplMath

RuiLoureiro

Quote from: HSE on October 20, 2016, 11:04:19 AM
Thanks Rui!!

I'm working in the interface, but next week I have another round with the cleaner  :t

Hi HSE
         The cleaner is working well but needs
         some more work
Quote
EXPRESSION:   x^1+(5/1)*x^2
RESULT:
+((1)*x^(1-1))+(5/1)*((2)*x^(2-1))

der.x = (x^0)+5*(2*(x^1))   <<<<<------ x^0= 1  and x^1= x
Good luck  :t
:icon14:

HSE

Thanks Rui!

The power is solved making a second pass in the cleanner. In first pass there is parenthesis ^( ).

+((1)*a^(1-1))+(5/1)*((2)*a^(2-1))

(a^0)+5*(2*(a^1))           <   result clean 1

1+5*(2*(a))                       <  result clean 2

1+5*(2*a)                          <  result clean 3

der.a = 1+5*(2*a)             <  result clean4 ( no improvement)

Note that parenthesis isn't removed, solution is 1+10*a. I also have some very absurd problems: (-1-1) is solved like (0)  :biggrin:, also (--) (+-), etc.  But now I'm a little in the dark side (J2ME) improving a Horse' data base I maked for my cell phone. 
Equations in Assembly: SmplMath

RuiLoureiro

Hi HSE,

correct this:
[cos(cos(x))]'

This is your result:
Quote
(cos(cos(x))*((-sin(x))))       <<<<- why a lot of brackets ?

   +0                 <---  why this ?
Do this:
cos(cos(x)) = cos( argX)   where argX= cos(x) and [cos(x)]'= -sin(x)
So,
Quote
[cos(cos(x))]' = [cos(argX)]' * [argX]'
                   = -sin(argX)   * (-sin(x))
                   =  sin(argX)   * sin(x)
                   = sin(cos(x)) * sin(x)   <<<<--- give this result (remove brackets)

Good luck  :t

HSE

Perfect :t

I will see next week!

Theoretically the cleanning process remove parenthesis, but perhaps not. Sometimes work so bad that program crash! Because that, last version can disable cleanning from "options". When active solution say "der.x = ".

Thanks Rui!
Equations in Assembly: SmplMath

HSE

Solved (I think) and updated! 
Equations in Assembly: SmplMath