-
March 28th, 2014, 02:34 AM
#1
[RESOLVED] How to solve arithmetical problems?
Here is the problem I need to solve:
Here is the code I created in order to solve it:
Code:
double numx, numz, result;
numx = Convert.ToDouble(textBox1.Text);
numz = Convert.ToDouble(textBox2.Text);
result = Math.Pow(numx, 2) + Math.Pow(numz, 2) / 1 - Math.Pow(numx, 2) - Math.Pow(numz, 2) / 2;
label1.Text = result.ToString();
But when solving the problem manually I get different answer, so what I'm doing wrong? A help would be appreciated and thanks for your time in advance.
Kind regards,
Ron
-
March 28th, 2014, 08:51 AM
#2
Re: How to solve arithmetical problems?
You are grouping wrong. Multiplication and division precede addition and substraction.
Code:
result = (Math.Pow(numx, 2) + Math.Pow(numz, 2)) / (1 - (Math.Pow(numx, 2) - Math.Pow(numz, 2)) / 2);
When having doubts with this sort of problems, reduce your expression to chunks of the ecuation.
Code:
A = X^2 + Z^2
B = X^2 - Z^2
C = B / 2
D = 1 - C
E = A / D
result = E
Hope it helps. Good luck!
Last edited by Nikel; March 28th, 2014 at 08:53 AM.
Reason: Just formatting.
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
|