How to simplify the folowing very simple expression:
syms a b c
e1 = -(b*(b^2 - 4*a*c)^(1/2) - 4*a*c + b^2)/(2*a*(b^2 - 4*a*c)^(1/2))
which is equal to the
e2 = -(b + (b^2 - 4*a*c)^(1/2))/(2*a)
simplify(e1-e2)
ans =
0
>> isAlways(e1 == e2)
ans =
logical
1
but
simplify(e1)
produce only identical expression with "e1", not with "e2" as expected?!
Is there any possibility to use "simplify" command in a different way, to get expected result?

댓글 수: 7

Dyuman Joshi
Dyuman Joshi 2023년 3월 30일
편집: Dyuman Joshi 2023년 3월 30일
"produce only identical expression with "e1", not with "e2" as expected?!"
What makes you think e2 is the expected output?
There is no unique simplified expression for most of the expressions, (one such exception being - sin^2 + cos^ == 1, for any input). This is mentioned in the documentation of simplify as well - "There is no universal idea as to which form of an expression is simplest."
Let's see how many simplified expressions we can obtain with the given expression -
syms a b c
e1 = -(b*(b^2 - 4*a*c)^(1/2) - 4*a*c + b^2)/(2*a*(b^2 - 4*a*c)^(1/2));
e2 = -(b + (b^2 - 4*a*c)^(1/2))/(2*a);
out1=simplify(e1,'Steps',50,'All',true)
out1 = 
8 outputs for 50 steps. The # of outputs is 10 for 500 steps (After 500, the # of outputs doesn't seem to change regardless of # of steps, I tried till 5e6)
Now, which one should be "the" simplified expression?
"Is there any possibility to use "simplify" command in a different way, to get expected result?"
Unfortunately no, it doesn't look like you will obtain the solution in the form you want. The closest option might be the 3rd element of out.
Michal
Michal 2023년 3월 30일
편집: Michal 2023년 3월 30일
"What makes you think e2 is the expected output?" ... what about minimal number of operations? :) For example...
Some other CAS's (Computer Algebra Systems) are able to produce "expected" result, but I understand that in general any CAS does not know what equivalent expression is expected by user. But, this case is so simple ... I am a bit surprised. That is all.
Dyuman Joshi
Dyuman Joshi 2023년 3월 30일
Wolfram Alpha also provides multiple solutions rather than a single answer, one of those solutions being the original expression. Although, it does contain the output you want to obtain.
Sympy simply returns the same expression. (feels a bit ironic)
Steven Lord
Steven Lord 2023년 3월 30일
Sometimes simple questions can have multiple potential answers. What two numbers do you think Cleve had in mind when he asked his question?
Michal
Michal 2023년 3월 31일
편집: Michal 2023년 3월 31일
Mathematica 13.2.1:
Maple 2023.0:
John D'Errico
John D'Errico 2023년 3월 31일
@Michal - Just because one (or more) tool can find a particular solution that you happen to like does not mean that all tools will do so. They are equivalent.
Michal
Michal 2023년 3월 31일
@John D'Errico Yes, of course! But your claim - "They are equivalent" is very vague or controversial, because then any simplification attempt loses sense.
I hope you understand my point. Anyone wants to see the expression, which is simplest as possible of all (infinitely) others equivalent expressions (typically, from the point of required operations number, for example).
But once again, this case is so trivial that I am just a bit surprised, why all CAS cannot find the same simplest expression.

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

답변 (0개)

제품

릴리스

R2023a

태그

질문:

2023년 3월 30일

댓글:

2023년 3월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by