Results 1 to 9 of 9

Thread: Another help!

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Another help!

    Hello again, I faced a new problem with math, I'm not smart in English math because I don't study Math in English, hope you understand this situation!

    This time with Simultaneous mixed equations:
    ax+by=m

    cx2+dy2=n

    The codes are:

    Dim a, b, c, d, m, n As Integer
    Dim x1, y1, x2, y2 As Double

    a = Val(Txt_a.Text)
    b = Val(Txt_b.Text)
    m = Val(Txt_m.Text)
    c = Val(Txt_c.Text)
    d = Val(Txt_d.Text)
    n = Val(Txt_n.Text)
    x1 = (m * a * d + Math.Sqrt(m ^ 2 * a ^ 2 * d ^ 2 - (b ^ 2 * c + a ^ 2 * d) * (d * m ^ 2 - b ^ 2 * n))) / (b ^ 2 * c + a ^ 2 * d)

    x2 = (m * a * d - Math.Sqrt(m ^ 2 * a ^ 2 * d ^ 2 - (b ^ 2 * c + a ^ 2 * d) * (d * m ^ 2 - b ^ 2 * n))) / (b ^ 2 * c + a ^ 2 * d)

    y1 = (m - a * x1)
    y2 = (m - a * x2)
    Txt_x1.Text = Convert.ToString(x1)
    Txt_x2.Text = Convert.ToString(x2)
    Txt_y1.Text = Convert.ToString(y1)
    Txt_y2.Text = Convert.ToString(y2)

    I'm sure that the bug is from equations' solution.

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: Another help!

    Here is a picture:
    Name:  devenv_2017-12-06_19-12-20.png
Views: 132
Size:  9.7 KB

  3. #3
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Another help!

    x1, x2 seem right. But for y1, y2

    y1 = (m - a * x1) / b

    y2 = (m - a * x2) / b
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: Another help!

    It was like this but didn't work correctly.

  5. #5
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Another help!

    What are the equations you are trying to solve? What should be the answers? I solved the ones given in post #1 algebraically and got the same values for x1, x2 as used in the code. y1, y2 should be as post #3.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  6. #6

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: Another help!

    The Equations:
    -1x+2y=2
    3x^2 +4y^2=28

    The expected answers:
    X= 2 Y= 2

    The given answers:
    X1= 2 X2= 2
    Y1= -3 Y2= -0.5
    Last edited by casper.mta; Dec 6th, 2017 at 01:16 PM.

  7. #7

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: Another help!

    hm? still waiting you

  8. #8
    Fanatic Member 2kaud's Avatar
    Join Date
    May 2014
    Location
    England
    Posts
    996

    Re: Another help!

    The given answers:
    X1= 2 X2= 2
    Y1= -3 Y2= -0.5
    Somehow you're mixed up the names. The correct solution is
    Code:
    x1 = 2 y1 = 2
    x2 = -3 y2 = -0.5
    As a quadratic is involved, there must be two answers (which can be the same or complex).
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #9

    Thread Starter
    Member
    Join Date
    Dec 2017
    Posts
    34

    Re: Another help!

    Thank you again!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width