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:
FindRoot

Subject: FindRoot

From: Philipp Steffen

Date: 13 Nov, 2010 18:45:05

Message: 1 of 4

Hi all,

I would need some help regarding an optimization. I have got the following function:

function [ nucleararea ] = areaexpression( d, R )
nucleararea=0.5*(d*sqrt(-d^2 + 4*R^2) + 4*R^2*acsc((2*R)/d));
end


I now would like to find R when I know d and the value of nucleararea.

Could anybody please help me with this? I am struggling with fzero but dont quite get it to work.

Thanks a lot in advance,

Philipp

Subject: FindRoot

From: Matt Fig

Date: 13 Nov, 2010 20:02:03

Message: 2 of 4

For example:

>> d = .3;
>> nucarea = 2;
>> rt = fzero(@(x) areaexpression(d,x) - nucarea,3.2)

Also, you will need to vectorize the expression in your function:
nucleararea = 0.5*(d*sqrt(-d.^2 + 4*R.^2) + 4*R.^2.*acsc((2*R)./d));

Subject: FindRoot

From: Roger Stafford

Date: 13 Nov, 2010 20:52:03

Message: 3 of 4

"Philipp Steffen" <philipp.steffen@imba.oeaw.ac.at> wrote in message <ibmmbh$oag$1@fred.mathworks.com>...
> .........
> nucleararea=0.5*(d*sqrt(-d^2 + 4*R^2) + 4*R^2*acsc((2*R)/d));
> I now would like to find R when I know d and the value of nucleararea.
> .........
- - - - - - - - - -
  I see only a couple of ways you might have trouble with 'fzero': if you assigned a value to 'nucleararea' less than pi/4*d^2, or if you started fzero with an initial estimate for R of less than d/2.

  I assume that R and d are positive quantities and your arccosecant values are its principal values as given by matlab's 'acsc' function. Let's call nucleararea = n for short. You might get a better insight into your problem by posing the problem in terms of theta: 2*R/d = csc(theta). Then the problem can be written as

 2*n/d^2 = cot(theta) + theta*csc(theta)^2

If you make a plot of the right hand side as a function of theta from 0 to pi/2 (well, at 0 it becomes infinite so you'll have to stay above 0) you'll see that it is monotonically decreasing from plus infinity down to pi/2. That means for any positive value of 2*n/d^2 not less than pi/2 there will be a unique solution for theta and therefore for R. You should be able to find it easily with 'fzero'.

Roger Stafford

Subject: FindRoot

From: Philipp Steffen

Date: 15 Nov, 2010 09:40:19

Message: 4 of 4

Hi Matt and Roger,

thanks for your help! I had troubles with the anonymous function. Matts code therefore helped me sorting this out.

Best,

Philipp
"Philipp Steffen" <philipp.steffen@imba.oeaw.ac.at> wrote in message <ibmmbh$oag$1@fred.mathworks.com>...
> Hi all,
>
> I would need some help regarding an optimization. I have got the following function:
>
> function [ nucleararea ] = areaexpression( d, R )
> nucleararea=0.5*(d*sqrt(-d^2 + 4*R^2) + 4*R^2*acsc((2*R)/d));
> end
>
>
> I now would like to find R when I know d and the value of nucleararea.
>
> Could anybody please help me with this? I am struggling with fzero but dont quite get it to work.
>
> Thanks a lot in advance,
>
> Philipp

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