Ozgur

78 Reputation

8 Badges

17 years, 67 days

MaplePrimes Activity


These are replies submitted by Ozgur

Thank you Doug.

Just FYI: Think of y as quantity (q) and x as price (p) of Economics and q(p)=(p-6)-0.01*(p-6)^3 is the equation of a market demand function. What my procedure needs to do is to take this function q(p) as an argument, and return an expression for the price elasticity of demand, which is defined as (dq/dp)(p/q); that's why I needed to use q (y, in my previous post) both as the left hand side variable and as an independent variable.

Let me switch back to x-y notation, since that's what I started with and it may be more intuitive for most people. 

Maybe I should have written G:=(x,y)->D(y)(x)*x/y(x) to stress that y is a function of x?

Anyway, your solution works, but I still couldn't make the procedure work. Here is what I had done:


y := x->-(x-6)-0.01*(x-6)^3:

elasticity := proc(y::anything)
   local x,z,G;
G  :=  (x,z) -> D(y)(x)*x/z;
return G(x,z);
end proc:

(As a side note, I don't write proc(y::function) since type(y(x), function) returns false! Another thing that I don't understand.)

 

E:=(x,z)->elasticity(y):

(Another note: I thought I should have called elasticity with y(x) instead of y. Calling it with y(x) didn't work, yet another point that puzzles me).

E(x,z);

returns

(-1-0.03*(x-6)^2)*x/z

as it should, but

E(6,-0.05);

also returns

(-1-0.03*(x-6)^2)*x/z

while it is supposed to return 120..

What am I doing wrong here?

 

 

Thank you Doug.

Just FYI: Think of y as quantity (q) and x as price (p) of Economics and q(p)=(p-6)-0.01*(p-6)^3 is the equation of a market demand function. What my procedure needs to do is to take this function q(p) as an argument, and return an expression for the price elasticity of demand, which is defined as (dq/dp)(p/q); that's why I needed to use q (y, in my previous post) both as the left hand side variable and as an independent variable.

Let me switch back to x-y notation, since that's what I started with and it may be more intuitive for most people. 

Maybe I should have written G:=(x,y)->D(y)(x)*x/y(x) to stress that y is a function of x?

Anyway, your solution works, but I still couldn't make the procedure work. Here is what I had done:


y := x->-(x-6)-0.01*(x-6)^3:

elasticity := proc(y::anything)
   local x,z,G;
G  :=  (x,z) -> D(y)(x)*x/z;
return G(x,z);
end proc:

(As a side note, I don't write proc(y::function) since type(y(x), function) returns false! Another thing that I don't understand.)

 

E:=(x,z)->elasticity(y):

(Another note: I thought I should have called elasticity with y(x) instead of y. Calling it with y(x) didn't work, yet another point that puzzles me).

E(x,z);

returns

(-1-0.03*(x-6)^2)*x/z

as it should, but

E(6,-0.05);

also returns

(-1-0.03*(x-6)^2)*x/z

while it is supposed to return 120..

What am I doing wrong here?

 

 

acer,

"The "formulae" for the roots of a cubic may appear to be complex-valued, with `I` present, even though evaluation and symbolic simplification leads to a theoretically expected purely real answer."

Well, yes, this was my problem: I know that there may be complex conjugate roots for some cubic polynomials. But in some specific examples, even though all 3 roots should have been purely real (of course including some symbolic variables), I got a complex-valued root - an expression with "I"s in it. That's what puzzled me.

Thank you again,

Ozgur

Thanks a lot acer.

When I check the discriminant of the cubic function whose root I want to find (a quadratic function of y), I see for some values of y, I shouldn't see any complex expressions in the root. That does not turn out to be the case though.

I may have more questions on this later. I must be doing a mistake somewhere; I'm still trying to find it.

Cheers,

Ozgur

Hi Sandor,

It was an article actually and here is the  bibtex  info:

@article{FritschCarlson1980,
   author = "F. N. Fritsch and R. E. Carlson",
   title = "Monotone Piecewise Cubic Interpolation",
   year = "1980",
   journal = "SIAM Journal on Numerical Analysis",
   volume = " 17",
   number = "2",
   pages = "238--246",
}
 

If you cannot find it let me know, I'll e-mail it to you.

Cheers,

Ozgur

Thank you for your time Jacques. Actually, a couple of days ago, Joe Riel replied as follows:

"Something along these lines:

piecewise(seq([x<=args[2*k+1],k][], k=1..iquo(nargs,2)-1))"

And that worked perfect. 


Currently I am the only one using this procedure but I agree with you that error messages which actually make sense are absolutely necessary!

Cheers!
Ozgur

Thank you for your time Jacques. Actually, a couple of days ago, Joe Riel replied as follows:

"Something along these lines:

piecewise(seq([x<=args[2*k+1],k][], k=1..iquo(nargs,2)-1))"

And that worked perfect. 


Currently I am the only one using this procedure but I agree with you that error messages which actually make sense are absolutely necessary!

Cheers!
Ozgur

Thank you for the explanations. Just in case you wonder; I was trying to write a code which calculates and plots monotone spline for a given set of monotone points. If I can print the results nicely, I will post the code here, maybe some other people also need monotone spline.

Thank you for the explanations. Just in case you wonder; I was trying to write a code which calculates and plots monotone spline for a given set of monotone points. If I can print the results nicely, I will post the code here, maybe some other people also need monotone spline.

Thanks a lot Joe. I don't quite understand the syntax (in particular, the empty brackets [ ] after

[x<=args[2*k+1],k] ) but this works! 

Cheers,

Ozgur

Thanks a lot Joe. I don't quite understand the syntax (in particular, the empty brackets [ ] after

[x<=args[2*k+1],k] ) but this works! 

Cheers,

Ozgur

1 2 Page 2 of 2