Posts

Showing posts from January, 2023

Prove that (f+g)(x) is an odd function, if f and g are odd functions (Stewart, Calculus)

Suppose f(x) and g(x) are odd functions. Prove that (f+g)(x) is also an odd function.  Answer:  1. Strategy By definition, f is an odd function if and only if f(-x) = - f(x) To show (f+g) is an odd function, we need to show (f+g)(-x) = - (f+g)(x) 2. Explanation Since f(x) and g(x) are odd functions f(x)=f(x) and g(x)=g(x) By definition of sum of functions. (f+g)(x)=f(x)+g(x) =f(x)g(x) =(f(x)+g(x)) =(f+g)(x) (by definition of sum of functions) (f+g)(x)=(f+g)(x) f+g is an odd function. Q.E.D. 

[Python] Answers to: Why error messages are shown a line-by-line way? Why not shown as a block of codes?

It would be nice if errors in a program are shown at once.  Unfortunately, (I think) Python's error outputs are structured so that a line by line error messages are shown.    I think the "one-by-one" error message is shown because we are using Python as the programing language. Because 1) Python is an 'interpreter' language, 2) an interpreter language translates a code line by line into a machine language, 3) a machine executes a line by line, 4) when a line contains an error, then the machine stops executing and presents an error message.    I also think the youtube video below helps how an interpreter language (like Python) presents an error message ( https://www.youtube.com/watch?v=3iLUls6Z_tw - title: compiler vs interpreter)   

[Python] Sublime Text: set a build on Python 2.7 creating a sublime-build file (solution to WinError 2 problem)

Image
If anyone attempts to install Sublime Text, faces an error message [WinError 2], and notices your Python code does not work (like I did), I suggest you to do the following: (note: I am working this on Windows 10)  Situation: error message on my computer when I run "Build" by pressing ctrl+B  1. Make sure your Python code is saved (e.g. I saved my HelloWorld.py file on my C:\Brian\PythonLab)  2. Go to Tools > Build System > New Build System 3. on the untitled.sublime-build, type the following {     "cmd": ["( your directory for Python goes here )", "-u", "$file"],     "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",     "selector": "source.python" } In my case, I installed Python 2.7 on the directory C:\python27 Note that the directory should be represented using double \ (\\).  That is, C:\\Python27\\python.exe  So in my case: { "cmd": ["C:\\Python27\\python.exe...

[Math] A proof of Triangle Inequality (1)

Prove: |x+y||x|+|y| (triangle inequality)  xy|xy|  xy|x||y|  2xy2|x||y| x2+y2+2xyx2+y2+2|x||y|  x2+y2+2xy|x|2+|y|2+2|x||y|  (x+y)2(|x|+|y|)2 [equation 1] case 1) if x+y>0 then |x+y|=x+y  [equation1] (|x+y|)2(|x|+|y|)2 [equation 2] |x+y||x|+|y|  case 2) if x+y<0 then |x+y|=(x+y)  note that ((x+y))2=(x+y)2=|x+y|2 [equation 2] |x+y||x|+|y| Published on: January 10, 2023  By: ComputeFinance