Carl Love

Carl Love

28055 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Umang Varshney Just as in English writing, semicolons separate (rather than terminate) statements: If the item preceding the semicolon is a statement and the item following is not a statement, then the semicolon is not required, and the situation is syntactically equivalent to placing a NULL statement after it. It follows that a semicolon is allowed but not required immediately before endelseeliffi, od, or catch (except in those rare situations where one needs a null statement to comprise the entirety of procedure's or module's body following some header declarations).

Also as in English prose writing, line breaks don't serve as punctuation marks; they are syntactically equivalent to other white space.

@nguyenhuyenag But only the one after the final end if is required in this case. The others may be used for stylistic preference, but they perform no syntactic function.

@emendes Please show me an example of sols such that these two commands return different non-error values:

  1. ormap(x->x=true,map(has,rhs~(op~(sols)),_Z))
  2. has(sols, _Z)

(Yes, I know that it's possible to contrive such an example by putting _Z on the left side of an equation and no _Zs on the right. The OP won't have such an example in actual practice.)

If you're trying to use SolveTools:-PolynomialSystems with Threads: Given that it's hundreds, perhaps thousands, of lines of deeply nested module code that wasn't written with the intention of being threadsafe, the probability that it's accidentally threadsafe (like index) is infinitesimal. I don't know why CodeTools:-ThreadSafetyCheck gets it wrong.

Your original ormap (item 1. above) can also be replaced by

ormap(has, rhs~(op~(sols)), _Z)

These are 100% functionally equivalent, even for contrived examples. An expression x=true is almost always redundant in newbie code. Nitpickers: Note the emphasis on almost.

@nm Yes, I am well aware of that.

The purpose of my Answer is to give the OP something that does what they actually want. Its purpose is not to explain the cause of the error. To avoid the error, one must delay the evaluation of numbcomb until j's value becomes integer. The best and most natural way to do that is to make it into a procedure.

Now, I may have guessed wrong about what the OP actually wants. They might want a hypergeom symbolic expression. In that case, use binomial, like Acer says.

@ReactionUra Usually, when fsolve returns unevaluated, it means that there's no solution within the specified ranges. However, sometimes it means that it couldn't get the solution to sufficient precision. That's the case here. By reducing the requested precision to 7 digits, I got an all-nonnegative solution:

Digits:= 7:
fsolve(
    {eq||(1..12)},
    {ionic, n_Cl, n_H, n_HCl, n_Na, n_NaOH, n_OH, m, u_Cl, u_H, u_Na, u_OH}=~ 0..infinity    
);
  /                                                     
 { ionic = 48.98702, m = 0.003277555, n_Cl = 0.1750121, 
  \                                                     

   n_H = 0.05026130, n_HCl = 0.00001712527, n_Na = 0.09573009, 

                                  -13                    
   n_NaOH = 0., n_OH = 1.128623 10   , u_Cl = 0.6624931, 

                                                   \ 
   u_H = 963.1730, u_Na = 137.5875, u_OH = 459.2063 }
                                                   / 

@janhardo Okay, I added some exposition to the worksheet. Let me know if you can understand it now. Unfortunately, MaplePrimes won't display it, but you can download it. By the way, the derivatives that I used are not implicit.

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/PointPlaneDistance.mw .
 

Download PointPlaneDistance.mw

@ReactionUra 

Use fsolve instead of solve:

fsolve({eq||(1..12)});
res := {ionic = -2.247127086, m = 0., n_Cl = -3.680938534, n_H = -0.2101029014, n_HCl = -7.502816177*10^7, n_Na = 4.769998672, n_NaOH = -4.769878672, n_OH = 8.240834305, u_Cl = -4.874160233, u_H = 3.688110962, u_Na = -2.974047722, u_OH = -4.110097263}

I suspect that some of these values are outside of allowed ranges. In particular, I suspect that the n_ variables should be nonnegative. You can specify the allowed ranges like this:

fsolve(
    {eq||(1..12)},
    ({n_Cl, n_H, n_HCl, n_Na, n_NaOH, n_OH}=~ 0..infinity)
    union
    ({ionic, m, u_Cl, u_H, u_Na, u_OH}=~ -infinity..infinity)
);

{ionic = -2.225127530, m = 0., n_Cl = 3.159530733, n_H = 5.462749423, n_HCl = 2.054664202*10^7, n_Na = 7.562418530, n_NaOH = 3.102492997*10^6, n_OH = 9.037400983, u_Cl = -4.874160233, u_H = 3.641064071, u_Na = 1.655806581, u_OH = -4.110097263}

@vv In this particular case, the results are practically the same without using parametric or real. I mention this because I think that the OP is using a very old version of Maple where the parametric option may work differently, if it works at all.

@ReactionUra Which are the 13 variables? Using Maple 2020, I solved it almost immediately, but I let it pick the variables to solve for. I can't investigate further without knowing the variables.

Also note that there are two instances of exp^(...that need to be corrected.

I can't tell what's going on without seeing how you've used Units in the preceding code. But this should give you the correct result:

max~(0, ResLoadcombination_unitfree)

Does that work for you?

Please Post this as a Reply to your earlier Question.

If you're trying to find a value of L such that y(2) = 0, it's done already. That value is L = 2.717402017. There's no need to use bisection as a root-finding method; fsolve takes care of that.

If you're going to download the OP's worksheet, make sure to turn off autosave first. If you don't, the first autosave will never finish, and you'll be forced to kill your entire Maple session. To turn off autosave, go to Tools => Options => General, uncheck the last item, and Apply to Session.

@janhardo Okay, I see my mistake of a lack of generality. Your solution can be obtained from pdsolve by

pdsolve(diff(u(x,y), x, y) = -diff(u(x,y), x));
             u(x, y) = _F1(y) + exp(-y)*_F2(x)

 

@janhardo What long calculation? I get the solution _C1*x*exp(-y) + _C2.

@acer Acer, would you please explain the purpose of

a:= 'a':  b:= 'b':  c:= 'c':

that appears before the gc() that appears before timed code? My guess is that its purpose is to force garbage collection of %%%, and %%%.

Also, I'm guessing from the way that you recoded ZigZag that compiled procedures can't use op(procname). I used that to avoid the extra procedure layer (i,j)-> ZigZag(i,j,n).

First 177 178 179 180 181 182 183 Last Page 179 of 709