News:

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

The calculator

Started by RuiLoureiro, April 09, 2012, 02:16:47 PM

Previous topic - Next topic

RuiLoureiro

Hi all,
        Here is calcula32 in a window version (GUI)
       
        Try it and say something

        Good luck !
        RuiLoureiro

        We can solve:
                        0. We can define a set of 10 variables:  t=10;x=2.3;...
                        1. any expression
                        2. mean(x1,...,xn):    mean(12,13,12,13,14)
                        3. factorial and k-combination of n: 12!, comb(12,5)
                        4. equation: aX^2+bX+c=0
                        5. System of 2 equations: type aX+bY=c;fX+gY=h;
                        6. System of 3 equations: type aX+bY+cZ=d;fX+gY+hZ=i;
                                                       jX+kY+mZ=l;
        (note: a,b,c, ... real numbers)

    EDIT: Please, dont use calcula32 to solve systems of equations
          because, in some cases -impossible/infinite-the result is not correct.
          Use the last calcula35 where you can type and press ENTER or
          press DELETE to delete the input.

    EDIT: i decided to remove calcula32 and to replace it by calcula36

EDIT: calcula45 was replaced by the new
          calcula46 v1.06. Please, see the last post

        EDIT: calcula46 was replaced by the new
           calcula47 v1.07. Please, see the last post


RuiLoureiro

#1
        Here is calcula33 in a window version (GUI)

        The procedures to solve systems of equations are now correct;
       
        It solves also equations like this: piX+Y=12;eX+piY=5; where pi and e
        are system constants;

        If you know some more problems, please tell me here, no problems !
       
        Remember that, we can type an expression with spaces like this:
                        pi X + Y = 1 2 ; e X + p i Y = 5 ;

        . The prog removes all spaces before starting to work

        . We can type an expression and press ENTER or press DELETE to delete the input

        Do you want to say something about it ? Please, write something
        Thanks
       
        Good luck !
        RuiLoureiro

        EDIT: With systems of equations we must write first X next Y next Z
              It is wrong to write 3Y+2X=5;Y-X=1;

         EDIT: Please, use the last calcula35.


qWord

Hey,
what about calculating the determinant of linear equation systems (3x3)? Would be helpfull, if the system has no or none unique solution.
FPU in a trice: SmplMath
It's that simple!

RuiLoureiro

qWord,
        Thank you for reply and for that particular question.

        First, i solved the system (2x2) and (3x3) using matrices
        and it compute the determinant (2x2) and (3x3) to get the
        solutions. But ok, i can show the determinant value in the next calcula??;

        Second, if the system has no or none unique solution, it
        gives the result: impossible or infinite.

        Try to solve this in calcula33:
       
                a)      X+Y=10 ; 2X+2Y= 20;    (infinite solutions)
               
                b)      X+Y=1  ; X+Y= 3;       (impossible)

        In any way thank you for your reply   :U   

qWord

ok  :P
I've misinterpreted the output: your program maybe better returns a sentence instead of Infinite for all variables.
FPU in a trice: SmplMath
It's that simple!

RuiLoureiro

Quote from: qWord on April 10, 2012, 04:15:53 PM
ok  :P
I've misinterpreted the output: your program maybe better returns a sentence instead of Infinite for all variables.
               Thanks, no problem !  :wink
               What is your suggestion ? I accept all suggestions.  :U
                When i write "infinite" i want to say infinite solutions
                In the next calcula?? it gives "Infinite solutions" and
                it shows the determinant in all cases

qWord

Quote from: RuiLoureiro on April 10, 2012, 04:51:36 PM               What is your suggestion ? I accept all suggestions.  :U
"The System of linear equations has no unique solution" and "The System of linear equations has no solution"?

qWord
FPU in a trice: SmplMath
It's that simple!

RuiLoureiro

