0% found this document useful (0 votes)
5 views45 pages

Merge33 Merged

5y45y5yer45

Uploaded by

hassanmansuri570
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views45 pages

Merge33 Merged

5y45y5yer45

Uploaded by

hassanmansuri570
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 45

2/2/24, 9:41 2024-01-27-file-1

PM (3).html

Kernel: SageMath 10.2

Experiment no 3: 3-D plotting


Roll No – 24

Name – Kshitij Banode


Aim- 3-D Plotting with SageMath

In [6]:arrow2d((0,0),(3,4))

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 1/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[
2]:

In [7]:plot(vector((3,4)))

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 2/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[
3]:

In [0]:

In [0]:

In [5]:a=arrow3d((0,0,0),(1,1,1),2)
b=arrow3d((0,0,0),(2,2,2),color='red')

c=arrow3d((0,0,0),(3,3,3),1,color='blue') show(a+b+c)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 3/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[
4]:

In [6]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 4/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[
5]:

In [8]:var('x,y,z') n=3
f(x,y,z) = x^n+y^n+z^n-4
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2,color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 5/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[8]
:

In [0]:

In [11]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 6/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[11]
:

In [9]:var('x,y,z')

f(x,y,z) = x^n+y^n+z^n-4
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 7/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[9]
:

In [7]:var('x,y,z') n=9
f(x,y,z) = x^n+y^n+z^n-4
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 8/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[7]
:

In [12]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 9/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[12]
:

In [26]:
2

Out[26]: 2

In [48]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 10/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[48]:

In [52]: # combine graph"

In [0]:

Surface of revolution

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 11/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html

In [69]:

Out[69]:

In [71]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 12/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[71]
:

In [10]:var('x')
f(x) = cos(x)

revolution_plot3d(f,(x,-1,1),(0,2*pi),parallel_axis= 'y' , show_curve = 'True')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 13/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[10]
:

In [1]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 14/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[1]
:

In [11]:var('x') f(x) = x^3

revolution_plot3d(f,(x,-2,2),parallel_axis= 'y' , show_curve = 'True')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 15/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[11]
:

In [74]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 16/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[74]
:

In [12]:var('x') f(x) = x^3

revolution_plot3d(f,(x,-2,2),parallel_axis= 'x' , show_curve = 'True')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 17/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[12]
:

In
[76]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 18/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[76]
:

In
[81]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 19/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[81]
:

In
[85]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 20/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[85]
:

Paramtetric curve

In [87]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 21/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[87]
:

In [19]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 22/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[19]
:

In [13]:var('t')
revolution_plot3d(2*(1-cos(t)), (t , -2*pi , 2*pi),title = 'Cardioid' , parallel_axis= 'x' , color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 23/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[13]
:

In [18]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 24/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[18]
:

In [14]:var('t')
revolution_plot3d(2*(1-cos(t)), (t , -2*pi , 2*pi),title = 'Cardioid' , parallel_axis= 'z' , color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 25/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[14]
:

In [0]:

In [14]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 26/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[14]
:

In [15]:var('t')
revolution_plot3d(2*(1-cos(t)), (t , 0 , 2*pi),title = 'Cardioid' , parallel_axis= 'x' , color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 27/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[15]:

In [0]:

In [13]: a=arrow3d((0,1,-1),(2,-1,3),2)
b=arrow3d((-1,1,-1),(1,-1,1),color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 28/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
c=arrow3d((2,1,-3),(3,-2,1),1,color='blue') show(a+b+c)

Out[13]:

In [0]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 29/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
In [25]:
3+6

Out[25]: 9

In [20]:var('x,y,z') n=8
f(x,y,z) = x^n+y^n+z^n-4
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2)

Out[20]:

In [0]:

In [0]:

In [0]:

In [0]:

In [21]: var('x')
f(x) = x^3+x^2

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 30/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html

revolution_plot3d(f,(x,-2,2),(0,pi),parallel_axis= 'x' , show_curve = 'False' , color='red')

Out[21]:

In [22]:var('x')
f(x) = x^3+x^2

revolution_plot3d(f,(x,-2,2),(0,2*pi),parallel_axis= 'z' , show_curve = 'False')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 31/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
2]:

In
var('x')
[23]:
f(x) = x^3+x^2

revolution_plot3d(f,(x,-2,2),(0,2*pi),parallel_axis= 'x' , show_curve = 'False')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 32/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
3]:

In
[24]: var('x,y,z'
) n=9
f(x,y,z) = x^n+y^n+z^n-4
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 33/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
4]:

