Or findstring(): a vector or the scalar -1. That's could be not the best option, I guess that best is return zero.Ĭheck for example the outputs of findrows(): a vector or the scalar zero. Thus the outputs of your function could be a vector or a string. Now, you return an string if there are not solutions in the interval. Also, SMath doesn't have functions like IsScalar() nor IsMatrix(). To avoid that kind of errors is that I say that in Mathcad one can redefine rows() and cols() for return zero for scalars. If you goes to check the number of outputs with rows() you could get an error in the case of scalar. Notice that this output could be an scalar representing only one root for a degenerate polynomial or a vector with two or three values. RealPolyRootsRange.sm (10kb) downloaded 10 time(s).Ĭubicroots.sm (10kb) downloaded 10 time(s). I didnt understand what you meant in the part I highlighted. Thanks for the tips for "best practices", they are very helpful and much appreciated. Obviously, only after I fail before with the 4th degree. I know that symbolic solver for 3er degree it's very hard to implement in SMath just because I try it for get eigenvalues and the Jordan canonical form of a matrix. An usual technique in Mathcad was redefining rows() and cols() for return zero for scalars, but this doesn't works in SMath, so storing zero also can help for handle that case anytime that you call your function.ĭon't worry. Finally, you can use the same question for check the result of your entire procedure. A way to avoid that is defining roots.filtered:=0 in the body of the procedure, probably just after n:=0.Īs a side effect you can handle the case where there are not real roots in your interval asking if roots.filtered it's equal to zero, and then do nothing if it's true, and sorting it in the else case, just for prevent an error calling sort() of an scalar or an undefined variable. Just only one very small "best practices" recommendation: notice that if you have defined roots.filtered as an array with more than n elements before your routine then it take roots.filtered as a global variable an preserve the last elements. It looks very well as a filter for the numerical roots given a real interval. Re 4, does this look like what you would have made to serve this purpose? I guess using polyroots and the neat trick to filter the relevant roots has solved my problem. I am failing to see how I can use this in my project. What it returns is simply your 4 set of the resulting design valuesīTW, linfit is unlimited in the order of polynomial fit.Ĭubic solver QUICK Explorer.sm (50kb) downloaded 12 time(s). Infinitely re-usable for each set of new experimental XY The attached linfit module does all that, no sweat/quick, Neither for symbolic of any kind, neither partial fraction expansion. Make sense wrt the nature of your expectation, then solve for the coefficients of the cubic polynomial.ĭoing so, no needs for cubic, neither polyroots To pass a cubic polynomial through, you define a set of 4 points that At this next point, if you want either/both functions At this point of your project, you have reduced the long argumentsīy sol_1(x), sol_2(x). The nuance is that if the last v[4 is not '1' then the plot is scaled The cubic module as constructed is same as polyroots with the nuance.Ĭubic takes the vector.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |