## How to substitute algebraic variables and function...

I have a set of 15 equations in state space form, and I'm just trying to program a way to substitute all variables representing the time derivates as for example x__s_dot (t) as diff(x__s (t), t)  and diff( x__s_dot (t),t) as diff(x__s (t), t,t) so I can manipulate my equations easier.

The last half of the list xx has the variables that I want to substitute, the x,y and u (with respective diff(x__s (t), t) ) variables are always constant, but in the case of zeta, eta and u I might have indexes from 1 to n , in this case just 1 and 2.

I tried a bunch of methods including creating vectors with the seq, op commands and substituting them into my original equations with subs, algsubs but none of the things I programmed worked the way I wanted, I ended up with a very inefficient way , doing it manually, but the point is that I wanted to automate this bit. I've been doing maple for about 2 weeks and I still struggle a lot with it, I would greatly appreciate any guidence/advice.

My original equations are actually much bigger and my original code too, I tried to shorten it a bit just for making my problem simpler to understand but the equations still look really big here, If there is another way to format this question please do advice so.

EDIT : I think my last code was hard to understand because my equations were too big and it looked all messy and horrible, I edited to show just one vector of variables, I think that if it works here, it should work on the rest of my code:

 > interface(rtablesize=50):
 >
 > nq := 15;             xxUNDOT := [ seq ( xx[i], i = 1..nq),              seq ( diff(xx[i],t), i = 1..nq)];
 (1)
 > DOTL := [ seq ( xx[i], i = 1..nops(xx)) ]: DOTR := [ seq ( xxUNDOT[i], i = 1..nops(xx))]: Vector[column](DOTL),Vector[column](DOTR); for i from nq+1 to nops(xx) do newxx    := subs[inplace][eval](   op(i,DOTL) = op(i,DOTR) ,xx): end do:
 (2)
 > Vector[column](newxx);
 (3)

I tried to make a for loop that substitutes each variable one by one, but it only seems to work for the last term, I don't know why, please help or suggest another method? I also have diff(x__s,t,t) terms in my equations, not just diff(x__s,t), but I guess only by specifying the first derivate it should work?

Thanks.

## Difference between eval and evalf...

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).

## Manipulation of derivative symbolically ...

Dear friend,

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

```Typesetting[Suppress]([f(x)]);
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.

## Numerical integration...

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:

```f_list:=convert(f,list):

integralbodyx:=[seq(0+((200-0)/100)*i,i=1..100)]:

integralbodyy:=[seq(sum((eval(f_list[0+((200-0)/100)*j],x=(0+((200-0)/100)*j)))*2,j=1..i),i=1..100)]:```

but I get an error

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

Can you help me with the syntax? Thank you.

## how to define function and evaluate these function...

emal := proc(zipeq,abc1param,abc2param,abc3param,abc4param,abc5param)
source1 := Prefix(zipeq);
print(source1);
source2 := subs(s=abc5param,subs(v=abc4param,subs(u=abc3param,subs(t=abc2param,subs(a=abc1param,source1))))):
print(source2);
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?

## an error occurred, diff received 0...

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.

Amr

## How to change summation index of Sum from PDE sol...

Hello.

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.

Thanks.

 >
 >
 >
 >
 >
 (1)
 >
 (2)
 >
 (3)
 >
 (4)
 >

## bound or dummy but ......

g:= a -> int(f(x+a),x=a..2*a):
eval(g(x),x=1);
int(f(2 x), x = 1 .. 2)
eval(g(z),z=1);
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):
evalf(eval(g(x),x=1))=evalf(eval(g(z),z=1));
0.1052070507 = 0.5294405453

## how to control the timing of evaluation...

Hello people in mapleprimes,

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

For  example,

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

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

1+mu

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.

taro

## Integral Evaluation...

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?

Q1.mw

## Urgent question/error on eval...

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

33

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
13

32

31

17

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,
-Z

## Problem with KelvinBei function...

Hello,

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??

## Strange result for the evaluation of a sum...

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?

 >
 >
 (1)
 >
 (2)

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

 >
 (3)
 >
 (4)

Thanks for your help,

Sören

## Eval Physics[diff]...

Hey all,

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

 > restart;
 > myexp:=dfdb+sthlong
 (1)
 > b:=;
 (2)
 > dfdb:=Physics[diff]~(f(b),b)
 (3)
 > f:=b->b(1)^2+b(2)
 (4)
 > eval(myexp);  #actual result
 >
 >
 (5)
 > dfdb:=Physics[diff]~(f(b),b):
 > eval(myexp); #expected result
 (6)
 >

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

Thanks

Honigmelone

## Odd behaviour of eval?...

`conv1 := (x) -> eval(x, tau*f(t) = f(-t)):     # Using evalconv2 := (x) -> algsubs(tau*f(t) = f(-t),x):   # Using algsubsexpr := Vector([     tau*f(t),   I*tau*f(t)]);conv1(expr),conv2(expr);`