vv

13977 Reputation

20 Badges

10 years, 36 days

MaplePrimes Activity


These are replies submitted by vv

@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]);

 

@mmcdara 

1. Not for permutations. E.g. it is known the number of invertible nxn matrices over Zp (i.e. the order of the group GL(n, Zp)).

2. Yes, I have mysef a post here with a Sudoku solver using a Groebner basis: 
https://www.mapleprimes.com/posts/207910-A-Compact-Sudoku-Solver-Via-Groebner

@one man 

The parametric equation of an inellipse is here. Probably in Maple 17 this will work:

restart;
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]]), s=0. .. 1, t=0. .. 1);


 

restart;
A:=[1,0]: B:=[1/3, 2]:
K:= 1/(s-1)/(t-1): U:=s*~A: V:=t*~B:
ell := (4*xi^2*~U+K*~V ) /~ (4*xi^2+4*xi+K):
Explore(plot([ [[0,0],A,B,[0,0]], [ell[], xi=-infinity..infinity]]),s=0.0 .. 1, t=0.0..1);


 

This reminds me of the simplest bijection f : N^2 --> N.
f(n,k) = 2^(k-1) * (2*n-1).

 

@dharr 

Nice, but unfortunately for n=4 the  reduction is almost the same and n>4 is out of the question.
Also, rhe diagonal dominance could just eliminate a "few" nonsingular matrices.

@dharr 

It is possible a reduction by a factor of n!*n.
I was curious about a compiled version. I have used a custom "nextperm" and "det" and the runtime was 0.015 sec for n=3.

But it is not very useful. Trying n=4, the estimated runtime is about a week!!! Without compilation it would be years!
It would be interestiong a theoretical approach, but I have no idea about that.
 

 

@janhardo 

If you cannot find the book, you can at least download (from the author's site) and work the exercises and their solutions. They are for Maple 8 but are valid for Maple 2020 too.

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