MATLAB Answers

Unable to find explicit solution to a very simple equation

조회 수: 2(최근 30일)
Teemu Hämäläinen
Teemu Hämäläinen 2021년 9월 15일
댓글: Teemu Hämäläinen 2021년 9월 15일
So my code is
syms x
solve(-3*x^4+12*x^2 > 0,x)
And for some reason matlab cant answer this. I have tried everything but nothing has worked so far
the answer should be x=0 and x=+-2, but instead i get
Warning: Unable to find explicit solution. For options, see help.
ans =
Empty sym: 0-by-1
What am i doing wrong? I am losing my mind cause I know this is a very simple task

채택된 답변

Paul
Paul 2021년 9월 15일
편집: Paul 2021년 9월 15일
The equation in the question is an inequality, but the supposed solution posed in the question is for an equality:
syms x real
f(x) = -3*x^4 + 12*x^2;
solve(f(x)==0,x)
ans = 
Plot f(x)
fplot(f(x),[-2 2])
So that gives us an idea of what the solution should be for f(x) > 0.
assume(x,'real') % otherwise the solver will consider x as complex
sol = solve(f(x)>0,'ReturnConditions',true);
sol.x
ans = 
sol.parameters
ans = 
x
sol.conditions
ans = 
Which looks like the expected solution based on the graph.
  댓글 수: 1
Teemu Hämäläinen
Teemu Hämäläinen 2021년 9월 15일
Thanks a million times! I wouldn't have figured it out on my own. It works now! <3

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by