Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • twoway function to express a quadratic form

    Hi,

    How can I get the output of this graph?
    twoway function y=(x+y)^2

    I understand that y should be expressed in terms of x: y=f(x), but the left hand side is y(1-2x-y)=x^2. Can you please advise on how to get around this?

    Thank you in advance,

  • #2
    Perhaps WolframAlpha will help you, see for example.

    Comment


    • #3
      Thank you for your reply Dirk.

      My goal is to include additional info in the graph which Stata would easily allow to do. desmos graphing is another alternative but again I can't make edits to the graph the way Stata would allow

      Comment


      • #4
        twoway function y = (x+y)^2

        Comment


        • #5
          George: I obtain the following error message:
          error in expression: (x+y)^2
          r(111);

          Comment


          • #6
            Perhaps you can go on from here:
            Code:
            twoway (function 0.5*(-2*x + sqrt(1 - 4*x) + 1), range(-2 0.5)) ///
                   (function 0.5*(-2*x - sqrt(1 - 4*x) + 1), range(-2 0.5)), ///
                   title("y = (x + y)²") legend(order(1 "(1)" 2 "(2)"))

            Comment


            • #7
              I should have increased the evaluation points considerably and there is no need to use different colors:
              Code:
              twoway (function 0.5*(-2*x - sqrt(1 - 4*x) + 1), range(-1.5 0.5) n(100000) lcolor(cranberry)) ///
                     (function 0.5*(-2*x + sqrt(1 - 4*x) + 1), range(-1.5 0.5) n(100000) lcolor(cranberry)), ///
                     title(`"y = (x + y)²"') legend(off)

              Comment


              • #8
                Dirk Enzmann, how did you make that superscript 2 in your DO file? I thought one had to use {superscript}, like this:

                Code:
                title("y = (x + y){superscript: 2}")
                --
                Bruce Weaver
                Email: [email protected]
                Version: Stata/MP 18.5 (Windows)

                Comment


                • #9
                  I simply used the character from my keyboard, but smcl-code probably looks slightly better, it is a matter of taste or convenience.

                  Comment

                  Working...
                  X