Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@N00bstyle Your procedure reductiefactorvoetgangershoogte is unnecessarily complicated and involves a lot of calls to eigenfrequentieigvvoetgangers. But in this case the main problem is that evalb (which is used in the if statements) cannot handle Pi:
try
if Pi<3 then 7 else 0 end if;
evalb(Pi<3);
You could use 'is' instead of evalb as in
if is(Pi<3) then 7 else 0 end if;
is(Pi<3);
Instead you could replace Pi by evalf(Pi).
So a suggestion for your procedure reductiefactorvoetgangershoogte would be to change the procedure to
reductiefactorvoetgangershoogte := proc (_hoogte)
local eg; eg := evalf(eigenfrequentieigvvoetgangers(_hoogte));
if eg <= 1.25 then 0 elif 1.25 < eg and eg < 1.7 then (eg-1.25)/(1.7-1.25) elif 1.7 <= eg and eg <= 2.1 then 1 elif 2.1 < eg and eg < 2.3 then (2.3-eg)/(2.3-2.1) elif 2.3 <= eg and eg <= 2.5 then 0 elif 2.5 < eg and eg < 3.4 then .25*(eg-2.5)/(3.4-2.5) elif 3.4 <= eg and eg <= 4.2 then .25 elif 4.2 < seg and seg < 4.6 then .25*(4.6-eg)/(4.6-4.2) elif 4.6 <= eg then 0 end if end proc;
(I'll let you do the indenting)
My points are: eigenfrequentieigvvoetgangers(_hoogte) is evaluated only once and then evalf is aplied.
However, I still think you should use unapply and piecewise instead of your present approach.
Why insist on making it complicated?

@N00bstyle Your procedure reductiefactorvoetgangershoogte is unnecessarily complicated and involves a lot of calls to eigenfrequentieigvvoetgangers. But in this case the main problem is that evalb (which is used in the if statements) cannot handle Pi:
try
if Pi<3 then 7 else 0 end if;
evalb(Pi<3);
You could use 'is' instead of evalb as in
if is(Pi<3) then 7 else 0 end if;
is(Pi<3);
Instead you could replace Pi by evalf(Pi).
So a suggestion for your procedure reductiefactorvoetgangershoogte would be to change the procedure to
reductiefactorvoetgangershoogte := proc (_hoogte)
local eg; eg := evalf(eigenfrequentieigvvoetgangers(_hoogte));
if eg <= 1.25 then 0 elif 1.25 < eg and eg < 1.7 then (eg-1.25)/(1.7-1.25) elif 1.7 <= eg and eg <= 2.1 then 1 elif 2.1 < eg and eg < 2.3 then (2.3-eg)/(2.3-2.1) elif 2.3 <= eg and eg <= 2.5 then 0 elif 2.5 < eg and eg < 3.4 then .25*(eg-2.5)/(3.4-2.5) elif 3.4 <= eg and eg <= 4.2 then .25 elif 4.2 < seg and seg < 4.6 then .25*(4.6-eg)/(4.6-4.2) elif 4.6 <= eg then 0 end if end proc;
(I'll let you do the indenting)
My points are: eigenfrequentieigvvoetgangers(_hoogte) is evaluated only once and then evalf is aplied.
However, I still think you should use unapply and piecewise instead of your present approach.
Why insist on making it complicated?

@N00bstyle If after having defined eigenfrequentie in your version, you try the command
eigenfrequentie;
then you reveive the error
Error, (in qigvvoetgangers) cannot determine if this expression is true or false: 0 <= 0.153846153846154e-1*(65.0*hoogte+.967200000000000)/hoogte-21/20
That is where you have to ask yourself what to do. In fact you must have noticed the problem yourself (I guess) since you don't use eigenfrequentie in the plot command defining ploteigenfrequentie, but rather the expression used to define eigenfrequentie.


@N00bstyle If after having defined eigenfrequentie in your version, you try the command
eigenfrequentie;
then you reveive the error
Error, (in qigvvoetgangers) cannot determine if this expression is true or false: 0 <= 0.153846153846154e-1*(65.0*hoogte+.967200000000000)/hoogte-21/20
That is where you have to ask yourself what to do. In fact you must have noticed the problem yourself (I guess) since you don't use eigenfrequentie in the plot command defining ploteigenfrequentie, but rather the expression used to define eigenfrequentie.


@Markiyan Hirnyk Try

inttrans[invlaplace](s^(-2.3)/(s+c),s,t); #No problem
inttrans[invlaplace](s^(-2.3)*cos(s)/(s+c),s,t); #Not found
That the last one is not found is just because invlaplace isn't perfect.

In the question p was assumed constant. However, it may be worth mentioning that the non-constant case can be handled as well, but we must use DEtools[mult]:

with(DEtools):
L:=(Dx-p(x))^2;
diffop2de(L,f(x),[Dx,x]); # does not correspond to composition
#This gives the correct version:
mult(Dx-p(x),Dx-p(x),[Dx,x]);
diffop2de(%,f(x),[Dx,x]);

In the question p was assumed constant. However, it may be worth mentioning that the non-constant case can be handled as well, but we must use DEtools[mult]:

with(DEtools):
L:=(Dx-p(x))^2;
diffop2de(L,f(x),[Dx,x]); # does not correspond to composition
#This gives the correct version:
mult(Dx-p(x),Dx-p(x),[Dx,x]);
diffop2de(%,f(x),[Dx,x]);

@GOODLUCK If you are rewriting your system using other names, then be sure to avoid gamma, Pi, I, and D, since they have special meanings in Maple:
gamma is Euler's constant, try evalf(gamma);
As said earlier Pi is the usual, try evalf(Pi);
I stands for sqrt(-1), try I^2;
D is the differentiation operator, D(sin); and D(sin)(Pi/3); #compare to diff(sin(x),x);
Also avoid using a name like alpha together with indexed versions of alpha like alpha[0]. Say you assign to alpha[0], alpha[0]:=7.913. Then you have implicitly created a table with name alpha, try eval(alpha);
Also use * as the multiplication sign, the dot is really meant for matrix multiplication.

@GOODLUCK Notice the tilde in my command
fvars:=freeze~(vars);
That means that the procedure freeze will be applied to each element in the set (or list or other "container") vars.
This syntax for elementwise operation was introduced in Maple 13.
See
?elementwise
If instead you just do freeze(vars); then you freeze the whole set of variables.
Notice the different outputs of
freeze(vars); #returns one "freeze" name
and
freeze~(vars); #returns a set of "freeze" names and also regular names (these are not frozen as there is no need for that).

@GOODLUCK fsolve needs to know the values of the parameters in the equations.
I tried this:

params:=indets(feqns,name) minus convert(fvars,set); #The parameters
paramvals:=`=`~(params,.1); #values set arbitrarily to 0.1 each and everyone
#The command
fsolve(eval(feqns,paramvals),convert(subs(Pi=pi,fvars),set));
#didn't finish before my patience (short) ran out.
#Correction: It is worse:
params:=indets(feqns,{name,name^name}) minus convert(fvars,set);
Also you have to be careful about using alpha and alpha[0] (and alpha[whatever] ) in the same calculations.
Evaluating alpha[0] at alpha=.1 :
eval(alpha[0],alpha=.1);
#returns .1[0] which doesn't evaluate to a float.
My suggestion is that you use other names not involving `^` or `[]`.

If possible it is a good idea to treat a considerably smaller system first, the idea being: if a smaller system cannot be solved there is not much chance of success with a larger one.

@GOODLUCK As Carl is pointing out, it is strange to call mu^H a variable. Assuming that by mu^H you don't mean mu raised to the power H, but just mu with an upper index H, you could freeze mu^H so that Maple doesn't treat it as mu raised to power H:

vars:=[c^B,n^B,h^B,mu^B,mu^H,c^s,n^s,h^s,d^s,c^L,m^F,d^L,mu^c,mu^I,
nu^c,nu^I,c^D,d^D,m^R,m^N,K,q,mu^F,k^L,E^L,k^D,E^D,y,M,w^B,P^H,r^B,r^H,
r^D,Pi,r^F,w^F,w^I,w^R,w^N]; #list
fvars:=freeze~(vars); #freezing
feqns:=subs(`=`~(vars,fvars),{eqn||(1..40)}): #Replacing your "variables" by frozen ones
#You used a "variable" called Pi. Pi in Maple is the usual Pi, so use pi:
solve(feqns,subs(Pi=pi,fvars));
No solution.

From the image it looks like there is possibly missing a multiplication sign, so that what is really attempted is
EC2:= Z=1+beta-(q*beta*(Z-beta)/(Z+epsilon*beta)(Z+sigma*beta));
solve(eval(EC2, P), Z);

In Maple 15 this results in the warning mentioned, whereas in Maple 16 and 17 it results in errors (different though).

From the image it looks like there is possibly missing a multiplication sign, so that what is really attempted is
EC2:= Z=1+beta-(q*beta*(Z-beta)/(Z+epsilon*beta)(Z+sigma*beta));
solve(eval(EC2, P), Z);

In Maple 15 this results in the warning mentioned, whereas in Maple 16 and 17 it results in errors (different though).

Why don't you just write the ode in Maple syntax and use dsolve?

@Axel Vogt Thank you!
You forgot "return" before 'procname'.
I still wonder what goes on in plot and plot3d.

First 163 164 165 166 167 168 169 Last Page 165 of 231