Carl Love

Carl Love

28070 Reputation

25 Badges

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

MaplePrimes Activity


These are replies submitted by Carl Love

@Rohith You wrote:

  • Your first solution is working perfectcly fine almost all cases except when when I have  complex terms in denomenator like in case 4. I would be glad if there is way to solve these.

??? Well what about my revision two Replies above this, "It's not flat"? Doesn't that provide a "way to solve these" for your example 4??  When I post an update or revision to some code, please discard any previous versions and focus all criticism on the the most-recent version. I can't maintain separate versions.

Three Replies above, you said that you wanted the output as 

a*cos(psi)*sin(a)^2, a

---in other words, the function term first, then the coefficient, and with the coefficient attached to the term. But now you show that you want the coefficients first, then the term, and with the coeffcients removed from the terms.

Here is a revision. It handles all five examples from your Reply immediately above. In particular, it handles the distribution of 1/b from example 5.

getFuncCoeff:= proc(e)
option `Author: Carl Love <carl.j.love@gmail.com> 20-Nov-2018`;
local 
     One, sav, FRZ, FRZn:= 0, Freezer:= table(),
     #The thaw of ordinary freeze/thaw is not subtle enough for this.
     Freeze:= proc(e) 
          FRZn:= FRZn+1;
          Freezer[FRZ[FRZn]]:= e;
          FRZ[FRZn]
     end proc,
     #Thaw and recompose the function:
     Thaw:= proc(f::function) 
          local fn:= op(0,f), fc:= Freezer[fn];
          op(1,fc)(op(2,fc)(op(f)))
     end proc,
     Funcs:= [select(
          x-> membertype({function, function^anything}, {op(x)}),
          indets(
               subsindets(
                    subsindets(
                         frontend(expand, [e]), 
                         anyfunc(function),
                         ff-> Freeze([op(0,ff), op([1,0], ff)])(op(op(ff)))
                    ),
                    function, 
                    f-> One*f
               ), 
               `*`
          )
     )[]],
     Coeffs:= subsindets(Funcs, {function, identical(One)}, 1)
;
     Funcs:= eval(Funcs/~Coeffs, One= 1);
     do 
          sav:= Funcs; 
          Funcs:= subsindets(Funcs, 'typefunc'('specindex'(FRZ)), Thaw)
     until sav = Funcs;
     Coeffs, Funcs
end proc:

But you've still not made clear how to handle

1/b*(v1*sin(x)+v2)*(v3*cos(x)+v4).

How should the 1/b be distributed?

Also, you haven't made clear how to handle functions of multiple arguments where some arguments are themselves functions and some other arguments are not. An example would be

arctan(sin(x), 1+cos(x))

When you post examples, please post them in plaintext form so that I can copy-and-paste them.

Your attached worksheet contains the equations only in output form. Ordinarily I'd be able to convert that to input form, but I can't do that with yours. I think there may be a size limit above which that doesn't work and yours is above it. So, could you please supply your equations in input form so that I can work with them?

@666 basha I have something for this situation, but not a complete solution yet. This will work for any 3D surface plot, not just those in my worksheet. If you include the options shading= ZHUE, lightmodel= NONE, you'll get something like this:

ParamPlot3d(
   GetNu, S= 0..12, Ha= 0..12, [Rd= 4.5, Ec= 0.06, Nb= 0.15, Nt= 0.15, Sc= 0.5],
   labels= [S, Ha, Nu],
   surfaceopts= [shading= ZHUE], lightmodel= NONE
);

You will notice that this has not changed the underlying contourplot. You can take any 3D plot and view it as a 2D plot by including the option orientation= [-90,0]. So, for the above

ParamPlot3d(
   GetNu, S= 0..12, Ha= 0..12, [Rd= 4.5, Ec= 0.06, Nb= 0.15, Nt= 0.15, Sc= 0.5],
   labels= [S, Ha, Nu], 
   surfaceopts= [shading= ZHUE], lightmodel= NONE, orientation= [-90,0]
);

