cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Recurrence Relation #4

Cornel
19-Tanzanite

Recurrence Relation #4

Hi,

Problem:

Cornel_0-1727164811708.png

 

Cornel_0-1727165444316.png

 

The plot result should be like below:

Cornel_2-1727164887750.png

 

ACCEPTED SOLUTION

Accepted Solutions

26 REPLIES 26

Like so:

dots.png

 

Cornel
19-Tanzanite
(To:AlanStevens)

And if I want to make in this way? Why is not possible?

Cornel_0-1727188867664.png

 

 

 

 



@Cornel wrote:

And if I want to make in this way? Why is not possible?

Cornel_0-1727188867664.png


In this form Mathcad attempts to run through all the n's for x before before tackling y; so when n gets to 1, y1 doesn't yet exist.   The only way I've found to make it proceed recursively, is to put it in an "if" statement.  (With full Mathcad Prime you could put the whole thing in a "for" loop, of course.  However, I only have the Express version).

 

Alan 

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E do you have any idea on how to do like this somehow?

Cornel_0-1727248216587.png

 

StuartBruff
23-Emerald III
(To:Cornel)

Put the x & y terms in vectors.  This forces Mathcad to evaluate them simultaneously rather than sequentially.

 

2024 09 25 D.png

 

Stuart

Cornel
19-Tanzanite
(To:StuartBruff)

Thanks.

StuartBruff
23-Emerald III
(To:Cornel)

No problem.

 

Stuart

ttokoro
20-Turquoise
(To:StuartBruff)

image.pngimage.png

image.pngimage.png

Cornel
19-Tanzanite
(To:ttokoro)

 I do not know what are these and how you generated these plots, if you do not post mathcad file..

StuartBruff
23-Emerald III
(To:Cornel)


@Cornel wrote:

 I do not know what are these and how you generated these plots, if you do not post mathcad file..


 

It's the same equation you gave, with more points (N = 39000 vs 3000) and an extra term for the z coordinate (so you can plot it in 3D).

 

The 3D plot is a space line showing how the x and y coordinates move as n increments (the z-axis). Try setting N = 30 to see this more clearly.

 

Looks kind of like a hydra or a bobbit worm in 3D with N = 4000.  Typical chaotic behaviour with everything looking like a nice pattern and then it takes a step change outside of that pattern.

 

2024 09 25 I.png

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Its fun to play around with modifications of number of point or the parameters a, b, c. Tiny changes often have big effects.

In Mathcad we also can create nice crochet doilies using the 3D plot.

Werner_E_0-1727315357477.png

 

Changing N exponentially

Ani1.gif

Changing N linear

Ani2.gif

Playing around with parameter a

GIF is too large to be inserted here (maximum allowed size is 9.79 MB - strange limit),

Try to attach the mp4

Werner_E
25-Diamond I
(To:Werner_E)

Ooops! Just noticed that in the post above I used a different sign in the definition of x.

But using the original minus sign makes up for some pretty crochet doilies as well:

Werner_E_1-1727316073459.png

I guess Valery would enjoy this thread and maybe he is following it anyway even though he obviously still can't post. Hope he is well.

Mathcad 15 worksheet attached

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Ooops! Just noticed that in the post above I used a different sign in the definition of x.

But using the original minus sign makes up for some pretty crochet doilies as well:


 

Very nice!

 

When I first looked at your crochet post, I thought "Must add Advanced Control Sliders to the MP10" version.  Not bad, although I had to look at the Help to understand the properties.

 

However, the Bad Idea Fairy paid me a visit and suggested I try adding the time() function as an input to one of the controls.  As I always listen to the BIF, I half-hoped for the result that I got - pseudo-animation in Mathcad Prime 10. 

 

Go to page 3 of the attached worksheet and enable the "a" slider.  I chose a rather than N because altering N slows the animation down too much for a demo. I did try to attach an animation (created using the Windows 11 Snipping Tool), but at 19 MiB, it would take too long to upload.

 

Playing around with the timing parameters might produce something interesting.

 

I guess somebody has already spotted and taken advantage of this capability?

 


@Werner_E wrote:

I guess Valery would enjoy this thread and maybe he is following it anyway even though he obviously still can't post. Hope he is well.

Mathcad 15 worksheet attached


Not having been around for a bit, I'm guessing Valery is collateral damage in the Ukraine-Russia war? 

 

I see that you fairly recently (2022) contributed to a paper he published: "Visualization in Mathematical Packages When Teaching with Information Technologies"?

 

Stuart

 

Cornel
19-Tanzanite
(To:StuartBruff)

And the only way to stop is to disable control slider a?

And is it possible to run 2 parameters in the same time as you did you a? So, a and b for example

Cornel
19-Tanzanite
(To:Cornel)

@Werner_E @StuartBruff 
See attached file.
But yeah, I do not know how to slow down the iterrations, and then for example how to itterate for example from 1 to 1 for b variable, so for example b to take 1, 2, 3, 4, etc. Right now b is taking 0.249, 0.437, 0.769, 0.958, 1,235, etc.

 

