Carl Love

Carl Love

28100 Reputation

25 Badges

13 years, 105 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

What does x | i mean? It's part of the argument of JacobiTheta0.

@testht06 The identity matrix in Maple has no predefined symbolic representation; it needs to be constructed to whatever size is appropriate in context. Capital is the imaginary unit rather than a matrix.

This works:

A:= M + LinearAlgebra:-IdentityMatrix(op([1,1], M)):
Gausselim(A, 'rank') mod 2:
rank;

@tomleslie A restart command needs to be in its own execution group to be fully effective. When it's in an execution group with other commands, the results are unpredictable. This is not clearly documented at ?restart, which merely says that the restart must be on its own "line". If you put the restart in its own execution group, my counterexample will be manifested.

@testht06 Yes, I know how to perform division in finite fields. That doesn't change the fact that the sum of a row could be zero. 

@sipa Please repost this as a separate Question, a new thread. The syntax for plotting ODE solutions is very different from that for plotting PDE solutions. There's no way to adapt the code that I give above to an ODE situation.

For your item (3), do you want the division to be in the finite field? I'm not sure if that's always possible. Couldn't the sum squared be 0 in the field?

I notice that you index your matrix columns starting with 0 rather than 1. But matrices (as opposed to arrays) are always indexed from 1. Is that going to cause a problem for you?

Since, as Tom points out, this can't really be done, I'd like to ask what your ultimate goal is. There's probably some other way to achieve it.

@tomleslie 

Your solution relies on the terms of the polynomial being put in the same order by both op and coeffs, but it doesn't necessarily happen that way. Simple example:

restart:
p:= y+2*x;
op(p);
coeffs(p);

@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.

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