While loop never ends

While loop never ends - 消息

#1 已发布: 2020/3/13 15:27:06
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Hi everyone, I've got problem with while loop. I have this function with Xstart = 0.2 ; Xfinish = 2 ; deltaX = 0.2 and I need to solve it in smath studio, but while loop is processing forever and never ends. I'm doing something wrong, or it's a bug? Thanks!

Images:

https://postimg.cc/Q9mqWkKd Smath studio

https://postimg.cc/KKZkgXPt Function I need to solve
#2 已发布: 2020/3/13 16:58:44
NDTM Amarasekera

NDTM Amarasekera

130个赞,共352个帖子。

组: User

Is this what you need?

while_test.png
Look within!... The secret is inside you. Best Regards Eng. NDTM Amarasekera - Sri Lanka
#3 已发布: 2020/3/13 17:14:41
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Wrote

Is this what you need?

while_test.png



No, I need a range of numbers for X and Y, like: First X = 0.2, it's calculating Y(0.2) and shows first Y result, then X = 0.4 (previous X + delta X) and it's calculating Y(0.4), and until x = 2. In final I need a range of all X and all Y results.
#4 已发布: 2020/3/13 17:30:47
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

I'm doing something wrong, or it's a bug? Thanks!


Some examples ...

Utilities Pts Critical Monte-Carlo.sm (18.33 KiB)已下载 1253 次。
Utilities Program While FindIndex.sm (34.87 KiB)已下载 1238 次。
#5 已发布: 2020/3/13 17:55:24
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Wrote

Wrote

I'm doing something wrong, or it's a bug? Thanks!


Some examples ...

Utilities Pts Critical Monte-Carlo.sm (18.33 KiB)已下载 1253 次。
Utilities Program While FindIndex.sm (34.87 KiB)已下载 1238 次。



I'm not sure I understood how to solve my function by this examples.

I don't know what I'm doing wrong:
https://postimg.cc/Q9mqWkKd
#6 已发布: 2020/3/13 20:38:39
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Wrote

I'm not sure I understood how to solve my function by this examples.


Your proposal is not a case of while loop,
strictly wrong application.

Page44 Unknown.sm (73.22 KiB)已下载 1468 次。
#7 已发布: 2020/3/14 06:06:47
Martin Kraska

Martin Kraska

1,362个赞,共2,276个帖子。

组: Moderator

You can do the job using a while loop but it is just one option (perhaps not the most straightforward one).

loops.png
loops.sm (10 KiB)已下载 1267 次。
Technische Mechanik mit SMath Studio: https://link.springer.com/book/10.1007/978-3-658-50592-9
3位用户喜欢此帖子
Davide Carpi 2020/3/14 07:20:00, frapuano 2020/3/14 08:38:00, sergio 2020/3/14 14:01:00
#8 已发布: 2020/3/14 06:19:48
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Wrote

Wrote

I'm not sure I understood how to solve my function by this examples.


Your proposal is not a case of while loop,
strictly wrong application.

Page44 Unknown.sm (73.22 KiB)已下载 1468 次。



I need all X and all Y(x) values in the end, for Xfirst = 0.2, Xlast = 2 with step 0.2.
y(0.2)=
y(0.4)=
y(0.6)=
...
y(2)=
And it should look something like this:
x= 0.2 y= -0.6126
x= 0.4 y= 0.2173
x= 0.6 y= 0.7064
x= 0.8 y= 1.0721
x= 1.0 y= 1.3842
x= 1.2 y= 1.6771
x= 1.4 y= 1.9738
x= 1.6 y= 2.2924
x= 1.8 y= 2.6501
x= 2.0 y= 3.0639

I can type every y(x) in smath studio:
https://postimg.cc/0bddLTqF
But, is it possible to do it with while loop?
#9 已发布: 2020/3/14 06:21:13
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Wrote

You can do the job using a while loop but it is just one option (perhaps not the most straightforward one).

loops.png
loops.sm (10 KiB)已下载 1267 次。



I need all X and all Y(x) values in the end, for Xfirst = 0.2, Xlast = 2 with step 0.2.
y(0.2)=
y(0.4)=
y(0.6)=
...
y(2)=
And it should look something like this:
x= 0.2 y= -0.6126
x= 0.4 y= 0.2173
x= 0.6 y= 0.7064
x= 0.8 y= 1.0721
x= 1.0 y= 1.3842
x= 1.2 y= 1.6771
x= 1.4 y= 1.9738
x= 1.6 y= 2.2924
x= 1.8 y= 2.6501
x= 2.0 y= 3.0639

I can type every y(x) in smath studio:
https://postimg.cc/0bddLTqF
But, is it possible to do it with while loop?
#10 已发布: 2020/3/14 08:25:47
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

What you are asking for is so restricted and useless for purpose !
Then you can:
1. start wherever [L] as long as computable your ln(,)
2. end wherever [N]
3. as fine step size [Δ]
4. algo style for infinite applications

Data.PNG
#11 已发布: 2020/3/14 08:52:29
Yes Man

Yes Man

0个赞,共6个帖子。

组: User

Wrote

What you are asking for is so restricted and useless for purpose !
Then you can:
1. start wherever [L] as long as computable your ln(,)
2. end wherever [N]
3. as fine step size [Δ]
4. algo style for infinite applications

Data.PNG



I'm asking for this cos' we are learning Pascal programming language in university, and we need to write this function in Pascal with [while a<=b do], and check it in MathCAD or SMath studio program.
I don't need any graphics, I just need to check the function with while loop. You sent example without while loop and without Xlast = 2, so is it possible to check this function with while loop, or no?



#12 已发布: 2020/3/14 10:11:42
Jean Giraud

Jean Giraud

983个赞,共6,866个帖子。

组: User

Pascal is pretty retarded these days for Engineering applications !
Years ago, Mathcad for Universities was pretty freaked.
Better use Smath productive for studies & Engineering.

Pt 100.PNG

Golden ratio will be a life time productive Companion.
As well as an advanced WhileLoop.

Golden Ratio jmG.sm (39.41 KiB)已下载 1232 次。
#13 已发布: 2020/3/14 11:20:50
Davide Carpi

Davide Carpi

1,443个赞,共2,936个帖子。

组: Moderator

Wrote

so is it possible to check this function with while loop, or no?



Absolutely, and there are several ways.

If you need a step-by step feedback on the fly you can use breakpoints (menu of math regions) and the debugger window ("View" menu). You might have to store the intermediate results in a dedicated variable though, to don't look into the whole matrix at each step.

Also you can use the function trace() and the output window, or you can build math strings using concat() and other functions, or maybe something more complex using the script region plugin by uni.

loops-1.sm (30.01 KiB)已下载 1174 次。
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
3位用户喜欢此帖子
sergio 2020/3/14 14:35:00, frapuano 2020/3/14 16:00:00, SteelCat 2020/5/17 15:51:00
  • 有新帖
  • 无新帖