@emre31 (Emre Çubuk) posted a new topic, subject "Can you help me to write this into octave?". It read:

   i tried ti write it into octave but it says “undefined near line 1, column 7”  
    any ideas how to write it ?

Then @arungiridhar (Arun Giridhar) said

    This is really odd homework, because there's nothing for you to write! Octave already has a built-in function called `cosh` which calculates the hyperbolic cosine. Type `help cosh` in Octave to see how to use it.

@nrjank (Nick Jankowski) replied

    assuming you need to write your own `cosh` function, why don't you show us what you tried and what is producing the error? it sounds like you're having some very basic difficulties using octave.
    
    also, you might want to refer to some basics at:  
    https://en.wikibooks.org/wiki/Octave_Programming_Tutorial/Getting_started

To which @dastew (Doug Stewart) replied

    Show us what you tried. Then we will know what kind of help you need.

To which @emre31 (Emre Çubuk) replied

    ok i will do that too

Then @emre31 (Emre Çubuk) said

    cosh (x) == e^(x) +e^(-x)/2 this was my try

To which @emre31 (Emre Çubuk) replied

    cosh (x) == e^(x) +e^(-x)/2 this was my try

To which @arungiridhar (Arun Giridhar) replied

    With what you wrote, you're not defining a new function. You're asking Octave to compare the value of `cosh (x)` with the value on the right-hand side. Octave already knows what `cosh` is but does not know what `x` is.
    
    See Defining Functions (GNU Octave (version 7.2.0)) if you need to do this again, but name it `mycosh` instead of `cosh` so that we can tell them apart.

So @emre31 (Emre Çubuk) replied

    so you mean i have to do it like this? sorry i am a beginner i dont know that much…  
    mycosh (x) == e^(x) +e^(-x)/2

After which, @dastew (Doug Stewart) added

    function ret = mycosh(x)  
    ret=( e^(x) +e^(-x) ) / 2  
    endfunction
    
    put this in an M file called mycosh.m

After which, @emre31 (Emre Çubuk) added

    alrighty thank you


{'source': 'discourse', 'url': 'https://octave.discourse.group/t/can-you-help-me-to-write-this-into-octave/3415', 'title': 'Can you help me to write this into octave?', 'views': 33, 'has_accepted_answer': False, 'word_count': 284, 'like_count': 2, 'reply_count': 7, 'participant_count': 4, 'posts': 11, 'tags': '', 'author': '@emre31 (Emre Çubuk)', 'participants': '@emre31 (Emre Çubuk), @arungiridhar (Arun Giridhar), @nrjank (Nick Jankowski), @dastew (Doug Stewart)', 'image_url': ['https://canada1.discourse-cdn.com/free1/uploads/octave/original/2X/6/6dfcb24d15dfbe13b8400dc95a41a438bc917575.png'], 'created_at': '2022-10-13T20:01:12.165Z', 'last_posted_at': '2022-10-13T20:48:52.862Z'}