In order to do this I write the following in matlab;
syms x
eq='cos(x)*cosh(x)+1=0';
s=solve(eq)
It takes a long time & then returns;
s =
-212.05750411731104359622842837137
which obviously is not the correct answer, the correct answer is
x=1.87510
I am not sure what I am doing wrong, can someone please advise me how to correct this
Thanks
Can you please explain this a bit more, I am new to Matlab.
Thanks a lot for your help
Thanks a lot for your kind guidance!!
However, the solution that Matlab provides to me with the "solve" command is incorrect as it does not satisfy the equation. Can you explain the reason please!!
Thanks again
Well, you forgot to pass x into solve (how does it know what to solve
for?)
solve(eq,x) might work. Give it a try.
-Nathan
I run into transcendental equations frequently, and understanding how
to solve one is a valuable tool. Matlab has some pretty fancy
functions, which might not always be available to you. I use matlab
all the time, but I have had only had one employer in 15 years which
was willing to pay for matlab, which is sad. Here is some pseudo code
to give a more generic means of solving. This can be used in Matlab,
or in any Basic or C programmer or Excel VBA.
tol=0.01 // set error tolerance
for the solver
inc=0.01 // set solver increment
amount
for k=-100 to 100 // set range accordingly
x=k*inc
if abs(cos(x)*cosh(x)+1)<=tol // check to see how close the
solver is - you're trying to drive the abs of the answer to zero
exit sub // if answer is
acceptable, jump out of loop
end if
x=x+1 // if answer is not close
enough, increment x
next
if x==100 // check to see if the
solver ran out of range
display("no solution found, increase range")
end if
display(x)
There are a lot of tricks/methods you can use to make the solver much
faster, more efficient, and more intelligent. This is about as basic
as you can get. Plotting the response will also yield a lot of
information. But to start, this is enough to get you started.
Thanks a lot for your help & guidance
"Faisal Siddiqui" <aero...@gmail.com> wrote in message <h3qqha$i91$1...@fred.mathworks.com>...
"Faisal Siddiqui" <aero...@gmail.com> wrote in message <h3qqha$i91$1...@fred.mathworks.com>...
>> solve('cos(x)*cosh(x)+1')
solve('cos(x)*cosh(x)+1','x')
x = solve('cos(x)*cosh(x)+1')
x = solve('cos(x)*cosh(x)+1','x')
ans =
1.8751040687119611664453082410782*i
ans =
1.8751040687119611664453082410782*i
x =
1.8751040687119611664453082410782*i
x =
1.8751040687119611664453082410782*i
Hope this helps.
Greg