Menu

Inequalities

Ignacio
2008-05-08
2013-04-11
  • Ignacio

    Ignacio - 2008-05-08

    Hello,
    how can I solve and plot inequalities ?
    For example:  ((x-1) sqrt(3-5x))<0.

    At the code "Simp1", what is "matrix/a_max" ?.I don't see a function key for that.I hava calc 4.0.
    Sorry for my bad english. I'm Spanish.

    prog/new/"Simpl"                ; shorthand for "Simplex"  :)
    ...
    ...
    ...                             ; A*[x,y] computed
    mem/RCL 5                       ; b
    -                               ; transform to A*[x,y]-b <= 0
    matrix/a_max <-----??????????   ; check if all components/lines ...
    stack/x<->y
    ...
    ...                      ; scale to 0.025*c*x    -> (1)
    prog/finish

     
    • Goetz Schwandtner

      Hi Ignacio,

      you must have found the programming examples I wrote for the upcoming version in the CVS. ;)

      In fact, the a_max and a_min functions for matrices were added after version 4.0 to support examples like the linear programming plot. So no support for this in 4.0, sorry. Either wait for the next release or grab a Java SDK, WTK, Eclipse and Antenna and build the current version from the CVS source. But I suggest that only if you have at least some experience with these tools.

      To your inequality: It is possible to plot inequality "trueth values" for one variable (x) or two variables (x,y) using the f(z)=z plot. But I have some problems with your inequality: All values x, for which the inequality is not satisfied are complex (because then 3-5x<0 and sqrt has a negative argument). So what do you mean by <0 for these complex numbers?

      For inequalities, we need comparisons of real numbers, not complex ones. :-/

      Maybe you have a better example and I might then show you how to implement it in Calc as a plot. :)

      - Goetz

       
    • Ignacio

      Ignacio - 2008-05-09

      Ok:
        well, my inequality is   (x+2)sqrt(5-4x)>=3.
        The solution is [-1,1].
        Wow can I solve and plot this inequalities ?
        Thanks Goetz.
       

       
      • Goetz Schwandtner

        Ok, to avoid the problems with complex numbers because of negative arguments of sqrt, we will plot the inequality (x+2)sqrt(max(5-4x,0))>=3:

        /--------------------------------------\ prog/new/"ineq"
        trig/complex/cplx->r    ; split complex argument into x and y
        stack/x<->y             ; remove y value ...
        clear
        ENTER
        2
        +                       ; (2+x)
        stack/x<->y
        4
        *
        5
        -
        +/-                     ; -(4*x-5)=5-4x
        0
        prog/util/max           ; now no negative args
        sqrt(x)
        *                       ; left hand side (lhs) of ineq finished
        3                       ; right hand side (rhs) of ineq
        prog/flow/x<=y?
        prog/flow/GTO 0         ; If lhs >= 3 does not hold, jump to 0
        clear                   ; remove lhs, rhs
        clear
        0                       ; result will be 0 in this case
        prog/flow/STOP
        prog/flow/LBL 0
        clear
        clear
        1                       ; result will be 1 if ineq is satisfied
        \--------------------------------------/

        You may then plot the inequality with, e.g.
        -2 2 -0.4 0.4 prog/draw/z=f(z)

        The green area will be the are, where the inequality is satisfied (e.g. return value 1), while the black area shows where the inequality is not satisfied. Using the plot grid and coordinates (with keys * and 0), you see that the stripe where the ineq is satisfied is the stripe with x in [-1, 1]. So x in [-1, 1] solves the ineqality. The y coordinate does not matter here.

        HTH,
        - Goetz

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.