Drawing a Koch Curve with MAPLE

In summary, the conversation is about creating a program with MAPLE to draw a Koch curve using two functions and a constant. The code provided has some errors and the person is asking for advice on how to improve it. They then mention trying the program again with Mathematica but are still encountering issues. They mention they will post the solution if they find it.
  • #1
Soff
36
0
I try to create my first program with MAPLE! Therefore, I really need your help!
I'd like to draw a Koch curve with the two function f and d and a constant a=0.5+sqrt(3)/6 *I.

Koch curve:=proc(x,y);

local a ,d, f,m;
z:=evalf(x+y*I);
a := 1/2+sqrt(3)/6*I;

d :=a*conjugate(z) ;
f:=a+(1-a)*conjugate(z) ;

m:=0; to 40 while abs(z)<1 do z:=d..f;
m:=m+1;
od m

end:
plot(Koch curve);

However, I know, I'm not very good at programming because it's the first time I do something like this. Can someone give me some advices? What's wrong with the program above? I think there are lots of errors, but can anyone help me? I really want to learn it!
 
Physics news on Phys.org
  • #2
Okay, I know, I did it totally wrong. However, I tried again and used this time the program Mathematica:

z := 1 + 2*I
x = 1/1000
a := 1/2 + Sqrt[3]/6*I
Element[b, {0, 1}]
Array[Solve[x = Sum[b/2\^k, k, {1, 10}], b], 1000]

Plot[Re[If[b = 0, a*Conjugate[z], a + (1 - a)*Conjugate[z]]],
Im[If[b = 0, a*Conjugate[z], a + (1 - a)*Conjugate[z]]]]

But program above doesn't work. But I'm getting closer to the solution! In case I find the solution to this problem, I will post it!
 
  • #3


Hi there, first of all, congratulations on taking the initiative to learn a new programming language and trying to create your first program with MAPLE! It can be challenging at first, but with practice and patience, you will get the hang of it.

Now, let's take a look at your program. It looks like you have the right idea in terms of using the two functions f and d to create the Koch curve. However, there are a few things that need to be fixed.

Firstly, the line "local a,d,f,m;" declares local variables that will be used within the procedure. However, you have already declared the variable "a" in the line above. This can cause confusion and lead to errors. It would be better to just declare the variable "m" as it is the only one being used within the procedure.

Secondly, the line "z:=evalf(x+y*I);" creates a complex number using the values of x and y. This is not necessary for creating the Koch curve and can be removed.

Next, the line "d:=a*conjugate(z);" and "f:=a+(1-a)*conjugate(z);" are not using the variables "d" and "f" that you have declared earlier. Instead, they are creating new variables with the same name. To use the previously declared variables, you can use the assignment operator ":=" instead of "=".

Lastly, in the while loop, you are using the ".." operator which is used for creating ranges. To iterate through a loop, you need to use the "do" and "end do" keywords. Also, the condition for the while loop should be based on the value of "m" instead of the absolute value of "z".

Taking all of these into consideration, your program should look something like this:

KochCurve := proc(x, y)
local a, d, f, m;
a := 0.5 + sqrt(3)/6 * I;
d := a * conjugate(x + y * I);
f := a + (1-a) * conjugate(x + y * I);
m := 0;
do while m < 40
x := d;
y := f;
m := m + 1;
end do;
plot([x, y], color = blue);
end proc;

To use this procedure, you can
 

1. What is a Koch Curve and how is it related to MAPLE?

A Koch Curve is a fractal mathematical curve, also known as the Koch snowflake, that is created by repeating a specific set of steps. MAPLE is a mathematical software program that can be used to draw and manipulate geometric figures, including the Koch Curve.

2. How do I draw a Koch Curve using MAPLE?

To draw a Koch Curve using MAPLE, you will need to use the programming language within the software. You can use a series of commands, such as "move" and "turn," to create the repetitive steps that will form the Koch Curve.

3. Can I customize the Koch Curve using MAPLE?

Yes, MAPLE allows for a high level of customization when drawing a Koch Curve. You can adjust the length and angle of each step, as well as the number of iterations or levels of the curve. This allows for a wide variety of unique Koch Curves to be created.

4. What are some real-world applications of the Koch Curve drawn with MAPLE?

The Koch Curve has applications in many fields, including physics, biology, and computer science. In physics, the Koch Curve can be used to model natural phenomena, such as the coastline of a country. In biology, it can be used to study the branching patterns of blood vessels. In computer science, the Koch Curve can be used to create complex algorithms and graphics.

5. Is it necessary to have a strong mathematical background to draw a Koch Curve with MAPLE?

While some understanding of mathematical concepts may be helpful, it is not necessary to have a strong mathematical background to draw a Koch Curve with MAPLE. The software provides a user-friendly interface and tutorials that can guide you through the process of creating a Koch Curve. However, a basic knowledge of geometry and programming may be beneficial.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
980
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
875
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
690
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
984
Back
Top