Quote from: qWord on April 10, 2012, 05:03:18 PM
["The System of linear equations has no unique solution" and "The System of linear equations has no solution"?

qWord
Ok, i accept the suggestion, it works.
                     It will go in the next calcula34 ! :wink

dedndave

"Undefined"

how about interpolate/extrapolate   :P
i.e., when they enter a linear equation, it waits for them to enter an X or Y to plot the point

...then add a BSL function with interpolate/extrapolate   :bg

RuiLoureiro

Hi Dave,
         It is a good idea. I will go to think about it  :wink

RuiLoureiro

#10
Hi all,
        Here is calcula34 in a window version (GUI)
       
        Now, it is not possible to define a name of a constant with symbols.
        Only letters or digits 0 to 9, starting with a letter;
       
        Remember that when we define a set of constants i.e. tt=10;sx=5.45;
        we can type the name to get the value: to get the value of sx
        type sx [ENTER] and we get 5.45;
       
        Now, when a system of equations has no solution or not unique
        the output is:
        "The System of linear equations has no solution"       
        or "The System of linear equations has no unique solution"
        following qWord suggestion; The determinant is shown also.

        Now, we can use constants (variables ) in a system of 2 equations;

        Now, we can use 6 memories to save what is in the input box
        and we can recall each one: Save1 - Recall1; Save2-Recall2; etc.

        For instance, we can define one set of constants (or variables)
        and save it with Save1; another set and Save2, etc. and
        then we can use one or another. To use one set, first Recall it
        ant press ENTER to set it into a table, then type an expression
        with that constants

        Thank you all

RuiLoureiro

#11
Hi all,
        Here is calcula35, a new version

        I decided to rewrite all procedures to solve a system of
        2 equations, a system of 3 equations and a quadratic equation.
       
        Now, any coefficient can be:
       
            . pi or +pi or -pi ;
            . e or +e or -e ;
            . a number (in scientific notation or not) ;
            . a variable name
       
        Systems of 2 equations

        . We must use X and Y       
        . But it is not importante to write first X or first Y.

            examples:
                        3Y - t X = m;  pi X + 2 Y= k;   (t,m, k are variables)
                       
                      -yyY - e X = 2e3; pi X - Y= xxx;  (yy,xxx are variables)


            Note that, when we type: x=12 ; y= 10;   
            it is a definition of variables x and y

            But     x=12 ; -y= 10 ;   is a system of 2 equations

        Systems of 3 equations

        . We must use X, Y and Z
        . But it is not importante to write first X or first Y or first Z.
       

                    Z+X=10 ;  y-X= t ;  2z-xxx x= 2.5;    (t,xxx are variables)


        Note that, when we type: z=1.3; x=12 ; y= 10;   
        it is a definition of variables z, x and y

        But     -z=1.3; x=12 ; y= 10 ;   is a system of 3 equations

        Quadratic equation

        . a X^2 + b X + c = c0   where a,b,c,c0 can be any coefficient
       
        . We must use X^2 and X or only X:   sX+2.3=5;  (s is a variable name)
       
        . We must use X^2 first and then X:  2 x-3 X^2+1=0 is error
       
                        -tX^2+piX-e=1e2     (t is a variable name)

        Any bug, pelase answer this post
       
        Good luck !
        Thank you all

        EDIT: there is a little problem with scientific notation
                     in the case like this "e2". It doesnt give ERROR
                     but gives a wrong result. I corrected it and
                     i uploaded the calcula35 again.
                     Now we can type "e2" in equations and calcula35 takes
                     it as "1e2" - replace "e2" by "1e2".
                     If we type e2 [ENTER] it gives ERROR

RuiLoureiro

            I am thinking that scientific notation sometimes is a problem.
            Why we cannot type e2 instead of 1e2 ?
            Why we need to write 1e2 and not e2 to stands for 100 ? (1eN=10^N)
            In this way, when we want 10^5 we type e5 and it is = 1e5.
           
            Taking this into account, now, when we write equations, calcula35
            replaces eN by 1eN, +eN by +1eN and -eN by -1eN before converting it
            and we dont need to type the "1". Is it better, no ?           
 

qWord

I think that many programming and scripting languages  do distinguish between identifier and numbers by the first character: if it is a digit between 0-9, it is a number, otherwise it is a identifier.
So most people with corresponding background would think that e1 is a identifier rather than a number...
(furthermore this would prohibit identifier begingin with 'e')
FPU in a trice: SmplMath
It's that simple!

RuiLoureiro

qWord:
Quote
I think that many programming and scripting languages  do distinguish between identifier
and numbers by the first character: if it is a digit between 0-9, it is a number,
otherwise it is a identifier           

            It is a good general rule, but in calculaXX i dont need to follow this
            rule when the expression is a system of equations or a quadratic
            equation because to distinguish between the constant e
            and scientific notation we need only to know what is behind
            X, Y or Z. We have the cases (we can use X or Y or Z):

                        eX      - is a constant e
                       +eX      - is a constant e
                       -eX      - is a constant e
                       edX      - is scientific notation  (d is a digit)
                      e+dX      - is scientific notation  (d is a digit)
                      e-dX      - is scientific notation  (d is a digit)
                       
            But if we write an expression we have problems.

            What is this:     e+d * exp(x) ?

            e+d is a scientific notation
            or e is the constant e and we want to add e plus d ?

            In calculaXX that e is taken as the constant e but
            1e+d is a scientific notation.