Cornel_0-1727355588028.png

Cornel_1-1727355595149.png

 

 

Werner_E
25-Diamond I
(To:Cornel)


@Cornel wrote:

And the only way to stop is to disable control slider a?


You could also use "Stop All Calculations" from the Calculation Ribbon.
I found this more efficient an comfortable - especially when using more than one time() driven control.

 


And is it possible to run 2 parameters in the same time as you did you a? So, a and b for example

Why didn't you gave it a try instead of asking?

Of course, the concept can be extended to several parameters. Just make sure in the script that the output is set equal to the input, as in the script for slider “a”.

See attachment.

To change more parameters simultaneously I guess it would be better to use just one control with a vector of all parameters as its output.

 

 

Cornel
19-Tanzanite
(To:Werner_E)

I uploaded already.

What I do not yet understand is how to slow down the iterrations, as you made in your video.

Show me for this example. Right now iterrations of a and b are fast, but I want a more slowly itterations. How to do this? 

Cornel_0-1727358085215.png

 

Werner_E
25-Diamond I
(To:Cornel)


What I do not yet understand is how to slow down the iterrations, as you made in your video.

My trick was to use a higher value of N and using a rather slow computer 😉

 

Of course you could round time(0) to a certain degree which effects that the value calculated does not change so often.

But I guess this would not cure the flickering - the same plot would just be redrawn multiple times.

Its sure not a perfect way to implement animations but a very interesting and brilliant idea anyway.

 

EDIT: Ah, just loaded your sheet and saw that its not working. You have to activate Multithreading in the Calculations Options!

 

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

@Cornel wrote:

And the only way to stop is to disable control slider a?


To change more parameters simultaneously I guess it would be better to use just one control with a vector of all parameters as its output.


A problem with using controls for complex tasks is that it means learning the foibles of some other language (JScript) as implemented in Mathcad.  Not a huge problem, but one still demanding of one's time, effort, hair roots, and bruised toes (from kicking the cat in frustration when trying to debug a language you have no real interest in using).  It rather smacks of buying an expensive guard dog and barking oneself.

 

Consequently, I prefer to do as little as inhumanly possible in a control scripts and keep the clever stuff in Mathcad - where it's visible!

 

So an alternative to using a master parameter setting control is to use a master clock control to act as the pulse for the other controls.  The way I've implemented it below means that there is still the screen flicker, but there is better control of the parameter changes.  Performance (and flicker reduction) could possibly be done by using the Mathcad API to directly change a parameter math region from within a control.  But, as I said, this is too much "non Mathcad" work for me to be bothered with at the moment.  I've got enough on my metaphorical plate dealing with actual Mathcad projects, not to mention my non-virtual plate calling for me to put some food on it.

Here's a pixelograph of a master clock implemented as a Text Box Control.

 

2024 09 26 A.png

 

Here are the scripts for each control,

 

a (parameter) control script:

 

//TextBox Input:
//[0] ← τ > 1

// TextBox Output:
// [0] a → a

// TextBox Script:

var adelta = 0.05;
var amax = 10;
var a = 0;

function SliderEvent_Start(Inputs, Outputs) {
    // TODO: Add your code here
};

function SliderEvent_Exec(Inputs, Outputs) {
    if (Inputs[0].Value = 1) {
        //    Outputs[0].Value = Slider.Position();
        a = (a + adelta) % amax;
        Slider.Position(a);
        Outputs[0].Value = a;
    }
};

function SliderEvent_Stop(Inputs, Outputs) {
    // TODO: Add your code here
};

function Slider_ValueChanged(Inputs, Outputs) {
    // TODO: Add your code here
};

 

 

tau (clock) control script

 

//TextBox Input:
//[0] ← Round(mod(time(0), 1000, 0.001)

// TextBox Output:
// [0] taudiff → τ

// TextBox Script:

var lasttau = 0.0;
var taustep = 1.0;
var taumax = 1000;

function TextBoxEvent_Start(Inputs, Outputs) {
    // TODO: Add your code here
};

function TextBoxEvent_Exec(Inputs, Outputs) {
    tau = Inputs[0].Value;
    taudiff = (tau + 2 * taumax - lasttau) % taumax;
    if (taudiff >= taustep) {
        lasttau = tau;
        TextBox.Text(taudiff.toString(10));
        Outputs[0].Value = 1;
    } else {
        Outputs[0].Value = 0;
    }
};

function TextBoxEvent_Stop(Inputs, Outputs) {
    // TODO: Add your code here
};

 

 

Note: When formatting a control's script in Notebook++, it is preferable to conduct the steps in the following order:

1. Copy script from control, close script.
2. Paste script into new, blank Notepad++ (NPP) editor window.
3. From NPP Language menu select Javascript.
4. From Plugins menu select JSTool a → JSFormat (ctrl-alt-M).
5. From Plugins menu select NppExport → Copy all formats to clipboard.
6. In Mathcad paste clipboard into TextBox (ctrl-t, ctrl-v).
7. In the TextBox select all and copy the formatted script (ctrl-a, ctrl-c).
8. Open the contol, select all and paste script (ctrl-a, ctrl-v).

