Doubt about formula transcription
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Doubt about formula transcription         


Author: Leonardo Marques
Date: Apr 7, 2008 12:36

hey guys,

im with a little problem when im transcripting a math formula from
maple to fortran, because when i put a solution on the equation, i got
a result diferent from zero.

The formula is: 2*arctan(sin(a)*cos(a)/(.8-cos(a)^2))-4/9*Pi ;
I've transcripted to fortran as: 2*atan((sin(a)*cos(a))/(0.8-
cos(a)**2))-((pi)*4/9)

There's correct?!
a piece of my code:
Show full article (0.77Kb)
33 Comments
Re: Doubt about formula transcription         


Author: Michael Metcalf
Date: Apr 7, 2008 13:09

"Leonardo Marques" gmail.com> wrote in message
news:9c4bdee7-084e-4644-8b90-74cbef524878@u3g2000hsc.googlegroups.com...
> hey guys,
>
> im with a little problem when im transcripting a math formula from
> maple to fortran, because when i put a solution on the equation, i got
> a result diferent from zero.
>
> The formula is: 2*arctan(sin(a)*cos(a)/(.8-cos(a)^2))-4/9*Pi ;
> I've transcripted to fortran as: 2*atan((sin(a)*cos(a))/(0.8-
> cos(a)**2))-((pi)*4/9)
>

I don't know Maple, but in Fortran 4/9 gives zero. Try 4.0/9.0.

Regards,

Mike Metcalf
no comments
Re: Doubt about formula transcription         


Author: fj
Date: Apr 7, 2008 13:34

On 7 avr, 22:09, "Michael Metcalf" compuserve.com>
wrote:
> "Leonardo Marques" gmail.com> wrote in message
>
> news:9c4bdee7-084e-4644-8b90-74cbef524878@u3g2000hsc.googlegroups.com...
>
>> hey guys,
>
>> im with a little problem when im transcripting a math formula from
>> maple to fortran, because when i put a solution on the equation, i got
>> a result diferent from zero.
>
>> The formula is: 2*arctan(sin(a)*cos(a)/(.8-cos(a)^2))-4/9*Pi ;
>> I've transcripted to fortran as: 2*atan((sin(a)*cos(a))/(0.8-
>> cos(a)**2))-((pi)*4/9)
>
> I don't know Maple, but in Fortran 4/9 gives zero. Try 4.0/9.0.
>
> Regards,
> ...
Show full article (0.80Kb)
no comments
Re: Doubt about formula transcription         


Author: e p chandler
Date: Apr 7, 2008 13:36

On Apr 7, 4:09 pm, "Michael Metcalf" compuserve.com>
wrote:
> "Leonardo Marques" gmail.com> wrote in message
>
> news:9c4bdee7-084e-4644-8b90-74cbef524878@u3g2000hsc.googlegroups.com...
>
>> hey guys,
>
>> im with a little problem when im transcripting a math formula from
>> maple to fortran, because when i put a solution on the equation, i got
>> a result diferent from zero.
>
>> The formula is: 2*arctan(sin(a)*cos(a)/(.8-cos(a)^2))-4/9*Pi ;
>> I've transcripted to fortran as: 2*atan((sin(a)*cos(a))/(0.8-
>> cos(a)**2))-((pi)*4/9)
>
> I don't know Maple, but in Fortran 4/9 gives zero. Try 4.0/9.0.
>
> Regards,
> ...
Show full article (0.77Kb)
no comments
Re: Doubt about formula transcription         


Author: Gordon Sande
Date: Apr 7, 2008 13:38

On 2008-04-07 16:36:05 -0300, Leonardo Marques gmail.com> said:
> hey guys,
>
> im with a little problem when im transcripting a math formula from
> maple to fortran, because when i put a solution on the equation, i got
> a result diferent from zero.
>
> The formula...
Show full article (2.41Kb)
no comments
Re: Doubt about formula transcription         


Author: James Giles
Date: Apr 7, 2008 14:11

Gordon Sande wrote:
...
> The 2 would be converted by default but easier to make it real.

