Items tagged with eval


I am interested to know difference between eval and evalf. Will evaluating a function at a point using these commands gives the same answer or not. I mean will there will be any exception or not. How can I evaluate the value of  a series using eval instead of evalf without the problem of memory running out (No comprimise in accuracy).

Dear friend,

please suggest a way for manipulation of derivative of a function symbolically. Assume

Ex1 :=expand(diff(f(x+y)+x*f(x-y), x)^2)+expand(diff(f(x-y)-y*f(x+y), x)^2);

Result is as needed:

Ex1 := (D(f))(x+y)^2+2*(D(f))(x+y)*f(x-y)+2*(D(f))(x+y)*x*(D(f))(x-y)+f(x-y)^2+2*f(x-y)*x*(D(f))(x-y)+x^2*(D(f))(x-y)^2+(D(f))(x-y)^2-2*(D(f))(x-y)*y*(D(f))(x+y)+y^2*(D(f))(x+y)^2

But later I cannot use D(f) as a function. Expressions

subs((D(f)) = (t -> 1-t), Ex1);
subs(diff(f(x),x) = (t -> 1-t), Ex1);

do not handle it as a function.

I have a derivative distribution function f that is defined:

f:=piecewise(x < .114e-1,0.,x < .129e-1,0.,x < .147e-1,0.,x < .167e-1,0.,x < .189e-1,0.,x < .215e-1,0.,x < .244e-1,0.,x < .278e-1,0.,x < .315e-1,0.,x < .358e-1,0.,x < .407e-1,0.,x < .463e-1,0.,x < .526e-1,0.,x < .597e-1,0.,x < .679e-1,0.,x < .771e-1,0.,x < .876e-1,0.,x < .995e-1,0.,x < .113,0.,x < .128,0.,x < .146,0.,x < .166,0.,x < .188,0.,x < .214,0.,x < .243,0.,x < .276,0.,x < .314,0.,x < .357,0.,x < .405,0.,x < .46,0.,x < .523,0.,x < .594,0.,x < .675,-.8800000000+1.481481481*x,x < .767,-.3935869565+.7608695652*x,x < .872,-.3213333333+.6666666667*x,x < .991,-.2529411765+.5882352941*x,x < 1.13,-.1690647482+.5035971223*x,x < 1.28,-.2026666667+.5333333333*x,x < 1.45,-.1223529412+.4705882353*x,x < 1.65,-.1650000000+.5000000000*x,x < 1.88,-.2726086957+.5652173913*x,x < 2.13,-.5636000000+.7200000000*x,x < 2.42,-.8662068966+.8620689655*x,x < 2.75,-1.200000000+1.000000000*x,x < 3.12,-1.645945946+1.162162162*x,x < 3.55,-1.865581395+1.232558140*x,x < 4.03,-2.075416667+1.291666667*x,x < 4.58,-1.925818182+1.254545455*x,x < 5.21,-1.559682540+1.174603175*x,x < 5.92,-.7967605634+1.028169014*x,x < 6.72,.3320000000+.8375000000*x,x < 7.64,1.942608696+.5978260870*x,x < 8.68,3.791923077+.3557692308*x,x < 9.86,5.850169492+.1186440678*x,x < 11.2,7.902985075-.8955223881e-1*x,x < 12.7,9.737333333-.2533333333*x,x < 14.5,10.82388889-.3388888889*x,x < 16.4,11.78631579-.4052631579*x,x < 18.7,11.34347826-.3782608696*x,x < 21.2,10.85240000-.3520000000*x,x < 24.1,9.311379310-.2793103448*x,x < 27.4,7.619090909-.2090909091*x,x < 31.1,5.814864865-.1432432432*x,x < 35.3,4.025714286-.8571428571e-1*x,x < 40.1,2.544375000-.4375000000e-1*x,x < 45.6,1.519090909-.1818181818e-1*x,x < 51.8,.8370967742-.3225806452e-2*x,x < 58.9,.6700000000,x < 66.9,.5963750000+.1250000000e-2*x,x < 76,.9005494505-.3296703297e-2*x,x < 86.4,1.161538462-.6730769231e-2*x,x < 98.1,1.318461538-.8547008547e-2*x,x < 111,1.544651163-.1085271318e-1*x,x < 127,1.241875000-.8125000000e-2*x,x < 144,1.106470588-.7058823529e-2*x,x < 163,.7721052632-.4736842105e-2*x,x < 186,0,x < 211,0,x < 240,0,x < 272,0,x < 310,0,x < 352,0,x < 400,0,x < 454,0,x < 516,0,x < 586,0,x < 666,0,x < 756,0,x < 859,0,x < 976,0,x < 1110,0,x < 1260,0,x < 1430,0,x < 1630,0,x < 1850,0,x < 2100,0,x < 2390,0,x < 2710,0,0):

