POV-Ray : Newsgroups : povray.general : How to find the maximum value of a function? Server Time
30 Jul 2024 20:19:46 EDT (-0400)
  How to find the maximum value of a function? (Message 4 to 13 of 13)  
<<< Previous 3 Messages Goto Initial 10 Messages
From: Mike Williams
Subject: Re: How to find the maximum value of a function?
Date: 15 Nov 2008 07:18:51
Message: <CjdvfyC$xrHJFw0J@econym.demon.co.uk>
Wasn't it SharkD who wrote:
>I have defined a function (function "fn_E", below) and would like to determine
>a. the maximum possible value of the function, and b. the coordinates where the
>maximum occurs. How can I accomplish this?

The general solution to such problems is to differentiate the function 
and solve that to find places where the differential is zero. The 
maxima, minima and turning points of the original function are at places 
where the differential is zero.

In the general case, that would require 3D calculus, but your particular 
example is symmetrical in y/z so you can probably get away with assuming 
that you can find the maxima and maxima on the line z=x or z=-x, and 
thereby reduce it to two 2D cases.

The approach would be to express fn_D in terms of x, y, and z, rather 
than by referencing the earlier functions, then substitute z=x, 
differentiate and solve.

My calculus is a bit rusty (I think I last did any about 32 years ago) 
so I wouldn't fancy attempting it.

-- 
Mike Williams
Gentleman of Leisure


Post a reply to this message

From: Dan Connelly
Subject: Re: How to find the maximum value of a function?
Date: 15 Nov 2008 09:04:13
Message: <491ed6dd@news.povray.org>
Numerical Recipes has a chapter on the topic.

Third Edition requires a subscription, or better, buy the book, which is a great read
if you like numerical methods.  But the second edition is on-line for free:
http://www.nrbook.com/a/bookcpdf.php

See chapter 10.

Dan


Post a reply to this message

From: triple r
Subject: Re: How to find the maximum value of a function?
Date: 15 Nov 2008 12:35:00
Message: <web.491f07d7c0004fc9ef2b9ba40@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "triple_r" <nomail@nomail> wrote:
> > In general?  I would evaluate it on a sparse grid, then refine that guess with
> > something like Powell's method or conjugate gradient.
> >
> > Here?  The maximum is at (1,0,0), and happens to be equal to 34.5012.
> >
> >  - Ricky
>
> Thanks for your reply!
>
> The maximum in this particular case can't be 34.5012, as plugging <1,0,0,> into
> the function results in a value of 3.808.

Oops.  Sorry -- must have made a typo plugging it into the old calculator...
End of a long week...

> I was hoping for a general method that I could apply anywhere, but I see now
> that there could possibly be multiple maximums--or no maximum at all!--unless a
> strict range were also given. This is not an issue in this case, however, since
> the function is not continuous.

That's why, ultimately, a grid may be the best way to get an estimate, but good
luck either way.  Hopefully your skills with addition and subtraction are
better than mine...

 - Ricky


Post a reply to this message

From: SharkD
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 02:05:00
Message: <web.491fc5c2c0004fc9771596a90@news.povray.org>
I've worked things out in excel so that all I need to do is find the equation of
this curve:

http://img266.imageshack.us/img266/4454/curvepo9.png

Unfortunately, I can't figure out what kind of curve it is. It kind of looks
like a catenary.

-Mike


Post a reply to this message

From: SharkD
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 02:45:01
Message: <web.491fceb2c0004fc97575d2b00@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> I've worked things out in excel so that all I need to do is find the equation of
> this curve:
>
> http://img266.imageshack.us/img266/4454/curvepo9.png
>
> Unfortunately, I can't figure out what kind of curve it is. It kind of looks
> like a catenary.
>
> -Mike

This curve (a catenary) seems to fit the points fairly closely:

f(x) = 0.2 cosh(x / 0.76) + 0.2

-Mike


Post a reply to this message

From: SharkD
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 03:00:01
Message: <web.491fd1f5c0004fc9a3b1deab0@news.povray.org>
"SharkD" <nomail@nomail> wrote:
> "SharkD" <nomail@nomail> wrote:
> > I've worked things out in excel so that all I need to do is find the equation of
> > this curve:
> >
> > http://img266.imageshack.us/img266/4454/curvepo9.png
> >
> > Unfortunately, I can't figure out what kind of curve it is. It kind of looks
> > like a catenary.
> >
> > -Mike
>
> This curve (a catenary) seems to fit the points fairly closely:
>
> f(x) = 0.2 cosh(x / 0.76) + 0.2
>
> -Mike

Woops! I forgot to scale the function properly. Here's a fixed version:

f(x) = 0.07 cosh(x / 0.28) - 0.07

-Mike


Post a reply to this message

From: SharkD
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 05:50:00
Message: <web.491ffa8bc0004fc970a34be80@news.povray.org>
I think I've been going about things entirely the wrong way. I'm more confused
now than I was at the start... :(

-Mike


Post a reply to this message

From: Dan Connelly
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 08:21:44
Message: <49201e68@news.povray.org>
SharkD wrote:
> I think I've been going about things entirely the wrong way. I'm more confused
> now than I was at the start... :(
> 


I'm not sure what this means.... finding extrema is a hard problem.  If you can
numerically differentiate the function with respect to conjugate axes which span the
parameter space it's a lot easier: then you end up finding the zeros of a function
rather than the extremes of one, and zeros are easier.


Post a reply to this message

From: SharkD
Subject: Re: How to find the maximum value of a function?
Date: 16 Nov 2008 13:45:00
Message: <web.49206995c0004fc94237defb0@news.povray.org>
Dan Connelly <djc### [at] yahoocom> wrote:
> SharkD wrote:
> > I think I've been going about things entirely the wrong way. I'm more confused
> > now than I was at the start... :(
> >
>
>
> I'm not sure what this means.... finding extrema is a hard problem.  If you can
numerically differentiate the functio
n with respect to conjugate axes which span the parameter space it's a lot easier:
then you end up finding the zeros of
 a function rather than the extremes of one, and zeros are easier.

What I mean is that I have been wasting time trying to do calculations by hand
and "guess" my way through the problem. Instead, I have now plotted the
functions in GeoGebra which can do most of the calculations automatically. This
is what I should have done from the start.

I have now determined that it is easier and better to calculate the maximum
*possible* value of the curve based on a certain set of constants and variables
instead of calculating the maxima and minima of the curve itself. I won't bore
you further with the details.......

-Mike


Post a reply to this message

From: Cousin Ricky
Subject: Re: How to find the maximum value of a function?
Date: 24 Nov 2008 15:50:00
Message: <web.492b12d7c0004fc985de7b680@news.povray.org>
Dan Connelly <djc### [at] yahoocom> wrote:
> Numerical Recipes has a chapter on the topic.
>
> Third Edition requires a subscription, or better, buy the book, which is a
> great read if you like numerical methods.  But the second edition is on-line
> for free:

There seem to be problems with _Numerical Recipes_:

http://www.uwyo.edu/buerkle/misc/wnotnr.html - Reliability issues.  The
criticisms appear to apply to the second edition.  Links to a rebuttal.

http://www.astro.umd.edu/~bjw/software/boycottnr.html - Licensing issues.  Which
edition is unspecified.  You'll need to disable <table>s (if your Web browser
can do that) in order to unscramble the page.


Post a reply to this message

<<< Previous 3 Messages Goto Initial 10 Messages

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.