FindRoot issue

FindRoot issue - Messaggi

#1 Pubblicato: 03/05/2019 21:53:16
Mo

Mo

0 apprezzamenti in 34 post.

Gruppo: User

Hi,
I was trying to solve 2 equations and getting the root using FindRoot with weird results, that when substituting with the SMath results the equations don't yield to the same results.
I know using units seem to create problems, but it sometimes works and I need to solve this somehow.
any suggestion?
Test.jpg

Test.sm (287,52 KiB) scaricato 1201 volta(e).
#2 Pubblicato: 03/05/2019 23:17:16
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

I was trying to solve 2 equations and getting the root using FindRoot with weird results, that when substituting with the SMath results the equations don't yield to the same results.
I know using units seem to create problems, but it sometimes works and I need to solve this somehow.
any suggestion?


1. I don't understand what you are trying to do.
2. Here is is a working example.
3. Your document is not backward compatible

Solve FindRoots LogLikely.sm (14,37 KiB) scaricato 1267 volta(e).

#3 Pubblicato: 04/05/2019 07:01:20
Davide Carpi

Davide Carpi

1.443 apprezzamenti in 2.936 post.

Gruppo: Moderator

Somehow it works better reversing the unknowns... dunno why...

Also since you are working with units you have to pay attention at the required precision. The one shown in the function description is about the base units, m for the length and m^2 for the area.

Test - r0.sm (277,65 KiB) scaricato 1216 volta(e).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Pubblicato: 06/05/2019 13:21:12
Mo

Mo

0 apprezzamenti in 34 post.

Gruppo: User

Thank Davide and Jean,
Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.

Davide, I am worried because this error should not occur.
I mean do I need to check every time I change my input that my output is correct?! and try to flip the variables to make it work? I tried your code in another old sheet and it did not work, I had to stick with the order a1=d first then the Area to make it work properly!!

Also, what happens if there are two positive real solutions, which one will be shown by SMath?

Thanks a lot for your help!!
#5 Pubblicato: 06/05/2019 15:37:00
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.


1. If it happens several roots, then solve(4)
2. Maple symbolic does not take units.
3. None of my Smath Process Control & Instrumentation [~ 100] carries units.
All results are in appropriate units ... [t/hr, mWc, cP ...]
4. What's the arc length unit => UnitGraphic that you can scale 1.23456789
5. Units were discussed ad nauseum Mathsoft Collaboratory.
Over 125000 exchange, not a single work sheet with units.
6. In few steps the resistance is no more Ohms ...
7. The unit system should be dead decoration, i.e: not sub-processing.

Cheers ... Jean

1 utenti hanno apprezzato questo post
Mo 07/05/2019 18:09:00
#6 Pubblicato: 06/05/2019 16:49:54
Martin Kraska

Martin Kraska

1.361 apprezzamenti in 2.275 post.

Gruppo: Moderator

Wrote

Thank Davide and Jean,
Jean, as a structural engineer I deal a lot with units and creating a sheet without units is not professional and typically creates errors from users which we try to avoid. I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.

Davide, I am worried because this error should not occur.
I mean do I need to check every time I change my input that my output is correct?! and try to flip the variables to make it work? I tried your code in another old sheet and it did not work, I had to stick with the order a1=d first then the Area to make it work properly!!

Also, what happens if there are two positive real solutions, which one will be shown by SMath?

Thanks a lot for your help!!



If using the Maxima plugin is an option for you, then the solution is straightforward.
- Units are no problem for the plugin (they are converted into symbolic variables, Maxima itself isn't unit-aware).
- Multiple solutions are returned by Solve as a row vector of solutions (with each being a list of equations). You can pick the solution by
index and apply it using Assign().

I don't know how you can know in advance which solution to use. Perhaps the reasoning on which one to select can be cast into some test for index generation.

Best regards, Martin

test1_kr.png
test1_kr.sm (290,11 KiB) scaricato 1215 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
sergio 06/05/2019 17:14:00, Mo 07/05/2019 18:09:00
#7 Pubblicato: 06/05/2019 21:36:29
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Wrote

I read on other forums that the function works well without units (same as your sheet) so I prefer to find a way that works with units.


Just remember maths are unitless.
You are solving for two monkeys that you can't augment with units.
And you have only one project in hand, what about if you are contracted
for the entire British Empire ?
Examine the attached Colebrook.
In < one page maths, it solves a monster big pile of information.
More can be added for tabulation. Little modifications will solve
for as many fluids the plant will have [commonly 100's of fluids].
At the end: one page recast will produces several inches thick of
documents in no time in unit-result visible, consultable by more
than the piping design team, thinking in terms of the $ illuminatis.
Try unitless, plot something ...

Cheers ... Jean

Inst_Colebrook Pipe Data.sm (59,42 KiB) scaricato 1171 volta(e).


1 utenti hanno apprezzato questo post
Mo 07/05/2019 18:09:00
#8 Pubblicato: 07/05/2019 01:08:56
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

Think twice: 1.23456789*9.87654321= result + an empty place holder
What is the 2nd place holder for ? I know: the slipping bar for the parrot
Rather from uniless maths to validate the unit-result as desired.
Whereas the standard you are using has dimension then no need to carry units
as the standard tells what the unit-result is.
In your project, I trust you [that stuff is extraterrestrial to me].

UnitLess.PNG
1 utenti hanno apprezzato questo post
Mo 07/05/2019 18:09:00
#9 Pubblicato: 07/05/2019 01:24:41
Jean Giraud

Jean Giraud

983 apprezzamenti in 6.866 post.

Gruppo: User

The SS 6179 document.

Solve Given_Find [Simple Demo].sm (68,7 KiB) scaricato 1029 volta(e).
1 utenti hanno apprezzato questo post
Mo 07/05/2019 18:09:00
#10 Pubblicato: 07/05/2019 19:04:02
Mo

Mo

0 apprezzamenti in 34 post.

Gruppo: User

That Works, Thanks a lot Jean and Martin !!
  • Nuovi post
  • Nessun nuovo post