Skip to main content
19-Tanzanite
August 21, 2025
Solved

How to plot Barnsley fern fractal?

  • August 21, 2025
  • 4 replies
  • 1551 views

Hi,

How a Mathcad program will look like in which Barnsley fern  fractal plot can be seen?

Cornel_0-1755789749960.jpeg

Best answer by Werner_E

Here is the main part of my sheet in P10 format

4 replies

25-Diamond I
August 21, 2025

Maybe not exactly what you are asking for (beacuse I guess you had Prime in mind, not Mathcad) but this thread possibly can give you some inspirations for own attempts. 

Fractals in Mathcad - PTC Community

 

Viktor's sheet uses xy-plots to show the results, so it may work in Prime as well (apart from the list box for selecting the fractal type). For testing purpose you may manually set variable "A" to a value from 1 to 101.
Creating a bitmap would provide better resolution and (if desired) a wider range of different colors. Its a real PITA that Prime does not provide an image operator and so bitmap images created could be displayed automatically directly in the sheet.

 

Fractal A=78 uses exactly the IFS matrix for the Barnsley fern:

Werner_E_0-1755793081656.png

 

Fractals.gif

25-Diamond I
August 21, 2025

I wondered why Viktors sheet won't render the stem of the fern and found the error in two parameters of the first iteration function which where erroneously exchanged. It should read

Werner_E_0-1755805992097.png

farn.gif

 

21-Topaz II
August 21, 2025

Hi,

Here is the Prime 11 version with @Werner_E correction to get stem of fern.

The list box works on conversion.

 

Cheers

Terry

25-Diamond I
August 22, 2025

Here is my version for plotting IFS driven iterations.

My approach uses a function to come up with the final coordinates instead of range variables so we could inspect multiple different fractals side by side.

Also the function does not mind how many iteration function are defined - it automatically deals with the number of functions provided in the matrix.

I also automated the creation of the list box to select a fractal. Once a new fractal type is added to the list (providing a name and the IFS matrix) the list box automatically updates and presents the fractal names in alphabetical order.

This uses a scripted component and the converter was not able to convert it correctly to a scripted Prime component. Rather the Prime file remains unusable. Its a shame how much work and modifications we have to apply to make a converted Prime sheet to look and work as expected.

 

Because scripted components are used you have to answer the security query at load time with "no" in case of Mathcad and with "yes" in case of the Prime sheet 😉

 

The plots are so much limited in Prime that its not possible to duplicate the look we have in Mathcad. We cannot remove the axis, cannot set a background color and as our plots uses more than 5000 points we are not even allowed to set the size of the points plotted which come out far too tiny.  So to have at least the best contrast available the plot is made in black in pure white background. Too bad!

Even when I do likewise in Mathcad its quite a difference to the Prime result:

Werner_E_0-1755837128296.pngWerner_E_1-1755837141275.png

I have added a couple of fractals from Viktor's sheet but not all (just 25 of the 101 provided in Viktor's sheet). Feel free to add more fractals from Viktor's sheet or make your own attempts. It should be quite obvious how to add more fractals to the list.

 

Attached are my original Mathcad (15) sheet and the converted and reworked Prime 11 sheet.

EDIT: Added random IFS in P11 sheet. So far no remarkable results. The best so to day has been

Werner_E_0-1755849525725.png

Note that the last column are not actually probabilities  (otherwise they would have to add up to 1). My program turns them into probability values by dividing them by the sum of that column.

 

23-Emerald V
August 23, 2025

Here's another (probably very similar) take on the Barnsley Fern.  It's a slight revamp of an old (Mathsoft) Mathcad 11 updated for Mathcad Prime 11.

 

2D Plot - Barnsley Fern

 

2025 08 23 B.png

 

Greyscale Bitmap - Barnsley Fern and Variants

 

2025 08 23 A.png

 

RGB Bitmaps - Barnsley Fern

 

2025 08 23 E.png

 

2D Plot - Random (Babylon 5 Shadow!)

 

2025 08 23 D.png

 

Clearly still needs work.  I used the ComboBox in an earlier Mathcad Express 7 variant, taking advantage of its inline capability.   I've got another development worksheet that I've just added a ListBox to, but I don't know how to inline it.  It would have been nice to have an Advanced version of the ListBox, so that I could easily automate filling it from the IFS library in the attached worksheet.

 

Stuart

 

 

 

 

 

 

Catalina
Community Moderator
August 27, 2025

Hi @Cornel,

I wanted to see if you got the help you needed.

If so, please mark the appropriate reply as the Accepted Solution or please feel free to detail in a reply what has helped you and mark it as the Accepted Solution. It will help other members who may have the same question.

Of course, if you have more to share on your issue, please pursue the conversation.

Thanks,

Catalina | PTC Community Moderator
Cornel19-TanzaniteAuthor
19-Tanzanite
August 28, 2025

Sorry, I do not have yet Prime 11 installed on my laptop (only Prime 10.1 at this moment). My company has not introduced yet this 11th version (I understood that it will be introduced, but do not know exactly the date). So I cannot see the above solutions yet.

23-Emerald V
August 28, 2025
OK. I’ve got MP10. I’ll see if I can put together an MP10 version this afternoon (GMT+1 Summer Time)).