News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Solving real expressions

Started by RuiLoureiro, March 24, 2012, 06:30:21 PM

Previous topic - Next topic

RuiLoureiro

Hi
        Now calcula23 use constants pi and e
        and it work with scientific format;

        It also solves equations ax^2+bx+c=c0
        where a,b,c are real constants in scientific format or not.
        It also gives the complex solutions if it is the case.

        If you want pi, type pi; if you want e, type e;

        I dont know any bug.
        If you know, please reply here and tell me

        Good luck ! :wink
        Thanks

EDIT: this calcula23 has some bugs. Please try the last calcula30

Adamanteus

Seem math mistakes there not much, but is  :naughty:
So 80-bit REAL format giving exactness more then 17 digital digits and 4096 exponent size, I seen only 15 and not seen exponent :
e^22 = 3584912846.131592 - I got - e^22 = 3584912846.131591
e^100 = unxpected value     - I got - e^100 = 2.688117141816135E43

jj2007

It seems to be a printing problem, as e^100 yields various one-character outputs (@, d, ...).

RuiLoureiro

Adamanteus
            Thank you for help me  :wink
           
            The same for jj !  :thumbu

            Try calcula24 now
jj,
Quote
It seems to be a printing problem           

            Not only, but a converting problem also
            That is the problem of calcula23

            Now we have calcula24.
            The problem is solved
            Good luck !
            Thanks

Adamanteus

Very exact program, I found only small mistakes :
sin(pi) = - 0
differ results (but I don't know what exact) e^10000 = 8.806818225662921E4342 - I got - e^10000 = 8.8068182256629479E4342

RuiLoureiro

#5
Adamanteus,
            Thank so much for your words
            If we try Ztest from raymond, we have 3 cases:

            my case   e^10000 = 8.806818225662921 E4342
            You got - e^10000 = 8.8068182256629479E4342 
            Ztest     - e^10000 = 8.806818225663056 E4342


Hi all,
        First, thank you so much to all people for trying calcula24
               and trying to help me;

        Please, if you see an error or bug, reply to
        this post; It is possible it needs some corrections.
        If i know i post it here.

        One word to Raymond: thank you so much for your lib and your help !

        Calcula24 has some minor problems with signs.
        I know also this problems with calcula24:

                1. sin(3.5*pi/2)^2+cos(3.5*pi/2)^2 must be 1
                2. -x^2+x+1=0   doesnt solve any -x^2... =0 or +x^2... =0
                   or 2x^2... =0
                   
        All this problems are solved.
        Now you can try Calcula25

        Calculation rules

            1. terms inside parentheses or brackets
            2. functions
            3. exponents or powers
            4. multiplication and division
            5. addition and subtraction

        a) All calculatios are made in 80 bit format
           e.g.: 2+3    both are taken as real10 numbers
           
        b) Exceptions: expressions X^Y. Y is taken as integer32
                       if possible;
                       
           e.g.: (-2)^(2+3*1/3-1) but not here (-2)^(2+3*1/3-1.0)
                 because one term is 1.0

        c) Expressions like this:  SIN(...)^Y, 10^(...)^Y, ...
                            means
                                  (SIN(...))^Y, (10^(...))^Y, ...
       
        Some results from calcula25:
       
Quote
...
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
sin(3.5*pi/2)^2+cos(3.5*pi/2)^2
This is your expression: sin(3.5*pi/2)^2+cos(3.5*pi/2)^2
This is your Result:   1.000000000000000
sin(3.5*pi/2)^2+cos(3.5*pi/2)^2= 1.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
-x^2+x+1=0
This is your expression: -x^2+x+1=0
RootX0= -0.5000000000+ i  0.8660254038
RootX1= -0.5000000000- i  0.8660254038
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
ln(e)
This is your expression: ln(e)
This is your Result:   1.000000000000000
ln(e)= 1.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
ln(5000)
This is your expression: ln(5000)
This is your Result:   8.517193191416237
ln(5000)= 8.517193191416237
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
log(10e5)
This is your expression: log(10e5)
This is your Result:   6.000000000000000
log(10e5)= 6.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^750
This is your expression: e^750
This is your Result:   5.258494541454804E+0325
e^750= 5.258494541454804E+0325
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^-500
This is your expression: e^-500
This is your Result:   0.000000000000000
e^-500= 0.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^0
This is your expression: e^0
This is your Result:   1.000000000000000
e^0= 1.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
pi
This is your expression: pi
This is your Result:   3.141592653589793
pi= 3.141592653589793
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e
This is your expression: e
This is your Result:   2.718281828459045
e= 2.718281828459045
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^-5000
This is your expression: e^-5000
This is your Result:   0.000000000000000
e^-5000= 0.000000000000000
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^-50000
This is your expression: e^-50000
This is your Result:   0
e^-50000= 0
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
10^5000
This is your expression: 10^5000
This is your Result:  OVERFLOW
10^5000=OVERFLOW
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
pi^pi
This is your expression: pi^pi
This is your Result:   36.46215960720791
pi^pi= 36.46215960720791
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
pi^e
This is your expression: pi^e
This is your Result:   22.45915771836105
pi^e= 22.45915771836105
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^pi
This is your expression: e^pi
This is your Result:   23.14069263277927
e^pi= 23.14069263277927
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^e
This is your expression: e^e
This is your Result:   15.15426224147926
e^e= 15.15426224147926
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
e^-pi
This is your expression: e^-pi
This is your Result:   0.043213918263772
e^-pi= 0.043213918263772
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
pi^-e
This is your expression: pi^-e
This is your Result:   0.044525267266923
pi^-e= 0.044525267266923
---------------------------------------------
EDIT: one procedure was not completed
      so i removed calcula25 for some time

