Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
solving equation of multiple exponent terms summation with variable 'z'

Subject: solving equation of multiple exponent terms summation with variable 'z'

From: qi li

Date: 4 Mar, 2012 11:59:15

Message: 1 of 3

Hi everyone,
    I have a problem and I cann't figure it out. the origin is from tempting to plot a 3-d deformation sphere in SVM, it needs solve
                              sigma(K(x,ai))=1
where K is gaussian kernel trick,which means K(x,ai)=exp(||ai-x||^2/(-2)),ai is 3 components vector,when i=1,2,3 a(:,1)=[1;1;1] a(:,2)=[2;2;2] a(:,3)=[3;3;3], x is [1;1;z] vector,z is varable ,so equation becomes
         for i=1:3
          s=s+exp(((1-a(1,i))^2+(1-a(2,i))^2+(z-a(3,i))^2)/(-2))
         end
 then next equation s-1=0 shoulde be figured out with 'z', who has the idea how to solve it? I found using fzero() may works,but if I have no idea about the initial value(I want all possible results of the equation) and in fact there may be hundreds of equations need to be solved(I make some simplications!).

        can someone help me? thanks advance

Subject: solving equation of multiple exponent terms summation with variable 'z'

From: Roger Stafford

Date: 4 Mar, 2012 23:42:13

Message: 2 of 3

"qi li" <liqi3837671@hotmail.com> wrote in message <jivlej$sg2$1@newscl01ah.mathworks.com>...
> Hi everyone,
> I have a problem and I cann't figure it out. the origin is from tempting to plot a 3-d deformation sphere in SVM, it needs solve
> sigma(K(x,ai))=1
> where K is gaussian kernel trick,which means K(x,ai)=exp(||ai-x||^2/(-2)),ai is 3 components vector,when i=1,2,3 a(:,1)=[1;1;1] a(:,2)=[2;2;2] a(:,3)=[3;3;3], x is [1;1;z] vector,z is varable ,so equation becomes
> for i=1:3
> s=s+exp(((1-a(1,i))^2+(1-a(2,i))^2+(z-a(3,i))^2)/(-2))
> end
> then next equation s-1=0 shoulde be figured out with 'z', who has the idea how to solve it? I found using fzero() may works,but if I have no idea about the initial value(I want all possible results of the equation) and in fact there may be hundreds of equations need to be solved(I make some simplications!).
>
> can someone help me? thanks advance
- - - - - - - - -
  As long as your problem remains one-dimensional with the single variable, z, (which I assume is real,) then a judicious use of the 'plot' function combined with 'fzero' ought to enable you to find all the roots in your problem. The more exponentials you sum, the larger the number of roots is likely to be. (I don't think there will be hundreds unless you have hundreds of exponentials.) Just plot your s as a function of z and observe the points in z where the curve appears to touch or cross the s = 1 level, and use your estimation of each point separately as an initial value in 'fzero'. Of course this means you will have to first compute s for a wide range of z values to be able to catch all roots this way. Piece of cake! (But it requires your participation in observing the plot very carefully.)

  It is when you have more than one variable to vary that things become more complicated. For example, with two variables, z1 and z2, you would want to obtain the contour line on the two-variable function s(z1,z2) over some finely-spaced grid for s = some constant, and this in general would provide you with infinitely many solutions along the contour. I'm not sure what you would do with them all. With three variables the problem is even more complicated with solution spaces then being two-dimensional in general.

Roger Stafford

Subject: solving equation of multiple exponent terms summation with variable 'z'

From: qi li

Date: 6 Mar, 2012 08:40:13

Message: 3 of 3

     Thanks for replying, I think indeed first plotting 's' as a function of z to get approximation initial value of z , then using fzero() to solve equation is a method, but I must plot a deformation sphere,not just a single z value, that means given a grid [X,Y]=meshgrid(-10:10,-10:10), there should be 2*20*20=800 z values, each is a results of the equation, I can not use a method to probing z axis points one by one to get approximation initial position only for single result! It's too slowly.
      I tried to use taylor series to approximate exponent expression in MATLAB, the details is first define symbolic variable z, and reserve the for-loop parts, but replace expression s with symbolic function taylor(): (default expand term is 6, y can define explicitly in n taylor(eq, n))
[x y]=meshgrid(-1:0.1:1,-1:0.1:1);
syms z
for i=1:3 s=s+taylor(exp(((x-a(1,i))^2+(y-a(2,i))^2+(z-a(3,i))^2)/(-2))); endafter step complete, I used
coef=sym2poly(s);
to get all polynomial coefficients ,at last, I used
r=roots(coef);
but the results was very bad, the most commonly result is complex number, very few is real, the higher taylor expand terms I reserved, the more complex results would appear, when I substitute real number to s use subs(s,z, results), there was a huge distance from 0. who can give me a good idea how to solve the equation? Thanks very much!

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us