In [27]:var('x,y,z') n=2
f(x,y,z) = x*y*z + x^(1/2)*y^2
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=2)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 34/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
5]:

In [28]:var('t')
revolution_plot3d([cos(t),sin(t)] , (t,0,2*pi), parallel_axis= 'x' , color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 35/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
6]:

In [29]:var('x')
f(x) = cos(x)

revolution_plot3d(f,(x,-1,17),(0,4*pi),parallel_axis= 'z' , show_curve = 'False')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 36/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[23
7]:

In [30]:var('x')
f(x) = cos(x)

revolution_plot3d(f,(x,-1,7),(0,2*pi),parallel_axis= 'x' , show_curve = 'False')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 37/4
(3).html 2
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[30]
:

In
[31]: var('x')
f(x) = cos(x)

revolution_plot3d(f,(x,-1,1),(0,2*pi),parallel_axis= 'z' , show_curve = 'True')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 38/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[33
9]:

In var('x,y,z'
[32]: ) n=7
f(x,y,z) = x*y*z + x^(1/2)*y^2
implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2),opacity=1,color='red')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 39/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[34
0]:

In
[33]: var('x')
f(x) =
x^3

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 40/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[34
1]:
revolution
_plot3d(f,
(x,-
2,2),paral
lel_axis=
'z' ,
show_curve
= 'True')

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 41/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
Out[33]:

In [34]:a = vector([1,1,1])
b = vector([2,2,2])
c = vector([3,3,3])
p1 = plot(a,color='red',thickness=3) p2 = plot(b,color='blue',thickness=2)

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 42/42
(3).html
2/2/24, 9:41 2024-01-27-file-1
PM (3).html
p3 = plot(c,color='yellow',thickness=1) show(p1+p2+p3)

Out[34]:

In [0]:

file:///C:/Users/ASUS/Downloads/2024-01-27-file-1 43/42
(3).html
Kernel: SageMath 10.2

Practical 3 : Exercise Questions

In [23]: a1 = arrow3d((0,1,-1),(2,-1,3))
a2 = arrow3d((-1, 1, -1),(1, -1, 1))
a3 = arrow3d((2, 1, -3),(3, -2, 1))
show(a1+a2+a3)

Out[23]:

In [1]: var('x,y,z') n=2


f(x,y,z) = x^n + y^n + z^n -4 implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2))

Out[1]:

In [2]: var('x,y,z') n=3


f(x,y,z) = x^n + y^n + z^n -4 implicit_plot3d(f,(x,-2,2),(y,-2,2),(z,-2,2))

Out[2]:

In [16]: var('x')
f(x) = x^3 + x^2

Out[16]: revolution_plot3d(f,(x,-2,2),(0,2*pi), parallel_axis='z',show_curve='True')

In [17]: revolution_plot3d(f,(x,-2,2),(0,2*pi), parallel_axis='y',show_curve='True')

Out[17]:

In [18]: revolution_plot3d(f,(x,-2,2),(0,pi), parallel_axis='z',show_curve='True')

Out[18]:

In [19]: revolution_plot3d(f,(x,-2,2),(0,2*pi), parallel_axis='x',show_curve='True')

Out[19]:

In [21]: revolution_plot3d(f,(x,-2,2),(0,pi), parallel_axis='x',show_curve='True')


Out[21]:

Learning: was able to learn how to plot 3D graph and concept of asymptote around different axis using different angles

Learning: was able to learn how to plot 3D graph and concept of asymptote around different axis using different angles.

In [0]:

You might also like