I want to do a simple numerical integration of that function - that means I have k points of independent variable x and together with dependent variable points it looks like:

I was trying to resolve this in Maple:




but I get an error 

Error, (in limit/mrv/limsimpl) too many levels of recursion

Can you help me with the syntax? Thank you.

emal := proc(zipeq,abc1param,abc2param,abc3param,abc4param,abc5param)
source1 := Prefix(zipeq);
source2 := subs(s=abc5param,subs(v=abc4param,subs(u=abc3param,subs(t=abc2param,subs(a=abc1param,source1))))):
zipplus := proc(mm, pp)
 return zip((x,y) -> x+y, mm, pp)
end proc:
zipstar := proc(mm, pp)
 return zip((x,y) -> x*y, mm, pp)
end proc:
return eval(source2);
end proc:

would like to do the Prefix first and then eval the prefix later but do not expect do define zipstar and zippplus in global

just want to eval this Prefix which is formula of zipstar and zipplus function


above result same as print(source2), but eval in return , it have not evaluate, why?

Hello, I have a function defined as

                                                   g :=  (x, y)->diff(u1(x, y), x, x)+diff(u2(x, y), x, y). 

I want to define another function as follows

                                                           f :=  (y) ->subs(x = 0, g(x, y)) ,

Now, when I want to calculate numerical values for the new function f(0), f(0.1), f(0.2),..... and so on. The following massage appear

Error, (in f) invalid input: diff received 0, which is not valid for its 2nd argument.

What is the problem here.





I have a Pde solution in from of the sum.

pde := diff(u(x, t), t) = diff(u(x, t), x$2)

symbolic := pdsolve([pde, u(x, 0) = 1, u(0, t) = 0, u(1, t) = 0])

symbolic := u(x, t) = Sum(-(2*((-1)^_Z9-1))*sin(_Z9*Pi*x)*exp(-Pi^2*_Z9^2*t)/(Pi*_Z9), _Z9 = 1 .. infinity)


I tried a subs or eval command dosen't work.




pde := diff(u(x, t), t) = diff(u(x, t), `$`(x, 2)):

ics := [u(x, 0) = 1, u(0, t) = 0, u(1, t) = 0]:

pds := pdsolve(pde, ics, numeric, time = t, range = 0 .. 1, spacestep = 1/4024, timestep = 1/4024):

symbolic := pdsolve([pde, u(x, 0) = 1, u(0, t) = 0, u(1, t) = 0])

u(x, t) = Sum(-2*((-1)^_Z9-1)*sin(_Z9*Pi*x)*exp(-Pi^2*_Z9^2*t)/(Pi*_Z9), _Z9 = 1 .. infinity)


eval(rhs(symbolic), `~`[_Z9] = n)

Sum(-2*((-1)^_Z9-1)*sin(_Z9*Pi*x)*exp(-Pi^2*_Z9^2*t)/(Pi*_Z9), _Z9 = 1 .. infinity)


subs(`~`[_Z9] = n, rhs(symbolic))

Sum(-2*((-1)^_Z9-1)*sin(_Z9*Pi*x)*exp(-Pi^2*_Z9^2*t)/(Pi*_Z9), _Z9 = 1 .. infinity)


subs[eval](`~`[_Z9] = n, rhs(symbolic))

Sum(-2*((-1)^_Z9-1)*sin(_Z9*Pi*x)*exp(-Pi^2*_Z9^2*t)/(Pi*_Z9), _Z9 = 1 .. infinity)






g:= a -> int(f(x+a),x=a..2*a):
                    int(f(2 x), x = 1 .. 2)
                   int(f(x + 1), x = 1 .. 2)

eval is advertised as smart, but it's not enough!

(Related to a recent answer of Carl Love about bound variables.)


Edit: shorter version

g:= a -> int(sin(sin(x+a)),x=a..2*a):
                  0.1052070507 = 0.5294405453

Hello people in mapleprimes,


I wonder if there is not any way to control the timing of substitution.

For  example,


brings mu := c^(a-b)/x. Please note that I made x unevaluated with '' around x, so that,

into the output of mu, the definition of x of (t^(1-s)+s^(1-2*s))^a does not appear.

But, in this case, when I typed the expression of


and clicked return, the definition of x is inserted into the result of 1+m, though

I want x to remain x yet.

Surely, if I wrote ''x'' in stead of 'x', 1+mu does not contain the definition of x.

But, in that case as well, when I have other following calculations, in those the definition 

of x should apear, which I don't like.


On the other hand, when I write as

x:=(t^(1-s)+s^(1-2*s))^a; x:='x';
mu:=c^(a-b)/x; 1+m;

surely as x is initialized once, the result of mu and 1+mu does not cotain the definition of x.

But, in this case, I have to write x:=(t^(1-s)+s^(1-2*s))^a; when I want the definition of x

