I am trying to have this problem be somewhat randomized (3 different function types, randomized numbers, up, down, left, right) and self correcting. I’ve gone over it again and again and can’t find my error. If a square root is involved, the self checking doesn’t ever work. If down is involved it seems the self check also doesn’t work.
I think you have c1 and c2 the wrong way around in the correct check - based on the graph it should be
correct = (n=1 and c=1 and c1=1) or (n=2 and c=1 and c2=1) or (n=1 and c>1 and c3=1) or (n=2 and c>1 and c4=1)
Also if a happens to be greater than 1 then the first element in g(M) is undefined (because sqrt of a negative number), meaning that total(|g(M)-s(M)|) will also be undefined. You will need to use different numbers in your list M to avoid this being a possibility.
Finally there seems to be a mix up on the ups and downs - sometimes I had to use a positive coefficient even though it said down, to get the green tick. Couldn’t work out quickly why that was an error…
Thank you for taking a look! You were right on the problems and I was able to finally figure out why my down problems weren’t working (I needed to give them an absolute value of b and then allow the sign of be to determine the sign… ). I appreciate your help! It’s all fixed now.