I have modified the code so that all dsolve solutions are stored in a remember table; so, it's possible now to change the options on a plot and have the new plot come up instantly. The new worksheet is nanofluid_BVP_Sheikholeslami.mw  The example above is the first of the 3D plots.

Maple's 3D plotting is more-sophisticated than its 2D plotting. Translating the coloring options of a 3D plot to an actual 2D contour plot is difficult (but I think that it's ultimately possible). The built-in coloring option of a contourplot allows for a range bounded by two colors, but not the whole red-to-violet visual spectrum (aka the "HUE" spectrum in some Maple commands). If the above meets your needs, great. If not, I'll try to modify the 2D plot also.

@Carl Love Please let me know if the above works for you. I can imagine some situations where it won't work, and I'm still not clear what output you're looking for in all cases.

@tomleslie I modified the code between when VV downloaded it and when you downloaded, and I introduced an error, which has now been fixed. In the first procedure, q:= R() should be q:= nextprime(R()).

@vv My code above works just as well (meaning without apparent effort) for thousand-bit keys also. I just used a 70-bit key because I wanted it all to fit nicely in the post.

Just do RSA:-GenKey(512);

@student_md The last line of my Answer can be used to "flatten" or "remove the brackets" from Tom's Answer, if you take his Matrix and use it as the T in my code.

But I suspect that Acer has a more-efficient Answer. I haven't analyzed his yet.

@666 basha So heat transfer = Nu? That's all that you needed to say several replies ago. I know how to translate numbers into colors.

Nu: symbol, concept that I understand;
Translating symbols to numbers: concept that I understand;
Translating numbers to plot colors: concept that I understand.

But...

"heat transfer": concept that I don't know much about.

It'll probably take me a day to get to it.

@tomleslie I just posted a complete implementation of RSA. The OP's procedure is equivalent to my procedure Stringify.

@666 basha Okay, I understand your desired color scheme. But what is the heat transfer formula? (And why didn't you answer that before?) Please remember that I don't know the first thing about fluid mechanics. (I'm not even sure that the field that we're discussing is properly called "fluid mechanics".) All I know is

  • symbolic computation
  • numeric computation
  • abstract ODEs
  • how to solve ODEs numerically
  • how to plot the solutions with Maple.

@Rohith  The issue that you present is not really about denominators; rather, it's about nested expressions. Since you had indets[flat] rather than indets in your Question, I used flat in my Answer, which avoids nested expressions; I assumed that that's what you wanted. The expression that you're trying to extract in this case, a*cos(psi)*sin(a)^2, is a `*` inside a `+` inside a `*` (because division is `*` also) inside a `+`. Regular indets will find it no matter how deeply it's nested, but indets[flat](..., `*`) will ignore it.

So, try this

getFuncCoeff:= proc(e)
local 
   One,
   Funcs:= [select(
      x-> membertype({function, function^anything}, {op(x)}),
      indets(subsindets(e, function, f-> One*f), `*`)
   )[]],
   Coeffs:= subsindets(Funcs, {function, identical(One)}, 1)
;
   eval(Funcs, One= 1), Coeffs
end proc;

 

@666 basha What is the formula for heat transfer in terms of the parameters of this BVP system? Is it the Nusselt number? Do you want higher heat transfer values at the red end of the spectrum or the violet end?

@666 basha I said to replace mul with (`*`@op), but you've replaced it with `*`@op. The parentheses matter.

@666 basha So, you want the coloring that's used for the 3D surface to be used for the 2D contour plot? And do you want that shown in 2D or 3D? And what coloring do you want, the X*Y that you show? What's the relevance of that?

@666 basha 

I said to replace mul with (`*`@op), but you have just replaced it with op. Just using op will remove all the cross-product terms from the model.

"Model is not of full rank" generally means that the data has insufficient variation in at least one of the input parameters. The input parameters in this case are  [S, Ha, Rd, Ec, Nt, Nb]. The data is collected over the course of running the worksheet. Each plot varies at most 2 parameters. If you run all the plots in the worksheet as I presented it, there will be about 15,000 data points with sufficient variation for Fit to not give the warning. If you continue to have this problem, let me know.

 

First 293 294 295 296 297 298 299 Last Page 295 of 709