to be inserted. Though in this case the definition of x is short, original relations I have and

haven't writen above is a little more complicated, so that to insert is not desiable.


Aren't there any good way to evaluate the value of particular variables and to leave them

unevaluated at each time I want to choose each one?


I hope I could have written my question as easly understood.

And, thanks in advance.






Hi everybody

In the following attached file, I try to evaluate an integration, K_fL. Unfortunately, Maple does not evaluate it and just puts integration symbol and its bounds. I want to have final integration value. Is there any solution to this integration or maybe Maple can not solve this integration because of the complexity of integrand?

Thanks in advance

After running Maple in a shell file, I come up with this error that I do not understand on my Mac,

gap_long := 0.117647058823529 Pi

gap_lat := 0.0588235294117647 Pi

lat_begin := 0.441176470588235 Pi

long_begin := -Pi

lat_begin_0 := 0.441176470588235 Pi

long_begin_0 := -Pi

long_max := 0.882352941176471 Pi

lat_max := -0.441176470588235 Pi


Warning, `parameter` is implicitly declared local to procedure `set_par_eff`

distance eff distance_eff
im in has not
im in has not
im in has not
im in has not
im in has not
im in has not
im in has not
im in has not
im in has not
Im in has par
Im in has par
Error, invalid input: eval expects its 2nd argument, eqns, to be of type
{integer, equation, set(equation)}, but received par_eff_post




hou := 0

mini := 0

seci := 0

memory used=4.0MB, alloc=32.3MB, time=0.23

If needed, I can attach more files if my question is still a bit too cryptic. Please let me know asap as this is urgent. Thank you so much,


I need to crate a function to be evaluated in a range of values, and this function i would to use in other expression, example:

cel1      "seq(i,i=0.001..2,0.001)"

cel2      "A:=&1";cel1

cel3      "f:=x->diff(KelvinBei(0,x),x)"

cel4      ""B:=map(x->f(x),[A])"


This is ok with a lot of function but with diff(KelvinBei(0,x),x) in cel4 show this error "Error,(in f) invalid input:.1e-2, which is not valid for its 2nd argument.

Why??? How can I do??

Hello guys,

I was just playing around with the Shanks transformation of a power series, when I noticed that polynomials aren't evaluated as I would expect.
I created this minimal working example; the function s should evaluate for z=0 to a[0], however it return simply 0.
Is there something I messed up?


s := proc (n, z) options operator, arrow; sum(a[k]*z^k, k = 0 .. n) end proc;

proc (n, z) options operator, arrow; sum(a[k]*z^k, k = 0 .. n) end proc


series(s(n, z), z = 0)



The value of s in z=0 should be a[0], however it returns 0:

s(n, 0)



s(1, 0)





Thanks for your help,


Hey all,

I want to symbolically differentiate a function and recalculate the result later. Here is what I have tried so far:






b := Vector(2, {(1) = b1(t), (2) = b2(t)})



dfdb := Vector(2, {(1) = (D(f))(Vector(2, {(1) = b1(t), (2) = b2(t)})), (2) = (D(f))(Vector(2, {(1) = b1(t), (2) = b2(t)}))})



proc (b) options operator, arrow; b(1)^2+b(2) end proc


eval(myexp);  #actual result



sthlong+(Vector(2, {(1) = (D(f))(Vector(2, {(1) = b1(t), (2) = b2(t)})), (2) = (D(f))(Vector(2, {(1) = b1(t), (2) = b2(t)}))}))



eval(myexp); #expected result

sthlong+(Vector(2, {(1) = 2*b1(t), (2) = 1}))




I wonder if this is even possible, or if I missunderstand something. Can you please help me?





Consider the following:

conv1 := (x) -> eval(x, tau*f(t) = f(-t)):     # Using eval
conv2 := (x) -> algsubs(tau*f(t) = f(-t),x):   # Using algsubs
expr := Vector([

I would have expected both components of expr to have been transformed, just as they do if algsubs is used, but the second component containing the imaginary unit I as well is not. Why not? Note that if I is replaced by any real number, then the substitution works quite as expected. Why should going from real to complex numbers change things fundamentally?

Additional note: Even though algsubs works above, I would like to avoid using it because the actual system I have contains more than a hundred substitutions to (potentially) be made, and algsubs can only take one at a time, in constrast to eval which in principle can take indefinitely (though finitely, of course) many at a time.

PS: In case the reader is wondering, tau is supposed to be a time reversal operator acting on some time-dependent function f(t).

Why does "eval(c, [b=1,l=1])" turn out to be "1" not "1/1+x"??? its driving me cracy. THX






eval(a, [l=1])



eval(a, [x=2,l=1])






eval(c, [b=1,l=1])





1 2 3 4 5 6 Page 1 of 6