raymond

QuoteOne word to Raymond: thank you so much for your lib and your help !

You are most welcome. Keep up the good work. You must be getting a lot of satisfaction from all that hard work which resulted in what you were trying to achieve. :clap: :clap: :clap:
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

RuiLoureiro

Hi Raymond,
            Thank you so much.
            In any case you did a very good work !  :clap: :clap: :clap:

Hi all

    1. Calcula25 doesnt solve (2+3)^2

Quote
-------------------------------------------------------------------       
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
(2+3)^2
This is your expression: (2+3)^2
This is your Result:  ERROR
(2+3)^2=ERROR

    2. Now, with calcula26 we can use the constants
       pi, +pi, -pi, e, +e, -e, or any constant in scientific notation
       in the equation aX^2+bX+c=c0 (but not expressions !)
       
       Examples:
-------------------------------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
-piX^2+eX+pi=2e3
This is your expression: -piX^2+eX+pi=2e3
RootX0=  0.432627989716133+ i -25.20778858587352
RootX1=  0.432627989716133- i -25.20778858587352
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
eX^2+piX=1
This is your expression: eX^2+piX=1
RootX0=  0.259874869004203
RootX1= -1.415602218795125
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
eX^2+piX-1=0
This is your expression: eX^2+piX-1=0
RootX0=  0.259874869004203
RootX1= -1.415602218795125
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
piX+e=2
This is your expression: piX+e=2
RootX0= -0.228636207064684
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
-eX^2=5
This is your expression: -eX^2=5
RootX0=  0+ i -1.356243785555241
RootX1=  0- i -1.356243785555241
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
-piX^2+2e3=1
This is your expression: -piX^2+2e3=1
RootX0= -25.22501660022046
RootX1=  25.22501660022046
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
-X^2+X-20=0
This is your expression: -X^2+X-20=0
RootX0=  0.500000000000000+ i -4.444097208657794
RootX1=  0.500000000000000- i -4.444097208657794
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
       
       
        3. We have:
       
        (e)^e = (+e)^e= e^e  and (-e)^2= e^2  and (-e)^3= -e^3 and (-e)^e= ERROR

        and
       
        (pi)^pi = (+pi)^pi= pi^pi  and (-pi)^2= pi^2  and (-pi)^3= -pi^3 and (-pi)^pi= ERROR

RuiLoureiro

Hi
        The first step to get the calculator is finished.
        All procedures are completed, at least for now
        (and while i dont find any error !  :wink).
       
        Here is calcula26.
        Try it and have a good luck !

        Thank you all
        RuiLoureiro

RuiLoureiro

#9
Hi all,

I added the following functions to calcula26:

                sec(x), csc(x), cot(x), secd(x), cscd(x), cotd(x)
         arcsec(x), arccsc(x), arccot(x), arcsecd(x), arccscd(x), arccotd(x)

They are in calcula27
Try it and say something !
Thanks :wink

Quote
-------------------------------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
cos(pi/6)
This is your expression: cos(pi/6)
This is your Result:   0.866025403784439
cos(pi/6)= 0.866025403784439
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
sec(pi/6)
This is your expression: sec(pi/6)
This is your Result:   1.154700538379252
sec(pi/6)= 1.154700538379252
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
1/cos(pi/6)
This is your expression: 1/cos(pi/6)
This is your Result:   1.154700538379252
1/cos(pi/6)= 1.154700538379252
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
pi/6
This is your expression: pi/6
This is your Result:   0.523598775598299
pi/6= 0.523598775598299
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
arcsec(1.1546)
This is your expression: arcsec(1.1546)
This is your Result:   0.523447935192547
arcsec(1.1546)= 0.523447935192547
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
sec(pi/6)
This is your expression: sec(pi/6)
This is your Result:   1.154700538379252
sec(pi/6)= 1.154700538379252
---------------------------------------------
Type an expression and press enter [ ex: -pi + 3.1*(7 - 2*8.3) ]
arcsec(1.154700538379252)
This is your expression: arcsec(1.154700538379252)
This is your Result:   0.523598775598300
arcsec(1.154700538379252)= 0.523598775598300
---------------------------------------------

