Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 361 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@acer Why did you use assign? Why not just

UpdatingRead:= proc(fn::string) ... end proc?

@mela 

The following procedure, MostConstrainedVariable, will get you started towards automating this process. If fsolve actually returns a solution, and you specified ranges for all the variables, this procedure will tell which variable is closest (in relative terms) to violating its range. The returned value is the variable, its value, its range, and the fraction of that range from the value to its nearest boundary. Remember, this procedure only works for cases where fsolve does return a solution.

 

restart:

 

eq1 := ((1-s)*w)^(1-gamma)*r^gamma-P_v = 0;

eq2 := (1-s)*w*H/M-(1-gamma)*P_v*q/phi = 0;

eq3 := r*(K+K_f)/M-gamma*P_v*q/phi = 0;

eq4 := prof-M*p_d*q+(1-s)*w*H+r*(K+K_f) = 0;

eq5 := -tau*y_x+q-y_d-y_g = 0;

eq6 := p_d-sigma*P_v/((sigma-1)*phi) = 0;

eq7 := y_d-M^(lambda-1)*Y*(p_d/P)^(-sigma) = 0;

eq8 := y_x-F_f*(tau*p_d)^(-sigma_x) = 0;

eq9 := y_f-M_f^(lambda-1)*Y*((1+z)*tau*p_f/P)^(-sigma) = 0;

eq10 := (G*alpha_g+Y)^(-alpha_c)/P-A*H^alpha_h/((1-t_w)*w) = 0;

eq11 := P*Y-(1-t_w)*w*H-(1-t_r)*r*K-(1-t_prof)*prof+T = 0;

eq12 := P*Y-M*p_d*y_d-M_f*(1+z)*tau*p_f*y_f = 0;

eq13 := (1-t_r)*r-r_f = 0;

eq14 := G-y_g*M^((lambda_g-1+sigma_g)/(sigma_g-1)) = 0;

eq15 := s*w*H+M*p_d*y_g-T-t_w*w*H-t_r*r*(K+K_f)-t_prof*prof-z*M_f*tau*p_f*y_f = 0;

Params:= [
      A = 7.716049383, K = 3.2, K_f = 0, alpha_c = .8, alpha_g = .2,
      alpha_h = 4, lambda = .5, p_f = 1, phi = .625, s = 0, sigma = 5,
      sigma_g = 5, sigma_x = 5, t_prof = .16, t_r = .16, t_w = .12, tau = 1.1,
      y_d = 1, y_f = 1, y_g = .4, y_x = 1, z = 0, lambda_g = .5, gamma = .25,
      gamma = .25
]:

Vars:= {F_f, G, H, M, M_f, P, P_v, T, Y, p_d, prof, q, r, r_f, w}:

Ranges:= {
     F_f = 2 .. 4, G = .1 .. .4, H = .4 .. .8, M = .4 .. .6, M_f = .3 .. .7,
     P = .8 .. 2, P_v = .4 .. .8, T = -.2 .. .3, Y = .7 .. 3, p_d = .9 .. 1.6,
     prof = .1 .. .4, q = 1.5 .. 2.7, r = 0.4e-1 .. 0.9e-1, r_f = 0.4e-1 .. 0.9e-1,
     w = .8 .. 3
}:

 

SOL2:= fsolve(eval({eq||(1..15)}, Params), Vars, Ranges);

 

 

 

((1-s)*w)^(1-gamma)*r^gamma-P_v = 0

(1-s)*w*H/M-(1-gamma)*P_v*q/phi = 0

r*(K+K_f)/M-gamma*P_v*q/phi = 0

prof-M*p_d*q+(1-s)*w*H+r*(K+K_f) = 0

-tau*y_x+q-y_d-y_g = 0

p_d-sigma*P_v/((sigma-1)*phi) = 0

y_d-M^(lambda-1)*Y*(p_d/P)^(-sigma) = 0

y_x-F_f*(tau*p_d)^(-sigma_x) = 0

y_f-M_f^(lambda-1)*Y*((1+z)*tau*p_f/P)^(-sigma) = 0

(G*alpha_g+Y)^(-alpha_c)/P-A*H^alpha_h/((1-t_w)*w) = 0

