From: deltaquattro on
Hi,

I have two different functions f(x) and g(x) described as plane Bezier
curves, say of fourth degree:

[f] =[(Pi_x,Pi_y)]
[g] =[(Qi_x,Qi_y)]

with i=1..5. I would like to compute some samples of a third curve
h(x)=f(x)/g(x). Right now, I'm computing h by calculating f and g at
many points, say 21 equispaced values of the parameter t:

t=[0,....19/20,1] -> (x_i,f(x_i)); (y_i,g(y_i))

Clearly, x_i and y_i will not in generally coincide, so I interpolate
the values of g at the abscissae of f and I compute 20 samples of h as
(x_i, f(x_i)/g_interp(x_i)). However, I have two problems:

1) since I have the Bezier nodes, I'd like to somewhat interpolate
them and then compute h, instead than evaluating f and g on a refined
grid and then computing h. It seems to me that I'm wasting cpu time
and information. Is there a way to do that?
2) even if I stick to my expensive sampling -> interpolation
procedure, it won't always work. The reason is that, because of
possible errors in the input, sometimes

P1_x <> Q1_x or P5_x <> Q5_x

i.e., f and g are not defined exactly on the same interval. So I am
not able to interpolate the g samples to the abscissae of the f
samples. How can I solve this? Thanks,

Best Regards,

deltaquattro
From: Gordon Sande on
On 2010-02-16 12:47:26 -0400, deltaquattro <deltaquattro(a)gmail.com> said:

> Hi,

Both numerical analysis and graphics have specialized newsgroups that
are a better match to what you seem to be asking.

> I have two different functions f(x) and g(x) described as plane Bezier
> curves, say of fourth degree:
>
> [f] =[(Pi_x,Pi_y)]
> [g] =[(Qi_x,Qi_y)]

So f and g are paths in the plane. They will be multivalued and otherwise
ill behaved as functions y = f(x) or y = g(x). The Pi_x are not monotone
so this is not a usual way to tabulate a function which one would expect
to be single valued in any case. Or at least that is what one expects from
the comment that they are plane Bezier curves.

> with i=1..5. I would like to compute some samples of a third curve
> h(x)=f(x)/g(x). Right now, I'm computing h by calculating f and g at
> many points, say 21 equispaced values of the parameter t:

What is t (other than arc length along the Bezier curve) and what is
x as a function of t? Is it single valued? Same for y. But why isn't
it (x_i,f(x_i)) and (x_i,g(x_i)), From your set up it seems y=f(x) or
y=g(x) so why the change of notation which just confuses the reader
(and makes the reader wonder if there are other confusions).

One is curious about why the ratio is of interest. That is a question
about how your problem arises. Perhaps there is an alternate solution
to the actual problem. There are lots of instances of good answers to
poor questions which end up being poor annswers in substance. Have you
head about the patient who died when it was an completely successful
operation for the sugeon!

> t=[0,....19/20,1] -> (x_i,f(x_i)); (y_i,g(y_i))
>
> Clearly, x_i and y_i will not in generally coincide, so I interpolate
> the values of g at the abscissae of f and I compute 20 samples of h as
> (x_i, f(x_i)/g_interp(x_i)). However, I have two problems:
>
> 1) since I have the Bezier nodes, I'd like to somewhat interpolate
> them and then compute h, instead than evaluating f and g on a refined
> grid and then computing h. It seems to me that I'm wasting cpu time
> and information. Is there a way to do that?

What is your hourly rate? (Zero if you are a graudate student according
to the behaviour of the management! :-( ) What is the hourly cost of your
computer? How many hours of yoour time will save how much computer time?

> 2) even if I stick to my expensive sampling -> interpolation
> procedure, it won't always work. The reason is that, because of
> possible errors in the input, sometimes
>
> P1_x <> Q1_x or P5_x <> Q5_x
>
> i.e., f and g are not defined exactly on the same interval. So I am
> not able to interpolate the g samples to the abscissae of the f
> samples. How can I solve this? Thanks,

If you just had numerical tables giving f and g then one would fit
some form (low order spline would do well) and then evaluate the rational
function on whatever set of points you wanted. But you have said enough
side tracking other things to wonder what it is that you actually want to do.

> Best Regards,
>
> deltaquattro


From: GianLuigi Piacentini on
deltaquattro wrote:

> Hi,
>
> I have two different functions f(x) and g(x) described as
plane Bezier
> curves, say of fourth degree:
>
> [f] =[(Pi_x,Pi_y)]
> [g] =[(Qi_x,Qi_y)]
>
> with i=1..5. I would like to compute some samples of a third
curve
> h(x)=f(x)/g(x). Right now, I'm computing h by calculating f
and g at
> many points, say 21 equispaced values of the parameter t:
>
> t=[0,....19/20,1] -> (x_i,f(x_i)); (y_i,g(y_i))
>
> Clearly, x_i and y_i will not in generally coincide, so I
interpolate
> the values of g at the abscissae of f and I compute 20
samples of h as
> (x_i, f(x_i)/g_interp(x_i)). However, I have two problems:
>
> 1) since I have the Bezier nodes, I'd like to somewhat
interpolate
> them and then compute h, instead than evaluating f and g on
a refined
> grid and then computing h. It seems to me that I'm wasting
cpu time
> and information. Is there a way to do that?
> 2) even if I stick to my expensive sampling -> interpolation
> procedure, it won't always work. The reason is that, because
of
> possible errors in the input, sometimes
>
> P1_x <> Q1_x or P5_x <> Q5_x
>
> i.e., f and g are not defined exactly on the same interval.
So I am
> not able to interpolate the g samples to the abscissae of
the f
> samples. How can I solve this? Thanks,
>
> Best Regards,
>
> deltaquattro
You could extrapolate the curves a little, so that their
definition interval will be equal (I think that the book of
Farin or that of Mortenson explains the math).
Many years ago, when I watched colleagues working with similar
problems, I remember that they used splines defined as y=f(x).
I used piecewise linear interpolation (again in the form
y=f(x)) since its precision was enough given the
uncertainities in the data.
Given that you want h(x), my opinion is that there is no point
in having x as a (parametric) function, instead of the
independent variable.

