longrob

Mr. Robert Long

1409 Reputation

18 Badges

15 years, 18 days
Leeds, United Kingdom

Social Networks and Content at Maplesoft.com

Business Consultant Data Scientist Statistician

MaplePrimes Activity


These are answers submitted by longrob

This looks like a heat/diffusion equation problem. 

May I ask where Q comes from ?

Have you looked at the behaviour of Q for certain fixed x or t ? For example, setting x=2*Pi, and plotting the evolution over various time periods > 0 indicates quite odd behaviour. Do you think it is correct, physically ? For example, see the plots on the attached sheet.


(1)

 

 

PDE :   

 

 

 

(2)

(3)

PP:=eval(P,x=2*Pi):

plot(PP,t=0..100);

 

plot(PP,t=0..1000);

 

 

plot(PP,t=0..20000);

 

plot(PP,t=0..390000);

 

plot(PP,t=390000..395000);

 

plot(PP,t=395000..397000);

 

plot(PP,t=405000..410000);

 

 

Download EhsanKayo_01.mw

@Christopher2222 I may be missing something, but looking at those 2 plots, why is Mathematica's much better than Maple's ? Edit: I'm talking about the Zeta() plots.

FYI I've produced the plot in Maple 15 with grid = [1500, 1500] and that looks nice to me, though I don't have mathematica to compare it to..... I can post a screenshot, or try to export it and upload it, if you like ? Edit: I'm talking about the exp(1/z) plot but I could also do the zeta() plot....

Another way might be with using frontend() though I wasn't able to get it to work. Perhaps Joe Riel or another esteemed expert on frontend() could weigh in on this ?

 

Here's my solution using unassign:

restart:
eq1:=a + b*x + c*x^alpha = 0;
alpha
a + b x + c x = 0
a:=alpha^2:
eq1;
2 alpha
alpha + b x + c x = 0
eq2:=subs(alpha=sqrt(5),eq1);
/ (1/2)\
\5 /
5 + b x + c x = 0
# which (if I understood correctly) is not what the OP wants
# Instead
a:='a':
eq2:=subs(alpha=sqrt(5),eq1):
a:=alpha^2:
eq2;
/ (1/2)\
2 \5 /
alpha + b x + c x = 0
# as (I think) required.
# But I thought there might be a way using frontend() to apply subs to eq1 so 
that the substitution is made only where alpha occurs in a power of x, something like
eq2:=frontend(subs,[alpha=sqrt(5),eq1],[{},{x^alpha}]);
which doesn't work.....
 

Can't you just unassign a,b,c,,d,..., prior to using subs to substitute for alpha, and then re-assign them afterwards ?

I was able to solve it directly as below. I don't know why you received [] as output. Often maple returns empty output when it finds no solution. As for recursive assignment error, this would happen if you tried to assign the values of  B[n1],B[n2],A[n1] or A[n2] rather than defiining equations (ie if you replaced the "=" with ":=" in your code above). Here's my code. I hope it helps:

eq1:= B[n1] = -A[n1]*R[s]^np/R[s]^(-np):
eq2:= B[n2] = -(-mu[r]*A[n2]*R[r]^np+mu[r]*A[n2]*R[r]^np*np^2-M[n]*R[r])/(mu[r]*R[r]^(-np)*(-1+np^2)):

eq3:= A[n2] = (-np*mu[R[m]]*A[n1]*R[m]^np+np^3*mu[R[m]]*A[n1]*R[m]^np+np*mu[R[m]]*B[n1]*R[m]^(-np)-np^3*mu[R[m]]*B[n1]*R[m]^(-np)-np*mu[R[m]]*B[n2]*R[m]^(-np)+np^3*mu[R[m]]*B[n2]*R[m]^(-np)+M[n]*R[m])/(np*mu[R[m]]*R[m]^np*(-1+np^2)):

eq4:= A[n1] = (mu[R[m]]*B[n1]*R[m]^(-np)-mu[R[m]]*B[n1]*R[m]^(-np)*np^2-mu[R[m]]*A[n2]*R[m]^np+mu[R[m]]*A[n2]*R[m]^np*np^2-mu[R[m]]*B[n2]*R[m]^(-np)+mu[R[m]]*B[n2]*R[m]^(-np)*np^2-M[n]*R[m])/(mu[R[m]]*R[m]^np*(-1+np^2)):

