-
Dec 6th, 2017, 12:09 PM
#1
Thread Starter
Member
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.
-
Dec 6th, 2017, 12:14 PM
#2
Thread Starter
Member
Re: Another help!
Here is a picture:
-
Dec 6th, 2017, 12:37 PM
#3
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)
-
Dec 6th, 2017, 12:45 PM
#4
Thread Starter
Member
Re: Another help!
It was like this but didn't work correctly.
-
Dec 6th, 2017, 12:59 PM
#5
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)
-
Dec 6th, 2017, 01:08 PM
#6
Thread Starter
Member
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.
-
Dec 6th, 2017, 01:51 PM
#7
Thread Starter
Member
Re: Another help!
hm? still waiting you
-
Dec 6th, 2017, 01:52 PM
#8
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)
-
Dec 6th, 2017, 02:01 PM
#9
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|