How can I obtain the most simplified version of the symbolic solution of an equation that contains such functions as 'log' in a fractional and not decimal representation?

2 次查看(过去 30 天)
Given is an equation that is sought to be symbolically solved in MATLAB using the Symbolic Math Toolbox, namely,
syms x
eqn = log(2*x)/log(3)==-1
It is known that the analytical solution of the latter equation is the following one,
res =
1/6
However, when using the function 'solve' from MATLAB and then the command 'simplify' with the Name-Value pair 'IgnoreAnalyticConstraints'-true, then 'log(3)' is firstly replaced by the fractional number '2473854946935173/2251799813685248' and as a result, the resulting expression appears still complex, namely,
>> res = simplify(solve(eqn,x,'IgnoreAnalyticConstraints',true))
res =
exp(-2473854946935173/2251799813685248)/2
MATLAB cannot simplify this expression further to '1/6' which is the expected solution.
How can I obtain the most simplified version of the symbolic solution of an equation that contains such functions as 'log' in a fractional and not decimal representation?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2022-4-15
In this case one needs to prevent MATLAB from expanding expression 'log(3)' to the aforementioned fractional number. To achieve this, please use an additional symbolic variable in the place of number 3, say 'y', solve the equation symbolically and substitute 'y' with 3 in the solution, namely,
syms x y
eqn = log(2*x)/log(y) == -1;
res = simplify(solve(eqn,x,'IgnoreAnalyticConstraints',true));
res = subs(res, y, 3);
This way the desirable result '1/6' can be obtained.
Another workaround is to declare the number 3 within function 'log' as symbolic, in which case the expression log(3) won't be expanded by MATLAB, see the following lines of code,
syms x
eqn = log(2*x)/log(sym(3))==-1
simplify(solve(eqn,x,'IgnoreAnalyticConstraints',true))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Assumptions 的更多信息

标签

尚未输入任何标签。

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by