Mathcad Toolbox

Mathcad Toolbox - Contains analogs of functions from Mathcad - Messages

#121 Posted: 12/10/2021 12:35:23 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi Viacheslav. Thanks again. I guess that with this new feature SMath must to be very close of version 1.0.

Just a question about derivatives. Yours ode solvers returns n-1 columns for the n-degree differential equation, so: which is the better way to implement y (x) : diff(y(x),x,n) ? Because SMath diff doesn't recognize lspline.

I think in 3 or 4 ways: return n columns for the differential equation of degree n, return functions y'(x), y''(x), ... and y(x) as you do for y(x), a function like lspline(3) but for the derivative (something like dlspline) since cubic splines have information about the derivative or a diff function like matlab's, which simply calculates the difference in the values of a vector, for each column of a matrix.

But the truth is, I don't know which method could be the best, nor do I have any idea what is the best way to obtain the function derived from the result of any of your many solvers at this time.

And one last question: could it be possible to implement the graph of parametric functions in the XY Plot plugin? Something like ParamtricPlot (x (t), y (t), a, b ) and that takes the number of points from the plugin configuration, or ParamtricPlot (x (t), y (t), a, b, N ) for N subdivisions (N + 1 points) of the interval a < t < b.

Best regards.
Alvaro.
#122 Posted: 12/10/2021 2:42:11 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

And one last question: could it be possible to implement the graph of parametric functions in the XY Plot plugin? Something like ParamtricPlot (x (t), y (t), a, b ) and that takes the number of points from the plugin configuration, or ParamtricPlot (x (t), y (t), a, b, N ) for N subdivisions (N 1 points) of the interval a


I think it is possible to mark a "vector" variable with a tilde "~": ~t. It might look like this. I need to think about whether this will work.

2021-12-10_22-38-31.png

Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Alvaro Diaz Falconi 12/10/2021 8:07:00 PM
#123 Posted: 12/11/2021 4:14:06 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote


I think it is possible to mark a "vector" variable with a tilde "~": ~t. It might look like this. I need to think about whether this will work.



It looks pretty good.

In the attached an example about how to add an "extra" column to the ode solver for return the last derivative. In the "traditional" implementation it it is not necessary because it is simply the last component of D (t, Y), the argument function of the solvers for systems of differential equations. But if what you have is the higher-order differential equation, things are no longer so simple.

It also shows how to "sterilize units", an expression that I had never read or heard, but that I am copying from Pompelmo. I think it is an easy and effective way to be able to program functions like nonlinear or ode solvers that accept units.

RK23.sm (71 KiB) downloaded 49 time(s).
RK23.pdf (340 KiB) downloaded 49 time(s).

Best regards.
Alvaro.
2 users liked this post
Вячеслав Мезенцев 12/11/2021 4:33:00 AM, sergio 12/11/2021 5:48:00 AM
#124 Posted: 12/13/2021 7:52:46 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

SMath Studio compatibility

Plugin updated.

Changes:

- added support for ODE systems with many variables;
- Adams() ode solver added (explicit Adams-Bashforth 5);
- CWD and TOL variables added;
- project restructured.

I don't know what AB method is used in Mathcad, but it clearly uses an adaptive step, since the usual explicit AB method is unstable (the small stiffness of the task makes it so).

Click to enlarge Click to enlarge Click to enlarge

Mathcad%20Block.%20Adams.sm Lorenz%20attractor.sm Chua's%20circuit.sm
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
sergio 12/13/2021 6:02:00 PM, Alvaro Diaz Falconi 12/13/2021 12:43:00 PM
#125 Posted: 12/13/2021 3:48:49 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

SMath Studio compatibility

Plugin updated.

Changes:

- Adams variable added (allows you to choose a method for the Adams() solver): "AB1".."AB8", "AB5" - default;
- CWD variable value changed.

To calculate the first steps of the method, Runge-Kutta of the 4th order is used, so while the order is not higher than the 5th it makes sense.

Click to enlarge
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Alvaro Diaz Falconi 12/14/2021 3:04:00 AM
#126 Posted: 12/15/2021 9:49:35 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

SMath Studio compatibility rkfixed.cs

Plugin updated.

Changes:

- rkfixed variable added (allows you to choose a method for the rkfixed() solver: "RK1".."RK6", "RK4" - default);
- to calculate the first steps for the Adams() solver now Runge-Kutta of the 6th order is used.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
sergio 12/15/2021 11:47:00 AM
#127 Posted: 12/17/2021 12:39:58 PM
AleksMoisei

