how to solve non-linear transcendental equation with many roots
Show older comments
Hi All,
I have to solve the following equation
x-(2*(sinh(x)*((cos(x)).^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/((1-cos(x)*cosh(x))) =0.
It is a nonlinear with many roots, so is there any function in matlab can do it? the function fzero only return a root near a initial root value, which is not a automatic task.
Thank you.
Answers (3)
Walter Roberson
on 13 Feb 2013
I suspect not, but I do not have the Symbolic Toolbox to test with. Using a different symbolic package, I find that there are an infinite number of roots, some real and some imaginary. There is no nice analytic expression for the roots.
One of the basic items repeated over and over in the forms is the root of cos(x) = x, which has no analytic solution.
The generalized solution for reals has three forms; the overall solution is the union of {0} and these three forms and three forms for the imaginary solutions. The three real forms are:
.7429621155 + 1.655668423 * B + 6.283185308 * Z
-0.7429621155 + 4.627516885 * B + 6.283185308 * Z
3.141592654 * B + 6.283185308 * Z
where B must be either 0 or 1, and Z is any arbitrary integer.
The 6.28<etc> is obviously 2*Pi, and the 3.14<etc> is obviously Pi, but the other numeric values have no obvious interpretation.
4 Comments
Youssef Khmou
on 13 Feb 2013
right, 'solve' gives the triplet {0,0,0}
David Zhang
on 14 Feb 2013
Walter Roberson
on 14 Feb 2013
It is possible that the above solution is incorrect; I am working through some difficulties I found with the other package.
Walter Roberson
on 14 Feb 2013
I have confirmed that the solution I showed in my Answer is incorrect, but I do not have anything worked out yet as to what the correct general solution should be.
Youssef Khmou
on 13 Feb 2013
Edited: Youssef Khmou
on 13 Feb 2013
Hi, there many ways to get solution,
You use a function Handle :
>>f=@(x) x-(2*(sinh(x)*((cos(x))^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/(1-cos(x)*cosh(x))
>>y=fsolve(f,10e-3)
'fsolve' starts at x0=10e-3 and tries to solve the equation , you can verify the solution :
>>f(y)
-2.0334e-009
This helps ?
3 Comments
Walter Roberson
on 13 Feb 2013
The poster is hoping for the many roots. fsolve() will not do that.
What can be tried is
syms x
f = x-(2*(sinh(x)*((cos(x)).^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/((1-cos(x)*cosh(x)));
feval(symengine, 'numeric::solve', f, x, 'AllRealRoots')
This might have a problem because of the fact that there are an infinite number of real roots.
David Zhang
on 14 Feb 2013
David Zhang
on 14 Feb 2013
Youssef Khmou
on 13 Feb 2013
2nd answer :
You can use " solve" with symbolic variable :
syms x
y=x-(2*(sinh(x)*((cos(x))^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/((1-cos(x)*cosh(x)))
z=solve(y) .
12 Comments
Walter Roberson
on 13 Feb 2013
Will this return an expression for all roots, or only for a single root?
Youssef Khmou
on 13 Feb 2013
Edited: Youssef Khmou
on 13 Feb 2013
it returns three elements : {root1,root2,root3}
Walter Roberson
on 13 Feb 2013
Three numeric roots, or expressions?
Youssef Khmou
on 13 Feb 2013
syms,
David Zhang
on 14 Feb 2013
Youssef Khmou
on 14 Feb 2013
Edited: Youssef Khmou
on 14 Feb 2013
correct david, the 2nd answer gives SYmbolic results but zeros :{0,0,0} !!
Youssef Khmou
on 14 Feb 2013
Edited: Youssef Khmou
on 14 Feb 2013
Addition : I tried to change the 2nd answer , by altering the first hyperbolic sinus with cosh, so it gives two symbolic solutions as numbers :
y=x-(2*(cosh(x)*((cos(x))^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/((1-cos(x)*cosh(x)))
y =
x-(2*cosh(x)*(cos(x)^2+cos(x)-1)+2*sin(x)*(cosh(x)-1))/(1-cos(x)*cosh(x))
>> z=solve(y)
z =
-3.7334546196297311376767645164302
.52183972722849489951741775832884-1.2746296333498672112488371780214*i
abs(z)
ans =
3.7334546196297311376767645164302
1.3773152882065627025290631464461
whos z
Name Size Bytes Class Attributes
z 2x1 390 sym
David Zhang
on 14 Feb 2013
David Zhang
on 14 Feb 2013
Youssef Khmou
on 14 Feb 2013
David, based on the code above, i tried to find indexes where zeros do exist, but the method failed, anyway i tried to plot the analytic function :
syms x
f = x-(2*(sinh(x)*((cos(x)).^2+cos(x)-1)+sin(x)*(cosh(x)-1)))/((1-cos(x)*cosh(x)));
>> ezplot(f,[1 1000])
So based on the reasoning above, the graph should cross Infinitely the x axis , but its not the case , so what do you think?
David Zhang
on 14 Feb 2013
Youssef Khmou
on 14 Feb 2013
ok; great !
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!