solve({eq1,eq2,eq3,eq4},[B[n1],B[n2],A[n1],A[n2]]);
 
 

[[ / np / (-np) np
[[B[n1] = - \R[s] \np R[m] R[r] R[m] mu[r]

(-np) np
- 2 np R[m] R[r] mu[R[m]] R[m]

(-np) np (-np) np
+ np R[r] R[m] R[m] mu[r] + R[m] R[r] R[m] mu[r]

(-np) np \ \// (-np)
- R[r] R[m] R[m] mu[r]/ M[n]/ \2 np mu[R[m]] R[m]

np / 2 np (-np) (-np) np
R[m] \-np R[r] R[s] - R[r] R[s]

np (-np) (-np) 2 np\ \ /
+ R[r] R[s] + R[r] np R[s] / mu[r]/, B[n2] = - \

/ np (-np) np
\R[r] R[m] R[s] np R[m] mu[r]

np (-np) np
+ R[r] R[m] R[s] R[m] mu[r]

np np (-np)
- R[r] R[m] R[s] R[m] mu[r]

np np (-np)
+ R[r] R[m] R[s] np R[m] mu[r]

np np (-np)\ \// /
- 2 R[r] np mu[R[m]] R[m] R[s] R[m] / M[n]/ \2 \-1

2\ / np (-np) (-np) np\ np
+ np / mu[r] \-R[r] R[s] + R[r] R[s] / R[m] np

(-np)\ // (-np) np
mu[R[m]] R[m] /, A[n1] = \\np R[m] R[r] R[m] mu[r]

(-np) np
- 2 np R[m] R[r] mu[R[m]] R[m]

(-np) np (-np) np
+ np R[r] R[m] R[m] mu[r] + R[m] R[r] R[m] mu[r]

(-np) np \ (-np)\//
- R[r] R[m] R[m] mu[r]/ M[n] R[s] / \2 np mu[R[m]]

(-np) np / 2 np (-np) (-np) np
R[m] R[m] \-np R[r] R[s] - R[r] R[s]

np (-np) (-np) 2 np\ \ /
+ R[r] R[s] + R[r] np R[s] / mu[r]/, A[n2] = \M[

/ (-np) (-np) np
n] \R[r] R[m] R[s] np R[m] mu[r]

(-np) (-np) np
+ R[r] R[m] R[s] R[m] mu[r]

(-np) np (-np)
- R[r] R[m] R[s] R[m] mu[r]

(-np) np (-np)
+ R[r] R[m] R[s] np R[m] mu[r]

(-np) np (-np)\\// / 2
- 2 np R[m] R[r] mu[R[m]] R[m] R[s] // \2 \-1 + np

\ / np (-np) (-np) np\ np
/ mu[r] \-R[r] R[s] + R[r] R[s] / R[m] np mu[R[m]

(-np)\]]
] R[m] /]]

If it's just happening with one worksheet, then just remove all the output from it, then paste the code to a new worksheet, and let us know if the problem persists - if it does, then could you post part of the code so we can try to reproduce it ?

I had this problem a while ago before I got a new laptop. it turns out to be a problem with the graphics card driver. I installed the latest driver and the problem was solved. I don't know what caused it, but I think it was just after a update/patch.

Have you tried opening the worksheet in question on a different machine ?

I'm not sure what you mean by "within a certain percentage". A percentage of what ? Leaving that aside, would something like this achieve what you want ?

f:=x^2:g:=x:

iq:=abs(f-g)<1:

solve(iq,x):

convert(%,list);

     [Open(1/2-(1/2)*sqrt(5)), Open((1/2)*sqrt(5)+1/2)]

Does this work as you intend ?  

testerror := proc(b) 
local bb:
print (b):
if b > 3 then
return;
end if;
bb:=b;
bb := bb+1;
testerror(bb);
return;
end proc:
 
?