It is important to paste into and copy from the TextBox and then paste into the contol. Otherwise, pasting directly from NPP into the control will lose any special characters that the script may contain (eg, Greek letters).

 

Stuart

Werner_E
25-Diamond I
(To:StuartBruff)

Great! Thats a nice idea with potential to use the time() function as a driver for an animation.

 

From what I remember is adding an animation feature on PTCs todo list. Not sure if its already planned for the next release.

 

All I tried so far for doing an animation was playing around with AutoIt and let it change values in Prime, take a screenshot and assemble at the end all screenshots to a video. But at the end it was too cumbersome to set up and I found no solution for more time  consuming calculations how to tell AutoIt that its time for the next step. Probably turning off Multithreading and displaying time(0) would have been a solution (AutoIt could detect if the displayed value has changed).

But then I laid it aside because why should I use Prime for animations when old Mathcad has the by far better and more feature rich plot facilities?

 

According Valery I think you are right. Just guessed that a VPN should have solved his problem.
I never was explicitly contributor to Valerys publications but when he used something I posted here in the forum he usually gave proper credit.

I guess the publication you mention refers to this thread Portrait of roots of two equations - PTC Community

It was exactly this thread I had in mind when I wrote that I think that Valery would enjoy this one here 😉

 

Werner_E
25-Diamond I
(To:StuartBruff)

Grammarly ?

Always suspected that your funny comments for which I always had to need help from Google translate or DeepL would have been KI generated 😄 🙂

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

Grammarly ?

Always suspected that your funny comments for which I always had to need help from Google translate or DeepL would have been KI generated ‌‌ ‌‌


 

Grammarly? I don't make much use of Grammarly, I'm afraid. I usually turn it off when posting on the Community because its notification icon places itself exactly where I don't want it.  

 

I'm sorry to say, all the funny stuff is strictly me, and hasn't changed much since I was about 12.  ☹️

 

I subscribed to Grammarly to help the kids while they studied for their Highers (Scottish 17/18-year-old qualifications, equivalent to Austrian Matura level and customarily required to progress to University).  

 

However, having seen your comment, I wondered if I ought to cancel my subscription.  No sooner had the thought crossed my mind when an email notification popped up saying that Grammarly had just subscribed for another year today.  Some days you just can't win.

 

Still, of recent Grammarly does have its uses.  I normally use my laptop on a small table that doesn't have room for a mouse (or any external pointing device).  Consequently, I have to use the trackpad.  I must seriously annoy trackpads because they're very sensitive to my presence.  I only have to waft my hands in the general vicinity of the trackpad (ie, same room, same continent, same planet, same galaxy, etc) and the ruddy thing randomly places the cursor elsewhere whilst I'm actively writing, selects and deletes stuff, closes tabs, undoes the last 5 minutes work, or whatever other ill takes its fancy.  So, occasionally, Grammarly is helpful in pointing out where such trackpad transgressions have taken place.

 

Stuart

 

(The trackpad issue is nowhere near as bad on my MacBook as with the Dell, and I've got the sensitivity as low as I can get it without disabling it)

Werner_E
25-Diamond I
(To:StuartBruff)

I didn't know about Grammarly but I saw the pic you posted was curious and googled the green G-icon just to find out that it seems to be some kind of AI driven "improve your style" tool.

According trackpads - they don't like me, too, and vice versa. I am almost helpless and lost when I have to operate a device without a mouse or similar. My working speed drops alarmingly towards zero - OK, not as slow as the development speed of Prime, but almost. 😈

StuartBruff
23-Emerald III
(To:Werner_E)


@Werner_E wrote:

I didn't know about Grammarly but I saw the pic you posted was curious and googled the green G-icon just to find out that it seems to be some kind of AI driven "improve your style" tool.


 

Yes.  However, it feels far too much like a Procrustean Thought Device.  I often take issue with its suggestions, which is why I ignore it most of the time. 

 


@Werner_E wrote:

According trackpads - they don't like me, too, and vice versa. I am almost helpless and lost when I have to operate a device without a mouse or similar. My working speed drops alarmingly towards zero - OK, not as slow as the development speed of Prime, but almost. 😈


 

We should form GROTT - Get Rid Of Treacherous Trackpads.

 

(Name inspired by Calvin and Hobbes' G.R.O.S.S. (Get Rid OSlimy GirlS)

 

Stuart

 

Werner_E
25-Diamond I
(To:Cornel)


@Cornel wrote:

@Werner_E do you have any idea on how to do like this somehow?

Cornel_0-1727248216587.png

 


As far as I see Alan already explained why your approach can't work and Stuart already provided a way to make it work.

Cornel
19-Tanzanite
(To:Werner_E)

Yes, now I am ok with Stuart's solution. He replied after I asked you.

Announcements

Top Tags