RuiLoureiro

#10
I added the following functions to calcula26:

                sec(x), csc(x), cot(x), secd(x), cscd(x), cotd(x)
         arcsec(x), arccsc(x), arccot(x), arcsecd(x), arccscd(x), arccotd(x)

I added also a table of constants to calcula26:

        We can define up to 10 constants;
       
        The name can have up to 8 characters: e.g.: exp=-10.5;sin=2.3;
        It must begin with a letter (A to Z or a to z);

        We type something like this:
       
        t=-1e3; x=1.2; y=4.5; i=3; n=5; m=100; u=-5.2; v=8.9; u=10.1; z=10;
        (with spaces or not)
       
        Each constant must end with ;

        If we want to change to another table of constants, simply
        we type another set;

        They are in calcula27
Quote
******This calculator solves expressions in 80-bit REAL format*****
------------------------By Rui Loureiro----------------------------
Type an Expression, Equation or Constants and press enter
exp=-15.3;t=-1e3;x=-12.53;y=45.2;

This is your expression: exp=-15.3;t=-1e3;x=-12.53;y=45.2;
Type an Expression, Equation or Constants and press enter
3*t+2*x-y
This is your expression: 3*t+2*x-y
This is your Result:  -3070.260000000000
3*t+2*x-y=-3070.260000000000
---------------------------------------------
Type an Expression, Equation or Constants and press enter
exp+t-x+y
This is your expression: exp+t-x+y
This is your Result:  -957.5700000000000
exp+t-x+y=-957.5700000000000
---------------------------------------------
Type an Expression, Equation or Constants and press enter
sin(x+y)
This is your expression: sin(x+y)
This is your Result:   0.950261196835101
sin(x+y)= 0.950261196835101

        Try it and say something !
        Thank you

raymond

QuoteThis is your expression: e^-t+10
This is your Result:   11.00000000000000
e^-t+10= 11.00000000000000

Could you have another look at this one.
You have t = -1e3 = -1000
Therefore, -t = +1000, and e^1000 should be a large number. How do you arrive at the quoted result?
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

RuiLoureiro

Raymond,
        Sorry it's an error in the calculator while
        trying to get the exponent in scientific format.
        This is because we can type e^e or e^+e or e^-e
        the second 'e' is a constant E not scientific format.
       
        Now it is correct, thank you  :thumbu

        I removed the old calcula27 and
        i replaced by the new calcula27
        Thanks  :wink
         
Quote
-------------------------------------------------------------------
Type an Expression, Equation or Constants and press enter
e^1000
This is your expression: e^1000
This is your Result:   1.970071114017047E+0434
e^1000= 1.970071114017047E+0434
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^1e3
This is your expression: e^1e3
This is your Result:   1.970071114017046E+0434
e^1e3= 1.970071114017046E+0434
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^+1e3
This is your expression: e^+1e3
This is your Result:   1.970071114017046E+0434
e^+1e3= 1.970071114017046E+0434
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^-1e3
This is your expression: e^-1e3
This is your Result:   0.000000000000000
e^-1e3= 0.000000000000000
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^-1000
This is your expression: e^-1000
This is your Result:   0.000000000000000
e^-1000= 0.000000000000000
---------------------------------------------
Type an Expression, Equation or Constants and press enter
t=-1e3;u=1e3;
This is your expression: t=-1e3;u=1e3;
Type an Expression, Equation or Constants and press enter
e^-t
This is your expression: e^-t
This is your Result:   1.970071114017046E+0434
e^-t= 1.970071114017046E+0434
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^u
This is your expression: e^u
This is your Result:   1.970071114017046E+0434
e^u= 1.970071114017046E+0434
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^e
This is your expression: e^e
This is your Result:   15.15426224147926
e^e= 15.15426224147926
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^+e
This is your expression: e^+e
This is your Result:   15.15426224147926
e^+e= 15.15426224147926
---------------------------------------------
Type an Expression, Equation or Constants and press enter
e^-e
This is your expression: e^-e
This is your Result:   0.065988035845313
e^-e= 0.065988035845313
---------------------------------------------
Type an Expression, Equation or Constants and press enter

RuiLoureiro

Can i load Fpu from a register ?
I have a value in the EAX register
and i want to load it directly into Fpu ?
Impossible ?
Thanks

dedndave

        push    eax
        fld real4 ptr [esp]
        pop     eax