POV-Ray : Newsgroups : povray.general : How to find the maximum value of a function? : Re: How to find the maximum value of a function? Server Time
30 Jul 2024 16:16:08 EDT (-0400)
  Re: How to find the maximum value of a function?  
From: triple r
Date: 15 Nov 2008 03:30:01
Message: <web.491e87e7c0004fc9ef2b9ba40@news.povray.org>
"SharkD" <nomail@nomail> 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?
>
> Thanks!
>
> -Mike
>
> #declare Blob_threshold = 0.2;
> #declare Blob_start = 1;
> #declare Blob_radius = 1;
> #declare fn_A = function { pow(x+1,2) + pow(y,2) + pow(z,2) - pow(Blob_radius,2)
> };
> #declare fn_B = function { pow(x-1,2) + pow(y,2) + pow(z,2) - pow(Blob_radius,2)
> };
> #declare fn_C = function { Blob_start + Blob_threshold }
> #declare fn_D = function { pow(Blob_threshold, fn_A(x,y,z)) +
> pow(Blob_threshold, fn_B(x,y,z)) - fn_C(x,y,z) };
> #declare fn_E = function { max(0,fn_D(x,y,z)) };

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


Post a reply to this message

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