Mathcad Toolbox

Mathcad Toolbox - Contains analogs of functions from Mathcad - Messaggi

#201 Pubblicato: 21/08/2025 20:59:20
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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


Modificato 21/08/2025 21:13:21
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
1 utenti hanno apprezzato questo post
#202 Pubblicato: 21/08/2025 21:25:35
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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) scaricato 1419 volta(e).

image.png
Modificato 21/08/2025 21:32:28
Russia ☭ forever, Viacheslav N. Mezentsev
1 utenti hanno apprezzato questo post
Alvaro 22/08/2025 02:25:04
#203 Pubblicato: 22/08/2025 02:36:02
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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) scaricato 1411 volta(e).

Best regards.
Alvaro.
Modificato 22/08/2025 02:45:16
#204 Pubblicato: 22/08/2025 02:43:19
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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) scaricato 1503 volta(e).
image.png

Best regards.
Alvaro.
2 utenti hanno apprezzato questo post
Вячеслав Мезенцев 22/08/2025 04:23:57, francesco rapuano 22/08/2025 12:28:36
#205 Pubblicato: 22/08/2025 12:42:19
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Citazione

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 Pubblicato: 22/08/2025 13:37:36
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Citazione

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
Modificato 22/08/2025 14:01:39
Russia ☭ forever, Viacheslav N. Mezentsev
1 utenti hanno apprezzato questo post
Alvaro 22/08/2025 19:26:29
#207 Pubblicato: 22/08/2025 20:05:22
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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.
1 utenti hanno apprezzato questo post
#208 Pubblicato: 23/08/2025 23:23:22
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

SMath Studio compatibility History page Changes AI Assistant

Plugin updated.

Changes:

- find() function syntax extended.

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
2 utenti hanno apprezzato questo post
Oscar Campo 23/08/2025 23:31:30, Alvaro 24/08/2025 05:45:17
#209 Pubblicato: 24/08/2025 05:49:38
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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) scaricato 1347 volta(e).

Best regards.
Alvaro.
3 utenti hanno apprezzato questo post
Вячеслав Мезенцев 24/08/2025 05:51:44, Oscar Campo 24/08/2025 09:54:25, francesco rapuano 24/08/2025 14:41:15
#210 Pubblicato: 24/08/2025 14:52:26
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

self-check

image.png
Modificato 24/08/2025 14:54:21
Russia ☭ forever, Viacheslav N. Mezentsev
#211 Pubblicato: 24/08/2025 14:55:32
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: 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) scaricato 1373 volta(e).
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
2 utenti hanno apprezzato questo post
francesco rapuano 24/08/2025 15:02:57, Alvaro 25/08/2025 06:21:19
#212 Pubblicato: 24/08/2025 15:08:34
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

You can also try it this way

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
2 utenti hanno apprezzato questo post
Alvaro 25/08/2025 06:21:12, Martin Kraska 24/08/2025 16:05:35
#213 Pubblicato: 25/08/2025 06:45:40
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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.
Modificato 25/08/2025 06:46:29
1 utenti hanno apprezzato questo post
#214 Pubblicato: 31/08/2025 06:44:52
netsonicyxf

netsonicyxf

1 apprezzamenti in 14 post.

Gruppo: 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 Pubblicato: 31/08/2025 09:46:57
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: 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
Modificato 31/08/2025 09:49:53
Russia ☭ forever, Viacheslav N. Mezentsev
#216 Pubblicato: 31/08/2025 10:01:24
Oscar Campo

Oscar Campo

135 apprezzamenti in 309 post.

Gruppo: 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 Pubblicato: 01/09/2025 05:34:56
netsonicyxf

netsonicyxf

1 apprezzamenti in 14 post.

Gruppo: 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 Pubblicato: 01/09/2025 06:25:38
Вячеслав Мезенцев

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

1.558 apprezzamenti in 1.868 post.

Gruppo: Moderator

Try this

image.png
Russia ☭ forever, Viacheslav N. Mezentsev
1 utenti hanno apprezzato questo post
Davide Carpi 01/09/2025 07:40:24
#219 Pubblicato: 01/09/2025 06:35:02
Alvaro

Alvaro

1.139 apprezzamenti in 1.805 post.

Gruppo: 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.
Modificato 01/09/2025 06:41:26
#220 Pubblicato: 01/09/2025 10:39:16
Oscar Campo

Oscar Campo

135 apprezzamenti in 309 post.

Gruppo: 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
2 utenti hanno apprezzato questo post
netsonicyxf 01/09/2025 11:06:14, sergio 01/09/2025 14:38:15
  • Nuovi post
  • Nessun nuovo post