P*Y-(1-t_w)*w*H-(1-t_r)*r*K-(1-t_prof)*prof+T = 0

P*Y-M*p_d*y_d-M_f*(1+z)*tau*p_f*y_f = 0

(1-t_r)*r-r_f = 0

G-y_g*M^((lambda_g-1+sigma_g)/(sigma_g-1)) = 0

s*w*H+M*p_d*y_g-T-t_w*w*H-t_r*r*(K+K_f)-t_prof*prof-z*M_f*tau*p_f*y_f = 0

{F_f = 2 .. 4, G = .1 .. .4, H = .4 .. .8, M = .4 .. .6, M_f = .3 .. .7, P = .8 .. 2, P_v = .4 .. .8, T = -.2 .. .3, Y = .7 .. 3, p_d = .9 .. 1.6, prof = .1 .. .4, q = 1.5 .. 2.7, r = 0.4e-1 .. 0.9e-1, r_f = 0.4e-1 .. 0.9e-1, w = .8 .. 3}

{F_f = 2.73478247238669, G = .142707518376225, H = .600113600750548, M = .400056799031096, M_f = .444747512894532, P = 1.03555183303629, P_v = .555855460989131, T = 0.266848507736719e-1, Y = .901905387333501, p_d = 1.11171092197826, prof = .222373756447266, q = 2.50000000000000, r = 0.694917988897706e-1, r_f = 0.583731110674073e-1, w = 1.11165830687297}

MostConstrainedVariable:= proc(
     Values::{set,list}(name=complexcons),
     Ranges::{set,list}(name=range(complexcons))
)
local r, V, val, var, MinVar, Min:= infinity;
     for V in Values do
          (var,val):= (lhs,rhs)(V);          
          r:= eval(var, Ranges);
          val:= min(abs(val-lhs(r)), abs(rhs(r)-val))/abs(rhs(r)-lhs(r));
          if val < Min then
               Min:= val;
               MinVar:= var
          end if
     end do;
     MinVar= eval(MinVar, Values), eval(MinVar, Ranges), evalf[2](Min)
end proc:

          

MostConstrainedVariable(SOL2, Ranges);

M = .400056799031096, .4 .. .6, 0.28e-3

 

 

Download MostConstrainedVariable.mw

Also, I'd like to point out that Maple's fsolve doesn't require you to specify ranges for the variables. You can specify initial guesses just like you say that you do in Matlab. Or you can specify both a range and an initial guess for a variable. Or you can specify nothing, although I don't advise doing that for a system as complicated as yours.

@aamirkhan Yes, simplify is designed to be exact. In other words, applying simplify to an expression results in another expression which is (or is supposed to be) mathematically identical to the first (numerically equal over all possible variable assignments over the complex numbers). If your expression contains floating-point numbers, that equality may be modulo some round-off error. The chance that that round-off error is manifested as a dramatic reduction in the size of the expression is infinitesimal.

@aamirkhan 

For some strange reason, fnormal is designed to automatically map over lists, sets, etc., but not over Matrices, Vectors, etc. Your M1f is a Matrix. We can correct for that deficiency in fnormal by using map like this:

M1ff:= map(fnormal, M1f, Digits, 5e-7);

where the 5e-7 indicates that any value with magnitude less than 5e-7 is to be changed to 0

You can correct fnormal with overload so that it automatically maps over Matrices, etc., like this

unprotect(fnormal):
fnormal:= overload([
     proc(e::rtable) option overload; map(fnormal, e, _rest) end proc,
     fnormal:-ModuleApply
]):
protect(fnormal):

Then proceed to use fnormal as it is documented at ?fnormal except that now the first argument can also be a Matrix, Vector, etc.:

M1ff:= fnormal(M1f, Digits, 5e-7);

You say that you want t[2] on the z-axis. I see no t[2] in your function.

You need to correct T[g/T[0]] to T[g]/T[0].

Please post a worksheet showing the command that you type and the resulting plot. One example should be sufficient, but include as many as you wish. Use the green uparrow (last item on the second row of the toolbar in the MaplePrimes editor) to upload and display the worksheet directly in your Reply.

