10 Reputation

One Badge

3 years, 132 days

MaplePrimes Activity

These are replies submitted by gst

@Carl Love , "The return value must be a procedure" - yes, that's what I wanted. My first guess was 

but it leads to the recursion error... And that's why I tried to write a procedure without "piecewise"(I thought that may be it causes the problem)
But "piecewise" actually is exactly what I needed, @Carl Love, your code works:

(I've left the "symbolic" part, that's enough for my purposes)

Eventually, I realised that all that I need is just to add "unapply" to the "fist guess": 

And that's it! Hmm, I should have guessed after the first answer... @Carl Love ,@Kitonum  , thank you so much for you help! The problem is solved.

@Kitonum ,thank you for your answer! But if I first call f1:=divide5(f,i) and then  f1(some particular numbers) it does not returns the  result I've expected... What am I doing wrong?

@Carl Love , I agree, it's obviuos that it doesn't work :)
What I want is to create a procedure that changes given function f(i,x) and that change should depend on the parameter i.

@Carl Love , thank you very much!

But I've tried to go further and got another error.

Let's forget that it is normalization for a sake of simplicity and let's just divide the function by 5. This code works :


divide5 := proc (g)

  local x, r; r := unapply((1/5)*g(x), x);


end proc; 

f := x-> x^2 :

f := divide5(f);


Now I want my function to be dependent on the parameter, say, i. This code doesn't work:


divide5 := proc (g, k)

  local x, r;

  if k < 3 then r := 0 else r := unapply((1/5)*g(k, x), k, x) end if;


end proc

f :=  (i, x) -> x^2+i :

f := divide5(f, i);

Error, (in divide5) cannot determine if this expression is true or false: i < 3

Could I trouble you to explain this?


Page 1 of 1