How to use solve function in matlab in this case

  • Context: MATLAB 
  • Thread starter Thread starter oahsen
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary
SUMMARY

The discussion focuses on using MATLAB's solve function to find the roots of a polynomial equation defined by exp(f(z)) = c, where c is a complex number. The user outlines their approach using a custom function, expsolve, to construct the polynomial from its coefficients and then attempts to solve the equation first - log(c) = 0. The correct syntax for using the solve function is provided, specifically using eqn = first - log(c) == 0 and s = solve(eqn, z) to find the roots effectively.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of polynomial functions
  • Knowledge of complex numbers
  • Experience with symbolic computation in MATLAB
NEXT STEPS
  • Learn about MATLAB symbolic variables and their usage
  • Explore the MATLAB solve function in detail
  • Study polynomial root-finding techniques in MATLAB
  • Investigate the implications of complex logarithms in mathematical functions
USEFUL FOR

Mathematics students, MATLAB programmers, and engineers working on polynomial equations and complex analysis will benefit from this discussion.

oahsen
Messages
58
Reaction score
0
We are trying to find the roots of a function where exp(f(z)) = c. (where c is a complex number). Also f(z) is a polynomial function. The function will have the following format:
expsolve( [an an-1 …] , c ) where n is the degree of “z”.
For do this I took the natural logarithm of both sides and find f(z) = log(c). The code I have written so far is as follows;

function expsolve(v,c);
len=length(v)
temp=log(c);
syms z;
syms def;
syms first;
first=0;
for(a=1:len)
def=v(len-a+1)*(z^(a-1))
first=first+def
end
first
equ=first-log(c)

--------------------
now if I write expsolve([1 5 3], 4) for instance
until the first part it gives me the correct result (first=z^2+5*z+3)
however, I could not do the rest. how can I find the roots of first-log(c).

I tried to write different combination of :
solve('equ=0','z').
However, it gave my either an error or a illogical answer.

How can I proceed in this question. Besides the code I have written is there any simpler way to solve the question?
 
Physics news on Phys.org
Let's take it up from first. Write the code like this:
Code:
syms z;
eqn = first - log(c) == 0;
s = solve(eqn, z)
 

Similar threads

Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
5K