Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline Yes Man  
#1 Posted : 13 March 2020 21:27:06(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

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

Edited by user 14 March 2020 16:35:01(UTC)  | Reason: Not specified

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Offline ndtma  
#2 Posted : 13 March 2020 22:58:44(UTC)
ndtma


Rank: Advanced Member

Groups: Registered
Joined: 05/06/2014(UTC)
Posts: 348
Man
Sri Lanka
Location: Colombo

Was thanked: 125 time(s) in 82 post(s)
Is this what you need?

while_test.png

Edited by user 13 March 2020 23:01:26(UTC)  | Reason: Not specified

Look within!... The secret is inside you.
Best Regards
Eng. NDTM Amarasekera - Sri Lanka
Offline Yes Man  
#3 Posted : 13 March 2020 23:14:41(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

Originally Posted by: ndtma Go to Quoted Post
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.
Offline Jean Giraud  
#4 Posted : 13 March 2020 23:30:47(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Yes Man Go to Quoted Post
I'm doing something wrong, or it's a bug? Thanks!

Some examples ...

Utilities Pts Critical Monte-Carlo.sm (19kb) downloaded 12 time(s).
Utilities Program While FindIndex.sm (35kb) downloaded 21 time(s).
Offline Yes Man  
#5 Posted : 13 March 2020 23:55:24(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: Yes Man Go to Quoted Post
I'm doing something wrong, or it's a bug? Thanks!

Some examples ...

Utilities Pts Critical Monte-Carlo.sm (19kb) downloaded 12 time(s).
Utilities Program While FindIndex.sm (35kb) downloaded 21 time(s).


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
Offline Jean Giraud  
#6 Posted : 14 March 2020 02:38:39(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: Yes Man Go to Quoted Post
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 (74kb) downloaded 10 time(s).
Offline mkraska  
#7 Posted : 14 March 2020 12:06:47(UTC)
mkraska


Rank: Advanced Member

Groups: Registered
Joined: 15/04/2012(UTC)
Posts: 1,986
Germany

Was thanked: 1124 time(s) in 721 post(s)
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 (11kb) downloaded 14 time(s).

Edited by user 14 March 2020 12:10:02(UTC)  | Reason: Not specified

Martin Kraska

Pre-configured portable distribution of SMath Studio: https://smath.com/wiki/SMath_with_Plugins.ashx
thanks 3 users thanked mkraska for this useful post.
on 14/03/2020(UTC),  on 14/03/2020(UTC),  on 14/03/2020(UTC)
Offline Yes Man  
#8 Posted : 14 March 2020 12:19:48(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

Originally Posted by: Jean Giraud Go to Quoted Post
Originally Posted by: Yes Man Go to Quoted Post
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 (74kb) downloaded 10 time(s).


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?
Offline Yes Man  
#9 Posted : 14 March 2020 12:21:13(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

Originally Posted by: mkraska Go to Quoted Post
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 (11kb) downloaded 14 time(s).


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?
Offline Jean Giraud  
#10 Posted : 14 March 2020 14:25:47(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
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
Offline Yes Man  
#11 Posted : 14 March 2020 14:52:29(UTC)
Yes Man

Rank: Newbie

Groups: Registered
Joined: 13/03/2020(UTC)
Posts: 6

Originally Posted by: Jean Giraud Go to Quoted Post
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?



Offline Jean Giraud  
#12 Posted : 14 March 2020 16:11:42(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
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 (40kb) downloaded 10 time(s).
Offline Davide Carpi  
#13 Posted : 14 March 2020 17:20:50(UTC)
Davide Carpi


Rank: Advanced Member

Groups: Registered, Advanced Member
Joined: 13/01/2012(UTC)
Posts: 2,647
Man
Italy
Location: Italy

Was thanked: 1329 time(s) in 875 post(s)
Originally Posted by: Yes Man Go to Quoted Post
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 (31kb) downloaded 19 time(s).

Edited by user 14 March 2020 19:40:33(UTC)  | Reason: wrong file attached, whoooops!

If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects
thanks 3 users thanked Davide Carpi for this useful post.
on 14/03/2020(UTC),  on 14/03/2020(UTC),  on 17/05/2020(UTC)
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.