AleksMoisei

0 likes in 8 posts.

Group: User

Скажите пожалуйста, можно ли с помощью данного расширения производить символьные расчеты как в Маткаде или только это касается графиков. Пробую посчитать символьно передаточную функцию, задействовал Maple Tools, simplify выдал что-то не то что должен был по моим разумениям.Raschjot17.sm (24 KiB) downloaded 32 time(s).
#128 Posted: 12/17/2021 1:30:28 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

Скажите пожалуйста, можно ли с помощью данного расширения производить символьные расчеты как в Маткаде или только это касается графиков. Пробую посчитать символьно передаточную функцию, задействовал Maple Tools, simplify выдал что-то не то что должен был по моим разумениям.]


Это расширение большей частью реализует численные аналоги некоторых функций из Mathcad. Символьные же вычисления можно попробовать выполнять при помощи MapleTools и функции maple(). Если она работает как-то не так, то можно посмотреть о "переговорах" между движками при помощи файла лога MapleTools.log, который находится в папке с плагином, если в файле конфигурации MapleTools.config включена опция отладки (<Debug>True</Debug>.

Путь такой: %appdata%\SMath\extensions\plugins\32dfd679-8cfd-483a-b79a-19d5ea838750\

Его нужно скопировать и вставить в адресную строку Проводника. Дальше выбрать подпапку с последний версией плагина, отредактировать файл MapleTools.config при закрытой программе и запустить её снова. После этого при старте будет создаваться файл лога MapleTools.log, в котором можно увидеть что именно передаёт функция maple() в символьный движок дополнения и как тот отвечает. Ну, а дальше уже искать ошибки.

Следует также отметить, что синтаксис команды скорее всего будет отличаться, т.к. Mathcad имеет специальную обёртку, "скрывающую" некоторые дополнительные действия, чтобы перевести его запрос на понятный символьному движку "диалект". Поэтому нельзя в общем случае писать также как в Mathcad. Нужно понимать как работает Maple и быть знакомым с его командами, их форматами вызова.
Russia ☭ forever, Viacheslav N. Mezentsev
#129 Posted: 12/17/2021 4:45:31 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote



... Maple Tools, simplify выдал что-то не то что должен был по моим разумениям.Raschjot17.sm (24 KiB) downloaded 32 time(s).



Hi. Notice that SMath does not operate automatically expands matrix operations. Also, the maple's linalg package have some issues too, and sometimes needs to call evalm function, which means "eval as matrix".

If D is a scalar I suppose that the correct result is (2), but if it is a 2x2 matrix I think it is (3).

In both cases you cannot calculate A ^ (- 1) because the second column of A is zero.

img0.png

Could you comment what is the expression you expect for A? Also perhaps something from this post may be useful to you: https://en.smath.com/forum/yaf_postst17472_Applications-for-equrep--expression-isolation-and-laplace-transform.aspx

Best regards.
Alvaro.
#130 Posted: 12/21/2021 6:26:33 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Updated test for the ODE solvers.

Section Math ODE precision (uni).sm (34 KiB) downloaded 54 time(s).

Original document: Section Math ODE precision.sm (23 KiB) downloaded 80 time(s).

Click to enlarge Click to enlarge
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
sergio 12/22/2021 7:54:00 AM, Alvaro Diaz Falconi 12/21/2021 5:31:00 PM
#131 Posted: 12/27/2021 5:04:34 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

I finally figured out how it works

Mathcad Block. Spring pendulum.sm (48 KiB) downloaded 77 time(s).

Click to enlarge Mathcad Block. Spring pendulum.gif
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
Andrey Ivashov 12/27/2021 7:42:00 PM, sergio 12/27/2021 5:56:00 PM
#132 Posted: 4/24/2022 2:42:52 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

SMath Studio compatibility

Plugin updated.

Changes:

- MathcadBlock improved (doesn't perform substitutions);
- File Access functions refactored;
- project restructured.

Here the variable x.min is defined above.

MathcadBlock improved.jpg
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
sergio 4/25/2022 5:29:00 AM
#133 Posted: 6/21/2022 12:44:53 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

SMath Studio compatibility

Plugin updated.

Changes:

- CWD and image processing functions fixed.

P.S. Found a critical issue while trying to resolve this kind of system (x'(t) and x''(t) in one equation):

ode system.jpg

The conversion of a complex system to a matrix form is not correct. A more complex algorithm is required. Only simple types of ODEs will be computed correctly.
Russia ☭ forever, Viacheslav N. Mezentsev
2 users liked this post
sergio 6/21/2022 2:59:00 PM, churichuro 6/21/2022 2:46:00 PM
#134 Posted: 6/21/2022 11:50:18 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

...

P.S. Found a critical issue while trying to resolve this kind of system (x'(t) and x''(t) in one equation):
...



Hi Viacheslav. This is a way to handle some of coupled systems. Or at least that's what I think, I hope I didn't solve it wrong.

odeCoupledExample.pdf (116 KiB) downloaded 35 time(s).
odeCoupledExample.sm (87 KiB) downloaded 38 time(s).

Best regards.
Alvaro.
1 users liked this post
Вячеслав Мезенцев 6/22/2022 12:55:00 AM
#135 Posted: 6/22/2022 12:54:35 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

I hope I didn't solve it wrong.





These ODEs is called the Arenstorf Orbit.

lsoda.Arenstorf Orbit.sm (15 KiB) downloaded 87 time(s).
lsoda.Arenstorf Orbit.pdf (93 KiB) downloaded 80 time(s).

The problem is that I use an universal algorithm that independently searches for derivatives in equations and arranges them in a matrix. I started with low order derivatives, so the equations were solved with respect to them first. It's wrong, but it worked in simple cases. When I redid the enumeration of derivatives of higher orders, I found that I did not take into account the case of different naming of variables. In this regard, an incorrect matrix is ​​obtained and the numerical algorithm cannot find a solution.
I need to organize a double loop that first takes into account different variables, and then their derivatives.
It is strange that I didn't do this earlier, because the rest of the code is designed for this.

I had a very simple set of examples that I experimented with. As soon as I tried something more complicated - it immediately revealed the problem.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Alvaro Diaz Falconi 6/22/2022 3:22:00 AM
#136 Posted: 6/22/2022 3:36:15 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hi Viacheslav. I guess that there are not a general form for get the ode system from a coupled system with more than one variable derivative. For instance, this is the maple function for get the system if there are only one variable: https://www.maplesoft.com/support/help/maple/view.aspx?path=DEtools%2Fconvertsys

But this other is for odes which "contains more than one function that is differentiated": https://www.maplesoft.com/support/help/maple/view.aspx?path=convert%2FODEs

There it seems that the Abel equations have some very interesting properties. The relevant point here for me is that I know about nothing about that.

But this method of isolating the second derivative for decoupling some useful equations is what I see that is useful for some usual system, for example, from lagrangian dynamics. This have some few other examples with coupled and not coupled systems with more than one dependent variable.

Examples Lagrangian.sm (1006 KiB) downloaded 40 time(s).
Examples Lagrangian.pdf (2 MiB) downloaded 35 time(s).

Best regards.
Alvaro.
1 users liked this post
#137 Posted: 6/22/2022 5:09:06 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Wrote

I guess that there are not a general form for get the ode system from a coupled system with more than one variable derivative.


Yes I agree, Alvaro. I meant that my algorithm is trying to convert the system of equations into a form that is understandable by numerical solvers. In our case, this is the "general form". I didn't know Maple had special features for this.

Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Alvaro Diaz Falconi 6/22/2022 12:48:00 PM
#138 Posted: 7/22/2022 2:25:20 AM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Wrote

... my algorithm is trying to convert the system of equations into a form that is understandable by numerical solvers ...



Hi. This is a way for use rk-solvers for very hard coupled systems, calling al_nleqsol with a guess for the derivatives of high order at the origin.

RKA.sm (50 KiB) downloaded 61 time(s).
RKA.pdf (309 KiB) downloaded 42 time(s).

Best regards.
2 users liked this post
sergio 7/22/2022 4:53:00 AM, Вячеслав Мезенцев 7/22/2022 3:24:00 AM
#139 Posted: 4/1/2023 9:14:15 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Russia ☭ forever, Viacheslav N. Mezentsev
3 users liked this post
Alvaro Diaz Falconi 4/2/2023 9:23:00 AM, sergio 4/3/2023 12:47:00 PM, Martin Kraska 4/2/2023 7:53:00 AM
#140 Posted: 4/2/2023 7:30:46 AM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

Three alternative solutions for different accuracy.

Click to enlarge Click to enlarge Click to enlarge

7-13-Three-Planets 4 (Mathcad Block).sm (27 KiB) downloaded 33 time(s).
7-13-Three-Planets 4 (Mathcad Block).pdf (77 KiB) downloaded 34 time(s).
Russia ☭ forever, Viacheslav N. Mezentsev
  • New Posts New Posts
  • No New Posts No New Posts