48 Reputation

2 Badges

18 years, 285 days

MaplePrimes Activity

These are answers submitted by lgunther

Dear Acer,

I figured out why Maple 'froze' for small x : y(x) becomes negative, so that I have to extend the range of fsolve to slightly negative y.


I am still trying to see how I can produce multiple plots of y and L vs. x for a set of values of e.


Dear Acer,

    I have used your latest worksheet to produce plots as shown below. I added a plot command for y(x).  The plots all look what I expected qualitatively and semi-quantitatively. 

See my worksheet below - plots don't show.  I copy/pasted so that it led to changes in the text. I hope this is intelligible. If not I can change what is below to what actuallly appears in my file.

It is a shame that there is a problem with x<0.1. 

Do you feel that my upcoming increase of RAM from 2Gb to 4Gb might help?


Also, I would like to produce three plots for y(x) and for L(x) using three values of e on one set of axes.

Is there a way to do this? 


Finally, I want to express my gratitude to you for all your help and dedication to me and others.



> restart;
> f := proc (x, y) options operator, arrow; -N+add(1/(exp(e*((n-x)^2-y))-1), n = -10 .. 10) end proc;
> fexpr := subs(N = 10000, e = 0.2e-1, d = 1/(e*N), f(x, Y));
> y := unapply(('fsolve')(fexpr, Y = 0 .. x^2), x);
> y(.1);
> plot(proc (x) options operator, arrow; y(x) end proc, -.9 .. .9, color = black, thickness = 2);

> Lproto := proc (a, b) options operator, arrow; -add((n-a)/(exp(e*((n-a)^2-b))-1), n = -10 .. 10)/N end proc;
> L := subs(N = 10000, e = 0.2e-1, d = 1/(e*N), eval(Lproto));
> L(.452, y(.452));
> plot(proc (t) options operator, arrow; L(t, y(t)) end proc, .1 .. .49999, color = black, thickness = 2);


I have made progress. But I can't produce a plot with any of the alternatives you gave me.

SEE my worksheet BELOW. Note that I am interested in plots of y(x) and of L(x) over the range x=0.. 0.5.


N:=10000;   e:=0.2; d:=1/(e*N);
f:=(x,y)-> -N + sum(1/(  exp(e*( (n-x)^2 - y) ) -1 ) ,  n=-50..50);
> y := proc (x) options operator, arrow; x, fsolve(f(x, Y), Y = 0 .. x^2) end proc;
> y(.4);
                              0.4, 0.1594985478
> plot(y(x), x = .1 .. .4);
Error, (in fsolve) 0 .. x^2 is an invalid range
L:=(a,b)-> -(1/N)*sum((n-a)/(  exp(e*((n-a)^2 - b) ) -1 ) ,  n=-50..50);
> P1 := plots:-implicitplot(f, 0 .. 1/2, 0.1 .. 0.45);
> k := plottools:-transform(proc (a, b) options operator, arrow; [a, L(a, b)] end proc);
> plots:-display(k(P1));

           [shows axes without any graph]

> plot((`(L@ y'(x), x = 0.01 .. .45);
    [ computation proceeds until there is an error message of there not being enough memory. NOTE that I have 2Gb Ram. If I have to increase memory in the software or virual memory, how do I do so?]

> plot(L@ F, 0.01.. .45);
Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct

I found the solution to my last trivial question: I have to omit the brackets in the fsolve line --thus fsolve(g(x)));

I found the solution to my last trivial question: I have to omit the brackets in the fsolve line --thus fsolve(g(x)));

Further question:

How do you take the output value from fsolve and use it in the next calculation?

Thus given a function g(x) in

fsolve( {g(x,y)=0}, {y=0..x^2});

we obtain a value of y for a  given x.

I would like to use this value of without having to copy it into an expression.

the symbol % includes the full output line {y=3} for example. I want to pass on only the "3".

Thanks so far. Unfortunately I am not all the way there:

From above

 f := (x,y) -> cos(x+y): # or more complicated

> F := y->(fsolve(f(x,y),x=0..1/2),y): # returns x,y pair
NOW I need to store the function y(x) generated by fsolve.
y(x) will be used to compute a function g[x, f(x)] that depends 
upon y(x).
As a simple case, I might need x^2+y(x).
My actual function g is more complicated.
Page 1 of 1