Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB MATLAB - solving equation with Bessel function

  1. Jan 1, 2019 #1
    Hello,

    i am trying to solve this equation for x

    besselj(0,0.5*x)*bessely(0,4.5*x)-besselj(0,4.5*x)*bessely(0,0.5*x) ==0;

    I tried vpasolve, but it gave me answer x=0 only. fzero function didnt work, too.
    What function can solve this equation?

    Thanks
     
  2. jcsd
  3. Jan 1, 2019 #2

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2018 Award

    Please show us exactly the code you have tried. Otherwise it is impossible to tell where you might have gone wrong. fzero works perfectly fine for me.
     
  4. Jan 1, 2019 #3
    Yes. I misused fzero function. now it works for me aswell!


    Code (Text):
    function ffu = f(x)
    ffu = besselj(0,0.5*x)*bessely(0,4.5*x) - besselj(0,4.5*x)*bessely(0,0.5*x);
    and fzero
    Code (Text):
    fun=@f
    x0=2;
    S=fzero(fun,x0)
     
    will find solution. It finds only one solution which is close to the x0 value but its not the problem.
     
  5. Jan 1, 2019 #4

    Orodruin

    User Avatar
    Staff Emeritus
    Science Advisor
    Homework Helper
    Gold Member
    2018 Award

    Yes, fzero finds just one solution. It will find different solutions depending on your x0 input.

    Also, when you have such a short and simple function, you can just as well define an inline function instead of writing an entire function file.
     
  6. Jan 1, 2019 #5
    I understand. A good way is to use ezplot as well for a rough estimation of points, where functions is zero (intersection with x axis) and then use this rough guess as x0 input in fzero for precise value
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?