"Easier" ? Well, it remains more legible if left as an integer.
Unless integer divide is present, a literal whose value is integral
is usually better left as an integer literal in the first place. That
way if all the declarations of the symbols in the expression change
to double precision you still don't have to alter the literals in the
expression.
> 4/9 evaluates to 0 as noted elsewhere because it is all integer. All
> the brackets are not really needed once the literals become real.

4/9 would evaluate to zero, but not PI*4/9. I think writing it as
4*PI/9 is better. Again, if you change the declaration of PI to
double precision, you don't have to change the literals at all.

--
J. Giles
Show full article (1.05Kb)
no comments
Re: Doubt about formula transcription         


Author: Gordon Sande
Date: Apr 7, 2008 14:49

On 2008-04-07 18:11:48 -0300, "James Giles" worldnet.att.net> said:
> Gordon Sande wrote:
> ...
>> The 2 would be converted by default but easier to make it real.
>
> "Easier" ? Well, it remains more legible if left as an integer.
> Unless integer divide is present, a literal whose value is integral
> is usually better left as an integer literal in the first place. That
> way if all the declarations of the symbols in the expression change
> to double precision you still don't have to alter the literals in the
> expression.

As a language lawyer you are correct but for a beginner it is too
confusing to know the arcane rules of local context for each
subexpression. Simplicity for a beginner is to avoid subtle
semantic traps.
Show full article (1.38Kb)
no comments
Re: Doubt about formula transcription         


Author: James Giles
Date: Apr 7, 2008 14:58

Gordon Sande wrote:
> On 2008-04-07 18:11:48 -0300, "James Giles"
> worldnet.att.net> said:
>> Gordon Sande wrote:
>> ...
>>> The 2 would be converted by default but easier to make it real.
>>
>> "Easier" ? Well, it remains more legible if left as an integer.
>> Unless integer divide is present, a literal whose value is integral
>> is usually better left as an integer literal in the first place. That way
>> if all the declarations of the symbols in the expression
>> change to double precision you still don't have to alter the
>> literals in the expression.
>
> As a language lawyer you are correct but for a beginner it is too
> confusing to know the arcane rules of local context for each
> subexpression. Simplicity for a beginner is to avoid subtle
> semantic traps.
Show full article (1.61Kb)
no comments
Re: Doubt about formula transcription         


Author: Leonardo Marques
Date: Apr 7, 2008 16:11

On 7 abr, 16:36, Leonardo Marques gmail.com> wrote:
> hey guys,
>
> im with a little problem when im transcripting a math formula from
> maple to fortran, because when i put a solution on the equation, i got
> a result diferent from zero.
>
> The formula is: 2*arctan(sin(a)*cos(a)/(.8-cos(a)^2))-4/9*Pi ;
> I've transcripted to fortran as: 2*atan((sin(a)*cos(a))/(0.8-
> cos(a)**2))-((pi)*4/9)
>
> There's correct?!
> a piece of my code:
>
> ! usando o metodo da zoada kkkkk
> program missel
> !constantes e variaveis
> real FUNCAO
> ! programa
> write(*,*)'Valor de f:',FUNCAO(1.023762140); ...
Show full article (2.11Kb)
no comments
Re: Doubt about formula transcription         


Author: glen herrmannsfeldt
Date: Apr 7, 2008 23:28

James Giles wrote:
> Gordon Sande wrote:
>>The 2 would be converted by default but easier to make it real.
> "Easier" ? Well, it remains more legible if left as an integer.
> Unless integer divide is present, a literal whose value is integral
> is usually better left as an integer literal in the first place. That
> way if all the declarations of the symbols in the expression change
> to double precision you still don't have to alter the literals in the
> expression.

In days long past, there were always stories about compilers
that would do the conversion at run time. That likely isn't true
for any compiler now, but that has always been used to scare people
into adding decimal points.
>>4/9 evaluates to 0 as noted elsewhere because it is all integer. All
>>the brackets are not really needed once the literals become real.
> 4/9 would evaluate to zero, but not PI*4/9. I think writing it as
> 4*PI/9 is better. Again, if you change the declaration of PI to
> double precision, you don't have to change the literals at all.
Show full article (1.28Kb)
no comments
1 2 3 4