vv

14117 Reputation

20 Badges

10 years, 171 days

MaplePrimes Activity


These are replies submitted by vv

It is not only old code, but you have also replaced the old keyword array with the new one Array in a few places. Revert these changes.

@mmcdara The first solution is very elegant; of course I like it. But it was probably provided by the author/committee or maybe by a very smart student (who deserves congratulations & a special prize, if he/she exists).

I don't know what experience you have in this field, but I was involved in these competitions
as a direct participant (a long time ago) and then as a team leader for my university students
(I have even proposed problems for the IMC contest).

Now I don't have such preoccupations but I still enjoy to occasionally watch these competitions
and find solutions (with or without Maple).

 

I think it's better to simplify first by hand.
Note first that expr = 0 for r>n (both terms are 0).
Then express everything w.r.t.
y = q^r;
x = q^n;
Y = product(y - q^i, i = 1 .. r - 1);
X = product(x - q^i, i = 1 .. r - 1);

and finally, simplify (or factor) the result (==> rational function in q,x,y,X,Y).

Maple simplifies telescoping sums:

ss:=sum(a[i],i=1..r) - sum(a[i+1],i=1..r):
combine(ss);

                        -a[r + 1] + a[1]
but not telescopic products.
pp:=product(a[i],i=1..r) / product(a[i+1], i=1..r);
 
Actually, combine works only if we rewrite
pp:=product(a[i],i=1..r) * product(a[i+1]^(-1), i=1..r);
 
to obtain
      product(a[i]/a[i+1],i = 1 .. r)
but it is not simplified further to a[1] / a[r+1].
The only solution seems to be a simple custom procedure simp_telescopic.
 

@nm You are confusing the inverse of a function with multiplicative inverse.

@nm 

Of course I would not classify y = g(y') as d'Alembert, but it matches the pattern y = x*f(y') + g(y') for f = 0
and the solution is valid for f=0 too. Anyway, the classification is mainly didactic and Maple does non necessarily use the classical methods. So, your problem is more or less artificial.

@acer Ok, so, a bug in IntegrationTools:-Expand (2015).

@mthkvv 

modp1 is builtin, so its code is not accessible. You will need to be employed by Maplesoft :-)

@gawati2611 

https://www.maplesoft.com/applications/view.aspx?SID=33406

(it is the first result with any search engine)

@gawati2611

You must download (from Maple Application Center) and install the package. 

