I am trying to do multi step math and keep returning the wrong answer

I am given the equation and this is my code but it keeps telling me that it is returning the wrong value.
b=(1/7)+((72/13)^2)/(sqrt((125/2)-(25/3)))

4 件のコメント

Dyuman Joshi
Dyuman Joshi 2024 年 4 月 19 日
How is the value wrong?
How precise do you want the output value to be?
Matthew
Matthew 2024 年 4 月 19 日
I am in MATLAB grader for a class and don't know what other value I should be getting and wanted someone else to see if I was missing any parentheses or operations.
Dyuman Joshi
Dyuman Joshi 2024 年 4 月 19 日
The expression and the code match, so you are good.
How is the test case in Grader comparing the value with the output?
Matthew
Matthew 2024 年 4 月 19 日
Variable b has an incorrect value.
This is all it tells me, I believe she just has a value set that she got from running it. Thank you for looking I will talk to her.

サインインしてコメントする。

 採用された回答

John D'Errico
John D'Errico 2024 年 4 月 19 日
編集済み: John D'Errico 2024 年 4 月 19 日
Of course it is wrong. Why did you write 72/13? Why 25/3?
I think you don't understand that
8(1/3) is NOT the same thing as
8 + 1/3
Similarly, you see essentially
5 (7/13)
and you are trying to add fractions!
b=(1/7)+((5*7/13)^2)/(sqrt((125/2)-8*1/3))
b = 1.0799
Do you see what you are doing? When you have an expression like that, you should not assume an implicit addition there. I think you are confused because some people will write
5 1/2
as meaning 5 PLUS 1/2, and thus effectively 5.5.

4 件のコメント

Matthew
Matthew 2024 年 4 月 19 日
I saw those and was thinking mixed numbers not multiplication or addition, thank you for the explanation
John D'Errico
John D'Errico 2024 年 4 月 19 日
Exactly. It took me a few seconds to recognize what you had done. And now that I think of it, I can see the subtle ambiguity. One of those optical illusions in a sense, that you can look at a picture in several different ways.
Sam Chak
Sam Chak 2024 年 4 月 19 日
Also be careful when you guys use WolframAlpha.
Case 1: Without space
Case 2: With space
Dyuman Joshi
Dyuman Joshi 2024 年 4 月 19 日
Even I took them as mixed fractions and responded accordingly. I was going to ask for a clarification but in the mean time John had already answered the question.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by