# What is the change in time complexity due to substitution of variables?

This is a question I have after listening to a lecture.

def gosperize(curve):
scaled_curve = scale(sqrt(2)/2)(curve)
left_curve = rotate(pi/4)(scaled_curve)
right_curve = translate(0.5,0.5)(rotate(-pi/4)(scaled_curve))

return connect_rigidly(left_curve, right_curve)

def gosper_curve(level):
return repeated(gosperize, level)(curve)

def identity(x):
return x

def repeated(f, n):
if (n == 0):
return identity
return composed(f, repeated(f, n-1))

def rotate(angle):
def transform(curve):
def rotated_curve(t):
pt = curve(t)
x, y = x_of(pt), y_of(pt)
cos_a, sin_a = cos(angle), sin(angle)

return make_point(cos_a*x - sin_a*y, sin_a*x + cos_a*y)
return rotated_curve
return transform

def joe_rotate(angle):
def transform(curve):
def rotated_curve(t):
x, y = x_of(curve(t)), y_of(curve(t))
cos_a, sin_a = cos(angle), sin(angle)

return make_point(cos_a*x - sin_a*y, sin_a*x + cos_a*y)
return rotated_curve
return transform


I think this is all the code that is needed to contextualise my question properly. The lecture was on an abstraction on curves. It was mentioned that for the function gosper_curve,if joe_rotate is used instead of rotate, gosper_curve will turn into a process whose time is linear in the level into one which is exponential in the level. I do not understand how assigning pt=curve(t) could change the time complexity of the function. I would appreciate any help on my order of growth fundamentals.

• Indeed, the difference between joe_rotate and rotate seem bounded by a constant to me. Are you sure that this is the only difference? Are there lecture notes or something else the lecture was based on that explicitly defines these functions such that we can see their exact difference (it seem likely either the lecturer has made a mistake or you made a mistake in transcribing the material, it would be useful to find out what is the case!) – Discrete lizard Feb 13 '18 at 13:34
• @Discretelizard yea I'm pretty sure it's the only difference since I copied it exactly from the slides. It seems weird to me, thats why I'm asking for help here. – Prashin Jeevaganth Feb 13 '18 at 13:42
• Could you provide a link to those slides? Some more context could make this issue a lot clearer. – Discrete lizard Feb 13 '18 at 13:46
• Welcome to Computer Science! Please get rid of the source code and replace it with ideas, pseudo code and arguments of correctness. See here and here for related meta discussions. – Raphael Feb 13 '18 at 13:47
• The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! – Raphael Feb 13 '18 at 13:47