I think you are supposed to do the computations by hand (it's very easy) and then check them with Maple.
If you don't, you will never know linear algebra!

dharr 

 

I solved the problem as a math problem not as a chemical one.
Even if the quantities ar not normalized, working with high precision the system can be managed. Note that even in your solution, if you start with Digits=25, fsolve fails! [So, you had luck in solving the system. The hybrid method (when possible) is much more robust].

The problem is that the system has two very close solutions! The second one has positive components.
Here are both solutions.

 

restart;

dig:=15;
Dig:=500;

15

 

500

(1)

Digits:=dig;

15

(2)

eq1:=K_1=(((n_Cl-x)*u_Cl)*(n_H*u_H))/(n_HCl*m);
eq2:=K_2=(((n_Na-x)*u_Na)*(n_OH*u_OH))/(n_NaOH*m);
eq3:=K_w=(n_H*u_H/m)*(n_OH*u_OH/m);
eq4:=(n_NaCl-x)=(n_Na-x)+n_NaOH;
eq5:=(n_NaCl-x)=(n_Cl-x)+n_HCl;
eq6:=(n_Na-x)+n_H=(n_Cl-x)+n_OH;
eq7:=2*ionic=(n_H/m)+((n_Cl-x)/m)+((n_Na-x)/m)+(n_OH/m);
eq8:=u_H=0.4077*ionic^2-0.3152*ionic+0.9213;
eq9:=u_Na=0.0615*ionic^2-0.2196*ionic+0.8627;
eq10:=u_OH=0.1948*ionic^2-0.1803*ionic+0.8887;
eq11:=m=r*V;
eq12:=u_Cl=(1.417625986641341e-01)*exp(-ionic/2.199955601666953e-02)+2.369460669647978e-01*exp(-ionic/3.756472377688394e-01)+5.859738096037875e-01;
 

K_1 = (n_Cl-x)*u_Cl*n_H*u_H/(n_HCl*m)

 

K_2 = (n_Na-x)*u_Na*n_OH*u_OH/(n_NaOH*m)

 

K_w = n_H*u_H*n_OH*u_OH/m^2

 

n_NaCl-x = n_Na-x+n_NaOH

 

n_NaCl-x = n_Cl-x+n_HCl

 

n_Na-x+n_H = n_Cl-x+n_OH

 

2*ionic = n_H/m+(n_Cl-x)/m+(n_Na-x)/m+n_OH/m

 

u_H = .4077*ionic^2-.3152*ionic+.9213

 

u_Na = 0.615e-1*ionic^2-.2196*ionic+.8627

 

u_OH = .1948*ionic^2-.1803*ionic+.8887

 

m = r*V

 

u_Cl = .1417625986641341*exp(-45.4554627939891*ionic)+.2369460669647978*exp(-2.66207201719228*ionic)+.5859738096037875

(3)

#constants
K_1:=10^(8);K_2:=10^(-0.2);K_w:=10^(-13.995);n_NaCl:=1.2*10^(-4);V:=5*10^(-8);r:=997.0;x:=0;
 

100000000

 

.630957344480193

 

0.101157945425990e-13

 

0.120000000000000e-3

 

1/20000000

 

997.0

 

0

(4)

eq:={seq(eq||i,i=1..12)}:

Eq:=convert(eq,rational):

nops(Eq);

12

(5)

X:=indets(Eq,name);nops(%);

{ionic, m, n_Cl, n_H, n_HCl, n_Na, n_NaOH, n_OH, u_Cl, u_H, u_Na, u_OH}

 

12

(6)

S:=eliminate(Eq, X minus {ionic}):

f:=simplify(S[2])[]:

############

Digits:=Dig;

500

(7)

############

plot(f, ionic=0..3);

 

ionicS:=fsolve(f):

fsol:=fsolve(f, ionic=2..3, maxsols=4);

2.4072216428762064719709836229735741800889042421577428430537781518115503868004156610600823184790235582817124524344812646563654643777684793591645018003899689015817427173179752634079939003372580778910117251886921767039403180747010437087571428366550700116442476342934147314239344628682714390267374557235869179128731362248614883275894073767620207010250812742674618672565735979954188672644876167737474652628163903812114118227918718074279946285067014424835271403831469999619981894945738392256132856119033804, 2.4072216871137633357650873567132796005943570834918808892029385420170892989399292286850612515531552784097009318682474925120434274561318247604812109570896298690021014741210983094411953617299872175339734761428520595821699622162016473250588750927352871172010279172602164599295625182139979491163163541079616912134910472650620522616220553867460689623033644828672852349620815922422127489013599363589101476837483454485781158832844608657444742327219956690842787006059290738120338229107614498999976795218845853

(8)

numsol:=nops([fsol]);
fsol[numsol]-fsol[1];

2

 

0.442375568637941037337397054205054528413341380461491603902055389121395135676249789330741317201279884794337662278556779630783633454013167091566996609674203587568031230460332014613927291396429617509541598828782296441415006036163017322560802171055567802829668017285056280553457265100895788983843747733006179110402005639340326480099840482612782832085998233677055079942467938816368723195851626824209319550673667040604925890583164796042152942266007515602227820738500356334161876106743843939099812049e-7

(9)

for i to numsol do
SOL[i]:= [ionic=fsol[i], eval(S[1], ionic=fsol[i])[]]
od:

for i to numsol do evalf[dig](SOL[i]) od;

[ionic = 2.40722164287621, m = 0.498500000000000e-4, n_Cl = 0.120000000000000e-3, n_H = -0.570189355755727e-11, n_HCl = -0.203222877739516e-18, n_Na = 0.120000004599272e-3, n_NaOH = -0.459927245018502e-11, n_OH = -0.110262131059512e-11, u_Cl = .586364294954344, u_H = 2.52504946683014, u_Na = .690449163557180, u_OH = 1.58348862197850]

 

[ionic = 2.40722168711376, m = 0.498500000000000e-4, n_Cl = 0.120000000000000e-3, n_H = 0.570189329858645e-11, n_HCl = 0.203222874359743e-18, n_Na = 0.119999995400728e-3, n_NaOH = 0.459927219629856e-11, n_OH = 0.110262130551076e-11, u_Cl = .586364294908359, u_H = 2.52504953971809, u_Na = .690449166940834, u_OH = 1.58348865549082]

(10)

 

 

seq(  evalf[dig](evalf(eval((lhs-rhs)~(eq),SOL[i]))),  i=1..numsol);

{-0.9e-14, -0.68940488e-18, 0., 0.203222877739516e-18, 0.45018502e-18, 0.1e-14, 0.2e-14, 0.5e-14, 0.225595811e-13}, {-0.124575880e-13, -0.1e-14, -0.30551076e-18, -0.203222874359743e-18, -0.19629856e-18, -0.1e-27, 0., 0.1e-14, 0.2e-14, 0.7e-14}

(11)

# So, the second solution has all components >0. !!!
# It is very strange that the two solutions are so close!!!

 

 

@ReactionUra 

Some variables are mathematically negative; they are small in absolute value, so probably they can be considered 0.

Note that dharr's solution is similar; actually if you start his worksheet with Digits:=25, fsolve fails just because of those variables.

Explore(plot([[[0,0],[1,0],[1/3,2],[0,0]],[(12*s*(t-1)*(s-1)*xi^2+t)/(3+12*(t-1)*(s-1)*xi^2+12*(t-1)*(s-1)*xi),2*t/(1+4*(t-1)*(s-1)*xi^2+4*(t-1)*(s-1)*xi), xi=-infinity..infinity]]), parameters=[s=0. .. 1, t=0. .. 1]);

 

First 43 44 45 46 47 48 49 Last Page 45 of 177