Hoping this helps...

G.L. Piacentini

From: Arjan on
Don't extrapolate! This will lead to disasters! Get the interval that
is covered by both functions and limit h to that domain!

The Bezier coefficients may have been estimated using a criterion that
will give you f and g with a certain precision, but this does not
guarantee precision of h! Division can lead to asymtots. How do you
expect to catch them? In case you estimated those Bezier coefficients
yourself, possibly because f and g are too time-consuming to calculate
from their definition, isn't it possible to use the original functions
behind f and g just once again, in your construction of a new array of
values for h? ;-)

Arjan
From: deltaquattro on
On 16 Feb, 18:56, Gordon Sande <g.sa...(a)worldnet.att.net> wrote:
> On 2010-02-16 12:47:26 -0400, deltaquattro <deltaquat...(a)gmail.com> said:
>
> > Hi,
>
> Both numerical analysis and graphics have specialized newsgroups that
> are a better match to what you seem to be asking.

No. I crossposted to both comp.lang.fortran and sci.math.num-analysis
because I felt that Fortran programmers may be familiar with such
problems, and I was right since all the answers came from
comp.lang.fortran.

>
> > I have two different functions f(x) and g(x) described as plane Bezier
> > curves, say of fourth degree:
>
> > [f] =[(Pi_x,Pi_y)]
> > [g] =[(Qi_x,Qi_y)]
>
> So f and g are paths in the plane. They will be multivalued and otherwise
> ill behaved as functions y = f(x) or y = g(x). The Pi_x are not monotone
> so this is not a usual way to tabulate a function which one would expect
> to be single valued in any case. Or at least that is what one expects from
> the comment that they are plane Bezier curves.

They're not multivalued and the Pi_x, Qi_x are monotone. f and g are
functions: they are only described as plane Bezier curves, which means
that their graph (a curve in the plane) has been represented by
interpolation with a plane Bezier curve. I thought that would be clear
from the context, and since the other repliers understood me, that
means that I was at least not too obscure.

>
> > with i=1..5. I would like to compute some samples of a third curve
> > h(x)=f(x)/g(x). Right now, I'm computing h by calculating f and g at
> > many points, say 21 equispaced values of the parameter t:
>
> What is t (other than arc length along the Bezier curve) and what is
> x as a function of t? Is it single valued? Same for y.

It's not the arc length, it's just the parameter of the Bernstein
representation:

f:
x(t)=sum(i=0,...,4)Pi_x*B(t)^n_i
y(t)=sum(i=0,...,4)Pi_y*B(t)^n_i

g:
x(t)=sum(i=0,...,4)Qi_x*B(t)^n_i
y(t)=sum(i=0,...,4)Qi_y*B(t)^n_i

where B(t)^n_i are the Bernstein polynomials. In both cases x(t) is a
single valued function of x.

> it (x_i,f(x_i)) and (x_i,g(x_i)), From your set up it seems y=f(x) or
> y=g(x) so why the change of notation which just confuses the reader
> (and makes the reader wonder if there are other confusions).
>
> One is curious about why the ratio is of interest. That is a question
> about how your problem arises. Perhaps there is an alternate solution

? f(x) and g(x)) are two physical quantities which are given, and I
have to calculate the graphs of another quantity which is their ratio.

> to the actual problem. There are lots of instances of good answers to
> poor questions which end up being poor annswers in substance. Have you
> head about the patient who died when it was an completely successful
> operation for the sugeon!
>
> > t=[0,....19/20,1] -> (x_i,f(x_i)); (y_i,g(y_i))
>
> > Clearly, x_i and y_i will not in generally coincide, so I interpolate
> > the values of g at the abscissae of f and I compute 20 samples of h as
> > (x_i, f(x_i)/g_interp(x_i)). However, I have two problems:
>
> > 1) since I have the Bezier nodes, I'd like to somewhat interpolate
> > them and then compute h, instead than evaluating f and g on a refined
> > grid and then computing h. It seems to me that I'm wasting cpu time
> > and information. Is there a way to do that?
>
> What is your hourly rate? (Zero if you are a graudate student according
> to the behaviour of the management! :-( ) What is the hourly cost of your
> computer? How many hours of yoour time will save how much computer time?

I've never been asked such a question when coming to a ng for help.
Can we keep the discussion to the point, please?

>
> > 2) even if I stick to my expensive sampling -> interpolation
> > procedure, it won't always work. The reason is that, because of
> > possible errors in the input, sometimes
>
> > P1_x <> Q1_x or P5_x <> Q5_x
>
> > i.e., f and g are not defined exactly on the same interval. So I am
> > not able to interpolate the g samples to the abscissae of the f
> > samples. How can I solve this? Thanks,
>
> If you just had numerical tables giving f and g then one would fit
> some form (low order spline would do well) and then evaluate the rational
> function on whatever set of points you wanted. But you have said enough
> side tracking other things to wonder what it is that you actually want to do.
>

Thanks for the suggestion.

Regards

deltaquattro