FindRoot issue

FindRoot issue - Сообщения

#1 Опубликовано: 03.05.2019 21:53:16
Mo

Mo

0 сообщений из 34 понравились пользователям.

Группа: 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 КиБ) скачан 36 раз(а).
#2 Опубликовано: 03.05.2019 23:17:16
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 КиБ) скачан 49 раз(а).

#3 Опубликовано: 04.05.2019 07:01:20
Davide Carpi

Davide Carpi

1416 сообщений из 2873 понравились пользователям.

Группа: 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 КиБ) скачан 33 раз(а).
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#4 Опубликовано: 06.05.2019 13:21:12
Mo

Mo

0 сообщений из 34 понравились пользователям.

Группа: 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 Опубликовано: 06.05.2019 15:37:00
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Mo 07.05.2019 18:09:00
#6 Опубликовано: 06.05.2019 16:49:54
Martin Kraska

Martin Kraska

1222 сообщений из 2150 понравились пользователям.

Группа: 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 КиБ) скачан 34 раз(а).
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
2 пользователям понравился этот пост
sergio 06.05.2019 17:14:00, Mo 07.05.2019 18:09:00
#7 Опубликовано: 06.05.2019 21:36:29
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 КиБ) скачан 31 раз(а).


1 пользователям понравился этот пост
Mo 07.05.2019 18:09:00
#8 Опубликовано: 07.05.2019 01:08:56
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: 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 пользователям понравился этот пост
Mo 07.05.2019 18:09:00
#9 Опубликовано: 07.05.2019 01:24:41
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

The SS 6179 document.

Solve Given_Find [Simple Demo].sm (68 КиБ) скачан 70 раз(а).
1 пользователям понравился этот пост
Mo 07.05.2019 18:09:00
#10 Опубликовано: 07.05.2019 19:04:02
Mo

Mo

0 сообщений из 34 понравились пользователям.

Группа: User

That Works, Thanks a lot Jean and Martin !!
  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений