How to plot 3D surface for implicit functions in excel? - excel

I have the equation: sqrt(2)*cos(xy) = (z/sqrt(2)) + sin(z) - cos(z)
with following interval
-1 <= x <= 1 and dx = 0.1
0 <= y <= 1.5 and dx = 0.05
that I need to plot the 3D surface of on excel.
I can't simplify the equation interms of z so how can I calculate the possible values in the matrix form for the given x and y values?
I am following this tutorial: https://www.youtube.com/watch?v=jUoo_7KQfO0 but I don't know how to write the above equation in terms of z.

First of all your number of values of x/y looks different, x has 20 values, while y has 30
I think it should be
-1 <= x <= 1 and dx = 0.1
0 <= y <= 1 and dx = 0.05
Or
-1 <= x <= 2 and dx = 0.1
0 <= y <= 1.5 and dx = 0.05
Then about z, you can find it in excel using Goal Seek
with formulae
In above screenshot using Goal Seek you have to find value of (z/sqrt(2)) + sin(z) - cos(z) (column F) where it is equal to value of sqrt(2)*cos(xy) (column E) by changing the values of Z(column C)
As an example: For first value you would enter like below
After you have generated all z you can select all the data of x, y and z and insert the 3d surface graph.

Related

Creating a 2D grid of coordinates relative to a set heading

I am trying to create a grid of coordinates that also takes into account a heading as well.
I am able to make the grid but I am not sure how to rotate the grid based on a heading I pass in.
For example: I want to create a 2D grid starting at 0,0 that outputs 4 coordinate positions. This has 2 columns and 2 rows and has a heading of 45 degrees in radians (0.785398)
This is what I am currently seeing:
Current Result
This is what I am roughly hoping to see:
Intended result
Code:
import math
startX = 0.0
startY = 0.0
heading = 0.785398
columns = 2
column = 0
row = 0
rows = 2
total = columns * rows
spacing = 10.0
i = 0
x = 0.0
y = 0.0
while i < total:
i += 1
x = x + (spacing * math.cos(heading)) * column
y = y + (spacing * math.sin(heading)) * row
print(str(x) + "," + str(y))
column += 1
if column >= columns:
row += 1
column = 0
Any help would be greatly appreciated. Thanks!

I want to solve a system of equations containing a*x

Is it possible to solve a system of three equations in Excel, that contain x*y??
Let's suppose that my unknowns are a,b,x
The equations are
a + b = 1
a * x - 20y = 0
10x * a - 20a + b = 0
Is there a way to express the multiplier that is one of my unknowns??
here you can take z=x*a then your equations become:
a + b = 1
z - 20y = 0
10z - 20a + b = 0
Now solve these equation using simple method given here. You get value of z and a. Now you can find value x. So finally you get value of a, b, z, y

IF statement for binning data

I have a list of numbers in the 1st column. Based on the number in the 1st column I want to give each line another number i.e. if cell A2 has a value of bigger than 1300 and less than 1400, in B2 I want the cell to show 6.75.
If A1 has a value of 1350, then B1 will update with a value of "6.75".
If A1 has a value of 1450, then B1 will update with a value of "7.25", and so on.
There are 17 groupings that I need:
<1300 >1400 =6.75
<1400 >1500 =7.25
<1500 >1600 =7.75
<1600 >1700 =8.25
.
.
.
Bigger than 2900 =14.75
I could have numerous values on the spreadsheet in the 1st column so need to put them into a grouping bucket using some formula.
Any ideas?
Something like =VLOOKUP(A3,bArray,2) should suit, copied to suit, where bArray is the name for a two column list of the breakpoints and the values up to the respective breakpoint.
The break points may require slight adjustment to suit whatever is actually required.
For a simple linear relationship like that, you could use a formula along the lines of:
=if(a1<1300, 0, if(a1>=2900, 14.75, (trunc(a1 / 100, 0) - 13) * 0.5 + 6.75))
In other words, check the too-low and too-high values first to deliver fixed results, otherwise use the final formula to convert to the desired number.
This involves dividing by 100 to turn (for example) 1727 into 17, subtracting 13 to get 4, multiplying that by 0.5 and adding the 6.25 base to get 8.75.
That will give you what you've asked for:
x < 1300: 0.00
1300 <= x < 1400: 6.75
1400 <= x < 1500: 7.25
1500 <= x < 1600: 7.75
1600 <= x < 1700: 8.25
1700 <= x < 1800: 8.75
1800 <= x < 1900: 9.25
1900 <= x < 2000: 9.75
2000 <= x < 2100: 10.25
2100 <= x < 2200: 10.75
2200 <= x < 2300: 11.25
2300 <= x < 2400: 11.75
2400 <= x < 2500: 12.25
2500 <= x < 2600: 12.75
2600 <= x < 2700: 13.25
2700 <= x < 2800: 13.75
2800 <= x < 2900: 14.25
2900 <= x : 14.75
You can see it in action from the following screen shot, showing the edge cases:
Note that you have a problem with your description of numbers like 1400 since you don't specify which range they should fall in. For the formula given above, the ranges are inclusive at the low end and exclusive at the high end (such as 1300..1399.9999).
If the relationship isn't so linear (or, more accurately, formulaic), you will probably need to consider the use of lookup tables as per the excellent suggestion by pnuts.

Square divided by a ray. What is the area of a part?

I have a square, for simplicity assume bottom left corner is on origin and width of the square is 1.
A ray divides the square into two parts. I have the coordinates of intersection points. I want to obtain the area that lies right of the vector from p1 to p2:
Right now I have 16 if statements checking every combination of 2 points and calculating the area accordingly. It looks awful. Is there a more clever way of doing this?
Call the points A and B instead of p1 and p2. I'll assume x increases to the right and y increases upward, as per convention.
The point A must have a coordinate (x or y) that is 0 or 1. Rotate the square (really just the two points) to make it x=0.
The point B might be at x=-1, in which case the area is 1-(Ay+By)/2.
Or B might be at y=0, area = 1+(AyBx)/2
Or B might be at y=1, area = (Ay-1)Bx/2
This solution assumes that p1 and p2 form a right-triangle as depicted in the shaded area:
Area to the right of the vector = (w * w) - (0.5 * p1 * p2)
where w is the width of the square, and 0 <= p1 <= w, and 0 <= p2 <= w.
For example if w = 1, p1 = 0.5, and p2 = 0.75
then Area = (1 * 1) - (0.5 * 0.5 * 0.75) = 0.8125

Minimum number of training examples for Find-S/Candidate Elimination algorithms?

Consider the instance space consisting of integer points in the x, y plane, where 0 ≤ x, y ≤ 10, and the set of hypotheses consisting of rectangles (i.e. being of the form (a ≤ x ≤ b, c ≤ y ≤ d), where 0 ≤ a, b, c, d ≤ 10).
What is the smallest number of training examples one needs to provide so that the Find-S algorithm perfectly learns a particular target concept (e.g. (2 ≤ x ≤ 4, 6 ≤ y ≤ 9))?
When can we say that the target concept is exactly learned in the case of the Find-S algorithm, and what is the optimal query strategy?
I'd also like to know the answer w.r.t Candidate Elimination.
Thanks in advance.
You need two positive examples: (2,6)
(2 <= x <= 2, 6 <= y <= 6)
and then (4,9)
(2 <= x <= 4, 6 <= y <= 9)
That is the S set done and this is the end of the answer to teaching/learning with FIND-S
With Candidate elimination, we need to give negative examples to build the G set.
We need four negative examples to define the four boundaries of the rectangle:
G starts as (-Inf <= x <= Inf, -Inf <= y <= Inf)
Add (3,5)- and we get hypothesis:
(-Inf <= x <= Inf, 6 <= y <= Inf)
Add (3,10)-
(-Inf <= x <= Inf, 6 <= y <= 9)
Add (1,7)-
(2 <= x <= Inf, 6 <= y <= 9)
Add (5,7)-
(2 <= x <= 4, 6 <= y <= 9)
So now S=G={(2 <= x <= 4, 6 <= y <= 9)}. As S=G, it has perfectly learned the concept.
I have seen this question in different formats. Replace -Inf with 0 and Inf with 10 if it specifies the problem domain as such.
This is the optimal order to feed in the training examples. The worst order is to do the G set first, as you will create four different candidate hypotheses, which will merge to three with the second example and then merge to one with the 3rd example. It is useful to illustrate C-E with a tree as in the Mitchell book, and perhaps sketch the hypothesis graph next to each.
This answer is confirmed here:
http://ssdi.di.fct.unl.pt/scl/docs/exercises/Clemens%20Dubslaff%20hm4.pdf
Assuming all ranges are a ≤ x ≤ b and a and b are integer then...
In a 1 dimensional case (only x) there would be 4 samples, (a-1,a,b,b+1) that would prove it.
If you extend that to 2 dimensions (x and y) it should be 16 samples, which are those above as x, and (c-1,c,d,d+1) for y, with all possible combinations.
Please correct me if I don't understand the problem.

Resources