This has the same problems as you last question

1. You are using = instead of :=

2. You are assigning a value to a parameter.

 

The problem occurs because you assign a value to terminal_counter which is one of the parameters of the procedure.

To avoid this, either use a new local parameter and assign the value of terminal_counter to it and use it in place of terminal_counter in your code; or change the name of terminal_counter in the parameter list to a new name and assign it's value to terminal_counter.

For example (using the 2nd suggestion)

evolf := proc(z, f, tc)  #<- terminal_counter changed to tc
local h1,h2,h3,h4,h5,h6,h7,N,test,fitness,total_fitness,i,j,temp1,temp2,terminal_counter;
h1 := z + f;
h2 := z - f;
h3 := z*f;
h4 := z+diff(f,x);
h5 := z-diff(f,x);
h6 := z*diff(f,x);
h7 := subs(x=z, f);
terminal_counter:=tc; # <-----terminal_counter is assigned the value of the parameter tc
N := 7;
test := [h1, h2, h3, h4, h5, h6, h7];
print(test);
fitness := [0, 0, 0, 0, 0, 0, 0];

if terminal_counter > 5 then
return fitness;
end if;

total_fitness := 0;
for i from 1 to N do
temp1 := 0;
temp2 := 0;
for j from 0 by 0.1 to 1 do
temp1 := eval(subs(x=j,test[i])^2);
temp2 := eval(subs(x=j,f)^2);
od;
fitness[i] := 1/(1+temp1+temp2);
total_fitness := total_fitness + 1/(1+temp1+temp2);
od;
for i from 1 to N do
fitness[i] := fitness[i]/evalf(total_fitness);
od;
print(select(t->type(fitness[op(t)], max(fitness)), [$1..nops(fitness)])[1]);
print(test[select(t->type(fitness[op(t)], max(fitness)), [$1..nops(fitness)])[1]]);

terminal_counter := terminal_counter + 1;
if max(fitness) = min(fitness) then
return fitness;
end if;
fitness := evolf(test[select(t->type(fitness[op(t)], max(fitness)), [$1..nops(fitness)])[1]], f, terminal_counter);
return fitness;
end proc:
fitness := evolf(x^2, x+1, 1);

The best I can do is

expand(t);
n
2
--
n
5
You can use the DeleteRow command in the LinearAlgebra package
http://www.maplesoft.com/support/help/Maple/view.aspx?path=LinearAlgebra/DeleteRow

You need to close the for loop with an "end do" before closing the procedure.

There are some other issues in your code, such as
using = instead of := 
not declaring variables as local
It may also be an idea to declare the type of parameter that is being passed in to the procedure (seems like it's a function so you can use f::mathfunc)

So, 

evolf := proc(f::mathfunc)
local h1,h2,h3,h4,h5,h6,h7,h8,h9,test,F,i;
h1 := z + f(x);
h2 := z - f(x);
h3 := z*f(x);
h4 := f(x)/z;
h5 := z+diff(f(x),x);
h6 := z-diff(f(x),x);
h7 := z*diff(f(x),x);
h8 := diff(f(x),x)/z;
h9 := subs(x=z, f(x));
test := [h1, h2, h3, h4, h5, h6, h7, h8, h9];
F := 0;
for i from 1 to 9 do
F := F + 1/(1+exp(subs(x=0,test[i])-subs(x=0,f(x))));
end do;
end proc:

evolf(sin);
1/(1+exp(z))+1/(1+exp(z-2*sin(0)))+1/(1+exp(z*sin(0)-sin(0)))+1/(1+exp(sin(0)/z-sin(0)))+1/(1+exp(z+cos(0)-sin(0)))+1/(1+exp(z-cos(0)-sin(0)))+1/(1+exp(z*cos(0)-sin(0)))+1/(1+exp(cos(0)/z-sin(0)))+1/(1+exp(sin(z)-sin(0)))

 

 

Did you try using fieldplot ?

I tried to enter your equations into maple, but couldn't succeed.  It would be a bit easier (for me, at least) to help if you write your post with maple code instead.

1 2 3 4 5 6 7 Page 3 of 9