Mathcad Toolbox

Mathcad Toolbox - Contains analogs of functions from Mathcad - Mensajes

#201 Publicado: 21/8/2025 20:59:20
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Interesting things are going on, I am really excited!

I think that the explanation by Gemini is not entirely correct. Yet, he hint on circularity is helpful.

image.png

If that was true, we would not have that circularity problem. Also we would not see the entire find command with it's arguments if we display the stored expression from the find block in the dynamic assistant.
Actually I believe that the find function (like any other function in any assignment does nothing (except for substituting existing definitions from the context) unless a result display is requested. I call this delayed evaluation.

Also, assignment to a variable should not affect anything above the current definition. Backfiring should be limited to absolute variables as sometimes used for iterations with on-the-fly animation.

If Gemini was right here, the simp() function in my above example would not help. simp() actually triggers evaluation because num2str() does so. BTW, in the given case S: eval(S) also does the job.

image.png


Editado 21/8/2025 21:13:21
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 1 usuarios les gustó este mensaje
#202 Publicado: 21/8/2025 21:25:35
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

SMath Studio compatibility History page Changes AI Assistant

Plugin updated.

Changes:

- Draghilev solver added.

This is a very simple implementation.

MathcadToolbox-Draghilev-simple.sm (20,83 KiB) descargado 1413 vez(es).

image.png
Editado 21/8/2025 21:32:28
Russia ☭ forever, Viacheslav N. Mezentsev
A 1 usuarios les gustó este mensaje
Alvaro 22/8/2025 2:25:04
#203 Publicado: 22/8/2025 2:36:02
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

... The set of variables to be solved is now implicitly determined from all initial guesses (`≈`) provided in the input system. This removes the need to explicitly declare all variables. ...



Hi Viacheslav. Very good job! Instead of sending the equation with the user variables to the solver, and having problems with cyclic recursions, you can send a system of equations based on a single vector variable. This also enables the use of al_nleqsolve, which is the most robust solver available, and is also compatible with the solvers in the nonlinear solvers plugin. This is demonstrated in the code in the attached file, along with combining the x ≈ a notation with the x = a notation.

nsol-handling-equations.sm (56,51 KiB) descargado 1405 vez(es).

Best regards.
Alvaro.
Editado 22/8/2025 2:45:16
#204 Publicado: 22/8/2025 2:43:19
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

... Draghilev solver added.


Hi Viacheslav. With a matrix non-zero finder, like the one in Matlab, you can simplify the axis crossing detection.

MathcadToolbox-Draghilev-MFind.sm (30,45 KiB) descargado 1496 vez(es).
image.png

Best regards.
Alvaro.
A 2 usuarios les gustó este mensaje
Вячеслав Мезенцев 22/8/2025 4:23:57, francesco rapuano 22/8/2025 12:28:36
#205 Publicado: 22/8/2025 12:42:19
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

Citar

BTW, in the given case S: eval(S) also does the job.


Сan be used as a temporary solution.

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
#206 Publicado: 22/8/2025 13:37:36
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

Citar

This is demonstrated in the code in the attached file, along with combining the x ≈ a notation with the x = a notation.


You might be interested to know that the find function was written using AI using the nsol function as an example. I have been working with AI for some time and now it can convert almost any description into code.
It understood perfectly what was happening in the nsol code, praised the author and offered the implementation as a find function. Of course, I told it what to do, but basically all the code was written by AI.
All numerical solvers that find() uses are also written by AI in 10 minutes.

The same goes for Draghilev's method, it is also based on your example. It is too complex to understand, but in general I know what is happening there, and for AI there were no difficulties at all.

Now I'm trying to port lsode (odesolve) from C code to c#. It's too huge to be done in one evening and there are many complexities, but the AI ​​said that everything will be fine.

I will later connect all the existing numerical solvers to the find function, and all the numerical differential solvers to odesolve. In particular, it will learn to classify a problem by a set of equations and select an appropriate solver.
Unfortunately, when working with the AI, you need less time, but more knowledge. Not everything it offers corresponds to my level as a programmer.

AI also helped to understand splines. It found an inaccuracy in the Mathcad.

image.png

image.png

image.png
Editado 22/8/2025 14:01:39
Russia ☭ forever, Viacheslav N. Mezentsev
A 1 usuarios les gustó este mensaje
Alvaro 22/8/2025 19:26:29
#207 Publicado: 22/8/2025 20:05:22
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Wrote

... You might be interested to know that the find function was written using AI using the nsol function as an example. I have been working with AI for some time and now it can convert almost any description into code.

In that case, please also check ndsol , as the way it converts differential equations into systems allows for numerical solutions of hard coupled systems that I can only solve in SMath, but not Maple or Mathematica.

Wrote

... All numerical solvers that find() uses are also written by AI in 10 minutes.

The nleqsol solver is the most powerful one you have at hand, it reminds me of the tksolver solver.

Wrote

... The same goes for Draghilev's method, it is also based on your example. It is too complex to understand, but in general I know what is happening there, and for AI there were no difficulties at all.

Remember to add the option to have the Jacobian as an argument, and the ode solver too.

Wrote

... I will later connect all the existing numerical solvers to the find function, and all the numerical differential solvers to odesolve. In particular, it will learn to classify a problem by a set of equations and select an appropriate solver.

I haven't reviewed the code in the SMath plugin repository, but Adams' algorithm is clearly much faster than the others. Perhaps you could implement the way it evaluates D(t,u) values ​​in rkfixed and RKadapt.

Wrote

... AI also helped to understand splines. It found an inaccuracy in the Mathcad.


You can find the codes in SMath here: https://smath.com/en-US/forum/topic/sKU7o2/CSpline-interpolation#msg129361 . My idea for math software is that advanced functions should be written in their own code, with the exception of those that require a large number of flops (Matlab Word). This should make it easier for developers to discover bugs and optimize the core code. However, there is something very good about SMath's code for the cspline function. Unlike Mathcad, it doesn't require prior calculation of the matrix with splines, yet it still works very quickly.

Finally, as you refine your procedures and add examples, you'll eventually need to consider how to pass arguments to find and specialized ode solvers, as they won't be able to solve all problems with the default parameters. The option I suggest is something similar to the Options(~fname, "pname", pvalue) function you can find in nsol to store "pname" and "pvalue" as strings in the ~fname variable, and Options(~fname,"pname") to obtain pvalue. Remembering that in SMath, every function can modify the value of its arguments globally, and treating ~fname as if it were an object that has the pname parameters as if they were properties of an object.

Best regards.
Alvaro.
A 1 usuarios les gustó este mensaje
#208 Publicado: 23/8/2025 23:23:22
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

SMath Studio compatibility History page Changes AI Assistant

Plugin updated.

Changes:

- find() function syntax extended.

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
A 2 usuarios les gustó este mensaje
Oscar Campo 23/8/2025 23:31:30, Alvaro 24/8/2025 5:45:17
#209 Publicado: 24/8/2025 5:49:38
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi Viacheslav. You also can ask the IA for matrices with known examples to check the answers. In this case, one variable function, the guess and the root.

image.png

check-find.sm (37,51 KiB) descargado 1339 vez(es).

Best regards.
Alvaro.
A 3 usuarios les gustó este mensaje
Вячеслав Мезенцев 24/8/2025 5:51:44, Oscar Campo 24/8/2025 9:54:25, francesco rapuano 24/8/2025 14:41:15
#210 Publicado: 24/8/2025 14:52:26
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

self-check

image.png
Editado 24/8/2025 14:54:21
Russia ☭ forever, Viacheslav N. Mezentsev
#211 Publicado: 24/8/2025 14:55:32
Martin Kraska

Martin Kraska

1.361 me gusta en 2.275 mensajes.

Grupo: Moderator

Mathcad block for entering matrices. This allows for inserting and deleting rows and columns using ordinary SMath edit. Each entry is a formula cell.

Problem is that it is easy to get the wrong sequence by slightly misplacing entries.

Also, it is not nice that the procedure can't guess the shape of the matrix from the arrangement of the entries.

image.png

collect.sm (14,9 KiB) descargado 1369 vez(es).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
A 2 usuarios les gustó este mensaje
francesco rapuano 24/8/2025 15:02:57, Alvaro 25/8/2025 6:21:19
#212 Publicado: 24/8/2025 15:08:34
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

You can also try it this way

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
A 2 usuarios les gustó este mensaje
Alvaro 25/8/2025 6:21:12, Martin Kraska 24/8/2025 16:05:35
#213 Publicado: 25/8/2025 6:45:40
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi, I see you're using the character at position 8 to find the newline. The text inside the mathcad block uses a different character than the one used in the text inside a description(). One way to get both is this (Carriage Return & Line Feed)

image.png

You can then handle text from both the mathcad block and description(), for example, using strrep(text,'CR,'LF)

Best regards.
Alvaro.
Editado 25/8/2025 6:46:29
A 1 usuarios les gustó este mensaje
#214 Publicado: 31/8/2025 6:44:52
netsonicyxf

netsonicyxf

1 me gusta en 14 mensajes.

Grupo: User

Smath v1.3.0.9126, MathCad Toolbox v0.6.9367

These equations used to work in the original document, but today they all show red. Then I copy them and paste them to a new blank document, the 1st and 2nd equ works except 3rd one.
123.jpg
#215 Publicado: 31/8/2025 9:46:57
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

This is the basic form of using the find() function.

image.png

All other methods should be used after mastering the basic ones.

image.png

image.png
Editado 31/8/2025 9:49:53
Russia ☭ forever, Viacheslav N. Mezentsev
#216 Publicado: 31/8/2025 10:01:24
Oscar Campo

Oscar Campo

135 me gusta en 309 mensajes.

Grupo: Moderator

Wrote

Smath v1.3.0.9126, MathCad Toolbox v0.6.9367

These equations used to work in the original document, but today they all show red. Then I copy them and paste them to a new blank document, the 1st and 2nd equ works except 3rd one.
...



use Clear() function between 2nd and 3rd equations and evaluate:

image.png

When this function is evaluated, the value of arguments in the function are cleaned.

Regards,
Oscar
#217 Publicado: 1/9/2025 5:34:56
netsonicyxf

netsonicyxf

1 me gusta en 14 mensajes.

Grupo: User

Wrote

Wrote

Smath v1.3.0.9126, MathCad Toolbox v0.6.9367

These equations used to work in the original document, but today they all show red. Then I copy them and paste them to a new blank document, the 1st and 2nd equ works except 3rd one.
...



use Clear() function between 2nd and 3rd equations and evaluate:

image.png

When this function is evaluated, the value of arguments in the function are cleaned.

Regards,
Oscar


123.jpg

#218 Publicado: 1/9/2025 6:25:38
Вячеслав Мезенцев

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

1.558 me gusta en 1.868 mensajes.

Grupo: Moderator

Try this

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
A 1 usuarios les gustó este mensaje
Davide Carpi 1/9/2025 7:40:24
#219 Publicado: 1/9/2025 6:35:02
Alvaro

Alvaro

1.139 me gusta en 1.805 mensajes.

Grupo: User

Hi. Usually, isn't easy verify the calculus from a picture, it's better from the source. You use ":=", instead "=", as Oscar suggest.

image.png

Best regards.
Alvaro.
Editado 1/9/2025 6:41:26
#220 Publicado: 1/9/2025 10:39:16
Oscar Campo

Oscar Campo

135 me gusta en 309 mensajes.

Grupo: Moderator

Wrote


123.jpg



Pay attention to this convention:
When you type ":" in SMath, you are assigneing a value to a variable and SMath renders as: ":=" .
When you type "=", you are asking for the value of a variable, or evaluating a function, and smath renders it as: "="

In your case, Clear() is a function, so, when you type "Clear(z[Ctrl+g]):1" which renders:

image.png

Here you must to type "1" and you are assigning the value "1" to "Clear(zeta)" . This is wrong.
The correct syntaxis to evaluate the function Clear() is : "Clear(z[Ctrl+g])=" which renders:

image.png

Here you don't type "1". The value "1" is an automatic response to evaluation of the function Clear(). It is the boolean answer of successfully having evaluated the Clear() function

Best,

Oscar
A 2 usuarios les gustó este mensaje
netsonicyxf 1/9/2025 11:06:14, sergio 1/9/2025 14:38:15
  • Nuevos mensajes
  • Sin mensajes nuevos