Problem 61082. Slicing the area of a circle
- in the first row (i=1), A1 stands for the area of one slice (like a pizza slice), and a1 stands for the logical 1 if A1 is smaller than or reaches the square's area A or a1 stands for the logical 0 if A1 surpasses A;
- in the second row (i=2), A2 stands for the area of two slices and a2 has the same previous false-true meaning relative to the areas A2 and A;
- and so on, until last slice of the circle;
- in the last row (i=n+1), A_r is the area of the rectangle, with dimensions L×r, which contains the maximum possible number of slices, such that have the true meaning of their sum has the area smaller or equal than the square's area, in their adjacent arrangement.
Solution Stats
Problem Comments
-
6 Comments
I must admit I'm not fully understanding the last requirement. You're supposed to consider the maximum number of slices such that their combined area does not exceed A, arrange them with the "tips" pointing up and down alternatingly, and then report the area and width of the rectangle of height r containing them?
Also, it'd be nice if you could always use some tolerance when checking for numerical equality, for all elements of the matrix returned. isapprox() is a builtin that does this BTW.
Yes, the rectangle is exactly as you described. It is like the rectangle of Problem 61081, but it contains slices of circle instead triangles.
Thank you for the advice, @Christian Schröder. But I will need some extra time to fix it as a matrix, because
"Error using assert The condition input argument must be convertible to a scalar logical. Error in Test2 (line 5) assert(isapprox(slicing_circle(A,n),y_correct))".
Sorry, I will be away all week. So, I will only be able to fix the tolerance tests as you claimed later.
Hoping that this does not prevent the resolution of the problem.
Thanks for the feedback on the rectangle, Luisa. In that case there's either a bug in my code or in the test cases.
isapprox(A, B) returns a logical matrix of the same size as A and B; you may want all(isapprox(...), "all").
Luisa -- I have it all working except test problem #2, which needs a tolerance.
Solution Comments
Show commentsProblem Recent Solvers0
Suggested Problems
-
0 Solvers
More from this Author5
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!