@MDD I think so, but I am not sure. You can run debug on any procedure or group of procedures from Groebner. Then run an eliminate command on polynomials. If any of the Groebner procedures that you listed are called, you'll be notified of thatby the debug.

@MDD Your procedure seems to work so far. My knowledge of Groebner bases is minimal. I think it's great that you were able to write the Maple procedure on your own. Yes, it is probably a better way than eliminate.

@MDD 

I didn't "deduce" that you were rude and evasive; that's just my opinion. I don't want thanks later; I want to know what you're working on, now. You still haven't provided a title. State in clear mathematical language the "new result" that you are trying to prove.

@MDD 

Considering the huge amount of extremely detailed help that you've received here at MaplePrimes in the last few weeks, I consider the vagueness and brevity of your Reply to Axel to be rude and evasive.

What is the title of your "main project"? Are you developing an algorithm? Trying to prove a theorem? 

@rit 

It is no surprise at all that you are banned on StackExchange. Please tell that to the psychiatrist; I'm absolutely sure that he or she will find it relevant. Unfortunately, MaplePrimes is not as well organized as StackExchange.

I've been reading your Questions on MaplePrimes for about two years, and I've tried to answer a few of them. I've given up on that because you are mentally ill. Please seek psychiatric help. I don't mean to offend you; I am saying this in all seriousness and out of a desire to help you. I know that you live in Hong Kong, so I would guess that you have access to some sort of public health facility.

You constantly ask questions about higher-level math when it is obvious that you don't understand the necessary lower-level math. For example, in this Question you are asking about a high-level concept (free groups), yet it is clear that you don't fully understand the low-level concept of equivalence relations. It seems like a lot of your math knowledge comes from reading, at random, the help pages of computer-algebra packages.

You constantly ask questions about obscure Maple commands in abstract-math packages when it is clear that you don't understand basic Maple. You write page after page of nonsensical Maple code where you repeatedly type out long command names like MatrixMatrixMultiply(A,B) to express simply A.B. I believe that you have a symptom called hypergraphia which you express through writing Maple code. Please tell that to the psychiatrist.

On the rare occasions when someone answers one of your Questions, you never seem to accept or understand the answer.

From this point forward, I am just going to delete any Question of yours that I judge to be either irrelevant or nonsensical. Unfortunately, there is no formal process for deletion like there is on StackExchange. 

I hope that you go somewhere where you can get the help that you need. After that, you may start asking basic, sensical, and relevant Questions which I'll be happy to answer.

[If anyone doubts what I say here, please read through the OP's massive list of 341 Questions before criticizing me.]

 

 

@MDD 

There's no file attached to your most-recent Reply.

@MDD 

I was able to make a change so that the procedure handles this latest case, but I don't understand why it works. The change is to reduce the equations with respect to Null (using simplify with side relations) before calling the solver eliminate. I hope that someone else can jump in here and help (Roman? Acer?). Specifically what I don't understand is, given that

  1. P1 and P2 are sets of polynomials,
  2. is a set of names that occur linearly in P1, and
  3. none of the names in C occur in P2

then how could eliminate(P1 union P2, C) return results fundamentally different from eliminate(simplify(P1, P2), C)? And what is a minimal example where this happens?

Here is the new procedure:

ExtPolyLinearCombo:= proc(
     F::list(polynom),
     f::polynom,
     V::set(name),
     Null::set(polynom):= {},
     NotNull::set(polynom):= {}
)
local
     c, k, C:= {c[k] $ k= 1..nops(F)},
     S:= eliminate(simplify({coeffs(expand(`+`((C*~F)[]) - f), V)}, Null), C)
;
     if
          lhs~(S[1]) <> C or
          not simplify(S[2], Null) subset {0}
          # or not andmap(s-> is(denom(rhs(s)) <> 0), S[1])
          # assuming (NotNull <>~ 0)[], (Null =~ 0)[]
     then
          return false, []
     end if;

     true, eval([C[]], S[1])
end proc:

@MDD

I think that it's a bad idea given that the NotNull conditions are in general polynomials and not individual variables. There may not be any solution where those polynomials are all equal to 1

First 474 475 476 477 478 479 480 Last Page 476 of 709