Difference between Matlab and Wolfram Alpha

조회 수: 53 (최근 30일)
Niklas Kurz
Niklas Kurz 2020년 7월 31일
편집: Niklas Kurz 2020년 7월 31일
These problems might occure frequently due to the varied syntax. This time it's about:
solve(x^2-8*x+15<=1)
what gives (according to Matlab): pi and 4. That's wrong or not what I ask for. In contrast Wolfram Alpha gives after typing in the same piece of code the correct solution (in my point of view.) Why is that?

채택된 답변

Jesús Zambrano
Jesús Zambrano 2020년 7월 31일
Hi Niklas,
You need to set 'ReturnConditions' to true to return any parameters in the solution and conditions on the solution. Therefore,
S = solve(x^2-(8*x)+15<=1, 'ReturnConditions',true);
S.conditions,
ans =
x <= 2^(1/2) + 4 & 4 - 2^(1/2) <= x
in(y, 'real')
which is the solution interval: 2.5858 <= x <= 5.4142

추가 답변 (1개)

Cam Salzberger
Cam Salzberger 2020년 7월 31일
Hey Niklas,
Technically, both pi and 4 are "correct" results, as if you plug them in, they will fulfill the condition. I think what you are looking for is using the solution = solve(___, "ReturnConditions", true) syntax, as suggested by the solving inequalities example in the documentation.
Also, it would generally be helpful to post what you got from Wolfram as well, so we know what you're expecting.
-Cam
  댓글 수: 1
Niklas Kurz
Niklas Kurz 2020년 7월 31일
편집: Niklas Kurz 2020년 7월 31일
Thank you, guys
x <= 2^(1/2) + 4 & 4 - 2^(1/2) <= x
is what I'm looking for.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by