It's known that we can easily define a function with optional value which is not related with other arguments, but my question is how can I define a function with an optional value which is really related with other variables.
fun[a_, b_:g[a]] = a + g[a]
g[a] = a^2 is a given function. I'd like to set the optional value of
b to be